|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" l% C' |' A! }) `
#include <linux/init.h>& o0 {8 @" x% H' `' n, a$ c' z1 o
#include <linux/module.h>. M+ Z( V2 Z$ z
#include <linux/kernel.h>
9 ]' z* h& Z( E4 j8 j#include <linux/types.h>
0 O% ~; R/ Q3 X#include <linux/gpio.h>; J/ b& l7 w: z+ p' w. T% Z
#include <linux/leds.h>1 H: d0 d, l* T8 C& [* r! n' _
#include <linux/platform_device.h>6 t$ {7 { U8 y ~* f2 n% \( {
' s; L6 @4 `0 f/ e. m5 ~#include <asm/mach-types.h>
/ k/ O' x5 n; j3 A5 E#include <asm/mach/arch.h>. [" z; A% [% i: ~# o9 Q6 B
#include <mach/da8xx.h># f$ @& _, E$ |5 d# I
#include <mach/mux.h>8 B0 e+ I8 m. }, A4 X* t
& U1 p! E: r2 [* C3 D5 t9 _) b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 _0 o$ m Y0 i9 k5 N. q6 x8 m+ W
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 b- W u7 e& ]; c3 W& K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ j- V' o2 _/ _6 b3 Q3 I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. a% D8 j; @3 z& B
. z1 Q: \+ |+ B3 S7 B6 h/* assign the tl som board LED-GPIOs*/
/ K- S5 ^5 O9 c* I( M9 B+ Mstatic const short da850_evm_tl_user_led_pins[] = {
1 n: g. [& L9 b5 I" s /* These pins are definition at <mach/mux.h> file */% u/ y7 H. u$ A4 H" _* f; T, V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, p2 h# B1 y4 G* T -1
- l6 {+ |( c/ ]% f0 M};
$ R% s# Y' b1 u, j7 X% H# G; v
4 h: z5 I0 k; h. J& i! gstatic struct gpio_led da850_evm_tl_leds[] = {5 j7 U! o5 `* u6 w" K, @. ]. p ^
{$ K N/ j- [1 M. N" a
.active_low = 0,
* [1 J& S0 u3 k7 I2 i .gpio = DA850_USER_LED0,
8 H+ H4 B5 {/ K4 e B- `. @ .name = "user_led0",1 S; a8 v) j/ D% y$ @
.default_trigger = "default-on",, F3 `7 l2 ?, y1 C
},
" N6 d- }2 X+ a9 C( [$ v8 R0 V( I {
3 V5 ?/ X& M7 G+ o' o. l. @ .active_low = 0,+ A% G: A/ w3 Z, a4 S
.gpio = DA850_USER_LED1,
9 O2 a( ^$ e- ` .name = "user_led1",
$ @" h" Z# V2 T' p; x3 X! R4 V .default_trigger = "default-on",
/ J$ A* J. f0 m8 N },
5 ?5 w7 R) l/ i) v {
7 d0 L/ o, [ \$ ], c5 t .active_low = 0,! Y2 { a. w4 d" ~/ X, ]/ u: w
.gpio = DA850_USER_LED2,
: ]5 `5 ] o4 J .name = "user_led2",
: |% s( ~& H9 @ .default_trigger = "default-on",3 [* d$ z' Y: D: G6 n* g, V0 s" x
},& ?0 x# Y6 n+ Y( k8 E
{, A4 p( Y' |7 o
.active_low = 0,, j& N' q' x0 j- \
.gpio = DA850_USER_LED3,
1 K$ Z# B4 o, ]) U* b .name = "user_led3",' @, E3 S% H& A0 d2 a
.default_trigger = "default-on",) s( D& o) w* f8 M8 ~) Y4 p0 W T
},
7 P' _* @' ]- u! \};9 T$ ^9 C# X8 z
, K6 b$ k* N" a" T8 Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 d' _) a* s5 H4 E' ~3 e/ y .leds = da850_evm_tl_leds,
( U1 E b0 F- P7 p4 y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- n2 y6 p5 V* m6 F( ^& A, h; G0 o
};
! z/ ]! H# v, | F) N3 d
E# V& I3 x& q rstatic void led_dev_release(struct device *dev)
* N+ `* R% |% n+ y) V5 o{' Z3 u0 d& U& m/ y( d
};1 R: I8 a% Y4 K1 T9 ?- i& ~
; `! V+ ]. Q/ _8 \
static struct platform_device da850_evm_tl_leds_device = {( D0 B* e( X+ `% T+ \- w% Q$ T" v9 n
.name = "leds-gpio",
5 Y) F4 d( Z! t .id = 1,7 A" a r1 N% D) p- ~9 j# r
.dev = {
: A' {9 ^: e% r& z) ^5 R6 S, l# T .platform_data = &da850_evm_tl_leds_pdata,
+ l7 B0 b$ i, Z' u z7 E# ~ .release = led_dev_release,4 X* F% p: g, w& t) a
}' {) e' l, |% e5 s( l8 B5 r f$ {- o
};; c5 s& l: P* z( F, c( s
8 ?5 d6 a; q5 |& X( _static int __init led_platform_init(void)
. q5 ^9 c/ Z, A4 k: S7 Z$ ?{
1 v7 a3 ^ G. F int ret;
/ Z) b; a( T1 D. }" o0 R: A#if 0
+ f+ O' |2 z( W- s, E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
x* f6 s6 ~: l9 X9 Z+ R if (ret)
5 }$ V S: s4 K" h% o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ q6 e. L/ C5 m3 {2 c$ v "%d\n", ret);+ _, v) m# ?# D% m' ]/ R% j
#endif
. V6 w9 q' I% |: X8 i ret = platform_device_register(&da850_evm_tl_leds_device);. o( e% l0 X# A ]" `7 d
if (ret)' ?8 R6 M4 ?$ a; ^
pr_warning("Could not register som GPIO expander LEDS");2 [2 D; o0 a5 p# u/ l5 m
else
1 r+ G4 \3 |1 ]- v5 j printk(KERN_INFO "LED register sucessful!\n");
0 D Q% o0 I8 B8 i6 \- z g2 k0 x1 Z6 }- d# t) q; _7 d, a
return ret;
5 I5 Q! y# g7 U f: B: \}* p4 @: H' d, H. p3 l
% S q( z$ q( O' v
static void __exit led_platform_exit(void)
6 Y' C0 O! r- y# g; @" B3 }( i: j{
' z. T. M$ A. R/ T7 }6 Y" W; E7 p platform_device_unregister(&da850_evm_tl_leds_device);
$ f6 b' R# _" d9 f# }! A1 s! F3 ]
* w! t4 B5 `7 V$ C! K/ T printk(KERN_INFO "LED unregister!\n"); b0 l, N& S, T( e1 X
}2 W% V3 {8 T0 M1 Z- h2 L1 E
" W' T$ Y3 [# h
module_init(led_platform_init);
% Q' c5 h# d& g+ dmodule_exit(led_platform_exit);% ?( K7 p7 ?2 g8 X2 M. C# [" h1 ^
- W4 x7 ]6 F8 O! K. x
MODULE_DESCRIPTION("Led platform driver");& n, a2 b$ v( x0 F3 t! X9 p1 L; }
MODULE_AUTHOR("Tronlong");
2 a2 B1 m }7 l5 |' xMODULE_LICENSE("GPL");
5 a% h; @9 ?& w# z' k3 ]: a% w$ {
|
|