|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 w# c4 ?% D9 q
#include <linux/init.h>; T) S8 M# I' ?5 p$ M& v9 O
#include <linux/module.h>( k% t5 Y, j" r6 A
#include <linux/kernel.h>
) ~# c$ j: u& U4 e#include <linux/types.h>1 E2 S2 \0 D7 u8 b" l
#include <linux/gpio.h>8 A3 a, @) ?' w
#include <linux/leds.h>3 H, D9 a, j; r1 W
#include <linux/platform_device.h>
3 z2 _* J I) O5 c% N' M9 X, P* |. a( p5 ]2 M" ]
#include <asm/mach-types.h>
% L0 k2 N! \3 I: B, w9 ^#include <asm/mach/arch.h>
& A' N" B# i* q; j$ Q1 j#include <mach/da8xx.h>7 k! ], ?; _$ M) d5 M5 c
#include <mach/mux.h>6 f* s0 l5 ^. O( W. t1 X. Z
% a9 x1 F3 B' A' d d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) O5 p: I% y0 w0 v$ @- ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 m3 Z* w9 S9 S( Z* k* f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ s) N" \5 C% t* j
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): z6 J [% D, L# k# W; a+ f" A1 s% L
3 u+ z' j- |5 H. e4 o2 v8 P
/* assign the tl som board LED-GPIOs*/
6 L* t, b) Q0 g0 xstatic const short da850_evm_tl_user_led_pins[] = {
- p$ W; A# e8 _ /* These pins are definition at <mach/mux.h> file */+ m8 a) Q. S3 z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 r. W! o0 g. g -1, s7 K$ Y8 \8 |
};# P: g$ A" k# ~! ]1 \; F& ]- w
+ ]3 x" N1 L5 w2 Astatic struct gpio_led da850_evm_tl_leds[] = {
$ R3 G7 z! E$ I! S {
: Z2 |+ m5 Z+ V% i3 a7 n$ K .active_low = 0,7 G* x& b3 o, l5 {
.gpio = DA850_USER_LED0,+ T$ a; G# k. D6 \" e1 ]7 l2 {
.name = "user_led0",% d4 ~$ R( [ D1 o
.default_trigger = "default-on",3 f( D( I) S/ o) b; T( } C
},( i- N4 c6 ~8 K2 n6 y4 @
{' s2 z, `5 F/ y! r3 Z" r- j, z
.active_low = 0,
|' u& o8 j+ ^4 X2 z1 F. J! { .gpio = DA850_USER_LED1,& U2 ]- Z& V( v6 ^0 a* g6 W
.name = "user_led1",
7 k: A0 x* x: e0 a" h E* T .default_trigger = "default-on",
& n- Q$ X+ \9 G. W9 t' q$ O },
9 Z3 U* c7 a2 Q0 F/ e" D; ` {
7 t7 ?: a) \1 F+ `# e/ J7 O5 [ .active_low = 0,5 ]" o2 T# [3 q \8 u5 j! O
.gpio = DA850_USER_LED2,) V6 z( d7 n( v8 u3 d6 @. [* n9 J
.name = "user_led2",
. L+ A) [- F, f" b" W+ o .default_trigger = "default-on",
o+ w2 v0 w: r- k/ z, @ },% z8 x" o7 V8 n8 B% D
{
5 N# X) t; L7 g .active_low = 0,& k o( z5 v/ ^
.gpio = DA850_USER_LED3,
5 Z' D% S# w" E- b0 q+ k: A .name = "user_led3",! Q8 @ j/ ~) z- L7 ]2 n% b$ b
.default_trigger = "default-on",2 D1 E; h# d) X! f3 l
},
( ]# K7 o. {' n$ R- a! Y) n o};
& v/ Q# K$ C! u8 N1 c1 J
! [# E9 @' {4 q+ wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, `( U4 ]" }" [7 K9 @) U1 n
.leds = da850_evm_tl_leds,3 ]. N, C( w, t3 a9 f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; ~7 W7 v* `# W# j};
* Z: |( d# b1 }! J7 p7 b
) |5 q+ u# b% w7 h% astatic void led_dev_release(struct device *dev)! j- z8 {6 u8 n2 q# t
{
c5 r, q) C" ^) i! z6 M};: J; y9 |: w6 ~8 T6 k1 @9 `
9 b" L* z9 _) X8 \$ L+ y& e& ^% R3 l
static struct platform_device da850_evm_tl_leds_device = {
- E) J9 Y; O9 G1 m; _! P .name = "leds-gpio",
% B% |8 \* L2 W# {, l! W; H .id = 1,
" A2 x; G7 y; H .dev = {8 z! e' Z% p6 Y3 v2 Z+ }/ P
.platform_data = &da850_evm_tl_leds_pdata,
2 H2 d8 L- w7 \) ?. U# B .release = led_dev_release,+ k, O3 G0 B/ d
}
' Y5 u: ]$ r( \};
: [" ?4 M: {: Z; _& S A
% S+ \! h) J' h/ _) u# O Hstatic int __init led_platform_init(void)
0 ^ J- s: o4 v5 u+ T: M* Q{
# a: y3 ^" n* p- t5 v int ret;
2 K' K4 r) ~; f% M' n2 Q#if 01 X9 \9 }) m& ]! C* k' t. b. d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* x. O/ U7 z6 L; y1 b/ R& A7 y! L
if (ret)
# t* S! S1 j6 `" A. d7 K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( Y/ S# I0 S$ t$ B! w4 ~& A
"%d\n", ret);+ _" @ c! `" Z3 G: G
#endif# N, g. j7 o7 o. f
ret = platform_device_register(&da850_evm_tl_leds_device);
" \: @' E" o/ h9 G) e/ I if (ret)
; ^, [' F) C3 g pr_warning("Could not register som GPIO expander LEDS");# z; T4 ~ y! _3 T
else
$ }* m0 U% v6 A! m R1 ~ printk(KERN_INFO "LED register sucessful!\n");
5 I6 Q1 I& u: c2 h" l8 |+ E8 y3 k! t! o: F3 B0 L& L! p7 P
return ret;: }2 K% c# l$ V5 ^
}: z4 w$ F: x7 g) A
% r: `( _0 F3 C) _3 }1 \. I
static void __exit led_platform_exit(void)2 J2 S: T, L6 u- H5 l0 P, ? P+ ` Z
{
. e1 V. w, ~9 n } platform_device_unregister(&da850_evm_tl_leds_device);
' H! e8 E. B6 k/ Q0 ~, I) ]; i3 q
printk(KERN_INFO "LED unregister!\n");' ?; E! q% r* A7 I0 Z' N4 u V
}: f1 {# d8 }: C/ S9 g, J* X% w
' d+ ^ l0 r& T, F
module_init(led_platform_init);+ ]; L/ c# O, R' D+ o: U
module_exit(led_platform_exit);
1 ]) }1 K! K& I
# c# b7 P/ N2 H" z$ F& c7 w fMODULE_DESCRIPTION("Led platform driver");1 @& c1 d! E7 ?& s: ^4 A! t
MODULE_AUTHOR("Tronlong");6 d3 H' I1 G7 [; t8 f% K& G6 [
MODULE_LICENSE("GPL");) n( x: h1 _" z
: P$ [) Q% f# ?3 ?
|
|