|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 b _* [9 r! V8 B/ Y" w) u#include <linux/init.h>1 ~3 l* Z d# p. m7 I$ x
#include <linux/module.h># L, F: I% G/ F' w- {6 m
#include <linux/kernel.h>7 {( }" }! X. F4 E5 n- d5 `8 C5 N
#include <linux/types.h>; a0 c: P# K( v! q& B( c
#include <linux/gpio.h>& q6 d. u9 J* s- i
#include <linux/leds.h>
* Q0 N) f' K. @, i" z _* J- J#include <linux/platform_device.h>
0 V, {0 |) a: Y1 f: c1 q6 Z) z- `2 ]" ] W O
#include <asm/mach-types.h>
: x9 t+ i% h7 D4 S% e; a#include <asm/mach/arch.h>
) f* ~1 Y U3 C, P3 a+ v#include <mach/da8xx.h>0 b! h+ I& J' ?
#include <mach/mux.h>) O# j8 l7 K0 H
, t) N6 ^2 Z' {0 G, ?* P/ _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 `* J0 I) M% {1 N" h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 p0 h. T! `3 W+ l3 u; G" ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 b, }4 \$ Q7 b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 u6 K; @ z- Q5 _& f
3 P$ m4 h. n% J# c4 ~7 ]5 c6 b
/* assign the tl som board LED-GPIOs*/7 k( d8 C8 C; ]( k# A- Q
static const short da850_evm_tl_user_led_pins[] = {
+ K- G3 M) e& X( h; _. |5 P, e, | /* These pins are definition at <mach/mux.h> file */
/ I% s3 A' m; b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 z1 v c8 P2 ` E P! d- A
-1
) K1 [6 D8 B; y! Z! s};/ `. D$ s6 W% z+ @
' p% b2 E6 h* D0 `, N7 `
static struct gpio_led da850_evm_tl_leds[] = {
- L4 ?* W" g8 o9 W! N {
! R* o" J& M9 u3 u" H) D .active_low = 0,; v* o, \6 [ d' H
.gpio = DA850_USER_LED0,
) g; u$ s- f S! C) f0 p7 T" Q! S .name = "user_led0",
/ V P4 y0 Z I" U% t: s% Y! W( Y/ J .default_trigger = "default-on",6 M. f7 D. d; t- z
},( @1 O. K5 o, \* L* R
{
7 H( |* d3 W$ S) s: y. M0 L .active_low = 0,4 `7 z" \4 w5 D. C" o1 t
.gpio = DA850_USER_LED1,5 z6 b% n' @6 ^- w# O0 ~$ m
.name = "user_led1",
# j' R* c* i) c9 G# {1 G# ~ k .default_trigger = "default-on",4 c/ t. ^# y; u! M2 ]
},. Z- c1 v' D% _8 _: I
{
( c) y' [5 I9 n# h# @$ U" R/ `1 x .active_low = 0,
. Q5 @% M0 G/ u, j$ c/ ^, N( }( y .gpio = DA850_USER_LED2,
/ P1 _1 u; Y7 L; b8 X .name = "user_led2",% @' B: S$ F( [; }6 T0 W% m$ N- F
.default_trigger = "default-on",, n, F% @/ n; J; k5 @/ h
},
7 l3 y3 f. h% g5 v {
1 ^* s, _3 i, s& q: I# Q% e .active_low = 0,. @6 O, M$ j0 u3 O
.gpio = DA850_USER_LED3, t# F5 r1 _: | k( n
.name = "user_led3",
5 l" h) h% R3 f8 }! u* \5 \ .default_trigger = "default-on",1 Z: B6 H& H. f3 W$ x3 d
},
7 M8 c3 }" {/ Y6 P! b# @/ [}; ~- S, _' Y, J" }. @/ t y' ~
# z2 ~* W1 c0 M( c: U% ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- T8 _ o' ` K& z W: I" R
.leds = da850_evm_tl_leds,
! w: W6 c$ v% p% h6 e .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 X! e1 @5 y& q- R( {) ~
};
) u' H3 x7 Q8 t8 S) k
% f3 w( q# c, a4 _+ E% ]$ hstatic void led_dev_release(struct device *dev)
" W4 i* K6 K& H) a0 {$ V0 |0 Q{
1 K& q; x% E/ M8 K& y/ U};
/ j T/ \; X( V9 ?* `, M) B
6 t- R; c+ K+ ~static struct platform_device da850_evm_tl_leds_device = {
0 ?2 P2 a G: W# o% G( q3 L .name = "leds-gpio",
( x8 [+ H h( X; F( X+ } .id = 1,
+ {0 a4 o& ^) R7 X .dev = {
* s/ z6 i2 A5 Q( I2 t) j; W7 C) d" b .platform_data = &da850_evm_tl_leds_pdata,
" C/ b& b% t* J9 h. B .release = led_dev_release,9 ~3 x9 {) B$ |0 S
}
% z( w6 e, W& k2 d" z};, ?4 z9 c5 }/ ]/ ]
- w" \/ w7 |! f$ U# Qstatic int __init led_platform_init(void)+ @, Q( A& @3 T; j
{$ x* p" Z% T7 K( H
int ret;+ s; f% E2 p8 h& @4 w9 p
#if 0; F! `$ y: @5 F" Z1 j: u! E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 x$ V; c3 B+ x$ ?, M5 o' V+ I" o0 g
if (ret)
; x+ E0 y3 B- v9 q0 \' } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 p6 m* ?/ n ]4 K% M "%d\n", ret);
' [- Z& o+ R7 i9 M#endif
& L: I7 _6 E* n! c, s ret = platform_device_register(&da850_evm_tl_leds_device);" V$ c& D* w; @) d" L. t
if (ret)
6 `+ T3 I) l, m& |! {0 t pr_warning("Could not register som GPIO expander LEDS");! d5 y3 q3 k5 Z' u
else
: Z$ x2 u6 t+ J# R2 \ printk(KERN_INFO "LED register sucessful!\n");
8 x/ N5 q$ C1 S: G% c/ t$ Q! D, |3 ? V+ N# q
return ret;, U' h6 _( w+ v+ e( N( u" I% q
}5 {+ L# Q% |" [" o( O
4 n& t0 f/ ?( P5 n+ U0 p
static void __exit led_platform_exit(void)+ `8 U% c* c; E" T2 z9 Q
{
& R6 ^4 t, e* p: Z( L- w" @2 d+ a platform_device_unregister(&da850_evm_tl_leds_device);( v' G. b$ q* l
. G3 x7 X8 g; T" m
printk(KERN_INFO "LED unregister!\n");
: [1 ]0 T1 Z2 m5 T+ a# d}
G/ w0 ?+ x3 p$ Z# |; X: q2 v
9 m, R, C4 X7 Emodule_init(led_platform_init);
; F4 K. Q7 x: s7 Qmodule_exit(led_platform_exit);( z+ I; T q h7 p
& U; I4 K" w0 m: RMODULE_DESCRIPTION("Led platform driver");: h0 q/ F I% ?8 f7 x
MODULE_AUTHOR("Tronlong");5 d# |" a6 H3 n, t. M Q4 _
MODULE_LICENSE("GPL");) T3 h5 Q' {- x2 V2 R
Y/ U5 f5 F+ Z1 i! @
|
|