|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: S$ R1 f$ u z9 \, P#include <linux/init.h>+ k3 H! H4 e# V/ u4 E
#include <linux/module.h># x* Z: }) \5 y
#include <linux/kernel.h>- j! G" s9 w, L' F
#include <linux/types.h>, q* {: L$ e9 b* Y1 z, n/ }
#include <linux/gpio.h>
' [7 G: C8 o$ M5 m* t/ Q#include <linux/leds.h>
/ y2 E R e& a6 c#include <linux/platform_device.h>) N# m$ R/ l: @" L
+ R: ]* ? Q* F$ ^$ ?3 K
#include <asm/mach-types.h>
. v w2 G+ n% j; Q6 `#include <asm/mach/arch.h>, k: k( }+ h( I5 G$ t" v
#include <mach/da8xx.h>
) W- Z3 e! Y; N* b! Z; }2 [#include <mach/mux.h>
4 i0 F3 f) m& [+ Z
$ e0 J% M6 _, {$ y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. a/ o" u! _! a1 |$ i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); l. C- E6 Q2 m& n+ c, ^2 G0 N7 c) }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 }% c5 U" q; \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% Q2 O; O1 H8 F/ h% `
3 O I, T% b! u3 F a8 ?! H2 j/* assign the tl som board LED-GPIOs*/: O' y6 M" `4 Z A
static const short da850_evm_tl_user_led_pins[] = {2 W$ O! u# |$ O# k
/* These pins are definition at <mach/mux.h> file */
0 P2 V0 b9 v% D0 |) Y" P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 k! Q* I; R' l- T/ Y
-1% L% h) {6 ~1 s I( v3 ^+ W w
};2 ~6 w: u/ q$ V6 N
V3 I/ L+ ] i6 Nstatic struct gpio_led da850_evm_tl_leds[] = {8 ]5 Y x: `$ `; o( h) L/ t1 h" |. A
{& m$ `, {7 j r$ G" ~7 V# p
.active_low = 0,! C! R0 M" q. n$ Y# e }' R' _
.gpio = DA850_USER_LED0,
$ ]$ s6 Y5 p! f! f! Q8 ? .name = "user_led0",
; H; o5 Y; a( _$ `- D .default_trigger = "default-on",7 @/ y1 p' ?) r0 ^5 L4 {
},
6 a2 E7 @' {8 V4 R {0 i! M! N7 c, h: n3 Z, l/ N
.active_low = 0,
) S- Z( @! L! O% P+ k7 ] .gpio = DA850_USER_LED1,# J9 D8 _5 q2 h* \5 a( E
.name = "user_led1",3 s% d5 a z1 D1 V9 C
.default_trigger = "default-on",
, [+ v; G1 t8 M* a },
8 g7 S. I) O% [" U g" w( h {6 {; B, Z) ^& Z) u# q8 E! U
.active_low = 0,
* B8 O, h( ]) t- ^ w .gpio = DA850_USER_LED2,, r/ a. Z6 ~5 q. H. j. ^6 P
.name = "user_led2",3 l, l8 K/ \2 i8 s
.default_trigger = "default-on",
" }+ m" K; l% {0 c" f8 _6 B' C; o }, J$ z( ]" h; J) q9 ?: l
{
3 K2 D: O1 y1 W& U8 S& C9 F .active_low = 0,
. ?5 m6 S$ U: u6 {! F .gpio = DA850_USER_LED3,
2 e8 o7 `( f& M3 h" w& y# u5 ~6 m .name = "user_led3",8 L4 j1 Y% Y3 B1 S. l) J
.default_trigger = "default-on",' H o+ f: E1 H9 m2 ?( Y! _
}," X$ k8 Y: s# U4 A# y' d
};
3 P# @& w9 [: [3 L( g2 v1 R( y5 h; v+ w5 M, |8 H; C" e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 O( w# z: `; ~/ g& k& G/ N" Y
.leds = da850_evm_tl_leds,$ `5 O" K$ U% p& j/ o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' t' t* R7 y Q9 r, e3 W3 }! S
};
' \& ?( G# f C! Y O. E: \8 [$ W
static void led_dev_release(struct device *dev) ^! c7 o" \* {5 z+ q) i" m
{' w m8 x. e# w4 H1 J& ?" M2 i' D9 u
};7 g+ s2 p! O. F9 K4 D
7 R* H1 \7 H' @9 ^; N" ^6 Ystatic struct platform_device da850_evm_tl_leds_device = {$ t/ X7 v6 l; h" D- l7 n2 Z
.name = "leds-gpio",& y2 m* q1 ~! k/ f) t
.id = 1,
( ], p: r |* F# L l" m$ w5 C .dev = {6 ]% ^0 e$ @( R) Y5 L# `8 Q& v8 X" Z& L
.platform_data = &da850_evm_tl_leds_pdata,- O/ O8 L/ D1 C6 x) R: m1 `/ S
.release = led_dev_release," ^* C' ?& E0 o' R) \( `
}
* B/ ^: [. i. d& }: _};' a$ Z5 ?4 z7 H8 t! g, H& V+ C" D0 M/ G
3 _! @$ A0 r7 E0 Q5 @static int __init led_platform_init(void)
4 Q% L) {5 O# x& e F2 l{# e3 f( W) Z/ `5 x1 P) Q: M
int ret;% \6 P- X& \0 M8 a [: `
#if 0% G# w5 g' P; P: h- y ]; g
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ A5 r2 J- T# `2 s' w: [
if (ret)* f6 Y# f1 b# A$ M& @' Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 o6 b7 F/ a' [) | "%d\n", ret);
" u `: S0 ^5 c! t u#endif& c# M. \' k, u5 |9 F
ret = platform_device_register(&da850_evm_tl_leds_device);
# A1 R; G! b& H% V& c if (ret)% \9 w! f4 m S& c2 Z1 `: E5 m. j
pr_warning("Could not register som GPIO expander LEDS");
: R; z4 B' l) b. b: w" B else. G/ S& x* ?9 }2 G+ \: k; U4 j
printk(KERN_INFO "LED register sucessful!\n");
5 Z: N! `7 c. [9 X
2 @1 M7 N$ S2 a. `2 ]' L& Y' r: T return ret;' H0 ^* Z: X1 R& \& h
}2 l% O; ]) K! J5 G; X: t2 ?' j
4 W; p) H- G. \9 @( Kstatic void __exit led_platform_exit(void)# k9 G/ O7 `' I8 {
{
0 R4 \& C; X; H% U5 Z. t5 @* Z platform_device_unregister(&da850_evm_tl_leds_device);
/ ^3 I0 v: E, f+ u; S2 I9 E7 a K# l. ~: `; N' ~& O
printk(KERN_INFO "LED unregister!\n");" C) v; Y* s: p- e2 c
}/ i) s, O3 ], I8 t9 T
|/ F" @) D% tmodule_init(led_platform_init);
+ t; j1 E/ \/ L' [3 D9 G! d& `module_exit(led_platform_exit);
5 F% @7 ^$ r6 l' V7 o5 n
' }( E6 O1 L+ }6 X! }MODULE_DESCRIPTION("Led platform driver");: F/ i# [' c" L5 q/ E2 G/ q
MODULE_AUTHOR("Tronlong");
( x! h. t& ^% m* U- v( {4 X, JMODULE_LICENSE("GPL");
) C% Q% L5 P4 S1 X4 H0 v# ^& ]
1 R5 I/ ~" P! k- X; Y5 f |
|