|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) U. J4 ^" h4 }
#include <linux/init.h>
a- U+ _( O0 g. n' ~5 `#include <linux/module.h>7 c. n7 a8 {3 ~2 G4 ` o9 \
#include <linux/kernel.h>
2 k( v' @1 ~$ _. u#include <linux/types.h>- U* U0 j2 U" T2 S \
#include <linux/gpio.h>
& ?8 V& D4 M m- d1 @#include <linux/leds.h>( [% w3 \3 S( e+ A& d: a, W
#include <linux/platform_device.h>: [2 F. v5 C( A! [2 q, U$ p
/ `' Y) A- s5 r0 ?
#include <asm/mach-types.h>
4 i: L8 M6 t$ R$ D b4 p#include <asm/mach/arch.h>
! A& Q/ L) C H$ l. q#include <mach/da8xx.h>
. [# h' _( j0 f# d4 _#include <mach/mux.h>
7 N% z. s0 ^: _0 p5 s V6 x% p& a3 z' j
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 D0 }0 T- e6 {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- ~( i) R' i) Y6 b' d7 o0 t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ g1 X" ~7 w% ^/ E8 C6 ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ m' \! n- r g% z4 q1 s5 {7 c4 `7 Q7 r6 @* D
/* assign the tl som board LED-GPIOs*/* V; Y6 k* M. N* ^9 J) B2 n
static const short da850_evm_tl_user_led_pins[] = {; [. b- W) \- |. G+ T# Q
/* These pins are definition at <mach/mux.h> file */. r! K0 `6 Y d b, }* q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 p! N& @9 s6 c) |! E -19 u1 j8 E% F7 `8 M
};7 j+ N! c9 n7 F- E7 K
$ s! O8 r/ }! k0 sstatic struct gpio_led da850_evm_tl_leds[] = {
6 b) H: v! u9 _& ` {; C9 ^1 \# f/ K
.active_low = 0,
8 A$ |. [4 c* J8 V4 H, l. ] .gpio = DA850_USER_LED0,
- o: k+ O+ r& @* j2 Z .name = "user_led0",( h9 [3 E% ?& F
.default_trigger = "default-on",/ L% r5 m/ k+ B8 H) s
},- w. B* J* n% P l/ l; l0 m) b% v
{
4 O! F* D$ ~# D0 n- r- ^- w" c5 U .active_low = 0,
; s) E4 I1 b2 G/ h* o5 s" e4 v8 q .gpio = DA850_USER_LED1,/ c6 s; [- V- h7 O7 Z4 B
.name = "user_led1",
. q' h. Y, L4 ~2 I .default_trigger = "default-on"," E7 Y+ l, x# \/ i y- |; L: f5 N
},4 u; j5 u. u, k
{
" U. J, U" s- Z5 Q .active_low = 0,
2 ~+ |! G* x' G7 x) @ .gpio = DA850_USER_LED2,
/ l+ s& ^+ g: V8 s* O2 {# x .name = "user_led2",
- J4 R( x, I4 x9 i% S .default_trigger = "default-on",' R. @8 Q4 @% I
},
- e; r2 v' w- t {: O! ~$ R; E1 f" r, j; i/ J0 D& r
.active_low = 0,
4 }4 e# U) @1 ~# W4 b .gpio = DA850_USER_LED3,
4 O5 B' z6 ~4 W, k8 |4 H .name = "user_led3",
' |) r1 i6 P- z4 Z! v .default_trigger = "default-on",
* R5 S E2 f2 J- E* b },/ k% Z7 E0 m6 k" X
};! O4 P6 H8 S9 a9 r# X) C3 d& E
( s* M! F4 L. y3 L$ E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 K* R4 Q/ H0 |' B( j0 b: {9 H .leds = da850_evm_tl_leds,' ]4 `& S; {& J3 F% b) p
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 u$ \- ]' B% m0 Q+ r
};2 u5 ?- G1 B9 t6 P( p2 X6 W/ U6 P$ }$ N
`: a8 j$ D; n0 }4 Z$ I) Fstatic void led_dev_release(struct device *dev)& D9 n. q ?2 i5 D* F1 V
{6 c4 U1 Q2 J/ h2 {2 a. q
};
, j8 `- Y3 h! x3 F* r+ \; g/ I7 B5 I) b9 ?, O- v6 Z( H; S
static struct platform_device da850_evm_tl_leds_device = {* b$ Z Y3 r5 ^2 T, A5 N/ E+ G$ U; `" o! p
.name = "leds-gpio",
0 B9 _# P2 i, a# j) L0 c .id = 1,
; u. }/ w$ M& T3 [4 t9 B! G .dev = {
( j' Y r* C) P! E, f0 T .platform_data = &da850_evm_tl_leds_pdata,. S6 O! h/ \0 x; V0 ?& K# g& S
.release = led_dev_release,
4 h4 s1 }7 n) R$ k }9 |* q {+ `' _/ U/ r( ]
};
, G( K# R) r& n) l3 k4 D
% t7 }( r! Q1 F/ hstatic int __init led_platform_init(void)
% S9 c0 m* G) {# @) t( G1 O! O{; C7 b- L* F6 ?3 p
int ret;; e$ s9 t& B( w6 D+ Q/ g, M2 s- Q
#if 0
H: O! a5 Q; q) l0 L ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 ]3 ~. T$ P% l* W if (ret)4 ~, n* K2 N8 F/ ?* K: a+ B- C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 c4 _+ s: D4 ?. g& W "%d\n", ret);
% A# u3 w1 M8 Z6 ?+ ^: F# J#endif, G: A8 I& ^5 @4 C
ret = platform_device_register(&da850_evm_tl_leds_device);
5 V ]! I% {, g) K5 J9 P: K5 s& m if (ret)
3 Z2 F2 I; K2 K pr_warning("Could not register som GPIO expander LEDS");
0 ~8 F5 y+ T% t. r9 {; q8 w T else
. w/ W I$ R7 s2 l+ C printk(KERN_INFO "LED register sucessful!\n");* j3 ?' X( S/ n# F
* z: A9 M) |. q return ret;
5 s4 v* R% U7 y5 S" v& K; f1 Z$ p$ q}
0 r+ h: E% F7 r$ t% U9 D- \5 ]: b8 r% g2 X p% E9 w
static void __exit led_platform_exit(void)$ ?3 q& }- _. m6 i, P/ ?9 R4 i4 Z
{ p% ^9 G# T1 \! t' W# P+ ]
platform_device_unregister(&da850_evm_tl_leds_device);
z9 ~# D }. a) C) R0 J; p- i% V. F- Z, u7 w$ r! {) q# T
printk(KERN_INFO "LED unregister!\n");
% I: m9 B/ Z }9 t: v}, ^; J* l" B: n+ @
1 Y) F1 m$ a O, Z& `+ d; n6 b
module_init(led_platform_init);
9 c# Z' }# J0 w2 q3 B3 I! Zmodule_exit(led_platform_exit);
$ ^, f- O6 |3 D+ w4 X
. C! n" V) J. K0 oMODULE_DESCRIPTION("Led platform driver");
7 `. s8 j" e' w1 s- RMODULE_AUTHOR("Tronlong");' T0 ~- i. g* R3 \/ I
MODULE_LICENSE("GPL");
" |# s2 R! \8 o! ~8 R, m: W
; F2 B7 w4 \$ O6 _1 P( z |
|