|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ N7 \! G6 U- X#include <linux/init.h>2 Y& }" @. W9 F5 M B
#include <linux/module.h>
% k3 E8 o# m$ y; `: U9 d0 R" d#include <linux/kernel.h>: L2 B& b* @. Q! j" O( D
#include <linux/types.h>6 ^- k+ U. y; n
#include <linux/gpio.h>+ A# ^$ p, i2 X5 R
#include <linux/leds.h>7 r1 @8 n( I( V8 W( O3 Z: l
#include <linux/platform_device.h>' `' T& X$ k2 V4 X, Z8 O; a- q5 P
- _" c4 G8 h$ j: o#include <asm/mach-types.h>
0 ^+ Q" W6 E+ P% G R#include <asm/mach/arch.h>$ i7 V* t6 e4 a9 G- x
#include <mach/da8xx.h>
( V% O' H, ?5 Y( y5 h( \1 g0 |#include <mach/mux.h>
5 M o7 z0 L3 v8 X4 g) |/ V f% ]/ Q0 Y' x3 A+ U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* I5 W+ o3 ?- M3 Q K* I1 D+ d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) n$ K" H0 P7 t8 S( _ L#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 \8 x6 P4 N: x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% V U$ q/ U# Y- K0 w5 n# Q
8 ?7 ]! U1 Z8 ^. E/* assign the tl som board LED-GPIOs*/
+ H: r3 K. x: U, y- W" h! e2 Wstatic const short da850_evm_tl_user_led_pins[] = {
( K- e6 K$ J& R# @ /* These pins are definition at <mach/mux.h> file */5 n1 V4 C5 S' f o5 }# D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) q- A( E: Z; S4 S9 C
-1+ `8 R6 d( K3 Q7 }3 t8 `
};
: ^3 N0 s# F5 g: L& f* [
- C- F, `5 ?8 j; \! kstatic struct gpio_led da850_evm_tl_leds[] = {# }0 M: t+ E2 Z* g7 }
{
- e. M9 l' D1 n' \* T' d8 r6 C .active_low = 0,
' G/ A, ^. U: |4 L- ^ .gpio = DA850_USER_LED0,, v2 ^+ ^4 k1 `- q$ O' ^: Y
.name = "user_led0",
' x" p, G$ P+ m9 ] .default_trigger = "default-on",3 D, ~) T9 P2 V% `) _6 v3 d
},
3 [+ e d; y' P. E+ _+ S% d. A) [& y {% F+ b' b. B) ?$ l' x4 e* I' u; h
.active_low = 0,
" R. m: U& _5 C! z" H .gpio = DA850_USER_LED1,
% K6 [ y, p+ f) A0 r* t .name = "user_led1",
0 O- b v) U( Z; z* D5 R4 I9 O .default_trigger = "default-on",* T, m( }/ s. _: e$ m
},' N! K5 q! H+ F. J7 f+ [- b, T
{: B1 K5 `9 H6 m$ U e3 Q( n
.active_low = 0,
P" V, O$ X9 B- l1 N% I n .gpio = DA850_USER_LED2,
' ^" I" S/ L/ W0 w9 [' c. j .name = "user_led2",) _1 C* u0 H. I; w, |
.default_trigger = "default-on",
" j- s: D3 E# g L* s! b },' F9 W6 }' u6 I( U& S
{
$ o" ?1 E$ z2 w# q4 ^/ m" E .active_low = 0,
2 \5 X' a) E: |3 K' z; n( q1 q .gpio = DA850_USER_LED3,& e5 R( U' R5 j9 ?: F) k
.name = "user_led3",
, Q8 o: W9 [2 t( J2 C4 ^7 q/ B .default_trigger = "default-on",
5 q8 U9 H5 O9 a5 h( `0 H },
6 C y7 F) ?0 j5 n- u};
5 K( {- R! M" s( {3 U2 K" c
) P+ @0 r X2 N% d- Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
C. u+ \( g# y1 X( G .leds = da850_evm_tl_leds,. b4 u* G6 O* m4 V" G. ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( ~" Q* J0 m: E. u" H};& b5 ]# ]0 L' e$ |6 T: Y
. s1 K) f- k( @- `! q7 ]$ n3 |: }, }
static void led_dev_release(struct device *dev)3 I) ` N* p# Y# s. W, ]
{
9 S$ v2 @/ q! }3 D; l! j7 Z};4 D8 P7 H( n# ?& ^# L4 T
" S: K% M8 ~* F
static struct platform_device da850_evm_tl_leds_device = {3 e7 L7 L5 r. o+ j2 |
.name = "leds-gpio",
& G2 W( a7 n$ ]& N) U3 r$ D! W .id = 1,
% D1 j6 p7 G0 x: v2 |% h .dev = {
& b, q q, n+ U5 H .platform_data = &da850_evm_tl_leds_pdata,
! x# f) V( U' K+ j .release = led_dev_release,
# s. M4 I$ H* u3 S% g$ A }
# l7 [5 C5 h- o};" Q8 R2 w: M( {9 F& T7 N
# {0 \5 X: l% }static int __init led_platform_init(void)
" k; j# O& G2 G6 m{: I1 Y$ Z' L* H1 g8 A# G
int ret;
" w& y5 N7 i" k; q( [$ C) D9 L# Q#if 0; R8 u/ }4 \( {: Z5 g f7 b+ s7 E1 w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ k0 Q. D- \7 A7 D- r+ j
if (ret)$ M3 X y* ?- c" x N Q! G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 U) ~% Q7 I- E6 i$ M, g4 ~ y "%d\n", ret);
6 y- T. ?+ T) s+ K7 {#endif
( D7 [" }/ @+ u; @ ret = platform_device_register(&da850_evm_tl_leds_device);# u) D% W, H; D& N
if (ret)
+ s/ P/ M1 G* C1 W: i pr_warning("Could not register som GPIO expander LEDS");8 G/ X; Q; Y. d" v6 T" O
else6 M0 w; l, ~) d
printk(KERN_INFO "LED register sucessful!\n");: j9 }( Q* \, H( @
* D; S4 K6 I0 S, k* i1 K. `! G
return ret;7 x; M1 q/ ^7 m/ u. \
}2 G, `# g* |% m& Q, Z( u, R$ v
' e f/ g4 {( o/ b( e/ q
static void __exit led_platform_exit(void)
! V, h2 V' _$ `7 x( W, m{$ y: H+ ~1 ?. W! m
platform_device_unregister(&da850_evm_tl_leds_device);" ?$ x9 H( y1 N% E. i$ @
% f# v6 {$ [ C" z
printk(KERN_INFO "LED unregister!\n");
% l5 _& N3 d. p2 `4 O8 M}
4 s+ |' {: D6 g* P4 u0 Z% n( r2 u: G
& n3 h9 A# P- w9 @3 p+ C# s0 _module_init(led_platform_init);8 h0 X8 e; [0 Z' a
module_exit(led_platform_exit);
, n/ A ?. @. e" [, V% S' \' F) O$ m0 U- v) i# l6 F% B5 i
MODULE_DESCRIPTION("Led platform driver");$ r* y1 `' b$ c
MODULE_AUTHOR("Tronlong");
+ B, N0 o0 O; O$ SMODULE_LICENSE("GPL");- }) w) X B8 T0 R7 z8 u* a
4 i" R4 ?; j. d1 _
|
|