|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; O" }* {; B- w& I+ q( `& T1 j#include <linux/init.h>
5 X$ a4 U7 M" |5 U, U#include <linux/module.h>
- S/ w2 b& O6 k#include <linux/kernel.h>
E* J4 u8 b, V P#include <linux/types.h>
; w0 P2 B/ G9 J* \' m8 o#include <linux/gpio.h>
7 v0 y- v5 h+ w, |+ P9 r#include <linux/leds.h>2 A1 S! G0 k) G# b1 o9 u1 q
#include <linux/platform_device.h>
/ q+ @1 [, E G7 {$ b+ r/ n* F% e* J6 ^ t( {. k& R
#include <asm/mach-types.h>
3 r# K4 }, ^- S4 D: g#include <asm/mach/arch.h>" f9 d8 z7 k- P" `# n. s! m
#include <mach/da8xx.h>/ l# a3 z- {, Z E+ E7 r M
#include <mach/mux.h>
- w5 Y8 f' H% B# W; m: c
6 e- x# C+ }% b/ s- J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) R0 U# }: Y$ N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( l3 C' U, A, Y+ L#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ C+ L3 J' ]6 R- l* T9 r( D) F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 K- \# o4 I2 I# D6 p# w. {
) ^: x# z$ W- ^3 ?/* assign the tl som board LED-GPIOs*/- r# v b3 q8 `% _
static const short da850_evm_tl_user_led_pins[] = {
( I$ i- F6 ~* r* z2 j/ ^0 Y /* These pins are definition at <mach/mux.h> file */2 b: S$ ^* O2 s$ L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- x9 K& V4 U6 U9 z
-17 l5 B7 W6 a' G7 _/ B
};
' i n5 x, g: H! G; A; s% y& i
3 @' Z; w0 W# k6 gstatic struct gpio_led da850_evm_tl_leds[] = {5 b) K) C, x, ^: b2 d/ j ?8 t! U/ n
{
( ^7 d3 j) I/ C; d$ ?1 y .active_low = 0,' c* s: g# K# u2 ]- |" X& V
.gpio = DA850_USER_LED0,
6 ]$ Q4 t! b( |- N& C5 |7 n) j .name = "user_led0"," L) R3 |, l. @% @6 f+ k
.default_trigger = "default-on",
: l" e5 f* @8 |2 V) r }, ~% p w% N5 S5 C4 d. W8 W
{
8 v. G! A7 O6 f .active_low = 0,! l$ @! I- b4 ~& t
.gpio = DA850_USER_LED1,
% B, L6 a8 Q# a0 ~( O .name = "user_led1",
9 a# _( D! Y/ F' F- t3 \; m U1 p .default_trigger = "default-on",( v d j- T4 q# j2 x# @' ]( t
},
2 W6 z- c; X* i7 m {
% r) G% L4 r' v4 O1 b .active_low = 0,) _ o4 D! @$ t9 u; ]
.gpio = DA850_USER_LED2,
* q" C8 x$ b- a, ~: t .name = "user_led2",
6 y3 H; v1 y% D$ [ .default_trigger = "default-on",
$ A6 u3 G9 s7 p4 X) d* w4 {& c7 Q# s },
7 D. j; i* Y. ]* x5 z; [3 R/ w {
6 ~: y3 @3 H8 i5 V0 j0 O# a .active_low = 0,( f' G$ n2 q9 `) y, G
.gpio = DA850_USER_LED3,5 z# K! o5 ], \, w. A: _
.name = "user_led3",
5 K0 _1 p' U1 Q .default_trigger = "default-on",
! J1 d1 `. w# r },1 J# k% E* w! i! F
};
u7 h" _2 L. g! v
& s! g) Q- b$ h C) ?# {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& j. T( Q( U" J* h& x' `' b .leds = da850_evm_tl_leds,
8 |$ F. f- c2 k+ Q0 ^ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 j7 j. x% M/ _1 Z
};
+ `3 ?3 K' t: ~8 G4 p$ W) _! y! K
/ u/ `, p5 g8 f- g( P- g, [: Xstatic void led_dev_release(struct device *dev)' R O2 G0 D f0 S- A& z" a2 q6 q
{# i* N( [. |! o& c* w
};* f9 {1 s' r2 o
Q+ ]1 ?# o0 z( J& n; Pstatic struct platform_device da850_evm_tl_leds_device = {
( ?* x( R* G" R% e. q .name = "leds-gpio",' t! y; O& }+ ~: N& A+ X
.id = 1,7 o9 L1 @$ k, V+ H8 U% i* S; a, P6 M: l
.dev = {
$ w' c3 R- S2 A( N% ~. n0 P: A, e .platform_data = &da850_evm_tl_leds_pdata,& k h! B+ X7 M/ t% u
.release = led_dev_release,$ \# b6 E% u8 j; Z
}
) u$ T! V1 x) N: q8 ]5 B$ A};
+ r, y' ?! \, i1 p" Q# h5 }
6 F4 S6 F0 x# ^0 h- y- P8 U4 @static int __init led_platform_init(void)
# `1 Y$ T# j' E ~1 N+ p6 M{# I5 X* a- [/ z6 q1 I4 X
int ret;1 _! t2 R c! x1 j) i
#if 08 m+ O B# n( C" i, Q7 e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 @7 N- \& g& P, I if (ret)
' @- }' S O5 \! A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 ~) D5 N0 \" L1 n4 U
"%d\n", ret);; G: X% _7 U1 o3 ^# k; J
#endif$ G7 C; ]9 F" P% h! U+ Q
ret = platform_device_register(&da850_evm_tl_leds_device);
9 j0 S2 W+ N: P' R- f+ M' n if (ret)
, }, o; d+ D$ N7 v/ ^8 [7 e pr_warning("Could not register som GPIO expander LEDS");6 m8 v" T: g/ ]5 F7 y0 n: i" u6 B
else
/ g& ?3 Y; R2 u1 f printk(KERN_INFO "LED register sucessful!\n");3 ^5 ~7 G' U7 m" y
2 c. y* Z3 b& ]5 L. q3 s return ret;
' {# ~6 i, J+ ~8 @+ `7 }}
" f% V4 N1 q" l+ Q; s0 r9 L
5 U" u1 J# `' cstatic void __exit led_platform_exit(void)1 C' l, a1 W% }' E9 |2 P! W
{
5 b9 M: x. c6 v9 y1 d& J platform_device_unregister(&da850_evm_tl_leds_device);- q: O) }( P5 [! b3 R
( I1 ^- }8 M! T+ W% A5 K
printk(KERN_INFO "LED unregister!\n");
: h: E2 [8 v0 \' L& U! w) ^}: K& u2 D# \0 u% n& W7 M- m
+ ^. Q+ b2 e5 R* cmodule_init(led_platform_init);3 i1 @1 M: K& R+ t4 M% I
module_exit(led_platform_exit);
' S& v [- S* T$ p" k3 h! }% n' z M1 }7 h
MODULE_DESCRIPTION("Led platform driver");8 U8 T) O" X1 O4 F8 p
MODULE_AUTHOR("Tronlong");( R, R+ L9 }' J
MODULE_LICENSE("GPL");
& g+ ^1 O z8 Q) ^7 D3 N& g5 d1 ^
; Z! @+ N7 R) @* v6 \& V% j |
|