|
求大神给下面的程序做注解,请稍详细些,谢谢。
% p w4 g% V$ l#include <linux/init.h>/ n$ ^- q2 z+ U- A/ @) V
#include <linux/module.h>1 f' t: \5 b: N7 j
#include <linux/kernel.h>
# H3 \8 x9 q' O' X, ]3 c#include <linux/types.h> ^$ w# ]3 I. n$ M j0 d/ U' z
#include <linux/gpio.h>$ j9 G6 l+ f9 T: C
#include <linux/leds.h>
6 U' }% c2 `! D7 }% f* S5 p2 _#include <linux/platform_device.h>
4 q" a$ Z9 [9 h+ m# v, q- x$ [
' M4 U k9 d/ T! f#include <asm/mach-types.h>% ^& ~1 C: K& `/ ?
#include <asm/mach/arch.h>
/ N8 \) [" q. Q' P#include <mach/da8xx.h>
" a7 w" R6 ?) a0 {#include <mach/mux.h>
+ d6 |. C* j! s3 O' O
9 P. a& }$ X8 \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ N5 @) R# R1 p' C/ M1 [* t: Z5 U( ]9 G
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) p# a- s3 R, U7 A5 O3 f, E1 ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( L3 J" t- v/ V1 Q! z& M# o#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# H: V0 n3 Q; S9 g
. u2 M: q( J8 @& ?- V& k/* assign the tl som board LED-GPIOs*/% H( [" j/ c# E& p, G. x" F7 C
static const short da850_evm_tl_user_led_pins[] = {
! g1 o0 i, N1 u& x( u* r2 p) T /* These pins are definition at <mach/mux.h> file */
) S0 m! X: v# R* r% A- y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. z: L W) Y w8 a
-1
7 w7 \( [4 E$ ]: H};
; j: \, {% V! R+ g, h
& y E Q( r7 h# P2 h& T# [static struct gpio_led da850_evm_tl_leds[] = {
+ @: _, B& k3 @ {
7 o9 _3 L1 g! T2 ] .active_low = 0,% B4 Q! Q, T) ^- c
.gpio = DA850_USER_LED0,
1 h' ]2 P9 B1 Z# r, t: {0 A .name = "user_led0",$ z/ p* V/ p0 F% k3 s s4 Y
.default_trigger = "default-on",( |$ Y/ B( R9 G4 R( ]! P5 [
},
5 i& ]: g9 A3 X/ }- v |. _( K" f {2 t; T7 x6 ]. N6 m
.active_low = 0,6 m7 \6 v* Y8 b: X
.gpio = DA850_USER_LED1,
; s [% J% d+ ~. R .name = "user_led1",
5 {" e$ k/ T0 S .default_trigger = "default-on",- x# J1 |6 b5 N0 ]
},/ n1 N% S& Q0 }9 g* @
{
/ m) M J- R I4 O6 b @/ S) H, A% B4 p+ [ .active_low = 0,
. o: E$ y( a6 j .gpio = DA850_USER_LED2,* k( X/ n. L7 q& V* S3 Y
.name = "user_led2",
- H' e \* [" [( J7 ` .default_trigger = "default-on",
" G2 m. P$ `; B; J },
# n9 y' V O8 [3 _) f {
) y$ }1 N1 [5 Q6 M1 B0 \ .active_low = 0,
$ Y$ t% u. d$ Q3 j7 Y .gpio = DA850_USER_LED3,( N" e: z5 f0 w. Q: ~
.name = "user_led3",
$ S6 j' i$ Q2 T, a% X .default_trigger = "default-on",4 ~; H) G4 v' \1 m* F& ^
},& p7 u- q x" {8 @# }
};& u" L3 b4 {( ]5 x: x/ H6 j$ |
& u3 ~" K; z6 }) V5 D% W- `! p
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% Y: o. R$ I) J7 s
.leds = da850_evm_tl_leds,
; U( s% E, X& T E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ s5 p6 l- l' B5 F};: C! |7 Q- t; `4 M& T4 J
$ I# f/ M# W+ V4 Q( ]# G
static void led_dev_release(struct device *dev)0 X. }/ [! p: K% R+ X; k* l
{
4 `! g1 \$ k, w( c( Z2 f( ^};$ S1 `- u) `+ `% K+ m; ^8 r
! F- N: H2 ]8 Y) N2 I( e0 i
static struct platform_device da850_evm_tl_leds_device = {
+ R* z6 ^4 l5 W$ a! B .name = "leds-gpio",
* Q# E) d2 f4 `- ^) } .id = 1,
# p' x4 T1 Z Q' ^; B; _2 e0 D .dev = {# R5 P* C) U& {' {3 i) j4 s+ O
.platform_data = &da850_evm_tl_leds_pdata,
a& ]4 D, ^6 y5 q .release = led_dev_release,5 b! u: O) m8 t+ d
}
, H# P/ W, D- L};
; K3 V7 F% x* V2 w" I9 J2 V
! k& \: o7 {5 x3 rstatic int __init led_platform_init(void)
8 A; ? f: i+ m7 b$ k5 V{' V) K7 S# c7 `# [$ n
int ret;6 |6 U5 L& H% @
#if 0
& G& |9 d; Z- G6 R' D( X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 d* A% Q3 A; g0 b$ X5 { U7 X
if (ret)6 M' X w8 _5 Q4 h; W9 o" h4 ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 L& o5 N$ ^2 m% t0 y "%d\n", ret);
9 v, F9 h5 s; K( a" p- F: ? x#endif
. k; E+ n4 d& i# s4 Y" A ret = platform_device_register(&da850_evm_tl_leds_device);
# Z. `8 w9 g9 P4 t7 z if (ret)
! y' f0 p6 a- n# u pr_warning("Could not register som GPIO expander LEDS");2 i# L( X5 J" C" o! A+ p9 E
else( a# g5 E* [/ S! I9 F8 Q
printk(KERN_INFO "LED register sucessful!\n");4 W6 `2 u" T6 l7 A
% m# l6 {% u7 b+ {
return ret;
/ C/ E' i: P4 [% K! L( I}
|/ A k6 [5 w
/ t% R4 O( Z6 M# V0 v5 l( D' ustatic void __exit led_platform_exit(void). l9 r: a, {( P3 C* Y- [2 V: r$ l! c
{
4 I5 p1 F R z platform_device_unregister(&da850_evm_tl_leds_device);0 m9 l- |# u1 _. U2 h9 a' \
" a$ Z' l( @8 a) c V) x' X
printk(KERN_INFO "LED unregister!\n");
; t% y3 t5 S4 V, g9 q}
, j9 }! O6 u H
+ y; ~+ X; Y# H& M2 D, mmodule_init(led_platform_init);3 M- r: j5 b8 m
module_exit(led_platform_exit);
2 \$ d9 _0 T9 V3 Q8 N4 r
; p# a! @. K7 W( B2 mMODULE_DESCRIPTION("Led platform driver");
& f! h" v4 T) H8 UMODULE_AUTHOR("Tronlong");
( }' ~. F: g: y: `* Y4 X! rMODULE_LICENSE("GPL");
, m6 |, z4 M/ k% t9 c4 s5 @" H" c9 p; R* f0 v& z
|
|