|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' l; o2 ^& Z& P) T- x7 s#include <linux/init.h>
) b9 q3 \/ V2 ]* G7 X" N#include <linux/module.h>9 u3 e$ Q ^& h/ u! S2 s1 d9 C$ f
#include <linux/kernel.h>
9 H( r# g: b0 M; U" i0 m#include <linux/types.h>
( L: ]7 u7 w0 {$ P8 g& e" `#include <linux/gpio.h>0 Y* W2 F' Z) S
#include <linux/leds.h>
+ i# J, S6 S8 K5 R k0 Q#include <linux/platform_device.h>
2 C- _) m- \/ ~ Q) z! k4 y/ i! _" {( s% r5 _
#include <asm/mach-types.h>7 \6 z3 k) D' A6 f1 _
#include <asm/mach/arch.h>+ t0 b$ k/ B( V# S/ G" Q$ `
#include <mach/da8xx.h>* q- F6 |. e6 [( Q# r$ C" S
#include <mach/mux.h>
3 E6 C6 l: H& V2 m9 e6 ]$ D+ N. O4 G9 X& S2 N+ g# p! N; t) [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& @9 e" m& j* W0 Z2 ~- }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 L. {( g3 H; }& _1 ?( @, Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ J& v, `1 f" r. q& M$ ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ M( N8 F6 R# C5 A% t' L( K
$ a( Q h+ B. |
/* assign the tl som board LED-GPIOs*/
' e; f' Z" Q( ]3 wstatic const short da850_evm_tl_user_led_pins[] = { J* o* n7 F2 ?: m- T
/* These pins are definition at <mach/mux.h> file */
7 a! W5 R: l/ r' M DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% s, Q2 }5 H3 R x4 E$ @" Q9 h
-1
9 q& Q3 y3 ~! j" u4 K* u+ q};1 w {. a, y$ P- o1 s0 `' L, S
1 A# L# A+ T! o! n* ]+ fstatic struct gpio_led da850_evm_tl_leds[] = {- @( a% O4 P1 ]& x- u+ `3 l, P
{% C, c1 F1 r1 n1 _+ U
.active_low = 0,; }; F2 s, D5 Y _
.gpio = DA850_USER_LED0,! N4 R5 i: t1 C# G
.name = "user_led0",5 u' `$ p" Z4 }, `+ x. `: Z5 Y5 A& g: }3 `
.default_trigger = "default-on",# @5 ?4 J/ j; {
}, d! {' `- s; G5 Y: O& \
{
4 v$ B: L& g- ~ .active_low = 0,' O W1 _- w. }% L! D1 t% E( N
.gpio = DA850_USER_LED1,# m6 u' ~) C2 z- o: g+ l2 ]7 \- u
.name = "user_led1",
: ~ {: Y4 B! t. U. w. u5 ] .default_trigger = "default-on",
; e" ?9 q) `0 Y L. W& l },
3 `' _# B" E" `! O {
+ \* i% C6 v! I .active_low = 0,& s3 l2 y) x p% E) M# o
.gpio = DA850_USER_LED2,' I) K* H3 Y3 B( f9 _0 R& p1 m* e9 k
.name = "user_led2",2 |) u7 Z& O( G* E
.default_trigger = "default-on",1 P4 @- P3 k, |' n' {# K8 |
},
. k& d8 b$ }9 P5 P; b% o, U {3 f3 U4 W3 a$ R# E/ I& O; P
.active_low = 0,6 ~3 d( d& W' w. W2 d& a |3 i9 w
.gpio = DA850_USER_LED3,
: u5 ~, C. q H& f: W .name = "user_led3",, [% N+ C& [2 E
.default_trigger = "default-on",
: b! m9 w+ t9 Y( i& a: J },( G! @) @+ v+ f' B- B1 E" _, [8 F
};
; C8 u# }; C) v& I9 n* ^3 D7 L2 L0 B$ ?& m( V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" T8 x" a- v9 s0 H( H; l& u7 [
.leds = da850_evm_tl_leds,
U' J8 o% [ U* @0 ? .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; K* E( B/ n# X% f& H2 s# U1 L};; q7 }) e ?5 ^) L
" c5 Q0 {& H7 z; f2 v7 s+ Nstatic void led_dev_release(struct device *dev)
" z4 Q0 N% Z6 t. s. }1 R- l{
0 O/ d1 P- T3 l- c' g+ e- o};6 F8 k& z* D5 t1 w
) Z7 Y6 a. K: U6 ~7 Y2 l( P
static struct platform_device da850_evm_tl_leds_device = {
; O, \4 g0 r C. o' [% Y/ I# M .name = "leds-gpio",
$ {! {9 [, ?" z5 g- V- k) U .id = 1,+ }* z1 b/ B0 _; }! P
.dev = {
/ e/ M3 b/ w8 n/ c2 K .platform_data = &da850_evm_tl_leds_pdata,
' A8 n$ Y k* U! B1 ] .release = led_dev_release,1 J! c) v: N: A
}) T, \( z8 X- v- x- o7 y
};
}# E# Q2 l' h+ s" o2 L% i6 r2 Y( m8 R* f
static int __init led_platform_init(void)- N' V$ i% P5 t/ C* m4 \4 l' n L2 o
{
1 O7 p, W, Y& k5 \( Q. x int ret;0 }) S) M( ^# [' m/ i
#if 0* F4 O& Z$ a1 }1 v ?0 b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, O- L& C: H' B, e+ S$ b- Z if (ret)2 C2 _' Q2 v( ^5 X4 b3 L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 @/ }$ n2 P9 j: M3 E& S( ] "%d\n", ret);
; `0 N4 N& X! a" r- F2 N; M#endif
, _' @ d% K/ V0 } ret = platform_device_register(&da850_evm_tl_leds_device);2 O! T1 @5 v+ E3 i) j. c) \
if (ret)6 k$ T4 x" g; I, k$ I2 b& u$ G
pr_warning("Could not register som GPIO expander LEDS");/ y/ j7 n2 o6 z: F7 [- S
else2 Y% F4 g! ~6 @2 z+ N, V
printk(KERN_INFO "LED register sucessful!\n");# `. D- v {! J* U! K& r
n& q8 o: V/ E0 M! n) z( @ return ret;
7 P6 K& M! V, A2 V+ I}5 y0 V. z1 Q& s0 D% i
' ~# C% i9 r# N; n3 d3 lstatic void __exit led_platform_exit(void)
5 T! L/ s; [/ l$ N4 z& I. l& \2 X{
( E2 j) \* d- I platform_device_unregister(&da850_evm_tl_leds_device);
4 r/ M p, R% @" k
$ n* [9 D+ R: k1 s printk(KERN_INFO "LED unregister!\n");4 L6 D9 I# A/ i
}
8 j. M( L) H' O0 c. q! Z& o
8 k& U, X+ [! Q" ~. }, bmodule_init(led_platform_init);1 M* e- L1 Z' Q" d0 \4 W
module_exit(led_platform_exit);
; Y$ {& A5 c, I
0 O5 i9 q: o: ?! R' k4 HMODULE_DESCRIPTION("Led platform driver");
0 P% M# n% r, \' e8 R4 e' ]MODULE_AUTHOR("Tronlong");
: v/ b& E# L' t: C6 J% iMODULE_LICENSE("GPL");% L3 `2 R; r# O1 v. J. Z
5 ?, R8 m- x* ]
|
|