|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 E. x! x* m/ z2 P4 G7 V# w5 D% r#include <linux/init.h>3 G: U& ]6 Q8 d9 M
#include <linux/module.h>
: T7 @% p& I: h! }#include <linux/kernel.h>8 K. T; Z% }% k9 n, h) e. q
#include <linux/types.h>
( i( T4 k1 K2 F9 x#include <linux/gpio.h>2 ^5 o6 d$ L/ O0 w
#include <linux/leds.h>
( W% e e J. b+ D3 |0 a7 X) t/ ], ?#include <linux/platform_device.h> {3 Q: e. R9 o; V- a0 [/ \ L
2 H* {& [; ]: m: _# p. K4 g0 o# [
#include <asm/mach-types.h>
' N2 J, {: }( Y* j0 v9 z1 R#include <asm/mach/arch.h>% y' X3 a2 t k: @' i' T
#include <mach/da8xx.h>( J- U8 s' {. D1 }) _% Q
#include <mach/mux.h>1 Z8 x5 { U; @( N0 i9 \
8 y/ ]/ S' r e1 Z u+ o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 V2 O8 Y7 g# u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). j( c! |# c" o. j0 F
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) J1 B0 |5 O7 ~7 l4 C6 U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) [; d6 U K& v# `2 m" ~+ k" R/ {, v( B' D
/* assign the tl som board LED-GPIOs*// }& V! a# y% \8 b/ n
static const short da850_evm_tl_user_led_pins[] = {1 Y( J7 U# Y, n, k* X
/* These pins are definition at <mach/mux.h> file */- N3 ?/ n4 H) w- E9 a! A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& M" S; w- \2 R
-1
x/ y0 ]' U2 D6 N};" U7 K' @* _, W J! Z6 E J
0 F; c" z; U J: T1 Tstatic struct gpio_led da850_evm_tl_leds[] = {2 T' Q& \: i- R5 f! B% \' m
{
3 _$ y' z/ J$ X: U- A8 v) | .active_low = 0,5 w* q9 o# u9 J1 Q
.gpio = DA850_USER_LED0,3 [8 K2 Y. p3 d" [( O4 E2 a9 x) t
.name = "user_led0",. T, B, U, v. H s& g
.default_trigger = "default-on",
1 _! C2 Z) b% l8 O3 r },
' y5 U- l/ c" {9 Z9 m) ` {$ i/ Z9 ?1 \) V: @! q% X
.active_low = 0,
0 B ~+ S% |( K+ {( g .gpio = DA850_USER_LED1,
: @0 J# q! J) v1 W .name = "user_led1",! o6 {" u' H6 j3 w- K3 l. G
.default_trigger = "default-on",' h+ ~5 Z0 J* n$ Y# e# C2 p
}," r2 {6 B9 F2 W x8 \6 w
{5 |* d8 T- q7 [3 P$ Q) W
.active_low = 0,/ L; L% Q1 E# V3 D% P$ t
.gpio = DA850_USER_LED2,, B1 x* ^ }+ Y$ I1 ]; Y- _+ p# _
.name = "user_led2",$ w; F: {. \$ n
.default_trigger = "default-on",
7 u8 S- s$ Y& E! o4 R },: j- B1 ~: k% `6 A. F( V
{
+ n4 c; n' S$ b .active_low = 0,* k2 D5 `2 A) V. @' s, `# {
.gpio = DA850_USER_LED3,
2 c2 u! b) S& m8 d .name = "user_led3",
/ o7 j/ [& U- m( M+ W .default_trigger = "default-on",- x. i% P, h. e
},
: S4 J/ v- X" W2 p) n1 Y- t2 c/ I};7 h: F6 W6 @' b& R o
& d: V4 L. } v1 L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; ]7 n! K$ w# V0 t k. W, ~5 e .leds = da850_evm_tl_leds,
3 Y* u5 J8 p1 k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 T" H& | D" G; W% f};
6 D6 O6 j& ^/ k& V' o
' p, r% r& N tstatic void led_dev_release(struct device *dev)1 T5 D& J, D2 [$ @
{! S- j, f) j1 X' P. o
};
7 \: T: q" R+ @6 Q' R8 [! Z# }# ~5 x9 x
static struct platform_device da850_evm_tl_leds_device = {' K# r0 v9 _0 k% u& h
.name = "leds-gpio",, x' [! S5 d% _/ R2 _, \' r4 s8 L
.id = 1,
( x- @% L2 y* z. |* v5 l .dev = {/ B9 ^- q6 [5 }6 S3 q
.platform_data = &da850_evm_tl_leds_pdata,
! z3 T) V* k6 e .release = led_dev_release,
* Y$ B- U5 V U% Z+ H! P, J7 ^+ y }
" i1 r1 Z3 D* ~* R% E" K};2 `$ z& h- G0 D {7 A6 k+ ]: B
7 x6 `" x/ o% ]8 D2 pstatic int __init led_platform_init(void)( T) U5 E; C2 k- V7 q- b, l Z
{3 B8 H5 E9 ?# W+ D: [6 n( a2 z
int ret;
+ ]2 k3 d. i& Y/ b% ?' Y# ^; V#if 05 Y; z! \! _7 d3 v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ s4 j! \2 @: @5 F3 Z
if (ret)" ^$ y! d! z* M! J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* ^4 c0 O+ w; {( {7 T! Q' f "%d\n", ret);
8 f$ e0 P* T/ d, ^#endif
1 ^. l* a- i( @7 g1 W% a m ret = platform_device_register(&da850_evm_tl_leds_device);) p/ }1 J/ [) k3 ^- S! C
if (ret)1 R4 [% B/ O I9 ~3 b' @7 @) F
pr_warning("Could not register som GPIO expander LEDS");0 O+ M. Z( x% r& P9 A5 n- N
else9 b& d7 l9 S7 S) D
printk(KERN_INFO "LED register sucessful!\n");. s, m+ A) j% ^7 A" k
9 {5 ?) G! y9 q$ k9 `
return ret;
) ]7 p; S3 I% ?0 G}; S# L9 T$ D. \8 x* ~6 j" n
- Z- X- U4 }8 B& P( b. ]& kstatic void __exit led_platform_exit(void)
& e% H# c' j% ^3 S- r1 r7 j{" G4 j& M# z! ?, V1 r" D
platform_device_unregister(&da850_evm_tl_leds_device);
! ^/ E9 ^" H5 \) t) f
. G a* J/ G m* D* x printk(KERN_INFO "LED unregister!\n");7 z! F6 o; p/ x( S {
}
4 |! B) s$ c% }! H3 D/ V& y
1 Z" q) V, M, ^+ i) Omodule_init(led_platform_init);
: W7 n* J0 |9 `0 [module_exit(led_platform_exit);9 N8 @; u7 i! ?% L2 K
8 ?. K" V0 T- I) Q- j0 Q- D" ^" SMODULE_DESCRIPTION("Led platform driver");$ \6 Y* l M+ x0 F# s9 r
MODULE_AUTHOR("Tronlong");
) o$ |. O: ~, W) a8 YMODULE_LICENSE("GPL");( I$ M$ X. y; A `9 S7 H( [
; N0 K% |8 A+ X' q |
|