|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, ?' M4 L2 S, ]/ X0 B2 {
#include <linux/init.h>
( D( H' \2 \5 o" t#include <linux/module.h>' R- P( x0 S9 \; ^3 D6 r
#include <linux/kernel.h>$ U9 M0 w4 Q, b" v
#include <linux/types.h>
4 b* G0 [: Y% I: U#include <linux/gpio.h>, Y5 M: c1 Z1 w! O
#include <linux/leds.h>
- `, L, P2 u* k: Z( O* R4 a- O#include <linux/platform_device.h>
# h# A S% `+ k8 Y7 |- T1 [: K0 N+ G7 s$ q6 U2 u1 u+ _" c
#include <asm/mach-types.h>4 R, c. a+ g7 L0 ?6 a3 y
#include <asm/mach/arch.h>
# M# [1 V+ Y" ^" _# d j- {#include <mach/da8xx.h>
. U2 J9 `3 I3 B! k) i r9 X7 x% O#include <mach/mux.h>
& R; b Q4 t+ d/ u8 o. j6 C! I
* U$ s9 i3 T& K D* a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 w7 @6 A B1 M. A2 H) B5 E#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! i& h$ o6 p! f& w% m; O#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
j! F e# \: O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* u8 X5 t |; P; v
' S7 M3 z/ ]3 G/* assign the tl som board LED-GPIOs*/
1 d3 Y" _4 y9 E4 L+ v) k: mstatic const short da850_evm_tl_user_led_pins[] = {! ~, m: @& X1 s* `
/* These pins are definition at <mach/mux.h> file */
& ?3 T/ t& H @" B' T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ R5 m# ]: Q9 C$ e- U6 h3 i0 o
-1
1 Q; u+ a- ], i+ w O2 s) A' {};
; I/ g0 l- I) E( L
$ k; |6 C2 M2 `, d2 @' ?" q. @: astatic struct gpio_led da850_evm_tl_leds[] = {
7 w$ V, V2 J& W8 L* l- e( f {5 [, H- A3 P) S- X
.active_low = 0,
9 m r! f; m# A: Z7 M .gpio = DA850_USER_LED0,0 V' F# e' C# B! ^5 t! ?" U; L+ G
.name = "user_led0",
( c# q! I$ d0 h' Y: A2 P. _ .default_trigger = "default-on",# u2 s$ K, L( b! y9 Y. l9 x
},7 W0 s0 n; S$ D. ~- r
{
6 Q0 V c4 t/ f8 I4 O6 I .active_low = 0,
* o* \3 x* @ U( t: O .gpio = DA850_USER_LED1,* e! t, n/ t! o
.name = "user_led1",1 ^0 _ G' L+ \8 W! F4 d
.default_trigger = "default-on",0 x9 c% _' l- b9 P- x
},
$ R X0 y: M- P {
& Z3 ^# u! s5 ~* Z6 S: o0 I .active_low = 0,
" ^2 k) [& o4 s8 u7 Q. E9 e0 W4 ] .gpio = DA850_USER_LED2,( x% U! z* `" q: b) M2 {6 m; _
.name = "user_led2",4 e- |( D0 Y% F8 u6 h3 N, b& c% G
.default_trigger = "default-on",
3 Q# M% P+ q: |- a& k8 h, G7 N },0 K% I2 i# C* J3 e, L c: F. h
{
8 }0 l( U, {3 d) t+ m .active_low = 0,7 b S/ C [, \
.gpio = DA850_USER_LED3,0 p2 G) M& e I, j
.name = "user_led3",7 j. c& H5 W. v! F
.default_trigger = "default-on",6 J" Y7 a5 S9 c2 Y5 H, v
}," x; w2 J, |# y' R. u: M1 _# [
};7 D _9 c8 I. O
- d& |1 Z* r _: Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 S7 A0 h/ Z7 H/ K e
.leds = da850_evm_tl_leds,. Z, V" u7 v. ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' o) L# ]; q+ W5 g, v. \
};6 c$ X5 E) F, V
' G2 M2 }" r6 B9 Ystatic void led_dev_release(struct device *dev)
$ U/ P! K' \) U- D. N9 V{8 }( u0 Q4 L4 r. N1 l' c3 ~
};$ o# \3 t" A8 G
0 w) d9 I4 Q; p8 @# A/ P+ g" l% Q
static struct platform_device da850_evm_tl_leds_device = {
$ l' ~! u0 @. ` z: U .name = "leds-gpio",9 ~$ ]3 g& w$ a c3 n$ {
.id = 1," O8 z, o$ v% z' r) u
.dev = {
+ @. z% v; y5 K! L! G .platform_data = &da850_evm_tl_leds_pdata,
1 i# a$ f; K/ J6 s% y8 R6 u0 x @ .release = led_dev_release,$ k" _) e9 b* w
}) O7 X& ]' C6 q8 }. C* ]
};
( M0 \1 D9 u8 S% l
- r: o. R0 z: \( H+ Sstatic int __init led_platform_init(void)$ }4 D' y" X) W \' z
{
% A5 d8 B: T3 c$ ]* i' h( B: O( p int ret;
4 \' U9 {. x6 B( x! _#if 01 c- ]. h4 U. e& ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 d1 Z* `. d2 k% L1 Z if (ret)3 k; U Y4 Z' D L8 S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! S! O/ _3 D+ ] l- f
"%d\n", ret);
- Y) Y' c2 F& N. t#endif
7 X$ X4 Z( Q2 Q& W1 [1 w ret = platform_device_register(&da850_evm_tl_leds_device);
! ~- e$ K2 I7 G if (ret)4 M! D: R, g2 z2 w
pr_warning("Could not register som GPIO expander LEDS");/ }8 B& [8 o$ |. U# D/ I
else
% u, B) N! J- i$ L" h0 S4 Y printk(KERN_INFO "LED register sucessful!\n");, @, ^. u. A& Y+ {( a( k
_9 V( B* N9 l3 X return ret;. ` V* Y" b5 o( i1 ^ L! b
}
0 x5 z. r, Y- T; m$ J( ? V! S8 }* F$ y
static void __exit led_platform_exit(void)$ u' H$ z* i" I0 l
{8 ^# t. [- g, P/ ?1 d# q5 { G
platform_device_unregister(&da850_evm_tl_leds_device);
5 C- p1 k# b/ @3 A3 C/ E7 L$ ^* q, p8 Q1 K( T. v3 L7 k7 G
printk(KERN_INFO "LED unregister!\n");
( R0 l1 W# U% t4 Y- c+ [' b}
$ B9 l. Z' y2 k( M
}5 K* l, a$ |module_init(led_platform_init);9 E1 \+ K& E w' R! Z7 s
module_exit(led_platform_exit);. u5 Y; w$ D q/ P7 {: ^" X+ V
0 \; P% G$ Z2 Z( n9 [* ]
MODULE_DESCRIPTION("Led platform driver");7 ?5 H" X) }( z2 o3 X. h
MODULE_AUTHOR("Tronlong");
# a1 f( f6 ~- H7 b) sMODULE_LICENSE("GPL");, G/ r8 l/ x& k
2 g% g. G o, Q! `0 z |
|