|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ v6 ?. c; j1 g& Y% x
#include <linux/init.h>
$ V/ e }% {' e* [#include <linux/module.h>5 w- @' x3 B0 |) b+ F% O
#include <linux/kernel.h>' X! D' D t0 Z6 m; X6 G
#include <linux/types.h>' y! V; V2 q0 \0 k
#include <linux/gpio.h>
6 Z9 s7 o1 `% U* J/ K% a. J3 V; f( q#include <linux/leds.h>
6 Y, S& z8 l7 Z* [( a; [* L#include <linux/platform_device.h>( `$ \' }8 j4 }7 j3 Q' ?
0 R6 @$ R1 e' `! S+ f7 R! A#include <asm/mach-types.h>
4 X' {8 n7 o+ ~1 _8 @#include <asm/mach/arch.h>
5 y; u" ~; q$ d9 ]" y% B6 _+ K#include <mach/da8xx.h>
' w0 N2 b' N( s' Z+ q8 ~2 N; V#include <mach/mux.h>& r' G; o0 ?3 C! R$ R# {0 D
' X1 m2 D* z3 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' F1 ?! `: n" l6 j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 S+ p# e$ o8 s+ B3 `. o; y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 J$ B- s6 B# Q( W$ Y* R/ D* j) Z) K+ ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: X' [$ |: c$ l+ N' O3 b! u9 M2 f
; x& R& z8 G. U6 ~) l8 ?6 |- ^/* assign the tl som board LED-GPIOs*/
$ W# y0 h8 C7 h/ _ m( T4 C! pstatic const short da850_evm_tl_user_led_pins[] = {
( t& q6 b, }5 o% Q /* These pins are definition at <mach/mux.h> file */
& c* v/ _( \% Z$ S# ^* c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 D. d" ^( M4 H7 }& E. Q; I* Q/ ?" K -1. ^& w" A2 e8 ?2 u7 g
};
7 K$ w3 }; |- Q- g/ Q% G% r/ v/ J6 z6 F! w; Z2 m4 J6 I3 G
static struct gpio_led da850_evm_tl_leds[] = {
$ j2 x) t4 z$ b( f8 n% m5 ] {! R9 M2 r0 u# N. ^% g; A: B
.active_low = 0,
/ \8 ~' D8 `6 D* ~+ @ .gpio = DA850_USER_LED0,. c9 |/ a) C* T! Z) ?, [
.name = "user_led0"," C5 }* F+ {) _5 ^, E% g
.default_trigger = "default-on",
3 i1 q0 s4 G/ S# }& W },9 m% A6 x5 L6 H. b' t, C0 E
{
5 A# n3 {! r) {3 w! {5 G .active_low = 0,* D3 H+ x( ] i) G& ]
.gpio = DA850_USER_LED1,
9 H9 e9 q" v6 C5 W! S% F .name = "user_led1",2 t( z5 O# `# w0 ?: s
.default_trigger = "default-on",; ]: e: o. Z( Q2 o; b- }# u, c- ^9 d
},
1 i; Q) j5 D$ C {
1 E1 W; C9 {1 i2 ^ .active_low = 0,) n2 C/ ^. O: {- ?. k6 V, p! v
.gpio = DA850_USER_LED2,
/ z8 g, U3 v+ ?6 R- M M9 g# D .name = "user_led2",
8 G: {) G. R Y .default_trigger = "default-on",/ E: P2 j, t/ d7 r
},
1 D% y. I7 K" V' F- h% w {& ~+ ~2 i3 A! ]6 U
.active_low = 0,0 N9 R& O: ?1 ~9 G) r! N& H
.gpio = DA850_USER_LED3,
* G2 W _+ |( j* v- n .name = "user_led3",
$ M& C; C/ g: V) ^ .default_trigger = "default-on",
. x* r2 i3 Z: o },* b7 R1 f6 f9 l& C7 {* b- A* s9 o7 _
};4 B8 C; _) U4 \$ [% w
' T% w& v5 A: w! U- z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ |: o4 c5 L) g2 S .leds = da850_evm_tl_leds,$ i! m }4 w7 I1 F. x1 X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ ]9 w( N- |% J
};
: b; h0 g; j, N8 D' b' o3 a& t- }. t2 N
7 L- o: `. O( V7 p4 Nstatic void led_dev_release(struct device *dev): T6 k" a" W. G& N$ f& `
{6 n5 g i' ^, b4 b/ d K. c
};
' \# Q8 ^) I+ j% Z* z' H a8 z6 j H1 z0 R
static struct platform_device da850_evm_tl_leds_device = {
- B0 L5 i4 K. r# u( y .name = "leds-gpio",
9 M j2 k. K0 A$ ~! w$ C, ? .id = 1,
7 V1 J2 A8 y. d7 f) h .dev = {
/ H8 f+ y( y' ` .platform_data = &da850_evm_tl_leds_pdata,
G: C% c& c* j2 Q* C .release = led_dev_release,4 `2 g- }: K: o
}7 j1 y' S* H6 s1 W/ A) A
};
+ S* S% B7 w6 O2 L5 r K2 T+ A; D( W& @5 B7 |# w
static int __init led_platform_init(void); H+ V6 V. r& r7 ~2 l
{
+ W7 ^ B. I6 _$ A int ret;
5 g I) M; z. K# W) u#if 0
4 @/ D0 ?) Y8 z( S Z4 Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 a5 Z, c% q& y2 e. {! [
if (ret)0 `" d' S2 A+ u4 D. z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: v6 u, N( A' D+ D6 r "%d\n", ret);
; i# _; ^' P& l' h- e+ W: s1 G6 \#endif6 q1 E1 E* {- D. T3 d+ X, |* r
ret = platform_device_register(&da850_evm_tl_leds_device);
5 [. W7 S- c2 x$ Z1 H/ f5 l8 } if (ret)
; I2 t% [# W+ U* Q' \ pr_warning("Could not register som GPIO expander LEDS");6 d% g( A( L/ u9 @- ~) N
else
* h: ~' P0 ^4 K) r printk(KERN_INFO "LED register sucessful!\n");
0 f6 V2 g4 |& r' s% j2 G7 b! l
9 w) ^' W" D" ^' v1 h return ret;( M9 L/ v2 t( s; P3 j* Z
}
; B9 c: J3 r3 D2 r' ~* D4 G. _; P
* o' \) S1 `( i' k+ pstatic void __exit led_platform_exit(void). c' m1 b/ i, S: `5 y
{
# F: J& a) x9 d# O3 S platform_device_unregister(&da850_evm_tl_leds_device);+ W2 s$ o- A9 r# o
7 ]! n. q4 I+ p' z- K printk(KERN_INFO "LED unregister!\n");; ]( E* [# \% t9 h1 G
}
3 G! {! K7 Y( b& j; x0 r: i4 g% W' M" a1 e6 r* t K; I
module_init(led_platform_init);3 { R2 b, ^) }
module_exit(led_platform_exit);: L8 G5 ]" R8 f E8 y$ ?$ C
+ @5 B' a1 ]5 e, h/ r- c3 e
MODULE_DESCRIPTION("Led platform driver"); H4 j. h0 \6 X' j+ T2 _$ c
MODULE_AUTHOR("Tronlong");
" @" Q% Y# H- r6 V/ mMODULE_LICENSE("GPL");
& L4 G; c9 h9 R) _0 A* ~0 {
2 W7 _1 _# ?% O/ S6 K |
|