|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 X s& K: k+ G) T! Q#include <linux/init.h>9 ]7 o6 z$ R$ x8 B( D
#include <linux/module.h>& p3 D2 u( C: d9 \" I* W5 s
#include <linux/kernel.h>0 b4 C9 @1 C* F4 G
#include <linux/types.h>
* L1 v' }1 R9 Y#include <linux/gpio.h>
; h+ p, |% @2 P#include <linux/leds.h>
/ T% a( e. [- w#include <linux/platform_device.h>
3 y' }* y6 G3 N' u+ {' n5 Q' }0 T* m5 `
2 ~: K8 Q4 b4 Y( c2 ]+ o/ P#include <asm/mach-types.h>9 R. S" V" w: E
#include <asm/mach/arch.h>
- m' G# g o0 c, ?0 Y% O: i9 F& _: a) D#include <mach/da8xx.h>! p @' m; |& `+ J. Y. |
#include <mach/mux.h>
1 ` A4 h" f+ A! L9 T% ^+ Y0 J0 Y! l: H: @! \' @0 T! Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; ^2 Z# s! N; @9 ], Z6 ?" Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 U% Z) b+ Q5 j1 D1 E3 Q( ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) n9 }5 J: H' J$ W& g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ a* P0 T2 E' ]2 L2 o/ J$ e4 ^+ @9 @2 c: N
/* assign the tl som board LED-GPIOs*/
0 V1 r# h) h/ g W/ Q9 ystatic const short da850_evm_tl_user_led_pins[] = {, c) Y# U3 D' Q. y1 e+ ]* d
/* These pins are definition at <mach/mux.h> file */% B! k! e$ W* C8 K; o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* n K' C2 J+ w$ ] k5 c
-1* w; n( [6 b( K! @
};
# }/ x8 S1 b" m3 j7 n5 ~3 C
6 F) s+ t2 C! x3 s2 B8 u+ e1 mstatic struct gpio_led da850_evm_tl_leds[] = {% m2 _5 u: Q0 Q$ n, a
{
7 w2 g- X+ Z/ V6 R/ p) o .active_low = 0,& V5 ?% r9 f ~3 f3 V
.gpio = DA850_USER_LED0,
" p. e& T5 B4 O9 }- u& x .name = "user_led0",) M: K6 {0 w3 ^5 } D: v! {
.default_trigger = "default-on"," ^6 k# }2 ~ x1 ?6 x, Z1 J" `
},
4 E* Q, e- k3 I6 r/ p {- M1 o5 W" ~- X5 _9 _
.active_low = 0,
/ |+ o4 |$ F% y( u- J, b% m .gpio = DA850_USER_LED1,
, Z" R$ b* t" v# @, l .name = "user_led1",3 K. j3 {6 I6 u! F1 c2 [7 i/ E
.default_trigger = "default-on",
4 B, C- @7 H, i: n6 }4 K },! r+ v3 g- ]6 `! o! g
{3 R# V7 y! H% M! K& H2 N
.active_low = 0,
3 E4 D6 a& Y s# d$ H .gpio = DA850_USER_LED2,4 _3 d: S7 E$ |3 X
.name = "user_led2",
S; E# W6 M: q$ Y# y5 `! V) V3 { .default_trigger = "default-on",
0 r: O: b8 F( w' E% N },3 H; R; ]! d' x2 J, i1 b# g H
{
" S8 B) ?* u* K- s. _* M .active_low = 0,
( \& |5 Q( j3 v+ B .gpio = DA850_USER_LED3, K- i( D- s3 q4 d4 K4 R: U, @" E' J
.name = "user_led3",
6 S. Z: o; B% p% h .default_trigger = "default-on",
" C8 ~! R b k* z+ ^, F7 U },2 s6 `- i+ h, ^- e& I" d) k
};
: A; j( W7 K4 z+ |; w, H$ O v4 G c$ K( y6 ` \# c- v; I& f8 a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* b- ~7 d3 F% ^9 p% d .leds = da850_evm_tl_leds,
0 S' Q- ?5 U: a) V! f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 i3 B. i' z8 b0 p+ |" h& s6 [; [};
3 t! \* J/ A' P, S4 I, K
9 ? \% F9 v0 h, vstatic void led_dev_release(struct device *dev)
/ M! [" a) @" \* T" y6 ]- h- C c% r{
" F; L2 c5 p' r" ^. k5 v! y};
/ A; h: q1 M2 `, Y
- U: ~ k: S |( P% Rstatic struct platform_device da850_evm_tl_leds_device = {. q1 K j) i1 w7 x
.name = "leds-gpio",
2 x2 S0 o4 P" Q. M5 z" p .id = 1,' u2 [/ I2 l- T. g3 z8 v
.dev = {
c ]2 `' W" N6 n- N3 f a6 R .platform_data = &da850_evm_tl_leds_pdata,4 [3 _& g( X* y& M3 |1 E/ }
.release = led_dev_release,
' v0 S/ u- w4 x% n- ^. |2 l }- C/ ]6 Z( \- U7 C4 F
};. _1 L% V& s3 v
+ K9 O0 d6 q8 z+ R- f ]% P. L4 ^
static int __init led_platform_init(void) ?) t4 l& @9 z2 E. A$ s+ ?! a
{1 v& S9 X4 \8 `7 b1 K8 R2 v
int ret;
5 ~- U+ }: a* @/ T) R" e#if 00 P3 N. Y- Q. n2 d! \4 s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 p1 r+ ]! B+ }4 a( k; w
if (ret)5 |4 N6 V# k4 l; x6 Q$ A$ c! w
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* } r+ P3 s; L. n0 L; ~' q
"%d\n", ret);
+ \& u- E9 T0 [) ]& T& h#endif
: h. N1 g# A, U3 b2 y ret = platform_device_register(&da850_evm_tl_leds_device);# v/ E+ }6 R( R$ f8 f1 g4 x
if (ret)
3 Z( r; |8 v" P% h0 ?1 M pr_warning("Could not register som GPIO expander LEDS");
( @8 X. a0 p* }9 b" C/ T8 C else
- G4 G# [+ N8 s( ^5 W* p printk(KERN_INFO "LED register sucessful!\n");) D) ?/ {: l, |0 p/ G2 n; K
; l) j7 y& g4 O' D% m6 g
return ret;
I/ Y" a( H0 u! L2 V}( j* [- w. k5 X( I8 C5 \" b3 }
: Z, t- p' _2 b9 {7 j' @: n$ A; rstatic void __exit led_platform_exit(void)8 B4 H' I% ]5 k1 {/ b) a! h8 \
{
4 y& ^& k% D, Q8 Z5 k# f/ k platform_device_unregister(&da850_evm_tl_leds_device);+ f# C2 F% `+ [; ?% I4 B
- `( `7 y0 `2 F, g0 U! T U
printk(KERN_INFO "LED unregister!\n");/ |) p* e, b0 w, i9 [
}
9 J% ^7 Y. q9 ]2 }5 E, a% ^& _; \7 T- j1 r' u2 U! e- x# `6 I- C
module_init(led_platform_init);. f6 ? K5 z$ c; F" J
module_exit(led_platform_exit);
$ y, _0 M5 R8 J+ p2 o- [+ ?0 D5 s$ ?7 A& `# o$ _8 W/ D
MODULE_DESCRIPTION("Led platform driver");
1 k7 X3 N. f7 WMODULE_AUTHOR("Tronlong");
( Q) h: m: Q2 a" U3 p8 oMODULE_LICENSE("GPL");
$ M& z6 X% ]0 ~1 X' O
- ]! {) S l6 N5 j$ s |
|