|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 D' \$ w. u1 ? J#include <linux/init.h>
; Z5 z. l+ E. r& {0 |) P#include <linux/module.h>: a- J5 z! h' H: {) I
#include <linux/kernel.h>: A# y) z7 L% o; K2 y
#include <linux/types.h>, Q2 \1 R7 o5 @0 U9 r' X; i6 f; @
#include <linux/gpio.h>
, u( u4 z' P1 E7 b$ m#include <linux/leds.h>' U1 u" S. m e5 A) u3 W& C
#include <linux/platform_device.h>
1 L9 T Q3 j4 [; h3 X2 q
. m2 b& B3 r/ c#include <asm/mach-types.h>
4 s# m i+ t+ A/ Z. C$ G0 x/ W#include <asm/mach/arch.h>
0 b s* l, x3 y5 I/ ~. K5 p" B#include <mach/da8xx.h>; T3 a& J/ [* [% l9 W5 b3 v/ o ^
#include <mach/mux.h>" j$ x! a' L) s
' [- Y! q. R+ \: x( M8 R( ^) S7 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 `$ ~: R, g! K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 P' ~' {8 e5 U3 q. V$ A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), V/ l$ r- a4 T% s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" Y5 C7 w4 s7 ^( N4 l' W4 {' E
. R' ?3 F9 a) D( J/* assign the tl som board LED-GPIOs*/
' J: X( V0 J2 w/ u; d) K. bstatic const short da850_evm_tl_user_led_pins[] = {
$ R; X% M; X2 W1 c3 } /* These pins are definition at <mach/mux.h> file */
7 v/ W: _! N* L. f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 I) w9 [4 s+ F, H! A -1! M7 ?9 f* Q; [) S6 P* J: j# |
};
9 E9 e1 I% N! o3 j: U
, y. v5 w1 P/ y; Kstatic struct gpio_led da850_evm_tl_leds[] = {
R- b- K9 I5 O6 x: B. W- n {8 W M; I2 q& J: ~7 |$ r. I
.active_low = 0,
5 ?% ]9 M" l0 s5 P: M .gpio = DA850_USER_LED0,
' @& p7 H2 X3 j) J; G: r6 l" c! M0 g" S .name = "user_led0",( Y* A0 T9 k3 i! @% j, E
.default_trigger = "default-on",( @1 A7 r: A* R% i2 }
},0 n* |/ ~, I/ d; Z: @& l
{& v- F; g7 a% g8 ~8 Y5 o
.active_low = 0,
( p: U+ G& f& u" n- L$ ~. |- E, F .gpio = DA850_USER_LED1,/ q5 W3 y4 d2 y1 H7 h" ]5 o
.name = "user_led1",9 D7 T- Q; @8 n7 o1 ^2 s" {
.default_trigger = "default-on",
* V% _7 X1 }9 V; n },
: v$ a" {7 ^' r; F8 X( V. S3 B4 F {
9 c9 t. I& d C9 _/ j0 _$ ]6 O0 ]2 a .active_low = 0,
! A6 l0 E: ]3 x: o8 y/ S1 G( B7 m .gpio = DA850_USER_LED2,
U# ?( _" r Y! U6 S$ L0 U* v .name = "user_led2"," R# ]( {1 B6 d7 x: z8 T p
.default_trigger = "default-on",
6 I7 ^* u* Y, I# D% v ~5 E# M- J; Q },
$ |2 ^3 P! n3 G$ G6 Q* F {6 j- a$ Y/ z9 v3 t0 k
.active_low = 0,: O; n* r' Z, [7 a$ y& ^
.gpio = DA850_USER_LED3," E; i4 {- J+ Z9 X4 j
.name = "user_led3",
2 k- }( ?9 U5 k; w6 b6 ^% ^ .default_trigger = "default-on",! [; ^9 _) `( K: P% J
},# P+ M& d8 x& s4 I
};
4 E* t$ s( K0 h2 E" B" S7 v5 _
/ G5 u9 u3 l( wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 {' R2 F2 |7 R
.leds = da850_evm_tl_leds,
! Y+ A2 F% M& I2 O .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 U4 L: }7 m/ Y};
8 o Z+ e$ ^: f) {' x- L% C
4 O5 l+ ] V7 q/ j5 E& U- \static void led_dev_release(struct device *dev)
0 ]6 j' ^# f( ~) W4 a6 @{$ \( L3 G+ _. R! _5 L$ T8 l6 o8 {
};
3 p! k0 F/ L& p3 E6 _( k+ O( }( Y' T
static struct platform_device da850_evm_tl_leds_device = {$ w: Q2 }$ z1 a- j, C8 _& O
.name = "leds-gpio",
9 _- q$ I( z- t6 c" a5 f, g .id = 1, G1 c; o: ]7 }* f. h( k
.dev = {8 w" h. @& Z3 F3 q/ F* F
.platform_data = &da850_evm_tl_leds_pdata,. F- C( O% Z$ {
.release = led_dev_release,( N5 [" P1 f1 d% y
}
, |2 v* I/ w' m1 | q, Y};
8 c! _; S$ V# j- X+ |5 u* G, u. T3 h# y/ @9 G& G
static int __init led_platform_init(void)6 v, X8 j& p2 j2 e) d
{
. Q3 y5 M# H8 t/ H' q7 E int ret;+ }( N* a; t K2 Z" {7 h$ _/ A& T
#if 09 M0 A* V Y: G" b/ h& a2 j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, U: q9 b: p4 G% X6 ~ h! W if (ret)
~- P% d* l' W pr_warning("da850_evm_tl_leds_init : User LED mux failed :": O: ]& e* e" {% u
"%d\n", ret);
4 t6 E, B3 v* w& W#endif
6 U& v$ I- s: t i4 j7 {1 r. `- g ret = platform_device_register(&da850_evm_tl_leds_device);4 d* |: F5 x' j
if (ret)
; u' u$ S& y; ^- w! G/ `" F pr_warning("Could not register som GPIO expander LEDS");7 V' u5 u) [/ r* c. J& R
else
; y: g/ D& @5 O! [; T$ S printk(KERN_INFO "LED register sucessful!\n");# S7 L. X# @. A! _. L! t# v
7 l3 ~ A+ O6 m) @, |
return ret;) g9 Y% w* e" [
}
& Z" M+ B" w/ \' N( X1 z E) z8 v& v) ~4 O3 V$ B! T/ l- a# j1 d2 g
static void __exit led_platform_exit(void)" t, U: h' x; F6 ^. `9 y# E% g3 C
{" A a7 x. ~/ A/ Q
platform_device_unregister(&da850_evm_tl_leds_device);0 T7 X3 I0 E2 B
, x& n) _" U4 B+ v; ?3 t
printk(KERN_INFO "LED unregister!\n");
$ P& p" U4 ?( k- h/ |" u}; T% O* D" X* V: @) y: e( K
, H: j' l( P! P3 j. J8 E
module_init(led_platform_init);! z/ J3 C. h5 }* O% V5 | z
module_exit(led_platform_exit);
1 E4 z- m1 s7 j8 W
& W; `: P5 ^7 m0 JMODULE_DESCRIPTION("Led platform driver");2 P0 O: U' h( e
MODULE_AUTHOR("Tronlong");; b/ a% v9 S$ l2 h1 j$ W
MODULE_LICENSE("GPL");9 w" k9 B, C; l. m- h& X9 h
* P) ^. s6 B+ z4 I& [. G$ T- { |
|