|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' {7 @" C7 m% Q, A; K; g
#include <linux/init.h>2 D$ O3 G* \& T1 S6 K( n
#include <linux/module.h>! |( @9 t7 W; k8 V; c/ ]8 z* a
#include <linux/kernel.h>3 u: B% |- C$ K$ e" f
#include <linux/types.h>
, q' {0 y5 t, `% ]#include <linux/gpio.h>7 O. f+ U! [/ P: s2 M% n& e9 r: R" z
#include <linux/leds.h>
% L4 M2 {. _9 Q ] m) h#include <linux/platform_device.h>; Y& p" v! j8 V2 ?: N9 i# i
1 k3 |" t: L% W; c% m; B( e3 x5 [#include <asm/mach-types.h>
; _7 b* \; W7 L# Z& Q#include <asm/mach/arch.h>
6 T! b* M: K4 j. L/ E6 Q0 S5 I+ F#include <mach/da8xx.h>
9 j( X2 J# w1 ^$ D" w8 g9 o& `# r#include <mach/mux.h>4 k5 t! _" o4 H d7 y1 [6 H3 L
% K8 f d. \. q6 g% p3 I P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' m" F* V, |) C$ r" T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 }8 Z. _/ I- G4 b. z& z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& p0 }7 f( Z- f1 I- @) | A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 c" }) n1 P: B& S
/ l7 ]3 C* c! d/ ?( R7 a" `9 u# r
/* assign the tl som board LED-GPIOs*/$ l. K6 M" q1 ~8 J2 z+ B
static const short da850_evm_tl_user_led_pins[] = {: U- g# n5 M1 N6 }% D" ^2 V
/* These pins are definition at <mach/mux.h> file */1 A: k: F. `& `% b2 k' {% E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! w% T) O% v, P7 [- x8 y
-1( w" a3 v1 R% c M7 _& O+ F/ {
};2 o0 O- o4 A8 J, v' b
. w8 W; e: R, O. y. |: dstatic struct gpio_led da850_evm_tl_leds[] = {
6 m1 e1 F& i g. l# _; h3 e+ ~! n5 Y { D" n) H- ^/ O# M. o
.active_low = 0,
( @+ _5 c5 l x7 R .gpio = DA850_USER_LED0,& S; L$ H& P5 T1 W, v
.name = "user_led0",
% Z1 t' U8 ?& k: y .default_trigger = "default-on",
- r4 d! T$ k3 S: p: M6 k },. b) m/ N# _# t3 V8 ~+ k
{
: v d f0 v6 l6 e3 G3 g4 O7 M .active_low = 0,+ W$ b2 K" G. d+ i( ]" o2 [0 [! k
.gpio = DA850_USER_LED1,
0 K. N' y/ ^$ Z8 D% ` .name = "user_led1",
( Y9 c; I/ s- E6 _7 O9 A .default_trigger = "default-on",
* {3 m4 b/ h5 a( n2 v },
/ }2 J" |# }" h! Z+ L {: s2 W1 R- S2 b- ~* f/ D% J/ f
.active_low = 0,6 {* c* X! G) G4 F! i/ H
.gpio = DA850_USER_LED2,
: N! i' d% h8 r .name = "user_led2",
4 O9 r: k1 F1 g, V( N7 p; i7 H .default_trigger = "default-on",3 Y1 E: v& w, g x! Y
},8 h' _$ ^* S- i3 ?, U- E
{- t$ l) v' N8 Z: ~, u3 p1 w& g
.active_low = 0,# Q6 }0 U' M0 l# I4 |; ]+ T
.gpio = DA850_USER_LED3,& r! S" o! n' h) E" a$ A
.name = "user_led3",* a3 M, m+ J# K; c3 A1 \
.default_trigger = "default-on",- P) v* D' `' U* b
},- ]+ `! X! J. N+ p) o' {( u
};8 F! A( A7 G- x1 ?* f
# B5 F$ {) | j3 h2 t% w+ q1 ?- `9 B; ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 b2 B3 P: u# k! ?/ H2 C .leds = da850_evm_tl_leds,. G& F! J, o6 D" T' v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 x3 S% d0 |: |};
- S, ^) O7 d* h/ B% a( w' O7 z6 S& {' U
static void led_dev_release(struct device *dev)
* d% a9 q0 E0 E9 K{
9 C+ v% w7 x' E2 k5 T};( {1 K5 O2 |- y$ e/ C2 P$ m
- }0 r6 c( H' w2 Tstatic struct platform_device da850_evm_tl_leds_device = {
: B Y; `" @3 U& R" Y2 \4 c* Q- x .name = "leds-gpio",$ s$ @$ c8 @/ _
.id = 1,6 C0 ?# c8 X: T% Y% y) V, [3 M
.dev = {
5 U! z7 ^( [8 F" N4 \3 U. K .platform_data = &da850_evm_tl_leds_pdata,5 J& a, f, J" ^* F% u3 R
.release = led_dev_release,' |, Q. j% D; J7 P7 n6 A
}
' f) L6 B! A4 ^" u};
0 E' g1 s. i2 c$ \* J- a# W+ m$ h& e
static int __init led_platform_init(void)
& Y' C2 f6 d& R. e0 h, v3 u% w5 D{+ S$ Z: Y8 j1 V) n8 x
int ret;
6 V; Y: E; m% P( M#if 0# I5 P& b) N4 k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) e" R" A, j% s. q M/ E
if (ret)
: \0 x8 I, |! p) B4 u2 l) k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 u- Q% `) R [+ [' u5 `9 O, \+ L
"%d\n", ret);3 Y, i0 s) F* A5 [* Z
#endif
8 {6 v2 S% p' k ret = platform_device_register(&da850_evm_tl_leds_device);1 F( N1 [( V' |1 R- r. F
if (ret)
' E* a" U8 a( y) t. n pr_warning("Could not register som GPIO expander LEDS");
* r E) f+ r3 y2 L& T. e else9 ?1 n/ I) P" n4 l3 A
printk(KERN_INFO "LED register sucessful!\n");' r6 v8 r+ ^ ~9 a* l# B8 }
& n6 l# W! T: s1 |4 O7 ~% A
return ret;
; |- k" G9 m( c$ ~& t# s* r, A}! g; r& {: P8 _1 e, h
" u* d' n' y* h$ O k1 S
static void __exit led_platform_exit(void)
. t3 O7 H4 n( @" s3 l% l; Q{* ?% l- P# [) A/ o% B+ M
platform_device_unregister(&da850_evm_tl_leds_device);
% }. A! ?1 O& [' R P* W3 Q7 G+ P- T' r" D& J; E7 Y
printk(KERN_INFO "LED unregister!\n");
v8 }. ]7 u6 Q; s8 k1 Q( f- S}4 u. R J8 d5 l& e; q' P. M2 {- R" n
8 ]. m+ q6 z/ j( u2 L' Y0 fmodule_init(led_platform_init);% n& f! O6 k! N
module_exit(led_platform_exit);
8 Y' q" m: O; M
3 {0 w% e6 c3 s: j7 H UMODULE_DESCRIPTION("Led platform driver");
1 N. }* J. c% |) C" _; lMODULE_AUTHOR("Tronlong");
( f$ N+ {- w3 \' K' yMODULE_LICENSE("GPL");' d; a% g5 T$ [
8 c0 `8 @; L! z; N; a% N) R; ^
|
|