|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# f Z- y: t: n+ s: Z
#include <linux/init.h>8 D" b- ~; `7 D, K4 F& i! s) O7 ?
#include <linux/module.h>+ G( d9 Z, {( v4 g
#include <linux/kernel.h>& u1 V& v; s) k$ }- I
#include <linux/types.h>
6 m1 q# m' s' Q( t#include <linux/gpio.h>
* B) \! A1 u, @) n#include <linux/leds.h>0 y- C3 k2 `+ p+ S$ [5 V3 U
#include <linux/platform_device.h>
/ @8 m! B8 s% v$ k ~
' z, ?6 }! Z' L, U4 U0 T# G& Z6 G#include <asm/mach-types.h>
1 D3 E9 B0 w- c9 s# n#include <asm/mach/arch.h>1 U2 F! ?) R4 ^
#include <mach/da8xx.h>' ?* j9 `% k( t/ P/ x6 u" |& i
#include <mach/mux.h>$ {3 v* y8 N P8 y( C; p" R, I
2 a6 Z3 z7 _1 B4 P#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ s' w0 I- t6 G; ]; P% q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* ]* F. N4 e+ x8 T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 r8 _3 n( w0 r: |4 T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- k7 J J- W( y+ I' d g0 }8 M- ]
! S Y5 o# c8 D/* assign the tl som board LED-GPIOs*/
) j' M+ k6 x: jstatic const short da850_evm_tl_user_led_pins[] = {9 B5 y& x. [; n
/* These pins are definition at <mach/mux.h> file */
/ z: o2 Q) O" v0 x3 U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 `$ J) K l" E1 i- c
-1' T) M3 n8 z! {5 D# S7 D& S* A
};/ `' i& t! Q+ M# r1 O: g
! j% P% r5 D6 p9 a
static struct gpio_led da850_evm_tl_leds[] = {
- P5 f+ t2 ~" i2 B8 F3 k/ {- d0 B0 F8 H0 ` {# U; h7 n- f' _* u
.active_low = 0,
' ]& }. x3 r4 A! Q7 E! a2 q G .gpio = DA850_USER_LED0,6 y$ d& f$ }! G+ K7 y
.name = "user_led0",
' s" d2 {" E6 p2 X* v+ P/ y: \( c+ o .default_trigger = "default-on",
4 z: I, y! S1 l% G! B2 ] },
b0 e* l: M& b9 @! M2 {2 F: k {5 t0 H4 W5 c% ]9 a
.active_low = 0,8 U# U+ |0 ^1 L2 h' _& P
.gpio = DA850_USER_LED1,! w" J: K; N+ M" X. O
.name = "user_led1",8 ~. }/ Q; p, B! p
.default_trigger = "default-on",2 b1 Z% R# y* |6 Y; R% m$ v
},
+ i+ d5 B( M O6 h. J( |' x {; z* m/ L3 t/ }( y M
.active_low = 0,
1 M1 v a. L* b6 g4 {! R .gpio = DA850_USER_LED2,# e/ _( T6 r5 L+ u
.name = "user_led2",
0 M$ a# z8 \! D- S .default_trigger = "default-on",; G Y1 {& n2 U' f, G0 t f0 d
},
3 z/ o# F9 R2 y6 g {
2 { _: [/ P2 r# _6 l" ?$ d .active_low = 0,) F, x% z4 w" H8 X5 {/ \
.gpio = DA850_USER_LED3,* E8 s! b1 j. `& o* A( z! Y
.name = "user_led3",
4 `8 d. f! h3 C: Q .default_trigger = "default-on",) I# e( L! c& l! ?- Q4 y2 e5 M
},
2 J. k7 @6 l0 [7 Y E" D};" y( s- {1 P8 F6 w' {( W! p2 J6 J
, V$ k6 Z& `) v+ @# {1 h& P jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( J F1 e8 G1 |+ T
.leds = da850_evm_tl_leds,
. ^# k; H0 i, G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ d% H/ b* c# V. X$ e: M4 A$ W; x};' O: b. ` j2 r# y% V# r0 X: w
* }. m0 M: d' a5 A
static void led_dev_release(struct device *dev)* b7 H, I* }) L
{( t3 G0 g9 G- [$ N" E3 `
};
) m+ V; r4 y a k( y( ^6 K. [! s2 |0 ^
static struct platform_device da850_evm_tl_leds_device = {% i/ _" O5 J5 Q0 N7 h
.name = "leds-gpio",
8 s& p5 G+ k. ^% o7 ~ H: R .id = 1,% y! h C) ]" j
.dev = {# @ P( ^$ O# d% V
.platform_data = &da850_evm_tl_leds_pdata,
5 u' Z( S; W, s; i( ~" l& l) [ .release = led_dev_release,
) l- e: C" k: K; j* Q7 M/ J }$ c. N# {# C; Y) J
};5 i- `; q9 o; D8 ]- ?
* v7 V) C7 ?) A Z9 f5 `$ q) j4 V5 ~static int __init led_platform_init(void)
0 B3 t: `1 c0 j9 h{
' \- C) Z4 `7 A9 \ int ret;
+ l' k* T& M' V5 n, ?( d#if 00 ?% I: t7 Q2 K9 k ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( q0 h# t9 ^# @3 c$ `
if (ret)
! y6 \; N4 |( A. m2 V$ q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 \1 `* h+ q6 l: W
"%d\n", ret);
& V- T: N _& a: Q6 D6 B* `- y* s2 P#endif
! q: |9 Z6 b( ]+ d- v5 I1 } ret = platform_device_register(&da850_evm_tl_leds_device);
* w3 L. _8 z$ h" d% b if (ret)
5 N& O9 g1 N) {* E pr_warning("Could not register som GPIO expander LEDS");
) z' C& z; S. C) I9 u8 z9 A& \ else
( _+ i' A3 i. G' Y printk(KERN_INFO "LED register sucessful!\n");# @3 H; x; f2 R" X6 f
3 |; g* q2 k- z, r C7 ?3 u
return ret;
# X1 ?5 T1 k* j8 ~0 ^}
5 O1 c8 K9 t3 n' S; }1 v1 I9 w( Q* _( U9 T
static void __exit led_platform_exit(void)
7 d i+ p d' e" m# f{4 Z n8 M, b5 e3 u2 a$ O v% c
platform_device_unregister(&da850_evm_tl_leds_device);
( j, c U/ V% G' D" O% c+ |1 ~! t* F* R; c7 e' }
printk(KERN_INFO "LED unregister!\n");
0 @4 d" ?9 L2 t}. |$ f* x, Z) C+ Q6 `8 c
( ]4 [# ^( ~3 }! |
module_init(led_platform_init);7 P6 s; o5 n) p% R+ y) S& E; f
module_exit(led_platform_exit);
k; h2 G5 H1 {+ N5 f- A0 E2 w+ d" H4 t! i0 k
MODULE_DESCRIPTION("Led platform driver");
+ A0 q" L# E& b, kMODULE_AUTHOR("Tronlong");
7 V. A( @( c. gMODULE_LICENSE("GPL");7 N' q& n) O2 t. E: }/ {
4 p. A0 c% o! h+ i4 t3 l |
|