|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 B6 n1 X: k* I8 c" B8 j( V7 j#include <linux/init.h>
0 w8 x4 M2 \- n/ n# x! ~#include <linux/module.h>) B: \1 y! L9 l: Y! G5 [5 u0 o6 u, V4 x
#include <linux/kernel.h>
Q; r+ m! t- ]' e, y#include <linux/types.h>
% E. M5 C1 M; L- R( k1 n#include <linux/gpio.h>
* ]: t' ]1 k' }3 U% p#include <linux/leds.h>- t3 S4 d4 Q7 |7 g& f, n
#include <linux/platform_device.h>
/ \; ]5 w: R2 M( W
% U" W9 M0 Y- E$ I% ]6 d: ~#include <asm/mach-types.h>6 a+ X- P5 o, s8 X2 v- O* X* z
#include <asm/mach/arch.h>: ?& l" v) l/ T9 P; A% n. i
#include <mach/da8xx.h>; U, y1 p3 b/ Z+ _! Q
#include <mach/mux.h>1 I5 [. ^! z; T
2 A4 ?7 ^1 r; H. i. m8 j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 k' c1 M! c; Q6 Y! m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' B/ N" `! i" R! M, w; z" Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 d- [ F9 `- g- Y+ X p; U#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 V, Y. N. G* T
% w4 e: A3 D8 _- \7 v; F6 z( ~
/* assign the tl som board LED-GPIOs*/
8 s! N( N; q* t/ hstatic const short da850_evm_tl_user_led_pins[] = {) E5 T0 H! P; \
/* These pins are definition at <mach/mux.h> file */
" d: f* @5 ?4 F7 U8 \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 d! e, r8 W: S8 q* t8 }
-1
3 S2 H+ E( f5 B7 F};, A% E% q& n/ U
: s1 E" T5 e5 h" e: k$ istatic struct gpio_led da850_evm_tl_leds[] = {. S: R9 U- q8 u8 o Z; P
{
: o1 \# B) [4 |. B! n; f .active_low = 0,* ?# q/ Q8 t2 _
.gpio = DA850_USER_LED0,
7 b' [! k2 p, j* A6 c4 i/ K' m .name = "user_led0",
( I$ n+ _- X8 @. ~8 Q .default_trigger = "default-on",; T+ O& U9 L! w+ V& ~) f! C4 L
},1 P2 i) Y6 @- v5 q
{7 e* u2 U, U7 Y) \! r
.active_low = 0,- w/ d. n" G$ R7 w' b
.gpio = DA850_USER_LED1,3 O5 L( x. c4 F; z* { K( {9 Y$ X
.name = "user_led1",
$ C3 i1 i& r7 \0 j) r .default_trigger = "default-on",& ^7 A2 T+ Y: o t B& N5 J; u
},' g& Z/ S! Z5 j8 O
{2 K9 l+ y! @# s5 `" [
.active_low = 0,5 ~9 P' A3 R6 R* J
.gpio = DA850_USER_LED2,* G& V; e- u) ^
.name = "user_led2",* I5 S; r" p1 `% w; M5 k* a
.default_trigger = "default-on",
' O8 ?4 J. N8 @$ F2 F9 b8 F9 z. f },7 w9 g3 c2 D1 u
{
! U" u% G: R1 l .active_low = 0,0 ]5 q8 G: W/ V
.gpio = DA850_USER_LED3,
2 t7 ~. L5 g2 q .name = "user_led3",
9 l0 ?; r6 P9 [8 Y .default_trigger = "default-on",- [# p4 x0 B3 [
},3 j0 V$ D+ c \" c) q$ b \! a. C" E
};! b4 G& o1 [; d) U9 T7 M
8 k. U0 P4 s* {2 D; g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { X5 K$ ]" n: D* H% f" ~$ l
.leds = da850_evm_tl_leds,( x8 Q/ ?+ m( b4 ?, ~2 T5 E) F9 d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& u' C5 o+ x+ c! t, l+ A' G5 \};
$ M, z2 N0 `& O9 z# ?' l; W' E' ]. T& G0 w) Z2 b# |, J5 B3 A4 ^
static void led_dev_release(struct device *dev)% X4 s7 @% C4 L1 b8 {
{
8 J2 a5 ?* M5 N( f& ~7 ?; y};
' Q- w' N2 H2 A h9 S; d3 e4 M3 Z, l" r- I
static struct platform_device da850_evm_tl_leds_device = {
. m( B+ L* g' q2 d% h .name = "leds-gpio",% g/ _) |2 U9 P$ u/ [6 k
.id = 1,: _2 r5 X3 B! S- T( }
.dev = {2 [, h7 B9 Q: U1 y4 ~7 Y5 e
.platform_data = &da850_evm_tl_leds_pdata,! \% I, ~4 h `$ Q! P; O5 d
.release = led_dev_release,4 a! y. f$ P, n# w
}8 y: ~7 \2 t# V/ }
};
1 z# l- T2 V) s( d4 y$ Y5 `$ Y {7 S$ p# d& b' {" Q
static int __init led_platform_init(void)
+ P* D7 g3 ?1 f! g# c2 t{
+ C; g- ^* t/ Z+ l( b int ret;! N+ D6 K3 z% F/ f g
#if 0, |2 J, {1 g3 z# {1 u) r& ]( H) Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! S7 f, m8 J/ r& C6 j6 y) K
if (ret)/ n/ f" x9 x: F. R& O: ~! t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 P8 }8 u0 S& M; J% D; C7 z! k! ?. {
"%d\n", ret); G) J- l+ _8 a( H* q
#endif& ]- R' S! }, b/ ?2 [ e
ret = platform_device_register(&da850_evm_tl_leds_device);
! F) U) Q' e7 A# R7 F if (ret)( ^/ e7 ?+ v' Q$ h$ |
pr_warning("Could not register som GPIO expander LEDS");
. a6 J& M' ~1 l' e else
1 {( I( K0 K T) D1 s4 u* N8 R& d printk(KERN_INFO "LED register sucessful!\n");
6 k$ o/ Q u' b6 `, n5 p+ y) q/ q: s7 H7 }
return ret;. f2 N% j! R. }) P
}7 {$ B7 S$ S5 x
$ G# c4 N, I4 Y' K1 b
static void __exit led_platform_exit(void)
; B! a d" e/ ~ r% W! l( W/ I% o{
- i+ H6 c$ i4 x platform_device_unregister(&da850_evm_tl_leds_device);6 Y2 e2 N w! t
/ j1 W% k7 h a5 y9 A1 U; d* [ printk(KERN_INFO "LED unregister!\n");& i( |4 I0 N; Y) J1 U
}
. C; @4 G+ F% |2 |. n" S& f% x0 q4 M& A$ X3 G2 f) b8 j
module_init(led_platform_init);
& M; Y9 u5 `4 o, M( z5 bmodule_exit(led_platform_exit);# r0 \6 U' l2 c E& H
q0 E: Y# m& V7 n( M' J; zMODULE_DESCRIPTION("Led platform driver");
9 }5 l. |% I$ h. U" dMODULE_AUTHOR("Tronlong");0 i7 t% R6 R" T$ h
MODULE_LICENSE("GPL");8 z) J9 g; ^5 l9 `3 X" V
0 b# h! u. X3 U6 n/ y* t$ u. H
|
|