|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 e% L2 G' O7 P2 k/ Q! V; O" O R8 _#include <linux/init.h>
" d! p7 [! J) X7 M#include <linux/module.h>
; _4 C) k/ W0 W, m' ]#include <linux/kernel.h>
7 j" b# J7 t* S- A$ [#include <linux/types.h>
) @, L( u8 B: ~- o ]#include <linux/gpio.h>- t- k! P" c8 \+ L$ b3 f: W7 \ k
#include <linux/leds.h>6 j8 T2 K# L8 ~; v u6 j2 ]7 d
#include <linux/platform_device.h>
, Q c* M, f3 } L% U& O7 \1 X' a7 W4 ` @* o' `
#include <asm/mach-types.h>
; G& v6 v3 ^- z' w* m0 x#include <asm/mach/arch.h>
5 r% d2 Y2 h% `#include <mach/da8xx.h>! f# M( Z6 N' `" G6 U
#include <mach/mux.h>7 H7 z% Q: C0 o' U o, E8 }
6 E9 T( f Y1 ^2 D$ F
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# t+ G& D6 X, f. ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ g' P7 M9 Z, u4 e2 n1 O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" e$ ]7 N8 f8 o+ z8 N: ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( x3 C5 o5 q% q! |" n' R
" B! x/ Q# _* z7 ^9 @3 H- o" c/* assign the tl som board LED-GPIOs*/+ `" Q+ w9 O7 C/ D0 O1 {
static const short da850_evm_tl_user_led_pins[] = {
C3 F0 O2 k. ]0 ^% }+ e /* These pins are definition at <mach/mux.h> file */0 E Y; f! q n; M& b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' ]$ K, D* b+ ^( q! s6 h( N, ^ -1+ u$ ~2 M S$ B5 T }
};7 h0 Z2 q+ {1 {+ r4 n
+ o L8 h. ~0 y" E' N- G7 W% x0 ?static struct gpio_led da850_evm_tl_leds[] = {8 S$ ~0 o' c; i. w# Q
{3 F v6 M5 L5 ]
.active_low = 0,2 n- _1 b1 e3 E
.gpio = DA850_USER_LED0,% f' E# v# F+ H% K( N# L! T
.name = "user_led0",# b, p0 A' {: t2 a) ~
.default_trigger = "default-on",
; I% ]+ O- g9 C },8 ^) j3 F0 L- E
{ h4 l, a% \* ? S) y
.active_low = 0,
% T, ~5 K9 e* B. ~; u9 @' v a2 X .gpio = DA850_USER_LED1,9 {+ z; w% R& c3 `$ k- @9 w7 V6 |
.name = "user_led1",8 {/ L8 K) e) H6 s! ~# @3 g
.default_trigger = "default-on",( ]- e4 k6 x# O
},
. E/ k6 M% d! M# O" n" H, a {* N: j, l n: U6 n a1 Q# _% @
.active_low = 0,
. U3 M2 G. d& }. q7 A' x9 }: M .gpio = DA850_USER_LED2,; v5 m+ `( b7 m/ t" J
.name = "user_led2",
+ d# h% x7 J T) g! s" z .default_trigger = "default-on",! \4 |( `; Q& h8 l! t$ S
},
+ E9 Y& T }6 G8 d a% d* g1 H {
/ u/ t) L) D$ ~8 ^) ~ .active_low = 0,/ L/ e" _. _( z$ B# h* k
.gpio = DA850_USER_LED3,1 H( I9 T- q# A) R: w5 H
.name = "user_led3"," m5 k9 _5 q- F
.default_trigger = "default-on",
1 R/ G7 o5 X- F },
; [/ \6 i3 N! j, Y6 a};! T/ V. M. s. m/ K$ e! b, e
. e! A" k" ?) `) S" ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* t0 _& p/ D( I
.leds = da850_evm_tl_leds,7 Z4 ?& c4 u0 z4 C: {2 ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; O: ]0 F- g* H% b$ G {};. ]# W( `$ n" z
7 ^/ _! Y& ~( q7 Istatic void led_dev_release(struct device *dev)
9 h# A+ \- k. }* s* @7 y+ z- c0 O{; U+ Q8 H5 A- K, x. V% _3 J; w/ r$ N
};
- ]/ q( ~3 v9 M$ C0 [. J1 z( Y* g1 Z; c5 _8 H- t1 i/ s% @
static struct platform_device da850_evm_tl_leds_device = {
; k9 D6 T' ]* D1 t .name = "leds-gpio",; }- Z" ?" r- L& z8 Y
.id = 1,1 x/ l% Y% L! e- Z6 X" y
.dev = {- B& ~" V) N% `: a( p4 e% B6 o
.platform_data = &da850_evm_tl_leds_pdata,
/ n5 b! I6 a V8 F3 g( Q .release = led_dev_release,
! ~/ o$ G$ N" I, K) Q) [% @ }
* @- V% S5 O9 v' z7 N: O};
! ^5 Q, U" j+ C$ ^& K, f+ F
. h# ~; _9 ]& H4 B0 D6 z0 y! lstatic int __init led_platform_init(void)" l1 V4 m% g, z) v
{
) @! s( \+ p, [ int ret;
' F) U; f2 l! ~: O, E#if 03 E" a( h2 T* [, ?; v. M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& [, r- \: J2 f5 L: l& Z
if (ret)% E# g$ k4 g2 @7 Y, } C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ n4 V# ]7 J8 Y E! D "%d\n", ret);
, n' B" V; t, U; c1 Y3 k#endif
9 A$ p- {0 X$ C9 T ret = platform_device_register(&da850_evm_tl_leds_device);
& e7 i& B/ p) h1 r8 K% ~ if (ret)
$ _ l' W+ o/ U9 g& V" j pr_warning("Could not register som GPIO expander LEDS");
# P& j8 B; [3 D7 C" B$ E5 C else' _2 }2 z& ]& m+ q2 q* Z1 K
printk(KERN_INFO "LED register sucessful!\n");9 ~! {$ S6 w/ b# Y2 P
7 z* J; d6 _2 q8 a9 K! V# j7 |
return ret;' T' g% x- r& L/ J4 m
}
* X1 ?* u. R; d: K* u. A: A8 x$ f% p) y1 U+ c Q. F9 l" o) f
static void __exit led_platform_exit(void)' {8 E2 d5 P( B* c' R# ?9 v
{
8 ]5 l5 v: Q' I' v platform_device_unregister(&da850_evm_tl_leds_device);
) _: I/ l; J! q G* Z
+ c2 z; i, e" p! V. s0 R: v printk(KERN_INFO "LED unregister!\n");2 @ r9 c* h* n* U8 m
}
! P* ^- ^% I6 f" w2 l
3 x7 k' ^. ~- @; v5 d3 Mmodule_init(led_platform_init);
6 \* d: |6 _) Z3 e# H8 N3 qmodule_exit(led_platform_exit);/ o2 I( R, R$ _ a
8 Q3 u7 t: X( E; W6 d- M$ d
MODULE_DESCRIPTION("Led platform driver");
; Q- }8 m3 Z; \$ n) TMODULE_AUTHOR("Tronlong");$ J0 j6 n0 A' t2 X, _/ D
MODULE_LICENSE("GPL");+ H; m; s" l# E3 p( l0 u& ^: g
; p' {; l% ?. r' W" s, B
|
|