|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 V1 X8 z. a9 P1 Y' {9 t
#include <linux/init.h>
$ J4 H2 c" y# N# \#include <linux/module.h> m8 C, D! e- A, N R
#include <linux/kernel.h>
1 d: g4 \1 C: s' {4 Q; b* n#include <linux/types.h>
; v2 Y) _( c1 Y) H: |0 `#include <linux/gpio.h>* Z5 x& x% K; y/ R" Y
#include <linux/leds.h>; F4 ?) h7 V* `3 y6 W; `/ Z
#include <linux/platform_device.h>0 G) ]3 f# ^1 v" T4 N1 a+ g8 w
7 j8 z; z& r- T) X' d
#include <asm/mach-types.h>6 C- m- q; b! K) W
#include <asm/mach/arch.h>
/ @7 O0 M4 y3 M1 |. J# e* M" {4 c#include <mach/da8xx.h>
9 s( u Q: \. _" e/ ?7 |#include <mach/mux.h>
' n, D4 u; y6 l2 e* z' L
9 e4 y' Q/ p7 ~& Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): l, `/ ]' d; y) j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 ]1 C% o; y0 |( [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& t8 C( M+ {' D% a( e; t6 @$ a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 L8 {, U! f/ A+ Q
0 Y# N4 ?; M! @) K# L: H M
/* assign the tl som board LED-GPIOs*/
% a7 U2 I8 |/ astatic const short da850_evm_tl_user_led_pins[] = {0 U q( ]& x4 I3 i
/* These pins are definition at <mach/mux.h> file */
4 y- U( h6 f3 e' Y8 ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: }) q( z/ C e/ Y; `- U -1# Y0 {! Z+ x! _6 l
};
5 ~" p( A% Q; f* \0 L- T+ b
, r% `; T0 m( I7 s! a+ _! Estatic struct gpio_led da850_evm_tl_leds[] = {% l. Y1 G$ r2 E$ J7 ?4 w
{6 g0 A- n n/ _
.active_low = 0,
2 g2 {; J) a# T; E+ L u .gpio = DA850_USER_LED0," Z/ r# j* w1 e% r% @) d( _, e7 b
.name = "user_led0",
3 r+ q$ ]' ~8 k2 c& m b .default_trigger = "default-on",3 h' J3 a9 Z- s' Q* ?0 T& }+ r6 \
},, ?% \8 u% H9 D! p s
{
3 ?5 E) d: r0 T6 `( B: y H .active_low = 0,& ^& S2 l; C4 R9 C# j+ {( y# r
.gpio = DA850_USER_LED1,7 c- T' M- z' r2 k u
.name = "user_led1"," ]+ _1 M" o9 x( v
.default_trigger = "default-on",4 g$ F# I5 Z& @' o
},
1 f4 ]# C8 x0 x* r# S& J; x2 V$ ^$ i9 ? {5 Y+ j* |" A$ U2 @3 M+ x/ t% y5 J
.active_low = 0,
. b. a ~) e: Q8 U. u .gpio = DA850_USER_LED2," h/ U6 D! h/ [. z7 r
.name = "user_led2",
$ v8 C u) @) a8 O3 v4 k7 ^! ? .default_trigger = "default-on",# K8 J" m5 _ D1 O# W
},
. g) L: a0 x1 y( N( @5 u {
( P, j8 c/ p1 t8 E1 ]+ ` .active_low = 0,
, n9 a9 ~4 H' _. k2 v1 h" W .gpio = DA850_USER_LED3,/ k0 I; V- p2 K1 A0 q1 \
.name = "user_led3",
' S0 u3 J9 K. R: G4 ]/ l .default_trigger = "default-on",. D% [8 c) c- ]$ R* |& h
},0 _+ N* K p `# `9 W" L
};$ ~" `; ^9 k* F+ Q
$ S' P% y X" l. C4 R: d/ i/ R+ i' L/ A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- V( K! F4 e( y$ l, H .leds = da850_evm_tl_leds,
( C0 W) r" a8 `9 N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* ]" V6 T/ w: ~2 ~6 k
};
/ C8 Q* f- p5 |* O& S- p3 r' e$ ~7 a9 x! K, ^
static void led_dev_release(struct device *dev)5 c" ~: \; Q; [" a2 Q M7 d n1 Y
{
/ u7 u# y8 z! Y5 |7 C- g9 b& w};
% X& }$ @' W# f+ y/ v1 P( W3 H; Q7 H; |9 f
static struct platform_device da850_evm_tl_leds_device = {/ Z4 s& H, B1 e* l
.name = "leds-gpio",
+ n& L1 L- w0 H5 H .id = 1,
- ]6 y" @; j. P- v% B- P$ V0 X& i. H$ i9 R .dev = {0 f2 e* s. x7 A7 B: Z
.platform_data = &da850_evm_tl_leds_pdata, i/ \8 F; D9 Y# k
.release = led_dev_release,
* b! K; j! ]0 C2 s8 J }* x8 Y" I; M2 k$ P
};
3 G' a" }) H, b6 H1 ?+ S' V
& ?8 q$ h( q' ]4 ostatic int __init led_platform_init(void)
( D0 c6 R8 Y. t' v" e0 l{
3 m% G9 r* n* L4 Q6 s! \ int ret;7 c+ v! W7 `4 c9 w& i- Q: z9 h
#if 0& T' e4 u0 p# E, r/ y1 }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 B2 `2 \, J( \! g# u! M: [7 b if (ret)4 M5 y# V% W. z3 ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 T6 M5 h. Q, G4 n G/ Q+ a4 x
"%d\n", ret);, ~ ~, j) b7 Z/ i
#endif6 x$ g% `: Z- @) Z2 ^+ Z) ^
ret = platform_device_register(&da850_evm_tl_leds_device); e- u) a6 {( E/ L% p5 q
if (ret)( L, _: q' h& B1 `& D$ W5 C4 H
pr_warning("Could not register som GPIO expander LEDS");: {- X+ y. h7 I1 f: }
else2 ^( I2 G- C9 `) |5 o0 }( ]* U
printk(KERN_INFO "LED register sucessful!\n");
& l4 ^* j; |! x5 D" o7 b1 H1 {8 M4 d6 y. L' Z; W: R
return ret;% i9 K8 t+ C6 `! e3 F4 q6 d8 o
}' i. ]- | Y/ q; d
# v! [/ N, {5 V- A& dstatic void __exit led_platform_exit(void)
" J2 }& m; c5 p6 N2 y{- w+ s1 B( H; h
platform_device_unregister(&da850_evm_tl_leds_device);7 p2 H8 d! f8 O+ f' i" A
7 D$ ]8 N0 V, w8 P% b3 A printk(KERN_INFO "LED unregister!\n");
: M K/ S6 V' n; c+ R- l; a}
( Z% ]: X8 \4 ?7 U3 t
' ], t0 d/ t3 O- S; mmodule_init(led_platform_init);
* F& F9 V K" _0 b3 e: B( C. V! xmodule_exit(led_platform_exit);
u) ^3 y6 K& H3 o5 F
) P L5 ?" y; l# i/ |1 zMODULE_DESCRIPTION("Led platform driver");! {- [% i3 x& c3 D, g( [
MODULE_AUTHOR("Tronlong");% a6 @, a) V9 S. z4 |: Z
MODULE_LICENSE("GPL");
. w% z9 x8 [2 n% N0 S. v4 o- O
& \* F' ]& n: V$ f/ h5 c |
|