|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! F# p+ o+ `0 m& d4 [% o
#include <linux/init.h>
8 G; w; o/ D" P: w#include <linux/module.h>
5 Q: G1 T" P) R2 u" u3 \- n6 o0 w#include <linux/kernel.h>
3 f+ s. j, g# x' a/ Y% k#include <linux/types.h>
c9 l5 d+ H; ^4 M9 E! o#include <linux/gpio.h>
+ o5 R1 y8 P7 z) y$ G$ w#include <linux/leds.h>
2 i' |. O+ |0 Y. H: F& @* } b#include <linux/platform_device.h>
) Y2 T# z8 a6 D: Q* j) M' _. Z( p; ]) L0 m U. `6 O
#include <asm/mach-types.h>
# x7 a$ |' ?6 D' B% R( ^6 D#include <asm/mach/arch.h># g4 W8 G* ^9 a- @
#include <mach/da8xx.h>& t+ V7 @' E4 J# C; m i0 V& p6 X
#include <mach/mux.h>1 V: @% h- T. K/ V2 M
1 |, f. _6 ~: d5 ^& ]0 ]# P2 R$ F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* B6 A8 t: L+ F: U4 h& B% _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 n" t" ?8 v7 U j+ T. u4 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, N8 J+ M9 @. F, G( L6 O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 y. T9 t4 X$ I9 e5 ?; x" P& N9 S8 R: ~* J. Y6 X3 F
/* assign the tl som board LED-GPIOs*/9 w8 u0 s/ q4 W7 k; ]8 z
static const short da850_evm_tl_user_led_pins[] = {/ q9 _, K; K$ j
/* These pins are definition at <mach/mux.h> file */. u1 l2 a- V8 y) B$ F$ o! M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," v/ o, H7 c" |9 ?" d; x6 R
-1
1 T: @+ t8 r; x' ]% g7 h};2 q: s2 n1 _! z1 B* o- q
$ z- j! Y9 Q- m+ o6 A7 Kstatic struct gpio_led da850_evm_tl_leds[] = {
1 `# A2 l$ t2 t% R K, K+ y {
' B- `& w6 i+ H& y; u0 a .active_low = 0,. z" z9 u V6 I" h
.gpio = DA850_USER_LED0,
5 g& C( p$ C$ G2 d3 V- w" E+ b7 u. _3 ` .name = "user_led0",2 v' g. Y' }4 H; g5 f( r# P. {
.default_trigger = "default-on", h; j& E8 f' R1 D7 [6 [( O
},
/ d3 C/ L/ Z' w( p; ~ {
; U% n, {# O* j. O; h& Z* F7 a, o .active_low = 0,
y" T/ Z+ K, a( D; _/ h .gpio = DA850_USER_LED1,
9 K9 M. W3 W; [! v. f; ] .name = "user_led1",! X. }, D m+ v `
.default_trigger = "default-on",# d! i( o' P: M$ k! a
},! }3 X$ T' D4 _3 `! @- M2 ] v i
{' L# `- z8 F7 i6 Y
.active_low = 0,
1 {6 l5 I3 P0 k: G$ T .gpio = DA850_USER_LED2,
# J$ p- z6 G y& V& k& ~ .name = "user_led2",: l& p! m4 D$ B# x
.default_trigger = "default-on",& U' K/ A6 _; o7 v+ b+ I2 g J4 z( R
},6 D4 W6 d" `. `# H5 n9 F( f$ A$ h
{3 k8 b7 U5 e) C7 c9 F1 a" g+ N, M
.active_low = 0,% s L+ x' H* M$ h- I6 w3 x: D7 v
.gpio = DA850_USER_LED3,
, t* k& a* L, r0 g/ M .name = "user_led3",
: `. s7 L" V1 r9 b. H6 a$ l .default_trigger = "default-on",
# w9 w5 ~5 ?" P d Y" [ },% _; ?( D- u6 t, W' |7 ?
};
% \4 _( e* G# L4 ^0 H6 z. n. ^
* f! e: Z' H" g$ i0 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" h) s* E) |( }4 I3 z U .leds = da850_evm_tl_leds,
0 S4 H0 o$ f6 L8 c& [5 J: j- [. C3 p7 n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ T) U; }$ ]8 U! R- i' G7 u, f! @};' t6 q2 w+ f2 z% h+ c
, Y" Q$ Y& l' i, z& }
static void led_dev_release(struct device *dev); X# B9 ]1 F+ L1 [, r I
{
, L3 a1 O# H% N& x};- t( X+ D5 b/ Q
+ i. L; S5 R; O% e0 T: ?
static struct platform_device da850_evm_tl_leds_device = {
* y: A' T4 K" g$ \% c2 N# D* o1 y .name = "leds-gpio",5 T/ |: V7 w+ y6 `3 b% J
.id = 1,
6 y- [- L6 |1 s .dev = {
/ t" G6 h5 K- n# `2 N .platform_data = &da850_evm_tl_leds_pdata,- ?' V! G* ^' ^0 r: K) S9 w+ z
.release = led_dev_release,
% T- A8 q0 H3 P& A. h$ C }7 C0 R1 o% d8 n
}; N9 }! K) U5 |4 L
' E" i5 M' H8 X% `& ]static int __init led_platform_init(void)
; K7 y- ?% c6 y# u) `0 k0 j) @0 g{( ?8 D) h7 b7 ^
int ret;
# [3 m0 a; x H, P#if 0
: i' J& h9 ]4 h# A, K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) Y8 a/ k. c5 r3 Y1 l* K
if (ret)
+ J3 m3 N* ^# M# I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 U+ I' d8 _/ l" P* H0 }7 _ "%d\n", ret);, C A. y7 `6 W5 h) [: z+ i- p
#endif
3 o+ w; v0 f" e: \& A ret = platform_device_register(&da850_evm_tl_leds_device);
3 G% b3 f8 T7 t4 N if (ret)
g9 d8 _: i- K pr_warning("Could not register som GPIO expander LEDS");
3 F7 ^6 \1 c. \5 d- Z& T else6 ~+ m! U6 @( M' A
printk(KERN_INFO "LED register sucessful!\n");
' u9 K' J/ l! R( Z! p3 H7 U0 ^" S4 I' u- l% m
return ret;, Y0 R$ ?& b l K) O# ?3 D$ Y5 Q0 s
}
& q, q v* k1 w& y
$ d Z% r4 p4 \' {. bstatic void __exit led_platform_exit(void)1 M6 L. v# u0 H5 W
{1 \8 r6 q; N( @
platform_device_unregister(&da850_evm_tl_leds_device);
* n7 N6 A0 a) x: W' f7 n1 g& Y! {3 g( d) B, k- `
printk(KERN_INFO "LED unregister!\n");. _1 c3 Z$ X1 N) [/ R# Z
}
8 c K/ p' k7 @8 A$ q; ~% W0 T) a1 `8 q4 G1 A. `& r
module_init(led_platform_init);
, l+ O! g9 Z% ~+ }, @& }3 l) J6 `module_exit(led_platform_exit);0 l0 T4 H5 m% z! `$ k# x/ ]) s
: K6 `( s4 q! N% l' UMODULE_DESCRIPTION("Led platform driver");
5 Z- G! D; l cMODULE_AUTHOR("Tronlong");
. B/ {( M! a- }9 }2 d1 M+ RMODULE_LICENSE("GPL");$ [2 x! {9 l0 Z" K- L7 }1 k
4 D# B5 C7 }8 r |
|