|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 V/ a2 Q5 r4 e/ a: S#include <linux/init.h>9 R# s$ q" P2 a" k! i# l, Z
#include <linux/module.h>
4 e' ^; ?6 e+ U/ e4 I' C' b#include <linux/kernel.h>
; m$ ]2 {; F. q) X1 @#include <linux/types.h>
5 ?) X- D: _3 a# e$ R7 h#include <linux/gpio.h>
B: k& N1 [& `5 P' {. |( h, g#include <linux/leds.h>; z" O( A' D" U, U) r, A
#include <linux/platform_device.h>
4 c* _" l5 Q, v' ^5 p
; w* M# p+ {; g& e- i# _" i#include <asm/mach-types.h>% D) V2 w- \6 u% W# S
#include <asm/mach/arch.h>" \* d5 s2 I0 a6 s- d" `
#include <mach/da8xx.h> b# c- X2 v! T# J) ^
#include <mach/mux.h>
4 i7 {: u7 p1 t0 k- G2 p; L+ f1 @' x: z0 B" ~- r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* G$ |! c+ u, k E2 k" O8 l7 M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 B* s6 s# r" x6 u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
y3 _: M8 i2 P7 X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): x" k: P1 e }- z/ R% W5 h
: r% G) b+ q+ t6 U; b7 d/* assign the tl som board LED-GPIOs*/
9 W$ y2 d: |9 { U) rstatic const short da850_evm_tl_user_led_pins[] = {
" ^+ O- {+ [4 L& _5 H& h2 I+ _ /* These pins are definition at <mach/mux.h> file */. H; b0 [% R! Q8 x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( }: Y' p$ ~/ @- C -1
3 z( R) _# H- _- |* n8 s" G};) g1 V/ S: ]# Q+ p
, G5 M! j* D- U! Astatic struct gpio_led da850_evm_tl_leds[] = {+ X8 n6 f Z4 k% O) U' e9 E
{& S8 I( Q: ^) f8 k, j7 h V
.active_low = 0,/ H9 f9 z& `4 o9 x
.gpio = DA850_USER_LED0,' S7 E& Z! [5 y. f
.name = "user_led0",
6 Y. }( c( }, p: n .default_trigger = "default-on",. `" P' C: `8 W
},/ J' H7 q4 ?8 E6 s9 S7 @
{9 a9 k/ b: g% u( _& {" J% `
.active_low = 0,; H; z1 q% B$ c
.gpio = DA850_USER_LED1,
; A3 f$ U; u) p4 N, p5 ]3 p" H .name = "user_led1",( Y7 X9 `3 x+ E$ W
.default_trigger = "default-on",
- V/ Q) h7 } T i# i },3 _, r8 c3 }. J: E. |
{( ?) a! E3 X# p8 C
.active_low = 0,
3 H( I: n" t7 t) v+ d8 h& s: L5 X .gpio = DA850_USER_LED2,9 _6 R7 o! Z3 ?
.name = "user_led2",9 ^* p& R! Q& f- r
.default_trigger = "default-on",
) Z- F, J% }! N5 K( j }," G: a* R: y$ `7 I: G4 J
{
" j- z& w0 N, T .active_low = 0,
( A- m: K5 R- J8 y" v; x .gpio = DA850_USER_LED3,
7 T( V4 q) U5 v0 H9 H9 | .name = "user_led3",
- X: u$ @5 X# h& x3 O( l .default_trigger = "default-on",
* |9 L% P _+ A1 e% m3 S },
* [' y( Z4 S4 R8 k$ n};
/ w8 g/ @: [ F5 c+ b2 h7 ~
5 k. D# ~( B8 [: N7 cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( p4 N& @* E+ h& b' `4 Q, Z( O! R .leds = da850_evm_tl_leds,% z8 s' ^- l7 V
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: B" q* F Z7 S/ p, @};
* H0 ^1 `' t8 P. z+ n: f% t; K5 J9 Q! k
static void led_dev_release(struct device *dev)% R* G0 c, e1 G1 V0 ~: j3 R
{
+ Y8 g# E7 v; E7 s% a};" z7 g1 S7 m& c
! W3 R4 D# U9 r$ L/ U
static struct platform_device da850_evm_tl_leds_device = {- I0 [- X2 f k- n% K, e9 F) t
.name = "leds-gpio",
3 Z& C& y& s! F, b: t0 x2 {9 r .id = 1,
% h5 e& Y( n. m7 i% \8 r .dev = {
# v0 U( U: K7 p$ g" r# G# x9 b: _ .platform_data = &da850_evm_tl_leds_pdata,
( O9 d) X: e6 O* H" t .release = led_dev_release,7 C$ U+ b5 O7 F& B
}0 z$ f% s2 F) V2 C" z* t8 k
};1 a/ p! T" s1 P
. V9 V$ m7 n% l
static int __init led_platform_init(void): t: g' J$ ]" _; E: V8 X
{
e% F. v7 @ i: T' [ int ret;
* e" r0 u) q" Y#if 0; T1 e2 t5 M; k/ ~/ e9 V- l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 U7 N. P9 m( e8 x/ }, O( b
if (ret)
+ l$ N4 j+ t8 D6 d0 p+ X: p# Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 S* A" E4 C' v% g
"%d\n", ret);$ T7 L) }1 X2 O- p0 `
#endif
' o S) `/ k6 y `; [. l8 s$ } ret = platform_device_register(&da850_evm_tl_leds_device);7 W2 ]$ f5 y9 F+ j: H
if (ret)2 t# w+ \& N' N3 O
pr_warning("Could not register som GPIO expander LEDS");, c+ s |* G! o' |
else& t$ V+ o( |# H
printk(KERN_INFO "LED register sucessful!\n");, i) F6 Y6 y# ~% o$ D; E
/ ?+ { x/ p2 }/ Z
return ret;
4 d% f4 R/ `) L, q}* c: R5 [6 P4 ?; z3 Y' c& j* R
" E% u$ q% m5 r: C8 s/ n
static void __exit led_platform_exit(void)4 K( S5 {# r( e0 o$ l
{
; [! K3 E) t9 O9 a2 }7 ^7 G platform_device_unregister(&da850_evm_tl_leds_device);
( Y1 P; q+ J5 K' L+ e$ `
, g; g% {8 h& H* K$ O printk(KERN_INFO "LED unregister!\n");
: G) }: b/ k! }7 p& n, C/ a6 `+ i}
- _1 F6 t& |8 g$ J6 L; W# C7 ^$ T2 r6 T& F
module_init(led_platform_init);" f9 J. ?7 C! K1 j+ q0 z3 H
module_exit(led_platform_exit);! c6 g3 Z: E, a% g9 h* e' g3 f# w
/ v5 d) i# ]/ Q Y
MODULE_DESCRIPTION("Led platform driver");
, j5 o' y* a; r! I& H" m: n: NMODULE_AUTHOR("Tronlong");/ N3 b, K6 B8 Z ~6 v! I1 |& @
MODULE_LICENSE("GPL");0 l4 s' r/ m3 n* W( j% X
3 [1 l# o. I, a! T' i7 p* h
|
|