|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! R% K$ y$ c/ A7 y4 R0 Z V#include <linux/init.h>! u+ s7 |0 m" K3 ], I: X
#include <linux/module.h>- s; ~8 [& Z2 Y6 z% ?) r
#include <linux/kernel.h>
7 g( s/ }# e2 v! y2 R: d#include <linux/types.h>; b% N( K1 d' Q2 g% Z5 }2 J- |
#include <linux/gpio.h>
/ y5 Q4 G" S% ~9 n2 l; l#include <linux/leds.h>
# y( Q1 p5 I5 Y& y2 w" T# a5 q#include <linux/platform_device.h>
" v" S6 E; J% r: u* G6 }) k0 @5 o: i; N/ V7 w
#include <asm/mach-types.h>
8 V0 T1 G9 y% L7 ]#include <asm/mach/arch.h>8 j) \5 ]5 N' [) L- v; t
#include <mach/da8xx.h>, M# V( f" i6 I4 z! v
#include <mach/mux.h>
0 a @. Z( ~& n) d4 g$ {4 Q" T0 G* v$ h; K0 c' S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 l5 x- i* \/ l4 q$ R7 U2 _/ ]' c3 p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). \/ \4 z4 u4 {9 h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 w* [& `6 D5 j# ~1 p
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 W* |0 c8 L2 n0 U0 j( b* y4 s& _4 }5 W3 x" ^+ E2 c3 \4 G
/* assign the tl som board LED-GPIOs*/
' f5 I6 S1 ?' \% P& g& |0 qstatic const short da850_evm_tl_user_led_pins[] = {
5 s% Y m1 Y5 o5 s, D1 m /* These pins are definition at <mach/mux.h> file */
& l) W) S5 o7 U6 E" T* X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, E3 ~7 l' n& i- }6 J$ _ -1
* b& \! W: y: ]) [8 _& P) U5 m};# w* v: @, W( J6 u* [
' ^0 e* S6 ?, @! C( g. p
static struct gpio_led da850_evm_tl_leds[] = {) I# R" M, G U) L
{
, G( e( x8 o: I. m/ U; _ .active_low = 0,8 G& |7 T5 |; ~9 ?
.gpio = DA850_USER_LED0,
]3 m+ ~, I" T K" g .name = "user_led0",
$ d2 F6 A7 E6 |4 |" J9 t .default_trigger = "default-on",
. a ~. R% I: q# D },
0 A' E& R! }' o" F" H0 M {0 [4 ?' j2 t5 a) \9 W, F) I
.active_low = 0,; N# H$ |9 \+ p% g# m; r6 j# c7 Q
.gpio = DA850_USER_LED1,
3 w( X o+ m& Q8 d; w- Z% ` .name = "user_led1",
$ y0 J( ~: X0 I! Z$ K8 Z) b: w* M1 t .default_trigger = "default-on",
& l- m9 ^0 E/ O8 v& {; i( G },
# y) a9 ^3 p" X% d {6 Z" h# B9 C# c1 g# f
.active_low = 0,
0 e2 i) ]+ g: W, B% a .gpio = DA850_USER_LED2,) V( s3 g& m/ S$ {" g/ S9 B
.name = "user_led2",6 _ P# R% ]: z9 t) i' t4 Z
.default_trigger = "default-on"," y% e& C2 M) v" Q* V. m4 t
},9 a: ^& N6 D7 H2 b4 D0 I
{' `& \+ R$ A$ p" H8 |- m6 s
.active_low = 0,
: g: ?; i$ g/ g B! k .gpio = DA850_USER_LED3,
( E6 g; a, J. x& A. k9 ] .name = "user_led3",) A0 I( d6 A1 b. A: m! M
.default_trigger = "default-on",3 q2 W+ d0 u8 I; j! I' c
},
! u4 T& H* ]' ?4 p" S};
6 a. A& H- n7 X. |' O+ x/ \% @, Y' M/ Y4 Z; y) a/ G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ h" ?& }- M9 t8 y9 f1 p; Q
.leds = da850_evm_tl_leds,
$ Y( o1 V& `' L) f, ? .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' C0 a' R7 g* g4 ]+ ]" q
};+ y& y" g" u1 z& Y8 Q
! y- \8 b/ A9 P: Astatic void led_dev_release(struct device *dev)* ?6 n" r5 Z% ~4 i9 p
{1 _: ]+ x2 q" s$ P; ^
};) G/ U, h W7 F
4 T+ Z! s7 k A! d
static struct platform_device da850_evm_tl_leds_device = {* d: e x/ e& O5 A8 V
.name = "leds-gpio",
5 u) ~% }7 ?3 O. a) R .id = 1,
U5 C, n" _2 x$ i$ s/ d+ O .dev = {) W. {7 H5 c1 C; q+ g' K& s& b, P% r
.platform_data = &da850_evm_tl_leds_pdata,
) g( U' _) b9 c. |: m5 w8 l .release = led_dev_release,
4 k$ D1 M! }; `# w* P }
2 _' b. c0 Y+ I _: S& W8 d' D};; a- W; q; [& \' O' z" O$ {1 }4 W
, A( n6 E/ o- Q
static int __init led_platform_init(void)
: L: O9 U1 M D( K$ d9 u: B* n{6 q8 T7 L( S4 Q" M' d: F
int ret;
& ]: P, H4 Z* I5 n#if 0
9 c" c$ }, e# d" z! I+ I! K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* c5 t. f5 x% U# z if (ret)
" Z8 m' }4 R) b# o6 u- u pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ g2 @" V; X" F/ P
"%d\n", ret);- @0 H" Q8 d% K6 M7 b' H) l
#endif
' w1 ]: H$ u& A; i( L ret = platform_device_register(&da850_evm_tl_leds_device);* M; h/ U; x7 J& Q: X5 e
if (ret)
8 M0 I2 m- H `6 \ pr_warning("Could not register som GPIO expander LEDS");
, w, c2 O) a3 t1 N else
( O* w3 X( d& W. C5 [: U; m printk(KERN_INFO "LED register sucessful!\n");" w, f. Z9 Y* D( k7 J9 c* P
# U+ u/ j* E1 v6 ^3 J. `% M/ r3 m return ret;- T8 F4 p& z2 l* G2 T [5 `
}
" X9 ?( i. Q& n# d. F( @/ e, C" a( j# D
static void __exit led_platform_exit(void)
1 Y( w: r: z9 z& O{) a( s1 O% s1 _, q& h
platform_device_unregister(&da850_evm_tl_leds_device);7 |$ K' ? w( ~6 B# M6 q/ B
4 s! `$ k) @, F! o
printk(KERN_INFO "LED unregister!\n");. M& k, z; @& E9 f# A' z2 t; g
}6 E' i$ k( [1 p0 Y M. C" O
, c4 o* m& _; t9 D( h* h% }9 i
module_init(led_platform_init);
4 x4 u& |" u2 M/ R% P( v L4 dmodule_exit(led_platform_exit);$ I- i( c$ e$ F$ Q- G; m2 _
8 O" D# m2 V/ I' ^" @, C9 Z
MODULE_DESCRIPTION("Led platform driver");
0 G+ B4 I* i5 t) {MODULE_AUTHOR("Tronlong");
! j& T5 V% b( w; S" t' }MODULE_LICENSE("GPL");
4 \0 T" R. S$ o6 [) e$ w4 y. m) F: G3 h, T+ M
|
|