|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 ?4 U7 p/ l" G#include <linux/init.h>( B4 K. h i. x" P/ h O' F3 t8 o
#include <linux/module.h>+ b- x' o: i7 m' P% |
#include <linux/kernel.h>6 S0 s4 N& D4 E" Y, u5 K. p8 ~3 ]
#include <linux/types.h>
6 \! f; ]5 k0 [8 h( v. ?' F#include <linux/gpio.h> J2 G e: O7 q3 [" s
#include <linux/leds.h># m0 q Y/ f8 f+ u( I) f
#include <linux/platform_device.h>
% W) |( g: B8 g! B# D. Z/ I, m0 z- y: o0 q" }. ~
#include <asm/mach-types.h>5 d( F4 k1 e' G5 W
#include <asm/mach/arch.h>. M" g6 L2 ~+ y$ L" t8 F
#include <mach/da8xx.h>" I1 V; D/ ]% h% B! d
#include <mach/mux.h>
; t# n0 v( c: @
5 w! w* f5 e& u% {0 F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! T* [4 ^( v' K! x; B. @ o#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 Z# R+ p; |* z: d# l: o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! \4 P) X2 F$ u% ]; G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. n/ d/ y1 N& Z) {+ O7 O
3 _5 O8 o* l$ ~: S6 [6 q w1 u/* assign the tl som board LED-GPIOs*/* ]7 U8 H# S/ j/ F
static const short da850_evm_tl_user_led_pins[] = {
: z6 m3 z6 N7 q* o4 }0 m% A+ e /* These pins are definition at <mach/mux.h> file */
. S$ f5 j8 F+ b) g: P9 I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& q3 {: g% U* Q) N2 L
-1
7 D6 B/ t. A& s1 D: o1 V) s};
9 l2 G. K8 U0 C. [' M% r' N8 I# y7 @4 j2 u
static struct gpio_led da850_evm_tl_leds[] = {! j2 A; V) N3 X- |8 ]1 |- O8 g( Z
{
8 T* K' C3 M: P .active_low = 0,3 \% J8 l) A. l9 ]2 k
.gpio = DA850_USER_LED0,
% s' H; }4 X6 Y1 J' { .name = "user_led0",
Z( |* y6 x4 o .default_trigger = "default-on",5 l0 Q% L9 j l7 d9 q
},0 R9 [) J2 b$ }7 t0 d
{
3 k% C1 e# l* I% t) v .active_low = 0,
* H* s- I- K) w; D: p8 |/ z .gpio = DA850_USER_LED1,
! b) X5 G$ h5 A t2 I! M) l .name = "user_led1",) {) p: x! Z+ {/ E( s% ~
.default_trigger = "default-on",
/ i! q, s! O4 a" ^ },/ c/ w7 r' s: K6 u, Z7 I* f2 r
{+ I1 \6 b6 Y5 i- i! J- C% o
.active_low = 0,& m7 t6 Y7 k$ a- N+ j
.gpio = DA850_USER_LED2, T0 ~0 x. V% T; I
.name = "user_led2",
- Y) k: \( G. n+ ?+ i .default_trigger = "default-on", b+ j! n0 y( S
},
- |+ C* q7 s. ^8 g) v {& T& ^7 \# _" V# S8 u! }& J
.active_low = 0,) _7 V! J) p4 e; _9 Y/ c" Q: H
.gpio = DA850_USER_LED3,
4 C8 v" |0 T- @( N* \% N .name = "user_led3",
. b% D; r- e/ S: R, x/ W- A, K .default_trigger = "default-on",
+ o+ [ o/ S. H },
. W" o8 _3 T9 y" \( m+ \};
0 T6 d! }6 `* T: H: P9 m
1 m; p2 G. M7 Q7 K$ \. lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 R) U$ H) d( ?- t
.leds = da850_evm_tl_leds,8 e. c0 ]1 U9 Z7 C% e" t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 f9 C p: y% f+ \, J
};( s Y& g; r& l
, _: g! e0 p! V. @; Lstatic void led_dev_release(struct device *dev)
# N/ ]2 {+ _- F1 C3 }5 C# \{3 s( V( L5 F% {, r3 b) {
};
$ a- Q$ _% y2 G* I! E( ?# S: t, R. ^$ C' K- h
static struct platform_device da850_evm_tl_leds_device = {4 z3 ?6 h/ g8 K% n7 @. V R
.name = "leds-gpio",
9 e0 j! u* f) a; { .id = 1,
2 _: |2 t, S. Y, |9 }1 a3 D .dev = {
; e4 j( ^# x, A" i9 ?* [ .platform_data = &da850_evm_tl_leds_pdata,% a# A2 m3 M$ ~! a, B7 v7 |
.release = led_dev_release,. C: C* G {9 x# C# Q) T% `
}
8 \: Q& m8 p* ^3 ^; {+ r% o, M9 x};8 G! ^( x U2 [' I/ s7 l
9 k; l9 U# ~: p7 Bstatic int __init led_platform_init(void)( j5 G; P3 n" y& e! f# j
{; Z- \; n) L8 X* a
int ret;: y7 q3 ~5 A3 q
#if 0( q( i7 A {5 d% O& Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 _# a/ G' s, C1 S) ^ if (ret)/ _; ^/ R4 O* v& g3 L' G }: ^5 {8 B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% h l. w2 f3 N' ` ?, O
"%d\n", ret);
& {! I0 `/ ]" r: e#endif
9 M/ J8 @) Q& V: h ret = platform_device_register(&da850_evm_tl_leds_device);, E1 w# S. N+ n8 L; Z
if (ret)8 M' H% r/ ]0 a) x5 D( K
pr_warning("Could not register som GPIO expander LEDS");" D3 Z3 w1 Z2 X) S; L: s
else2 q- r% e: a. D
printk(KERN_INFO "LED register sucessful!\n");
8 p# l' G* o; a8 c; Y
+ E$ F; V; w7 S+ k: [: c return ret;6 g! N' \. e, h/ B9 f$ w, M
}
8 V# Y8 ?; l" X+ [+ r/ c
4 K5 n7 t! w! d' u7 R7 u! Tstatic void __exit led_platform_exit(void)
5 |$ d) X/ W2 b& Z0 F{- [3 l1 W" K: i. ]
platform_device_unregister(&da850_evm_tl_leds_device);' S0 M$ |' w2 m2 q8 s
5 F' r. H* h! N$ A' |3 {% V B
printk(KERN_INFO "LED unregister!\n");7 Z! `# \! f) H" d; _( c1 y
}" y k$ T) E- Y$ B: w: b$ [
& m B" T, z; F e# q- J9 F7 N5 O
module_init(led_platform_init);4 [) s1 Q' K. w [& `
module_exit(led_platform_exit);
6 S& P( r3 V& Q( n2 X3 H
% U3 t* j& a$ \' C% v6 aMODULE_DESCRIPTION("Led platform driver");9 y U* b8 X7 v8 n: ^ Q# B6 h
MODULE_AUTHOR("Tronlong");* L& @# Q0 i6 y0 ]
MODULE_LICENSE("GPL");
& r0 \9 O' M& f0 C/ R8 h- B. E. B& y0 m% a
|
|