|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 I5 a |% [0 M, [#include <linux/init.h>
) h( x p, _. n#include <linux/module.h>
7 ~- V }$ b2 p- M Y$ \#include <linux/kernel.h>% C+ H/ E6 `4 T
#include <linux/types.h>: w) {8 p7 F" p5 i2 k6 O+ v) p' b
#include <linux/gpio.h>
' g3 X( {6 n' k* T#include <linux/leds.h># b4 u1 {; y! a: `
#include <linux/platform_device.h>
* N I# T7 c3 w: k E1 q
4 w- v- w n) O#include <asm/mach-types.h>6 n$ ?8 R+ t: [! m; l6 y
#include <asm/mach/arch.h>! E( k; b c& e. \# K. E3 d: d$ O% n
#include <mach/da8xx.h>
; Q2 Z& w. c, t9 b' v0 \#include <mach/mux.h>
% h* d+ s* x' w: e3 o
3 D" h7 `9 B! S2 \ {& g4 A/ r1 N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ Z. P- W: x1 u/ Q3 [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 V* e/ l* m& U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# T7 R; z5 i1 |! J- a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) s& r2 |* ?5 @8 W) N
8 H7 Y8 ^- V: ~/ }/* assign the tl som board LED-GPIOs*/$ L, g. I1 Q8 ]9 T
static const short da850_evm_tl_user_led_pins[] = {+ Z: r; j9 b7 Z2 X$ @# L
/* These pins are definition at <mach/mux.h> file */
5 C- P. q5 ]; d, ]' [3 D# Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: Y$ l k& ] S2 e( U
-1
" u% V& ^- G, z/ q0 l# y& P};" {6 C" w( ]1 U
( S& f$ A' F7 p% |9 }
static struct gpio_led da850_evm_tl_leds[] = {
9 O2 n* i9 X, S% Y, a& u! }" _( X {. h( E7 f" r6 }+ ^$ T
.active_low = 0,/ t4 _7 k8 K9 K. i
.gpio = DA850_USER_LED0,& O- ]9 U1 l! j2 k* b
.name = "user_led0",6 B! W3 f! l. H- r) Q7 s ]
.default_trigger = "default-on",3 ?+ ~' S2 d# K. `; P) h4 v' ]* ?) Y
},
3 ]! c! r( B3 Y3 L5 X3 N {
4 v5 R5 I' I: D% I* {, S3 f .active_low = 0,+ Y$ v. J1 H& `5 t5 `
.gpio = DA850_USER_LED1,
% R% F! Z0 F; y, D: { .name = "user_led1",
5 k& w! w$ J* a' T* N( _$ w8 X; n .default_trigger = "default-on",
3 w" p P; H8 q. a },- e( h* H$ m9 J9 n# W$ f9 A
{0 f" Y9 ~" z2 M5 ^/ S) X
.active_low = 0,
3 P& P M5 p+ m a$ H .gpio = DA850_USER_LED2,
0 c! P0 \2 [5 \ C8 ~ .name = "user_led2",
7 H3 ^! [3 j* Z6 b" a .default_trigger = "default-on",
3 I2 Q/ k/ ~3 f7 Q9 S' _' z G },9 q% |& N# T! _* b0 d( _" e
{
6 L4 ?3 y( u4 v .active_low = 0,
# ]( m" }! T% N2 r$ }5 @! ]$ Z+ P .gpio = DA850_USER_LED3,
/ d9 _3 M9 z& p( \ .name = "user_led3",3 {! b2 w n* g, x
.default_trigger = "default-on",1 m) B5 l2 f8 s1 J
},
: F4 W' D7 F6 |. a% h8 ?};1 ]" q$ I1 c& g7 [
8 B/ U! C( Q2 d9 M0 S$ x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 W; l" U% b- n( ~! Z \% @
.leds = da850_evm_tl_leds,
& W6 @* {) q9 P% p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 m0 B, j- y7 @: r
};) ?1 S, G1 n0 [8 g B/ C- K/ g) |
6 F# s. z7 y8 {
static void led_dev_release(struct device *dev)( _+ f6 P0 I9 Y5 Y
{# G+ q1 ]1 u/ ?! ^+ M
};
. K. M( p2 D; `: l. ~* `# c$ A/ B1 Q2 M3 R7 w- X
static struct platform_device da850_evm_tl_leds_device = {/ Y7 a$ _: m. n$ F1 Y
.name = "leds-gpio",8 N, E5 U3 T0 a6 \
.id = 1,+ G3 m' z( j8 a: V( o
.dev = {
! ~2 ^' E; Z$ G- d) x; N. A .platform_data = &da850_evm_tl_leds_pdata,
0 N7 P) }9 W4 Z( \ .release = led_dev_release,
# h. u# Q% S# m4 d( B- l! h8 ^ }9 i( R. A. N4 K- x; B( s7 |3 }
};
8 d. M# e% c9 b( ]
4 o V7 X5 e. X% ^' [0 I( dstatic int __init led_platform_init(void)5 m ]" W2 @3 N& Q) q" S1 P
{
# c" b6 v7 S" V! R6 w. }: E: L! m int ret;
/ W: H5 w, F' b! Q4 x#if 0
6 W; S( ~% }; o- u$ |& p6 r: G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" I& L' h2 f9 ^% H# k, Q+ l7 U6 v" }
if (ret)# F; ^4 A5 S* |* {* P7 ]3 F
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 v! W6 h6 v: d
"%d\n", ret);
) ?3 z* l9 l) S; P#endif: ^6 T/ M! K0 _1 K m1 z
ret = platform_device_register(&da850_evm_tl_leds_device);5 c. U6 e' D& W- N
if (ret)% F: A2 R' }* h/ V7 d
pr_warning("Could not register som GPIO expander LEDS");
$ ?! m$ B6 R4 q0 H else0 J4 r" j* s& E* X9 N4 O
printk(KERN_INFO "LED register sucessful!\n");
9 k) @- G2 C* Q* T3 A. ~ A2 {6 A2 S2 p8 y- k, F
return ret;
L0 W( k. T/ Y4 t! q# }}
K+ {9 `! H2 \1 m( e) v
' K) _" L. A$ Y5 X" r6 d' sstatic void __exit led_platform_exit(void)
0 J1 x) c* ~+ O4 M6 |; d/ X Y{
5 |9 ]8 b+ |& U$ _ t: K6 c! r platform_device_unregister(&da850_evm_tl_leds_device);
) V0 }; H2 w/ m2 q$ B# T
0 S$ J- v2 b/ d: R: R printk(KERN_INFO "LED unregister!\n");
* F, _- @" R7 X}
/ L* I3 X/ [* }, T
8 s6 |# J! P% tmodule_init(led_platform_init);; j! S! d! A) p' K* x& `
module_exit(led_platform_exit);4 ^0 H+ ~; E3 z V/ u2 j5 ]5 t5 k
3 K: K4 Y7 ^* K) o
MODULE_DESCRIPTION("Led platform driver");
4 c$ g/ ~: `9 FMODULE_AUTHOR("Tronlong");
- _( z# d T; k/ ^7 UMODULE_LICENSE("GPL");
1 ?' b) P; I" R3 i3 S1 m
# J [# B1 ^0 x! O4 x: z' U |
|