|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 ^2 g) N+ x1 A1 X
#include <linux/init.h>( _% F" y6 @! |% M) Z4 B( s
#include <linux/module.h> b% a0 d$ H( H) w+ q d( z7 f% Z$ C
#include <linux/kernel.h>
% K! ` n# I7 E1 L$ w1 H" K#include <linux/types.h>
: Z4 d0 c% i& {& n1 g7 s#include <linux/gpio.h>
0 Z L6 B! [; {" J3 P7 r0 p* O#include <linux/leds.h>: n" [" c& \6 J4 m3 R. q3 i) n8 O! s
#include <linux/platform_device.h>
; }% k7 S( i9 n( L
6 y- D) \" B( w$ x; T" G#include <asm/mach-types.h>
1 a! t( |- s" g; U: u' Y( P; ?#include <asm/mach/arch.h>, @' \+ n8 j( O3 E/ c/ J
#include <mach/da8xx.h>6 z$ e( F! F2 u4 E# s7 e" f
#include <mach/mux.h>9 T) e$ ~, I2 @$ T% m2 |& a4 R$ W
6 @1 \$ O6 q5 ~3 f l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 V4 o4 d7 e( t5 o3 t1 D9 u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' O2 V1 [* ^# u$ ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ U' d' y, S8 V( q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- T" I1 P7 |5 j0 N
8 l& k3 c9 ^/ C$ S f9 U6 H
/* assign the tl som board LED-GPIOs*/4 n5 w( L; Q+ u/ U- y
static const short da850_evm_tl_user_led_pins[] = {4 A0 ^8 M! _" s: e5 k
/* These pins are definition at <mach/mux.h> file */6 D' ~$ u( [, |; w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. ]' _/ ^2 { R! g4 m -1
3 L( S2 V O7 D2 o8 y};
, Q5 E# |/ y# q, o4 }! r% _8 [2 @
" c+ [3 ?9 Z N+ p+ h& K) fstatic struct gpio_led da850_evm_tl_leds[] = { p n+ e7 @) {" ^ |, W. w
{
& I4 p% k: m; s f) { .active_low = 0,
% ], ]0 b0 P: t/ w .gpio = DA850_USER_LED0,5 z ], W; K2 r
.name = "user_led0",1 f8 }9 k9 R. m0 u' h) p- P
.default_trigger = "default-on",
5 g3 V/ O, O' }8 @7 A },
3 W4 B1 w! B5 b, m( d- R {% w% ^% G& N B4 E
.active_low = 0,
+ k3 h. [& p" Z" K6 W, P .gpio = DA850_USER_LED1,+ q9 _+ U' ]7 m. ~
.name = "user_led1",' o$ H0 H6 c( O8 \8 s- i# z
.default_trigger = "default-on",& g* o0 v0 r( V# g7 P8 i
},1 x" t, x' N: `/ J
{
) k6 ?6 K, d r- O1 W! F+ Y# Y- z \ .active_low = 0,
2 q# `6 ?5 o7 ]; _9 A .gpio = DA850_USER_LED2,
0 I# M' K1 y0 b& ^2 X f6 { .name = "user_led2",+ p$ F+ w( b) k( r8 B' U7 ]
.default_trigger = "default-on",
% U: o2 b6 ?. T4 N8 k8 | },
9 H% E% A& T2 @0 _8 J {7 H: q8 Z( w5 [/ S" E d7 f) U
.active_low = 0," N" C" u4 R7 Q+ Q+ Q5 ~
.gpio = DA850_USER_LED3, P7 j/ |0 a; Q, t( @5 i1 j- k! ]
.name = "user_led3",
! P2 ^, o" z* O$ m .default_trigger = "default-on",
9 z* }/ A' X0 R& x1 R; V7 N# o" C },
% P/ w% x y9 g8 Z o6 T};
; S( E! Z) g+ y; L
' g( `, N I% F$ F8 n6 ^5 ~' ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! g. a' d/ s- L
.leds = da850_evm_tl_leds,
0 ~9 U0 j1 J& @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- K- \4 r7 x' R P' x1 H b6 x; p
};3 M: O" [6 X2 u6 k& f
( ~* H; `/ V' N+ p- v4 L
static void led_dev_release(struct device *dev)$ X5 I/ z3 \# B& `1 k
{& r, G6 X \' G' n
};# N& H' z1 z, l! y: T
9 [# `9 W4 l7 |; ^5 astatic struct platform_device da850_evm_tl_leds_device = {, h& m' o' A/ b: ^6 Z' s
.name = "leds-gpio",8 J8 m1 ^+ q5 p( \
.id = 1,
3 T6 n) z/ x) s3 y8 U* Q& e .dev = {- u4 G5 R# U! j1 \8 c* _
.platform_data = &da850_evm_tl_leds_pdata," C0 r8 p0 J9 }6 ?6 f& ]
.release = led_dev_release,: s* W0 n- S9 a9 W- G
}
f$ J- O2 i. l& t: c9 p};2 v) q! S1 ^$ z5 O2 r
- D/ ]8 w/ c! c* A! ystatic int __init led_platform_init(void)8 ] q' R7 y' J2 c" K1 P3 [6 Y
{( e8 {( N5 |- Y! x6 |. f
int ret;
/ d' O$ q( P6 V. s#if 0. Y& ~" s* x( ^1 I$ E- A. [5 Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 h$ h# _( p, Q. _5 a if (ret)6 c8 @4 v9 y; M) D0 X& [* I5 l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' q8 _5 h0 v2 j+ c "%d\n", ret);1 N) D4 G0 G/ H# U" M) t
#endif! t e/ g' y; z9 k6 j% k# k% x
ret = platform_device_register(&da850_evm_tl_leds_device);
4 a' R* f/ A% E6 a% J if (ret)& j7 G, u4 O7 v
pr_warning("Could not register som GPIO expander LEDS");8 C. C1 v8 K, r- e, G
else. T1 U& R' m2 Y. M! L. L* t W
printk(KERN_INFO "LED register sucessful!\n");4 P- a1 B; e! D$ w _
$ R8 j! v, q4 W( y" G9 w return ret;
4 Z1 z1 b' o, O! Q4 h J}
( [3 d. G f3 |; C
- w0 \( y) Y! M# F8 B/ R& Lstatic void __exit led_platform_exit(void)
( {0 ]6 F3 h0 w1 @) |2 X! S6 J{, g' s2 V0 q3 z+ T6 Z- N0 T
platform_device_unregister(&da850_evm_tl_leds_device);
7 ` Q. R r& `( o* t! [' L1 v/ }& N
: v/ ?$ }$ {5 ]) s2 `5 s printk(KERN_INFO "LED unregister!\n");. z: U9 t1 M4 z5 [4 }
}
# b ^% |+ o% F! N3 [
3 Y# B( d* {' ~5 R7 N- `' Qmodule_init(led_platform_init);2 ~5 A+ [5 h* w7 y8 m8 m. C4 _
module_exit(led_platform_exit);9 y3 T' u- O) |$ G8 t
1 ] C7 @ Z" z9 fMODULE_DESCRIPTION("Led platform driver");
3 E+ I8 G9 k. F6 }5 }- jMODULE_AUTHOR("Tronlong");
' K6 ?7 r9 x. a6 LMODULE_LICENSE("GPL");
f c. _* x: F2 O( K1 T( M1 C3 O: I) `/ F% T
|
|