|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" S/ K. S0 t' \ D. }3 M
#include <linux/init.h>
/ b% R% b6 z& O9 x: G- O. k#include <linux/module.h>
# b# o# e6 P$ B. m#include <linux/kernel.h>3 [3 Z) ^. Z. f
#include <linux/types.h>
) d& P7 n- o6 G- v( N3 h5 S v, S#include <linux/gpio.h>
0 L R, T% X) [9 s9 k+ u: ^5 D#include <linux/leds.h>
8 Y% w& X) d# J7 l' v#include <linux/platform_device.h>. U- D- h1 s' m- ?& f
! |+ Y4 l1 I) s
#include <asm/mach-types.h>
z& F. [$ S3 I0 W; v2 @ r! i; y/ o#include <asm/mach/arch.h>
& K+ ~; g, M9 x) W# Z#include <mach/da8xx.h>
$ ^6 n8 Y) h. Y#include <mach/mux.h> U; A' u. G3 Z) s9 P U+ Z% |+ v
~- o& x7 _, P, M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% }1 K4 x! i6 z: B' C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% ?1 }; h7 p7 x5 n f/ \9 g1 |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 B' m3 \$ w# H: \) V1 k O. _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! H! u4 o+ u( y" R
9 y8 o/ I2 u( o1 J: h
/* assign the tl som board LED-GPIOs*/
4 d$ B* ]6 _* ]9 k7 _static const short da850_evm_tl_user_led_pins[] = {! Z1 q8 G/ j E. w% h7 X
/* These pins are definition at <mach/mux.h> file */5 R, k5 a3 A6 |0 B$ F% E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' u! Q$ U. d" J/ d -1" C1 k! X( b: C% ]' f7 h. T( |: D8 n: p4 U
};- b7 f: o. ^3 {7 w
( o3 g4 `9 F* N" b! j' N% K) B
static struct gpio_led da850_evm_tl_leds[] = {" ?% ?( B. ^- J# U
{0 J) b& _- L; Z) Q% A/ o- \
.active_low = 0,; C/ K6 v) K; N% ?
.gpio = DA850_USER_LED0,
! L; j1 v7 \% p' p. e: L .name = "user_led0",* c7 w; B5 S% { w
.default_trigger = "default-on",+ z, a1 n( E, ?; ]7 I
},* T) b2 R+ T+ z; Z$ f3 _
{
- k1 J1 y! @8 F: v+ L3 P .active_low = 0,
# h/ S) T# ?4 G# x# I' }8 u( z .gpio = DA850_USER_LED1,
1 k0 Y/ w( z5 M; s' B .name = "user_led1",+ |4 d( S5 x1 M3 ?- T
.default_trigger = "default-on",# I8 Y8 y5 p x" @" K
},
* O' ]+ f" \6 g$ B. F* M* \% A# Y( R {
; c3 ^& t# J$ i3 y3 t7 K& ? .active_low = 0,
! H3 A* S6 w8 F, x5 U: t8 C- i; h .gpio = DA850_USER_LED2,* n5 h7 s- ^( L: w* O
.name = "user_led2",
3 m) m7 N4 {! F .default_trigger = "default-on",7 k3 q$ [' s! B0 }# b9 F2 ?1 d" h
},
6 Y, R3 a+ I7 \) @3 Z# e {
1 u2 N% q/ c) \3 B, N9 Y" ? .active_low = 0,
2 J- V! R3 a; M; L1 |8 r .gpio = DA850_USER_LED3,2 l, |5 |) T3 Z; J6 L
.name = "user_led3",
6 \/ Q$ U2 R2 [0 g% x .default_trigger = "default-on",
3 X$ r3 q% i: J# G& f. K },6 h2 N( i% y, B8 @' G
};
' f8 _$ F% a( z( o2 {' Q& E- N6 D* ~! r2 G; O' N7 ~1 d( F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 ^" _7 O' f- ~* f; y( f; { .leds = da850_evm_tl_leds,
4 v7 F% u3 _' J7 W .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% n* A7 I8 T; z};
7 L3 x$ j1 T4 | k9 f
; h: `+ _( x- r' T$ j \+ e) r. {static void led_dev_release(struct device *dev)
1 L( b' C/ ]2 q8 |4 q+ v) x{
. ^. F; k4 I! e, ?};# }) D2 G/ } `$ I( |
( q1 Z5 l* C' q( v2 J
static struct platform_device da850_evm_tl_leds_device = {5 z& A. L/ Z! G1 k& D
.name = "leds-gpio",. x2 x4 V" i y+ k* ]. L
.id = 1,
T& M5 e% u/ L( n+ [3 l O .dev = {7 B/ Y ?# P% D; C9 ^
.platform_data = &da850_evm_tl_leds_pdata,
Z2 T w2 Y, W- Q) a. E7 n) W .release = led_dev_release,
4 s# A2 n* E1 t: d; I4 e }+ N3 ]( r* M4 f# o0 v+ i
};
8 m7 l2 n' z; t/ r6 ]4 _* K& S2 H% A. k# C8 Y/ I
static int __init led_platform_init(void)
$ j9 F1 _# D) K7 W/ ?4 N{" u: I# Q% v1 R5 ?5 I
int ret;
2 M; I$ t, n2 B#if 0$ v/ Z1 ?' }9 c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) ]+ s! h( z7 c* z) J7 X% w
if (ret)
# A( w4 N2 Q; j5 C; s pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! v# @4 d+ H7 L5 |$ T: y7 W0 o% F
"%d\n", ret);
* a# g3 X# Z% n#endif" N+ }. a' B) n
ret = platform_device_register(&da850_evm_tl_leds_device);) D- E' {) f5 x9 R1 w
if (ret)
; d* p; D0 @& {! |8 z1 V0 E1 f; } pr_warning("Could not register som GPIO expander LEDS");
3 N( `) z B/ p* D. [ else% k* Q+ n: h( F( a
printk(KERN_INFO "LED register sucessful!\n");
$ F" B. I R/ p% p. N
4 D( b: F' o6 |9 |4 y4 u* I& F return ret;
3 A9 ?9 D5 @$ g' V W" m% G3 F}* T& j& L: I+ b# W g
- S& I1 k3 K* Z; r) M, Xstatic void __exit led_platform_exit(void)( m! O- B7 G1 i/ u
{
4 A5 o+ j; x0 T, H4 D2 o platform_device_unregister(&da850_evm_tl_leds_device);9 N1 p6 j) |5 U' g/ A
/ @8 X$ z. O0 V' E. `
printk(KERN_INFO "LED unregister!\n");+ n0 A1 @1 v# E3 W6 x! Q/ Y
}
4 v) x. ^* _0 a: G; Y5 {4 \4 C, c+ R! h' g7 X5 b
module_init(led_platform_init);
" {; |0 Y; P/ S# Z% Nmodule_exit(led_platform_exit);' B. |, l; X2 ?8 d* ]3 u
$ g3 Y- b. \+ V* WMODULE_DESCRIPTION("Led platform driver");
3 D) q3 v ]; L8 M4 X1 VMODULE_AUTHOR("Tronlong");" l. q$ I9 X0 g) Y
MODULE_LICENSE("GPL");/ g( Z3 n- L3 H) |+ W
* J7 z. j6 N7 Z |
|