|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ m+ j5 }3 X. a" J. ?: m- L' ?8 l
#include <linux/init.h>
, |, e4 U8 j" A# d3 t8 F- B#include <linux/module.h># B: O) w$ D- b0 i( j
#include <linux/kernel.h># d0 u' u& o. |+ B7 a3 G& p T! |" K
#include <linux/types.h>
* u2 o$ n; ^8 Z' J+ c#include <linux/gpio.h>+ g' Q- O- H/ U
#include <linux/leds.h>
; ~2 w. t- n: D6 c6 ?# ]0 X+ r#include <linux/platform_device.h>) Z5 r' {1 c6 P) |3 ]% f
. [ T& \" [" d+ _#include <asm/mach-types.h>
6 D7 l2 U% Y# q#include <asm/mach/arch.h>4 x/ x( U; d( A0 ?0 l
#include <mach/da8xx.h>0 n/ y5 G/ }7 [! R. Y
#include <mach/mux.h>& D, \- i. W: O; [0 W
7 F# q1 Z4 p" V C7 g; l" r4 c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 j% i& r. A9 v6 x: @5 \5 T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 \% _+ c3 S" W( [5 l. o9 d- T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 H+ p. o' l4 ?; ]# ?/ v#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ O4 f. c3 N+ W" G( P+ @
; }# h! q& j7 E: V3 o8 A7 }# d
/* assign the tl som board LED-GPIOs*/: s7 ]3 R$ Y; v" J1 N8 p' F
static const short da850_evm_tl_user_led_pins[] = {' B, q0 O) [+ O+ p" f" G
/* These pins are definition at <mach/mux.h> file */
) }3 c4 Y$ N/ p( ?+ y& e( s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 G1 e2 C; e6 j9 V. @
-1
& K' Z- m2 |5 g8 U};1 N- C4 e _# D( H* b/ a+ J
# q s4 ^, v6 d- k0 ] c& Y Estatic struct gpio_led da850_evm_tl_leds[] = {
- E( D* l' e3 }5 O* c" K {
, ]# a1 R1 f8 M9 S4 V .active_low = 0,. v% S2 A% v* @! u. d
.gpio = DA850_USER_LED0,
2 X* c9 r2 S) _3 f0 ~ .name = "user_led0", z: V8 n% R, |3 }( ]
.default_trigger = "default-on",
T, r* P" I5 d5 I y$ _8 P },/ y c, y! `# X+ P: j4 R2 J
{
! \( s8 I H5 m. P( z/ E2 o .active_low = 0,
, p% }. V5 P' p .gpio = DA850_USER_LED1,5 q" Z$ \6 B# H' a2 B
.name = "user_led1",5 R& k- _; ]: M
.default_trigger = "default-on",
D1 u1 M& q- n, M2 ]- e1 t' P, T6 m/ w' X },
' P- I2 d* V" R3 [! M% l {% A; Z/ U7 f9 a0 \& F& e
.active_low = 0,
2 K7 \( e9 b: J8 V) P' \ .gpio = DA850_USER_LED2,; w- q- e8 f9 L: Q3 b0 V
.name = "user_led2",; Q4 U3 q. x+ M$ m
.default_trigger = "default-on",) E0 B9 k7 `+ @$ u5 G* w
},/ ~ N; Z8 T0 t W0 [0 R
{8 V0 ^% o1 F4 Z' T" R/ h3 F
.active_low = 0,
) b6 J Q# A# ?4 n, Y" J .gpio = DA850_USER_LED3,
& u; N$ R, T3 r/ ]4 n% v+ I* \ .name = "user_led3",
% R$ W" ], ?9 F( P3 h .default_trigger = "default-on",
+ {3 [. q) D3 d6 { l1 g1 w },- }7 N9 G0 U& ?( F" q7 B
};
! q8 ], X) j" E# {5 @2 J; ~; K, D9 a/ u2 R) e( c1 T
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 E% ^. t. |0 a+ S# B' S
.leds = da850_evm_tl_leds,
2 d9 L) U y0 |8 Y# V/ P3 T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 [6 m2 |* Q x, w! }! j};
$ V2 ^6 N5 j- T* p7 `
& E( Y' g/ A' t7 lstatic void led_dev_release(struct device *dev)
6 M8 d6 d/ R H( {/ \& y* N{
) ]& v# |" b9 P3 H};
% W# e5 G! |# W3 \7 m) b, t9 o7 x1 @9 s/ I5 @
static struct platform_device da850_evm_tl_leds_device = {( v4 _4 O5 o3 C
.name = "leds-gpio",
& ^5 b( q. Y$ e7 K6 L$ V( [; m .id = 1,
& }& ^6 H" F# [5 P. m .dev = {/ S4 C2 _( T/ Y4 B8 l- j
.platform_data = &da850_evm_tl_leds_pdata,
+ m# a$ m/ M V/ d3 L+ t3 V5 ^! ] .release = led_dev_release,; H, h# }8 J8 S
}
! c% @2 }; N* G4 e' q! {1 V9 B* g};
0 z* t: |/ Q2 m! V- v, U: r" \- d" W# k* [
static int __init led_platform_init(void)' [' o/ [0 y5 D( r
{
5 W1 B5 i" D, X) B' J% k( t int ret;
* X [% Q* ^: ]+ p/ g n4 ^( o1 b, F#if 0: d& ~! D" C# [ K, y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ _3 h q" @' f* Y% Y" a if (ret)
# R9 M5 q7 M, ], X0 A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* D: w; e9 t) y: i- M) v) ~7 a6 t
"%d\n", ret);
% p8 C2 N$ d) C! v8 K. V9 _% z#endif7 ^- X( |4 U% J9 A& I8 o* C* X. r
ret = platform_device_register(&da850_evm_tl_leds_device);1 q$ ^8 A$ w$ M+ j/ E3 D
if (ret)
8 ^# n3 v6 X( F, R+ n pr_warning("Could not register som GPIO expander LEDS");" j# V7 I7 b! J# k% I2 u
else& C+ k. n; E9 p, T) x5 ]
printk(KERN_INFO "LED register sucessful!\n");
- C' @) v! x! W5 d4 O' o9 x& s: {, e$ P( B2 W6 F) V; K
return ret;
/ H ?6 m3 p7 v! Z+ j}- |$ L+ O6 |$ Y& r
: k! F- r5 a( \static void __exit led_platform_exit(void)
: z4 y4 Y/ [% K+ Q{
$ [0 g9 h( ?0 Z- }3 s4 o/ Q; [& f platform_device_unregister(&da850_evm_tl_leds_device);: g& n+ R0 l; o) b& w
1 p; I" a! _" P* P printk(KERN_INFO "LED unregister!\n");
; u& M7 d2 b- x: v) t}
$ J* n0 J+ a; s' y9 L! l) k6 Q% a: R9 m# U' n3 }0 {" q
module_init(led_platform_init);
/ v* A7 b, c1 r) t8 H) |% O: m7 J6 ?- b0 ?module_exit(led_platform_exit);) c1 ?- Q3 A" u$ D5 `
1 _7 C- W: y: g( O2 m3 d" M/ {
MODULE_DESCRIPTION("Led platform driver");
/ g! L# [, L ]MODULE_AUTHOR("Tronlong");8 \+ [0 H i9 J' f
MODULE_LICENSE("GPL");- P+ o2 r9 O8 b% g: @
0 G( ?' L+ w4 y( C5 X |
|