|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) j% h% ~$ D: I& _
#include <linux/init.h>
' @( C) t4 j7 d* }8 h0 y#include <linux/module.h>& P6 u6 l) h, H$ l
#include <linux/kernel.h>2 w0 }$ B4 l3 \1 V( D3 p
#include <linux/types.h>
5 n6 ]; K' ~4 t* |, P- n F( @#include <linux/gpio.h>
% ?! K# S% z: ? ~1 A2 {6 q#include <linux/leds.h>8 {# N" f7 n9 `. h7 B! [2 V% x' j
#include <linux/platform_device.h>: n8 w, s ?( G0 j5 C( O( r
( [3 [" u; D) {# Y2 h7 ^#include <asm/mach-types.h>
$ N) z2 T/ E6 I- O2 }/ G#include <asm/mach/arch.h>
7 K3 z$ I }: M, d$ H#include <mach/da8xx.h>
+ F. Z: T" o# R7 J- s#include <mach/mux.h>
4 W e/ s. J7 V2 N& |; d# M
I! q' M" v1 s: e4 p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" z2 B) R% n0 R1 a# O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 F5 K8 L, R! n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 `2 w. L; v I. U" e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- O" C" f3 \9 `6 J
3 o4 w1 @/ G6 |0 `/* assign the tl som board LED-GPIOs*/: D/ ]7 U5 Z# a& Q! o6 g
static const short da850_evm_tl_user_led_pins[] = {
- r# u; C/ u) T3 C% }1 | /* These pins are definition at <mach/mux.h> file */
h2 R. ~+ T/ t a: d) X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) V1 P( T+ o0 c, Y' K1 a
-1
~7 o+ n1 q+ n: M9 L};
+ k, U% O" B$ V) H$ j" ^' Q" I6 t% P$ h
static struct gpio_led da850_evm_tl_leds[] = {6 V. H$ M4 X% T" g- v
{
% \& n( k; }) w* Y .active_low = 0,6 Z+ s" y4 ?# a. Z0 f$ r
.gpio = DA850_USER_LED0,
) p+ u5 R. |2 f, s6 N$ ~* Z .name = "user_led0",, O: S; s- I4 k" T* x4 V, S7 ~( g
.default_trigger = "default-on",
/ O$ K: S) }" _/ b }," r9 A% s1 e/ R5 C
{
5 z0 G8 g2 }, r! R2 J7 k .active_low = 0,
% U+ @7 D5 ?$ T$ _/ M% r .gpio = DA850_USER_LED1,
: a M/ `" V1 o/ G5 E .name = "user_led1",+ j. b; o; [6 J: s/ i, E
.default_trigger = "default-on",/ ]' p- l- x6 J* _8 A2 o
},5 `) ?! q: G H: J9 A
{
- O- m9 B3 @- C% I6 l9 a, |) v .active_low = 0,6 d) Z/ N# a+ Z# i8 S
.gpio = DA850_USER_LED2,
) C, R. ~* C$ f1 j8 z9 } .name = "user_led2",4 r, @0 h. F8 y
.default_trigger = "default-on",/ M4 e, p2 F' A6 Q$ x0 L) h9 R
},
# G7 U4 w3 ?; }) ? {1 I' B+ ]3 P! P4 u2 J
.active_low = 0,
- p" H! Q' I, D0 h( k# l3 F8 m" S .gpio = DA850_USER_LED3,
, w1 @7 H3 b: B3 D$ \. E% c .name = "user_led3",
% N7 N& X& |" w! K9 ~' l .default_trigger = "default-on",. {" f$ j+ y" E9 }9 U
},7 G) f% L3 {/ o# V; @0 h
};; y1 w @+ r. e# j9 P1 @
4 z9 x% j+ O7 L2 [: [1 @0 cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ ]4 ~) `& H8 X* W' J .leds = da850_evm_tl_leds,
( m/ l+ B2 L/ G0 h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 {+ I4 W0 F* h; |* F
}; q! B8 O5 ^" I# c/ J- ~( U H& f- t
0 I& e* c# ^% I( r8 \
static void led_dev_release(struct device *dev)% B" L8 }5 W7 E6 I7 i% V
{9 t! j9 l% M: M* |1 t
};. b* W& ]4 @ {6 H: s1 r
4 e! q! o3 J8 C G4 a+ W
static struct platform_device da850_evm_tl_leds_device = {
1 V* x+ z8 g! p' G0 h1 T .name = "leds-gpio",
4 H0 S; |5 k2 n( z0 [ .id = 1,
2 J0 {- \/ C7 D% { .dev = {
% B& |+ [4 r2 w9 }% D) x .platform_data = &da850_evm_tl_leds_pdata,1 t+ r3 [5 r8 k5 |# @4 ^2 }! \
.release = led_dev_release,
0 A7 o/ `8 ^2 I: }/ T: R }+ `* u# l1 K6 W! P2 \3 e1 B1 _
};8 X# N9 u$ ^" D- O, f/ N
. K' {; e' M; O$ H O
static int __init led_platform_init(void)7 j- x# w: l u8 n( c; q3 e
{
4 |2 a- _) b/ [, }, c2 J int ret;
6 j$ w7 U4 [: a8 q" V h9 X$ D#if 0
7 u% h7 P) \3 g# h, t5 X9 Y- R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" ]0 g4 e+ y8 e: @+ e if (ret)
. w0 S& R( b& O5 Z6 h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 a# F$ a( I4 P% ` "%d\n", ret);7 S% `- w( H7 C( }! N: I
#endif$ A5 f$ X0 h3 h# ]# _) P, [
ret = platform_device_register(&da850_evm_tl_leds_device);
- f1 H) O$ F% Z: K% j' K if (ret)
8 s1 W4 n. R1 q, i- y pr_warning("Could not register som GPIO expander LEDS");
Z5 D3 H9 Q$ g# P4 [ else8 o1 r; V5 q/ W* {" b* n* t
printk(KERN_INFO "LED register sucessful!\n");2 \' I+ y/ u+ y, {1 Y, N0 P
! n& E2 F5 _3 [- L6 D8 r# B9 C; a return ret;% L+ q+ y0 y' m
}) j2 @4 `$ q7 L, ]5 H8 i# w
1 q8 G( A# [( D* S5 P
static void __exit led_platform_exit(void)3 M, K9 D: `$ K. ?& s4 Z4 @/ [
{
" a; o% T- L; o1 W' O9 v platform_device_unregister(&da850_evm_tl_leds_device);
1 B b2 M8 e' C6 K) d) E- h) v6 ~% w E1 C6 |
printk(KERN_INFO "LED unregister!\n");
' O3 S: a' _/ L4 P# D}8 G: _7 N" s G
! x7 Z; W; ], j8 k' qmodule_init(led_platform_init);
% g' Y! w: F4 O1 G# X7 p! o4 Amodule_exit(led_platform_exit);
6 M3 B) j. F0 I6 i1 u
+ }0 J7 }) ~8 I P( i" d' U; tMODULE_DESCRIPTION("Led platform driver");
$ H) L+ _, U" S0 O0 O$ NMODULE_AUTHOR("Tronlong");" r: N# B/ e! h& h
MODULE_LICENSE("GPL");
8 V0 j4 F$ d5 `7 l, q7 y9 f* w! V- C2 Z& k5 G; K
|
|