|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 L1 [7 M& a: o ^/ A
#include <linux/init.h>, |4 g& {4 @+ D. Q. } x
#include <linux/module.h>! j6 D0 j i" O' S. @' X. L- N
#include <linux/kernel.h>
) M( a9 ^/ v( `6 m#include <linux/types.h>
. { w( n/ L7 ^, E, A Z#include <linux/gpio.h>: S( x% ~5 G% z& l6 V3 T
#include <linux/leds.h>
7 ~) g0 }0 W$ P* M- M9 l& {/ z#include <linux/platform_device.h>
0 G1 r5 v2 N6 D: l. o% [1 W* W6 }- ]8 L& W5 T6 h8 J* O
#include <asm/mach-types.h>. U8 r: \4 t' E/ B8 L; i4 W
#include <asm/mach/arch.h>
6 Q# g5 J+ s' B6 Q i' _#include <mach/da8xx.h>+ z/ \7 }- y- g2 c0 B
#include <mach/mux.h>
' B# |% I! D( v% o, A: X" a, L0 L i8 Z6 U
: T7 P6 \! Q7 Y4 F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& m, t6 j W, p* V2 q, c! N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# j8 ^3 N! i! J, m4 n3 z' i: [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 R/ t0 R' S, P3 i0 E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 R/ j9 m& B5 n* z, G6 P8 e+ n9 h6 _
/ @- T) k, J) ^! h6 D& S4 o) V
/* assign the tl som board LED-GPIOs*/
& U+ J; ^' ~; d2 [0 V1 l& o( astatic const short da850_evm_tl_user_led_pins[] = {
. W* w7 [8 H7 z7 z /* These pins are definition at <mach/mux.h> file */
0 q h( x" {8 ^2 i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" ^7 i' T3 v& `7 a, m -1
3 \, G6 L O0 a/ t# \};6 n2 D1 B9 m1 i. o
6 q; t* f' ? D5 c( _/ r" [
static struct gpio_led da850_evm_tl_leds[] = {3 }+ Z9 I" I3 X$ x& j0 T
{" g+ }( e: \7 h6 d z
.active_low = 0,
8 T/ q, R% r3 U9 G .gpio = DA850_USER_LED0,
' `5 y) r# a* q3 O" Z5 C3 g .name = "user_led0",
: d: E/ _% ~2 h$ I1 A! _+ N .default_trigger = "default-on",
1 z6 c! m' _- |( H# L( s },
3 b, F/ Z& ?0 c3 v) z {
6 R+ P ^+ ?- q& V5 ]6 c, J) s .active_low = 0,
0 K2 q' A4 g; ? .gpio = DA850_USER_LED1,- [* x' d' J/ U7 Q/ i% |0 [2 X
.name = "user_led1",
7 O; U R; C# n# |2 c4 T .default_trigger = "default-on", d$ @6 k/ Z5 f; L0 U( Y( u
},
" w' e2 Y# I7 M. S! _6 v0 ^ {+ B$ d5 S- q/ R/ k9 E4 l5 X
.active_low = 0,( X, W4 i; z7 d. m
.gpio = DA850_USER_LED2,
2 Z- S$ U7 K, {2 J .name = "user_led2",
, z. I U: A, [) k .default_trigger = "default-on",! X4 `& _ {/ ]
},
& i2 ^% Y. F, z4 X& i3 V2 h c {
$ t+ Z$ M7 O8 w0 i B1 h S .active_low = 0,
; ], R- i% y5 \7 Z: B- X .gpio = DA850_USER_LED3,8 e( m/ G+ B2 Y$ H' \
.name = "user_led3",
; l6 J( F& v+ Q A2 i .default_trigger = "default-on"," A* s, C1 {/ } ]2 C" r2 D8 E8 y
},
1 Q! v! ^( d3 [8 v% ]};" A5 x5 U P* }9 ?# [
C) P9 R1 \/ b. Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: L* F5 }! v' Z" d$ O! H J+ T
.leds = da850_evm_tl_leds,: Z1 r; J. _: Q& {' p3 O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ ]5 x( s7 o9 G. b# H/ }
};+ s6 _, Q; j4 O2 F! U# N
) M+ h' l% u2 Vstatic void led_dev_release(struct device *dev)
! y9 I6 Y* Q/ M; y+ l J{
9 ]7 @. o) W# c& v/ ^+ j};# M2 O& t, l' H% q( I. k0 V6 e. d" D
# W: K1 s; V1 J( N! c
static struct platform_device da850_evm_tl_leds_device = {
4 H* P; M V l1 n6 D .name = "leds-gpio",1 q% B8 v/ \' G5 D" j I; v
.id = 1,
* R2 j' g8 G. ~% [7 I3 }) E& I .dev = {2 x) n+ i5 }! @
.platform_data = &da850_evm_tl_leds_pdata,
2 m) Y. q, C- b/ `6 \: F .release = led_dev_release,/ l. \2 R% b0 b# j7 k4 v
}
x- T; ]3 l& t" Z$ ?: T};" p3 F' {) @' C9 ]. S- _( V
+ n; P( h/ R& c4 L; ]
static int __init led_platform_init(void)* ~2 |3 O8 M/ Y" j7 Y# p- L$ M9 y
{1 d4 P5 ~! I& `7 E5 g* ?& H8 U
int ret;% }/ A1 a2 T6 W ~, L
#if 0
9 n( N$ j) ]- A$ f3 C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 l; f$ G) e* y9 U& w9 | if (ret). h+ G+ @1 l; i* u5 l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 L5 [3 G; B5 b- m4 N# b8 H8 Q
"%d\n", ret);
- B, v$ i) G. C5 H* ]$ y: I3 U1 n#endif2 A$ \0 v4 q- |( `0 W9 w6 z
ret = platform_device_register(&da850_evm_tl_leds_device);/ N# r9 R+ s v# A
if (ret)9 U( G9 J0 L1 @4 i T9 x: B
pr_warning("Could not register som GPIO expander LEDS");& p T% i% R& O. I3 }: j( `
else9 E+ {* y4 ~$ w$ R( K3 `
printk(KERN_INFO "LED register sucessful!\n");
5 r1 B- P% M, A; S- `
! x# |7 m) n3 _8 C- K* c7 E8 h$ T return ret;0 g" l' u' j1 ~, s' e; h( ^
}
& `9 U8 V0 P. \* X$ w: C) }$ |! O: n2 Q- D% k0 A$ o Y3 G
static void __exit led_platform_exit(void)4 j- S; @7 H) I0 u: X
{
! @2 {; k% ?3 F6 T platform_device_unregister(&da850_evm_tl_leds_device);! ?) V! f7 f3 T4 o
% _" Y2 ]6 a) W7 f" D k printk(KERN_INFO "LED unregister!\n");
- L0 i5 m+ E2 q# D% m7 ^$ F}; I/ K# I/ w& J. U; c4 g. }
9 q+ [# t1 d0 x6 ?8 b1 p. `module_init(led_platform_init);" }0 l+ f; D$ z. S% b# x
module_exit(led_platform_exit);. M6 q) Q5 o; E3 C. r
" S J' ]0 I7 X; c* C/ Q( t" IMODULE_DESCRIPTION("Led platform driver");
5 R P. k" c$ x5 g) cMODULE_AUTHOR("Tronlong");
$ z1 l6 [9 h' ^9 u6 e, zMODULE_LICENSE("GPL");
7 s7 ^# j0 r! `" w* ]3 f) ^$ P$ P: z% y
|
|