|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 @6 Y2 t! ?, y! @#include <linux/init.h>6 R% s) e2 S" A5 @( y) T- ]- P
#include <linux/module.h>
1 H) \8 l, Q9 g# p2 ]: F3 x4 k/ h7 _#include <linux/kernel.h>" |$ f5 s+ S# ?
#include <linux/types.h>
3 x& w- r6 s) I* ^4 u e7 M#include <linux/gpio.h> _" w Z4 j. T
#include <linux/leds.h>( b* l6 \, j [9 ?& X2 T' ^: f
#include <linux/platform_device.h>6 Q6 r* f7 G3 S7 a' [
o' L" T$ Y' t/ [ e
#include <asm/mach-types.h>6 y* m% n# e5 K5 V! k. O* J! I# W, d
#include <asm/mach/arch.h>4 F! U0 \" x) h9 j8 p6 F( c% q* Z
#include <mach/da8xx.h>/ h( c0 n3 {* Z; i3 n V, j
#include <mach/mux.h>! D* M' P: L2 C
9 u8 }' M" a. p h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 \1 a- u1 W( O" Z3 b# L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 C7 ~# ~' H. G* O' M/ V( ]5 s#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' _& t# V" n1 o4 W! y- I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" F) w) X5 K0 S3 w' F
4 R9 Q: O: Z5 Y) Q h# i/* assign the tl som board LED-GPIOs*/
2 N$ `- u7 Y) H2 B' bstatic const short da850_evm_tl_user_led_pins[] = {8 V5 D0 g" p. A j$ Y! s
/* These pins are definition at <mach/mux.h> file */
, L: F8 C5 h5 ]; N) E" P- w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* O" I* s& w2 g6 M0 o# G
-1
( p* B+ F/ }) C% E/ Q( \ j};
. a$ E. z* i1 c2 L& R+ D* o$ \3 T% t+ c, e5 x% i2 Q! w
static struct gpio_led da850_evm_tl_leds[] = {
7 G/ M, i8 \& R7 a3 a6 m {
& U" R+ F! ] V6 _. G; _! i .active_low = 0,
9 c8 g& l4 Z" W6 l .gpio = DA850_USER_LED0,1 `, d3 w8 X8 ^* V3 v. r+ |
.name = "user_led0",
- {# D6 G7 ]; F1 m" |' R .default_trigger = "default-on",
1 l2 l& x' R$ B$ k+ N0 E' |7 U# p5 x },
+ `3 o$ r+ U& s+ l/ { {0 {+ o! o& a( `% ]
.active_low = 0,4 y+ P0 }3 g" C1 {0 @; G
.gpio = DA850_USER_LED1,5 ~2 h" l5 `) T8 H X' ^: m
.name = "user_led1",4 a- H/ r+ ]2 |# ?" H& v1 ^$ k
.default_trigger = "default-on",
+ w9 z% Y. e# U1 R3 ^1 ^ },- Y$ D: d0 ^1 P+ G2 e0 {
{& r6 v; h+ }8 A9 Z& _! Y7 |% Y
.active_low = 0,
* B; Q! Z5 H+ e7 s6 { .gpio = DA850_USER_LED2,
) r7 T: J5 [! |5 k5 _' i! Z6 \ .name = "user_led2",8 A* w( Q T; L9 i o
.default_trigger = "default-on",: [3 w6 G- v/ \. k
},
4 q+ X+ f5 V7 L {1 j3 e5 Q8 z; x' s+ y
.active_low = 0,! i E5 P/ G" C# v% C
.gpio = DA850_USER_LED3,
1 q. p9 \. f0 i) W .name = "user_led3",0 g0 E6 t% @2 p7 w& f
.default_trigger = "default-on",8 F: ?% b. j. f: Q2 X+ h! O
},
7 ?$ Y5 g g; K4 P; |# l};
' G6 [9 o. k7 P6 o7 k+ u6 z
6 C$ s) A' T8 ?1 t0 l& zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 \+ g Q) [6 T: U) C2 @, R
.leds = da850_evm_tl_leds,* s3 J! `* t& ~ g' M: D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 u0 i8 t$ `6 O$ X E
};
" h5 Q$ \7 @( r2 |* Q0 q0 i( W/ D
static void led_dev_release(struct device *dev): [( c: U$ ]* s/ v& N, ?! q
{& o j% N6 Q2 C0 u# S p
};
. ]( N( y: C/ s4 Z8 R, \2 s, l5 u, b
static struct platform_device da850_evm_tl_leds_device = {. C+ {; m# I. e, X" b$ X8 t& b
.name = "leds-gpio",
3 ^) k7 C0 O$ l% u .id = 1,
1 N" C! O; l3 {' Q* b# ]) ^- a: I .dev = {: y# S8 i+ t. E- H* B/ k+ y6 t
.platform_data = &da850_evm_tl_leds_pdata,( ]9 U) e2 ]6 m. i" ?
.release = led_dev_release,
. W' g7 ^. [5 P6 w) r }. l* K9 j& ?5 j$ }7 P( R9 D
};
7 R ?) i7 | L9 z5 N, ?
m* }# G$ t5 e1 u B$ hstatic int __init led_platform_init(void)
4 D0 M& |5 {, z5 M1 f. q{
1 l% s0 S2 E6 Q int ret;
8 T1 l( t" `( \+ x% P#if 0+ P) `9 r% j0 h; o" Q- y8 _/ [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* V# ~' N, ?3 o/ b& Y/ `1 y4 `! h if (ret)
6 k) c/ r+ M- k) G1 j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; n9 L% F8 ^9 ]! A5 G H
"%d\n", ret);
. S+ I9 ^2 Y4 j; m* G: b#endif
7 t: b! A3 O8 }" u# z$ t! l ret = platform_device_register(&da850_evm_tl_leds_device);
$ ], Y! E7 E7 T8 s if (ret)
# j, z+ g: f4 z) @ pr_warning("Could not register som GPIO expander LEDS");. T f" {! k! v+ o' ^: O( o; ]9 s
else/ E3 Q2 u& n7 J: v: x2 p
printk(KERN_INFO "LED register sucessful!\n");
3 s& w* j7 Y1 p9 G2 t* m! {
2 q+ [. s# C, S& Y* Z return ret;! b' J6 o* a# W2 ?; n
}
D4 m& y/ M: g& W4 u( v& }# y* \ t7 x
static void __exit led_platform_exit(void)
R2 R; Z" y, m( ]{; B* {5 M& x* V
platform_device_unregister(&da850_evm_tl_leds_device);
_% \, N. O/ Q$ r6 ~$ o
, O* {# ]" U8 ]6 D$ I printk(KERN_INFO "LED unregister!\n");* r* Z$ N. N( T6 Y' g9 G
}9 u8 s C% O/ H2 l" Q2 w) q* z
3 `2 [3 Q- S' m1 t- A. n; Bmodule_init(led_platform_init);
5 v; H w* H; a$ Qmodule_exit(led_platform_exit);
& M8 ^/ R5 c, h9 k( T4 _% {; q U$ _! [' s! c6 ~3 G3 ]) h5 D
MODULE_DESCRIPTION("Led platform driver");
2 V/ l. G1 Z& @& B+ e: J; LMODULE_AUTHOR("Tronlong");
1 c+ r% d' Y' j$ @# m& d/ kMODULE_LICENSE("GPL");
2 t$ c; J h/ {& a
+ a l, ^3 H% T) ~9 E* O' y# N |
|