|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 E* w/ k0 b& I#include <linux/init.h>
3 C& J! V2 R$ [! J. \ U- j1 A#include <linux/module.h>; d( \1 ^! q( |. N+ I: o* Q* c1 u
#include <linux/kernel.h>! v- a2 ^; ?" G' y
#include <linux/types.h>' {3 H1 u+ s9 [2 P6 W$ e
#include <linux/gpio.h>
8 l$ |! U' \; k#include <linux/leds.h>
. d* k0 |' b, @8 z! r' C#include <linux/platform_device.h>
! S3 F/ m* r1 {* L, ]0 g6 W5 v) Q3 r& n& r& i" R
#include <asm/mach-types.h>
/ B. a N9 G, C$ o, V1 I" |, ]- C#include <asm/mach/arch.h>
9 i, I v* f b2 ]2 P2 ]#include <mach/da8xx.h>( d/ ]6 V+ d' U' M% Q
#include <mach/mux.h> b1 U" W2 M1 j) D: v, X' [/ D
& p- h h& q3 ^, `# v2 l: `; \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); d6 p" `; X" _4 X$ G6 a8 z; K
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( ?* D9 B. E) _7 j; A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 L& c: G) C# y% d( G8 S; l9 k/ j
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ F2 i+ E4 @' M9 \. X' U- V( O ?
- |5 I3 H! k1 y7 |- H% H/* assign the tl som board LED-GPIOs*/
4 N6 E) u# J; }static const short da850_evm_tl_user_led_pins[] = {0 E. z) D2 |! w2 R+ W
/* These pins are definition at <mach/mux.h> file */
) e' T# L v* \& n3 G( { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 h& V b8 n `8 C% |* g# w2 X, {
-15 _) @0 P/ U9 @3 V$ G
};* \9 C/ j; Z: u" O
" A- }! n ?) zstatic struct gpio_led da850_evm_tl_leds[] = {
! u* `8 L& x1 m+ r" Q7 ? {
. l; h8 t2 V) c .active_low = 0,
6 a$ a0 q7 ?" N; m0 T$ } .gpio = DA850_USER_LED0,! z2 D# l+ D3 `8 r# ~; g
.name = "user_led0",
$ k4 O, Z; ~, ?4 ~5 }6 t .default_trigger = "default-on",& ^ S1 A$ Z) i* N
},4 ~0 _* }) R* W \' o q) d
{% _$ ?9 ^8 |; O* s: q
.active_low = 0,
/ v, k$ X; ~! A3 T% U* x .gpio = DA850_USER_LED1,: Z& @; ^: l( I F
.name = "user_led1",- c: ?! r; a# o( O+ O+ x6 Y
.default_trigger = "default-on",' e3 A% ^% A" d
},
. q5 T! {# `: A( U' A {8 i# U+ N" B5 O7 \0 k) n, {0 Q
.active_low = 0,
/ k0 i, m; Z8 G8 Y, p# X .gpio = DA850_USER_LED2,
4 j" t7 K* B* X6 R) P .name = "user_led2",
0 u+ d- `+ X% W2 G" \ .default_trigger = "default-on",
! @0 J* q7 z& y" O& p8 E1 E k2 h },3 x" _5 M- p& K3 m8 T" z
{+ p& m4 r( R% v
.active_low = 0,
: g0 @/ Z- `# \$ g! `# q0 K: G2 h .gpio = DA850_USER_LED3,
, }# c% q' T1 S- m! k! M# g' d6 q .name = "user_led3",0 }/ l% }& K. w- ^
.default_trigger = "default-on",
- T+ ~4 F* V, k$ n% ^ },
% y7 d( g# r0 j* z3 q};; u9 ^2 U8 _3 X
2 G1 X; b6 M$ w0 t9 p
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' A, V+ g" Z% t) @+ Q! S9 D; b .leds = da850_evm_tl_leds,
! i- [+ Y7 ~; N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- Z: B! Q. u' M/ L0 F5 o};5 l3 b$ F$ n4 Z$ n7 y
+ ~+ A0 x% Z$ f# E h2 `static void led_dev_release(struct device *dev)9 x' b3 j( @! g: U: i
{- j8 W+ K7 @; d. _$ N$ K
};
$ v2 J8 k, L* U& Y8 p
3 {) @6 z$ v- Z9 astatic struct platform_device da850_evm_tl_leds_device = {
7 O, [; m) Q0 H& Y o, U/ E9 B% s( g .name = "leds-gpio",
2 V" I$ s3 S m/ x" d' v+ j .id = 1,$ |2 ] a$ c+ l
.dev = {
, E3 h' ^; i, V .platform_data = &da850_evm_tl_leds_pdata,; ^) r% i& B1 u+ ?
.release = led_dev_release,
. h& r3 b# L) {8 L* s$ V T }# g( T: L: a! X
};& o2 s: ^) _( W y
/ ^8 V1 x( N6 s2 m& ]static int __init led_platform_init(void)" i; F5 l8 o* r5 y
{
- @7 M2 @7 q4 Y$ T r4 n int ret;
2 c6 _; W t& l6 |1 b7 ^/ ~#if 0' U1 V. g9 e3 [# n. I8 U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! k& E7 m5 M8 D. }9 i! m if (ret)# {6 `3 y) W9 J5 p2 i: y& t, g' B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 Y4 P) n/ q& Z* x$ y ]& t
"%d\n", ret);5 ]6 c$ l' f5 D% d
#endif+ O; `) |- J3 R2 `8 V* [; h# P: ?
ret = platform_device_register(&da850_evm_tl_leds_device);
2 M' ^/ s f/ S/ Q# [ if (ret)
5 V& a: W7 b6 Y8 }$ n6 e1 Y5 p pr_warning("Could not register som GPIO expander LEDS");
e$ F/ Z0 `, u% A9 r8 V else$ N w. N' T+ N' F
printk(KERN_INFO "LED register sucessful!\n");
5 b2 J" t6 h. n, P( W; u
& _* P, |; T2 n return ret;& A5 Y( A) E6 ^: D/ r2 t" L! I
}. Q6 n/ w- G' E& N2 x
0 _; m2 D: V; E
static void __exit led_platform_exit(void)
- z; Z6 R# x6 V0 @+ c! q6 f{3 z. p. P1 s: I8 l
platform_device_unregister(&da850_evm_tl_leds_device);
; |3 R1 c/ x6 ~. E- J$ A E' C A9 [ w0 W
printk(KERN_INFO "LED unregister!\n");
: G# ~! w, f& i}/ Z) q3 m/ u$ C4 O/ D- L- T; r
' y9 p: x2 w& r
module_init(led_platform_init);2 U+ K# m. o i: I* m
module_exit(led_platform_exit);0 A5 l( n2 t$ V7 ]4 } |, \
3 z. H: x6 n6 \( w, E) ]. e
MODULE_DESCRIPTION("Led platform driver");9 N0 V+ _$ B" {" D! E
MODULE_AUTHOR("Tronlong");
. B; c4 S" y0 C# r$ gMODULE_LICENSE("GPL");% n5 A+ S \% P* S3 \" K
. f: j7 I6 _* Z r% N# g, b6 b
|
|