|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 b/ O/ ^* [( t3 k#include <linux/init.h>
/ Q" T4 A/ {, d0 l4 G#include <linux/module.h>
j8 p$ c. L$ Z6 `#include <linux/kernel.h>
( H/ Y2 U5 \" p1 [' `: O#include <linux/types.h>
) y/ w! c; j- i/ A#include <linux/gpio.h>" V/ L' x$ |. I' m8 @: j
#include <linux/leds.h>
]5 u* T0 w: x#include <linux/platform_device.h>5 m6 c. [! f) u/ b. h% a. j
5 d9 c9 J! x9 I#include <asm/mach-types.h>
a1 W3 E: `- \; L( V* k: U#include <asm/mach/arch.h>0 y% }2 W, i6 v$ }6 @
#include <mach/da8xx.h>
3 ]) r0 ~. V' f$ K#include <mach/mux.h>
; x! H9 \- \; _8 t- H& O# y
2 M# d# Z" v( l! I( E4 U5 B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( ~" K) |# k# y4 b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): r) y0 w& e* z7 N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% k# ^! ]0 U8 }" j% S7 `" j' G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
R9 N7 }& b8 p! \
* o! ]' G1 G) A) l& l d/* assign the tl som board LED-GPIOs*/
$ o6 I5 N: d4 ]) S' q) Istatic const short da850_evm_tl_user_led_pins[] = {/ W7 |7 J8 D3 o5 z5 d5 m
/* These pins are definition at <mach/mux.h> file *// h- D+ ^% l# g: Q$ Y/ w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ `7 {, g& u# J! [
-1; q! Y( u. ~" F+ q/ W
};
) w8 N: K( f! i2 v0 N6 ^ @6 D0 i1 F1 E" k
static struct gpio_led da850_evm_tl_leds[] = {: U- [2 k' `5 a' z& R$ Q2 z$ K( D
{/ V! ^8 g x2 H0 S" A
.active_low = 0,9 s" ?0 v6 ?; J2 f6 _% A
.gpio = DA850_USER_LED0,
# _3 O h+ S) ?+ n& W4 ]1 w. l9 l" K .name = "user_led0",
9 i* p+ }4 A2 P- V .default_trigger = "default-on",* N* d. |6 U" S
},) w; ^$ l5 _$ z& @0 Y% u* Z0 w* {+ t: a
{
% k$ Z2 t d' @0 [. Y2 v, O* ~# ]$ R" B .active_low = 0,
( y1 g9 m1 c- t* c: i3 d .gpio = DA850_USER_LED1,8 P6 A- ]1 j! C1 ]9 i- K
.name = "user_led1",
' _/ g0 H Q3 M6 F6 Z& ] .default_trigger = "default-on",
( i7 T2 O$ K8 K; W! A: _ },
" X A; [. ~) Y, Q+ |5 {9 I# D, m { v. z9 v# N1 f3 {
.active_low = 0,
1 f; \0 A2 }2 _# P/ } .gpio = DA850_USER_LED2,
, v- _, I) b6 b: h$ R% V .name = "user_led2",
/ U7 m& j$ H$ \5 {% z .default_trigger = "default-on",2 \+ W% A) z7 O0 I) V* A6 L3 e
},
, d4 h6 D/ a1 n {
) U/ _; q# d6 V! k% Q* F/ N .active_low = 0,/ Y; H. v* |( N: ^
.gpio = DA850_USER_LED3,
, K) k& c+ E% b& t- _9 a .name = "user_led3",
- m {& s& |* X; S0 Q .default_trigger = "default-on",
7 I. _ y' Z, u },' i. `9 y/ R' K2 n6 W4 Z; U# p. ]# S
};4 R& T" _1 K1 C7 X) }
{- @) x |( r2 lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% \1 G! c a' |, `" u) u .leds = da850_evm_tl_leds,9 o0 W8 ^7 J. \8 \% r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! D7 o4 M$ Z5 y! O. m
};
5 z3 t6 i# B: ^. V7 p3 P
9 U- h1 g% p, i9 m) C3 T1 Fstatic void led_dev_release(struct device *dev)
5 N h& C$ _5 g" M4 B# O5 S{% B- a# }% t B0 M" S$ A2 \
};& @# W* q {1 s, p/ ~8 w8 l) Q3 ^6 o
; D, f V! @5 B& s& o+ l
static struct platform_device da850_evm_tl_leds_device = {3 ?2 ?. i! `: f4 R5 Y. Y1 [
.name = "leds-gpio",
" |: N& P( W& C8 |2 q3 B9 k! f .id = 1,3 o$ L) i |" I
.dev = {/ `5 p9 y; K( v8 p: N) o
.platform_data = &da850_evm_tl_leds_pdata,
/ A5 L* j0 p& L8 }8 y! u .release = led_dev_release,% q( d6 @) @. I: g9 _, M
}4 ~% y8 x4 m& T7 ?
};
: N' Y! ?" ?& o$ n
+ E7 ?) Z& S1 X6 `9 E6 v& F1 ystatic int __init led_platform_init(void)( J% L: d, n. _* ?
{
: C4 o5 |/ |7 P int ret;
( R: N. {3 k2 d2 o' i% E#if 0) K1 \3 o8 a$ ^- T# Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 g' i, x" r7 i2 I4 P( w0 ^
if (ret)
4 e7 |; [' L F/ ]3 Q& b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; L( D6 g+ d% L( `) D; @
"%d\n", ret);
' B! K( q0 n" N3 ^ R#endif
1 Q d& E6 O! T$ j. A; ^. C ret = platform_device_register(&da850_evm_tl_leds_device);
2 y2 J% H& m; G" p. h if (ret) X4 ~! q+ C+ D3 K5 ]( }: {
pr_warning("Could not register som GPIO expander LEDS");: n4 t, F7 r0 t) s4 j* S
else; K/ a+ v- P& J* b4 o4 C
printk(KERN_INFO "LED register sucessful!\n");# ^: B3 |; z! |& i/ l
. M- \& p% `" f$ P2 l- j7 Q return ret;
, N/ v- q' ~& `! V}
1 `0 o0 a* O, |1 U. }- e D; W# \: `# u8 o" D. a& i `
static void __exit led_platform_exit(void)( N& z7 R) z! k7 [
{ a( O4 ] u2 y) \* k' p: l
platform_device_unregister(&da850_evm_tl_leds_device);
3 Q v) S/ j# [. _8 M% `+ R
+ e f% y" C& m7 { printk(KERN_INFO "LED unregister!\n");
+ m4 m8 Y% }4 k: r8 ?: Y}, M. p- W0 ]8 R5 M) F, s1 z
" L. t! S B& V u8 l; V. C
module_init(led_platform_init);
% ^, |$ V" T+ h1 U' Z! o1 [) h: Wmodule_exit(led_platform_exit);
( I/ h. u& b4 s5 i4 f- a' u1 I$ l. {) Z! f
MODULE_DESCRIPTION("Led platform driver");, X4 O$ N4 l5 `7 ~' Y6 u. r# k
MODULE_AUTHOR("Tronlong");: h# g! r+ N, z2 W6 t# M2 {- o5 Y& U
MODULE_LICENSE("GPL");
) D# F& k) g, s4 U4 l8 i' A: m& I* c9 ]6 f! m+ {
|
|