|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- a1 f+ u+ t! w8 K1 T5 S) U8 {4 d
#include <linux/init.h>
3 J8 o9 o6 g7 s+ q9 R#include <linux/module.h>: \1 D0 a7 m' }
#include <linux/kernel.h>* t* j m8 k; e
#include <linux/types.h>
6 ? I' A J: z9 u#include <linux/gpio.h>" w$ Q8 I4 A1 B8 j, I2 o: O
#include <linux/leds.h>
+ ]- |3 Z c& O#include <linux/platform_device.h>
7 c- k8 R. H' y: t
/ L. b& q8 U6 Y6 [! x8 f* N$ y#include <asm/mach-types.h>4 h0 u* j7 P3 T
#include <asm/mach/arch.h>
$ a! Q: w1 O6 I#include <mach/da8xx.h>7 R* o! t9 ~( i- f
#include <mach/mux.h>4 c! L- k/ C# s# Y! H3 I
, S8 M+ V- U, B4 d( f P#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 M% K5 z" T0 }& E* A2 }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 `1 a* L9 G" T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' K: ]" f2 C |3 R$ r6 a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 f3 |8 C; c p% F
6 A% o7 k* P- v! G/* assign the tl som board LED-GPIOs*/) Y1 z' _1 U, R$ Z* d3 d
static const short da850_evm_tl_user_led_pins[] = {- j2 I9 ?# U1 r7 x7 S
/* These pins are definition at <mach/mux.h> file */
0 I G" M6 P! { f4 f9 v# Q+ A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 {8 n" ] B ? -1- R, E" U k7 [- I9 z
};
, M+ W* w/ R$ Y3 y9 G) h+ N5 K* J* ]' z5 h( }2 l
static struct gpio_led da850_evm_tl_leds[] = {
' M- q( m' W, u {' u7 g& q" T( ]/ G2 I4 E" X" J
.active_low = 0,% k X' Z# n2 w0 s, `& m6 J/ K0 E, X
.gpio = DA850_USER_LED0,
1 a3 R: Y$ q6 C* ~1 g8 D) m4 E& G. o .name = "user_led0",
3 m m6 R, F; @# G) n .default_trigger = "default-on",& a6 F3 v: L# F9 c6 H& E2 ]3 C
},
. m& z6 y+ e' _ {
) \& W8 D+ a, E' z .active_low = 0,* z; K/ G" W4 c4 M; m2 D3 z/ w
.gpio = DA850_USER_LED1,6 x$ S8 N9 G4 C+ u/ V, g
.name = "user_led1",
( F! G1 F \7 e0 f4 A% p .default_trigger = "default-on",3 M8 R6 R6 v% A5 c8 ?
},
8 ]8 K% j$ i9 g* U$ Z {% I2 O& O+ Y* ~6 [( D
.active_low = 0,8 g) U3 S4 ^4 U9 X; u# K
.gpio = DA850_USER_LED2,
; h) n5 ~0 V d) L! ?- o2 o: s .name = "user_led2",
3 ~4 Y0 |8 N: e+ l1 A$ O .default_trigger = "default-on",
' v; o# D* i8 m* M% e3 ?" P- q },* c7 @# a* n) D) V2 ]
{
5 z7 z6 B5 u) T$ ?1 | .active_low = 0,
K$ q. e: l1 _* |# \ .gpio = DA850_USER_LED3,
* U! [- Z( I: {1 P! a4 m8 W .name = "user_led3",
; K0 g k/ O8 E: `( l .default_trigger = "default-on",
. A3 i( }% ^( Q7 s+ D+ | },8 z/ I3 {& `7 M
};( J4 @/ X: \% W" ~* w6 c
" m, z& R @4 A$ ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 a* L6 P! n# V u
.leds = da850_evm_tl_leds,
. P( f2 S5 v+ ]* F: C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ ^% T9 r# ?) a. M! Z- s};) n' T5 |* i3 f# z% b9 H
$ ?4 z% h x- b3 C( R3 \static void led_dev_release(struct device *dev)1 N7 j% _ [( J; m
{) ]# r2 J/ ^" }- h8 n6 `2 ]0 E
};
; J4 K( p* {' T f. `
& T4 w( e0 d M) Istatic struct platform_device da850_evm_tl_leds_device = {
- _+ y2 X0 j3 s) C8 Z+ F .name = "leds-gpio",
2 |, a& R5 c/ }- m& P .id = 1,
8 h$ g$ o( B: r1 ~# p .dev = {, z! h0 Z7 Y/ @4 e5 X! ^6 r
.platform_data = &da850_evm_tl_leds_pdata,8 C- _' q: q* ?! F+ E- c. |
.release = led_dev_release,: g2 j1 {& N8 M+ l& p& U" Z
}7 L6 [! ~( M `# }) O
};8 m% K6 B5 u9 V; `2 ^7 [+ H2 a! ^! b
0 j; T0 |! `: R: A0 v0 h }static int __init led_platform_init(void)
4 E/ s" I5 u1 B l3 Z& L{5 S5 N p, L& s2 w+ `. E" _
int ret;
; h# l1 f: S# D! E+ A# P& p$ ]#if 0% _* P8 c, o$ I! i& Y5 _3 W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! C) ]" W2 |1 | if (ret)
, C1 c$ W" B( q) \% E: ]) L! H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 E9 Y! k9 L& g+ r "%d\n", ret);
: k4 z b& L+ G* D* m( ]#endif
" g" e i2 e3 Y+ N' p# e% u$ v' ^ ret = platform_device_register(&da850_evm_tl_leds_device);
- Q o5 B ?4 p if (ret)0 Q6 k$ Y. X8 I3 s# X: B8 {
pr_warning("Could not register som GPIO expander LEDS");
. g" U' i$ Z" b# e9 z( b else2 @2 C3 L4 X- p
printk(KERN_INFO "LED register sucessful!\n");0 |0 T- t: Z) v( q3 \3 c3 _, ~
7 ?+ f- J* O- z% |' e( F
return ret;- i# {9 P1 R) u# X6 I! c8 `0 S
}! o0 l* J8 I/ g& n* n: m0 l
S% w! ^6 t5 P/ X: t- ^static void __exit led_platform_exit(void)5 V9 u' d: S1 Z3 r% r, y
{
) Y5 K% P3 h: y0 G4 R4 t platform_device_unregister(&da850_evm_tl_leds_device);+ F5 h+ h* W4 a1 Q' _* c
- n- m( j( d0 |. m4 w* U
printk(KERN_INFO "LED unregister!\n");
, W% W1 @7 h+ Q: m3 d}$ F% }( f9 E( {; X1 E% m, x' b% w2 o
5 _) s$ Q8 ^6 b8 ?module_init(led_platform_init);
8 Y7 N% }) ?0 Amodule_exit(led_platform_exit);1 x$ `: ~1 q, R' d4 p. ^' F$ r8 P
* y9 ~: ]; A- ~MODULE_DESCRIPTION("Led platform driver");
; C: F; }' w0 H4 GMODULE_AUTHOR("Tronlong");
- `! F& [0 y! c) GMODULE_LICENSE("GPL");
7 d/ ~9 H5 Y6 x) U8 @% H6 L
7 \: R; a7 U% M |
|