|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% i2 f8 c! H# k9 }
#include <linux/init.h>. H$ y* c0 l" M9 _! U) Z' Q# ~
#include <linux/module.h>
6 {+ C+ j f( G3 V8 o0 J+ E3 w#include <linux/kernel.h>
* _: w7 d4 T! S; u#include <linux/types.h>, a3 E' h- c/ F" x
#include <linux/gpio.h>
- a1 y2 h$ M8 I; ?$ J& Z+ S* |#include <linux/leds.h>9 w) m9 _) J' E y' G E
#include <linux/platform_device.h>
5 T! }% a* p; o. Z
: S L6 J! T c5 g @; S: P#include <asm/mach-types.h>4 {2 J; [, l2 V, L. `
#include <asm/mach/arch.h>2 B) L% I# E" C& R& D- x* b
#include <mach/da8xx.h>
1 d4 M6 F. ^+ d3 ^4 Y#include <mach/mux.h>
; |& @( W. V/ x6 ]4 R/ P# T& c2 I) d' d6 J9 I" [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% K9 ?$ _- ?3 d4 G: n6 A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; O: P* `5 m2 }) E- \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: Y: L+ S v/ B2 g' W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( @& ^. ^# C* C% e& ]. z' t4 O
u+ \' @4 y4 l' q4 [, b. `/* assign the tl som board LED-GPIOs*// d& K8 ^* [% m% A5 Z
static const short da850_evm_tl_user_led_pins[] = {
7 \9 l# x& |) U: H# x8 ]2 i /* These pins are definition at <mach/mux.h> file */
8 m+ m" w, T/ @) r6 ?7 X9 ^: Q, ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 } Q* k! i" _" z% }: n7 } -1
1 m) }0 Z! o" `# x6 T};
; ~, P, a5 a) T1 o- _& m5 e# W' Y( c
static struct gpio_led da850_evm_tl_leds[] = {% `) n" G8 U! \- g
{
; j m2 D/ `1 S/ o. O' ] .active_low = 0,8 y; Y& {, [7 I' G! Q
.gpio = DA850_USER_LED0,
! j4 S3 S6 C8 d D .name = "user_led0",, L- d0 X+ p# h: O( t3 ~! O3 ]
.default_trigger = "default-on",
, m; i, G/ f+ R },' G: j: k. |. K6 }/ }9 V
{5 O# o8 d- }/ t6 I( w0 d' N
.active_low = 0,# n/ J. _# I6 D5 p2 N2 Y
.gpio = DA850_USER_LED1,+ ]! s$ ~/ V! ~ e4 K* ?( q
.name = "user_led1",
* w' R; r, \8 I8 t .default_trigger = "default-on",8 D; S0 o `. a5 N) f9 c4 G
},8 }7 c) c1 W. o, V/ t) G' ^
{
: g! X2 ] X) T }6 l. j .active_low = 0,
$ {) g3 n: I& O* A .gpio = DA850_USER_LED2,: T/ `4 Q* d$ ^
.name = "user_led2",
4 [6 Q: V7 F& c1 H, A$ s1 w. n+ ` .default_trigger = "default-on",8 \$ o0 o* W# z4 K8 c* q
},
$ |. F' @, R/ {- m8 Y+ g. n {3 a. |2 W! Y: A& y# k4 v, N
.active_low = 0,& E: m8 Q4 S! q: U0 E- Q) I" h! W
.gpio = DA850_USER_LED3,8 k9 L4 d/ W; {: J" d
.name = "user_led3",
$ M6 @- I! t$ m2 w' z8 s4 u .default_trigger = "default-on",
+ W7 L! B/ N2 O5 Q) I/ j: u& E+ ~/ F2 ^ },! U& @9 w2 \( K5 _! B2 @2 p
};7 H; [0 ]% U9 z. q/ c8 C4 X
$ O8 c! g" K3 E( o: y- Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
G3 u7 Z% Y6 B9 y! ?. ~/ F/ ` .leds = da850_evm_tl_leds,
3 x0 ?8 x9 Z. _5 I& F1 t- g .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' z3 y( y# x6 f3 W
};
" v7 o, K- m) |' r. W7 X( ?/ C0 `: x% z1 y; ]
static void led_dev_release(struct device *dev)9 V& ^) Y( C* t" U2 h; v) X$ @9 N
{
9 F+ c. E0 F" d0 d, @2 `- Z1 ^};$ v8 [% J ?/ ]& F: p% W/ n5 z
" `% l- y1 n2 G* o, U9 T' l
static struct platform_device da850_evm_tl_leds_device = {
6 h2 f! t8 ~% Y( N( { .name = "leds-gpio",
0 K5 n2 e, B2 C3 J3 D .id = 1,
( C9 C, }; _! _! I) } .dev = {
, g8 p' H% }+ m2 b& ~; L% Z .platform_data = &da850_evm_tl_leds_pdata,* i7 ^9 i: i$ P" U
.release = led_dev_release,; A1 ^$ F+ `+ x$ D* f! f3 d0 o. F
}
# C' L# W# f& C9 W I};4 S8 ]2 H! R/ @3 O) v" }) J4 e
! G$ k# E- t1 U x, a% h
static int __init led_platform_init(void)1 w9 k+ R2 Z4 `4 J- S
{- R1 y* W- X6 d0 i
int ret;6 ^! E+ I3 Q& g$ |0 |- z; j
#if 0
4 B8 l% A# [, }$ k: g3 T! U, U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" V; B" z- ?7 \% v& ?7 A8 @ Z; b, ~ if (ret)
& a, y6 C; F0 T0 M5 e# S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
K5 Y+ q% t; L0 m; R "%d\n", ret);; U5 k7 M! b; ]4 W) F7 i
#endif8 e1 E* K2 g: Q
ret = platform_device_register(&da850_evm_tl_leds_device);
; B" @: I- j3 R' A1 r! B% ] if (ret)
& Z3 L A8 j4 `& p0 [5 N+ w pr_warning("Could not register som GPIO expander LEDS");- s M% l7 ?; t) t R
else* Z+ Q4 {3 G1 H F& a
printk(KERN_INFO "LED register sucessful!\n");
' m1 U% U* }! {9 Q3 ~/ U5 y% d
& A4 q0 A2 G% G+ ^3 r return ret;
" ^! T' J2 _9 F}
! Z+ Y$ {. W; `( F& O7 j: R
4 b k6 `6 ~- f' C! B$ Dstatic void __exit led_platform_exit(void); p4 @' `4 ~; k
{
- \6 e6 j* D% \7 {9 K; g7 v platform_device_unregister(&da850_evm_tl_leds_device);
7 p; D) b7 R: }" C8 S4 e5 n' J
, C5 p& l* a+ w5 Z# B printk(KERN_INFO "LED unregister!\n");0 K& {! ]6 a9 h9 C4 u, E+ W" _; J
}
0 P4 P% Q p6 |- V2 m* V
& @- P$ ], X3 tmodule_init(led_platform_init);
: i8 i( e9 N" b/ Smodule_exit(led_platform_exit);
( h; e1 x( L& k' n3 @
4 x/ e$ O/ P/ T4 }' H5 _+ ]MODULE_DESCRIPTION("Led platform driver");
, m! k$ g& N/ @: G4 CMODULE_AUTHOR("Tronlong");! U3 h" o: T* W
MODULE_LICENSE("GPL");3 N( ~% L; E8 U7 `- X. W
: N3 `3 t6 }9 t/ R6 C0 }$ L
|
|