|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- M0 A. w5 _0 @7 f8 e! ^. Y' Z8 D
#include <linux/init.h>
# k+ M+ M% b% Z& c4 ~#include <linux/module.h>3 b$ a; Q9 t9 ~3 l7 s
#include <linux/kernel.h>) P3 ^0 w; T( S! |7 A
#include <linux/types.h>
! X7 L6 L* B9 ~! G1 n+ f! S8 n9 ~#include <linux/gpio.h>
2 V a( V0 ]) C( j" d% k p#include <linux/leds.h>
: p+ C; `- S2 G2 @0 n& y" r+ p6 L#include <linux/platform_device.h>% Z, T- z% k" @: l' H O% S; Q
, l7 | ]+ B2 S- l
#include <asm/mach-types.h>% H8 e+ @' L1 w% I( v+ D" R" M
#include <asm/mach/arch.h>
; A& ?+ w/ q( [% ` G#include <mach/da8xx.h>% F2 @, D1 e# c" A
#include <mach/mux.h>
E3 O3 t! n: R) \4 D# q6 U% q4 B3 U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, ?8 m$ Q: b$ y0 k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); G8 j6 y$ `$ k; M# m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 l$ D7 t8 ]; _ [- z" I7 `. i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% W3 L: j2 N6 n9 P8 S j& Y0 J6 N
/* assign the tl som board LED-GPIOs*/; C b1 p6 }2 x* d3 |! H
static const short da850_evm_tl_user_led_pins[] = {
1 H6 d' R7 p! o' m3 | /* These pins are definition at <mach/mux.h> file */& ^) a. K6 e0 i) R5 [* @2 ~+ `- E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ u% P3 R3 N, K8 f
-1, V" E3 v8 v; J4 G- H) ], ]
};* k7 }8 P2 t/ l. i0 a6 i
- I# @$ r$ m. N$ j$ y. o lstatic struct gpio_led da850_evm_tl_leds[] = {: W: D! Z% i! o9 n
{9 D2 @! M. m' a" _+ A$ b
.active_low = 0,
7 ]6 e5 e) ^* b9 y& ~ .gpio = DA850_USER_LED0,2 _6 @' U4 e. M) X/ @
.name = "user_led0",- I0 R: C% ]8 A4 B) }3 F
.default_trigger = "default-on",) R5 r- Z5 C" |" O" a' V, N) e$ K
},4 q/ g, W& ]' b1 _
{$ X1 _* E4 }1 S" g% G( g2 c
.active_low = 0,- A, Y8 R- |1 ~! D5 p0 p* m2 S
.gpio = DA850_USER_LED1,
# {8 A* w8 u2 s7 M1 {) b; | .name = "user_led1",
6 i q' W% ~5 I, L, t .default_trigger = "default-on",: z) w/ I( T( D5 z Q; E: G. \8 o( N, i
},) L X, ^9 ?% k
{. t2 Z) N6 ^3 a0 z7 Z( [9 _
.active_low = 0,# t5 Q0 |- \7 o6 }7 e+ U, y% k
.gpio = DA850_USER_LED2,% H# H4 k2 D1 E, s, e: Z
.name = "user_led2",8 D8 C& X, n# r1 Y# s
.default_trigger = "default-on",9 G" p S3 ~6 Y+ j6 V5 E# f
},
+ J0 B% j9 _% K) }; V V {
4 K8 y: l+ N. k. |6 \( N/ L* r .active_low = 0,2 _# i1 \, t0 G/ Z
.gpio = DA850_USER_LED3,
3 F6 `% |9 G; m. c .name = "user_led3",( D2 R$ K7 i1 ]: b. A& V' G1 t
.default_trigger = "default-on"," m7 f! j7 M( V0 |# V9 r: t
},
: H- |$ g3 y; b4 a6 h9 j3 s2 r};6 ]0 Y+ Y5 ]$ I2 [# }
2 z' h; n. R" E" B& O% t, Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& u# R0 o { E- t
.leds = da850_evm_tl_leds,2 i; f/ \( J# n9 G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. i' S. ]1 J1 l m" W% m' J
};
" q" K% M0 `/ ], }/ N1 Z+ l' c+ V! E( j
static void led_dev_release(struct device *dev)3 h; W B, i* x7 d3 D* j' u1 o
{- q# b6 K [7 P: R; y* x* O& S
};
$ K1 }5 F; q" `( t
) Z0 p+ g& y6 [2 S+ A* X! b4 G) Zstatic struct platform_device da850_evm_tl_leds_device = {# A6 c$ @+ m Q% H
.name = "leds-gpio",
. T% D! @; ]8 T: ]" \ .id = 1,
2 q! P4 r. P8 S. f .dev = {- P" m- [0 C* t& [ Y( m0 C0 }
.platform_data = &da850_evm_tl_leds_pdata,
( Q- w9 |* w7 E5 M% M .release = led_dev_release,
+ L9 j% v. `& {+ D; w* I1 d1 ^ }8 P/ k! S3 T. |: [' S. @
};
$ v# L' T6 C; M5 X# v6 x* G% z
/ \+ m' X0 D. }2 g0 bstatic int __init led_platform_init(void)
' K! [3 {) C, u ]! ^# }{
6 g3 x4 H0 G, ~6 q5 Y0 B# v- h5 q int ret;6 Z' O, f+ H- C4 f% h8 l$ P
#if 0% n& p; C6 q" h+ L& w+ ?1 N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 G# x9 J6 h! P: D
if (ret)
: j. N2 s+ i$ T. U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 G- L: |; m) {% w7 ~
"%d\n", ret);
/ O! b: `3 }- }* z#endif5 |0 V. _5 }8 L1 M
ret = platform_device_register(&da850_evm_tl_leds_device);
]& k5 Z9 l J6 [0 j+ } if (ret)- W% N5 \! |; ?! g* s. ^
pr_warning("Could not register som GPIO expander LEDS");
7 g8 ]3 B. l7 y; w" @9 |0 j3 h else
! L. {1 u0 A# \, [ printk(KERN_INFO "LED register sucessful!\n");# e6 _& F' P4 A+ \9 ~: V, A5 ?
5 B# }1 k: Y. x$ i T% R1 s+ R, D
return ret;/ [: B7 r- ~2 r d" ~7 T
}
! g0 R7 M) q1 r( n. p t1 j1 Z9 V4 d& `' s& J
static void __exit led_platform_exit(void)# M' S: T- n8 J& C; m/ A
{
?! |4 R& l. \9 r `0 j/ `$ E platform_device_unregister(&da850_evm_tl_leds_device);
" c: w* L& s$ e7 i4 j
/ q; |( b7 m5 k; _ printk(KERN_INFO "LED unregister!\n");
, I1 C$ o0 H( S7 ~+ ~6 k}, B* I" b$ o: n2 {$ A; b' Z
; I, U d7 h7 O8 _$ ~$ gmodule_init(led_platform_init);
i2 K8 p9 k! g8 D2 n' T2 A8 j) w) N9 kmodule_exit(led_platform_exit);
9 r4 v3 a: W# t& j4 w. A5 r& D: w4 [5 R( D* v3 ?0 c
MODULE_DESCRIPTION("Led platform driver");. T% F; _( b0 J3 k% N% B2 m: @
MODULE_AUTHOR("Tronlong");
# n% u3 |+ j0 K% {/ J( h) U1 YMODULE_LICENSE("GPL");
" a: n9 O G9 ]( ]* y! F6 Z3 c$ h/ T/ ~& [& {9 ]; z2 a$ W# o M
|
|