|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; X. [) I7 R$ B# k5 u& a/ p
#include <linux/init.h>
( l" X! W+ g+ s% O3 ]6 E: k#include <linux/module.h>+ B! D" U0 e, R; a @1 U) `8 j
#include <linux/kernel.h># B( Q, p, S! }. `- t% {% _: V
#include <linux/types.h>6 s: l4 _5 @, s" Z% M `: \
#include <linux/gpio.h>' a+ _! _5 I @
#include <linux/leds.h>
* E+ F: C9 ?% d7 I" w#include <linux/platform_device.h>
2 ?( ~ |& g1 o; Q
: ?, C$ e) `6 z! K#include <asm/mach-types.h>" _8 ]( s4 u9 _) [. ]0 F0 P! n
#include <asm/mach/arch.h>/ b5 g i- R' g% K5 \' w
#include <mach/da8xx.h>( h6 [! |- t( l( N) M8 K; l
#include <mach/mux.h>
: f z+ l' z! h1 [# k! Z$ S6 j; k' ]
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) r3 D+ E% S, [9 _) h& H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 z/ E- D2 f* B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ i# w. \: F, O: w5 l8 Z. C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ ]# d! M: D& E( o1 B9 t
+ j: H* E) N. x! _' {: U/* assign the tl som board LED-GPIOs*/
! r) V& p! [' t" wstatic const short da850_evm_tl_user_led_pins[] = {
; u7 H5 q2 t) x /* These pins are definition at <mach/mux.h> file */
% j6 M# ?" M8 H! Q3 R# o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 D: i+ s4 L; s N9 K3 @5 a1 n
-1- L2 K5 M9 C' d3 y
};6 B6 A) a9 ?9 m9 V/ K
, Z. C) _& [2 s3 t& q( W7 Q" m7 @
static struct gpio_led da850_evm_tl_leds[] = {
0 d( `9 A1 K7 L2 J6 r8 L- c1 K& u {
/ H& v: e" \* W5 C* ] .active_low = 0,
4 f+ Q! {4 |- c+ ` } .gpio = DA850_USER_LED0,
`4 d5 v' a6 f .name = "user_led0",/ i: {# ?: ]0 Y3 ?% ?6 g3 g
.default_trigger = "default-on",
, d' L8 Y0 B. T* h2 S: ^ },1 ^! U2 F3 r; p' w
{
3 I6 L3 ]. E4 F$ C# ^6 Z .active_low = 0,
& S! G* c: N; P( u; S4 K( n .gpio = DA850_USER_LED1,1 u3 B- X- G2 k8 p2 |7 n8 z7 e
.name = "user_led1",7 ~# H5 L0 r$ S9 o& ?
.default_trigger = "default-on",) Z; @8 w( C) O% e% g9 R
},( w. b3 b+ a; q0 Y
{
+ C4 E: ], o5 k8 I+ |, Q& a6 [ .active_low = 0,. Z$ K: ^/ r3 e4 ^: J( B
.gpio = DA850_USER_LED2,+ u2 G; v" O* @5 d, i- P. |+ k
.name = "user_led2"," [# h6 }& e. z' [
.default_trigger = "default-on",
1 ^, s! ?7 Q. O( t$ D8 e# | },
, z, _" o8 U/ N7 h5 F4 q$ o2 V {: z) e8 d( g! g$ h
.active_low = 0,
3 K; ?6 g. i' _ .gpio = DA850_USER_LED3,1 u+ u6 L5 A) Q
.name = "user_led3",+ ^: o; Z, J$ D( r7 s8 p
.default_trigger = "default-on",
3 Y/ z3 y8 @# ^8 g! n7 A- V4 r1 w },
! L$ h: j4 V0 v5 Y0 m) U/ [3 p};8 Y- B- ^! `2 a* ~: f
: O, b& ~; ^( R; Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ r- y; w( }! g8 F* d
.leds = da850_evm_tl_leds,4 Y" K4 X/ ?- z2 ]; V
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 [9 N4 K2 W6 m. s' u9 v7 o};5 R' F4 p# T; ?* J6 t4 {' H0 ?
8 |$ m1 J. O9 A; n* w+ T3 B! v, c/ Pstatic void led_dev_release(struct device *dev)5 D0 i b4 J4 X {
{& J! u5 Z8 \2 ~, `( [: j1 ^
};
) O1 J& |3 V8 E4 L: \; e' I" L, z! U* a
static struct platform_device da850_evm_tl_leds_device = {
! {$ m( S! P, w1 w( P% x+ Z9 | .name = "leds-gpio",
1 c2 m2 u0 j; { .id = 1,8 k% j( {8 a8 i
.dev = {
+ m9 q, x. b7 a0 x7 {/ @. H .platform_data = &da850_evm_tl_leds_pdata,
w3 Q0 T4 H/ J3 s .release = led_dev_release,
0 i8 Y1 ]4 C; C2 _+ Q$ [9 L }
$ r( K! _9 \% F6 n6 A \( I( F- u};8 o9 p' t' l2 K
7 \: l+ X& M( H3 C7 v( ystatic int __init led_platform_init(void)
: l7 j2 l: h, c2 j3 m) u) ^{
4 r m" Y# H9 A) I+ h' a; @ int ret;
3 } Q8 t. v( [ a! H+ Q#if 0
0 X/ H6 |& h4 `; } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 S3 d* Q- S* D7 l if (ret); M; o; s/ h/ T9 }% z- n! d
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; ^* ?4 G0 n3 c; }" T
"%d\n", ret); I2 g' ] l+ D l* _2 ?9 Q
#endif+ M. z) v7 o3 g# K
ret = platform_device_register(&da850_evm_tl_leds_device);, V5 f0 a0 k; _- c/ l- F
if (ret)
2 M/ k R) M# o, _# n. A& f" b! _ pr_warning("Could not register som GPIO expander LEDS");7 d; y' `+ l) `# D$ c5 f: E0 Y
else
" c/ v2 i' S1 \; g printk(KERN_INFO "LED register sucessful!\n");! k z J. l. Y" p0 V
$ s, @. K, c- L; S* y return ret;% n; N9 |0 c. y2 z# z. y
}0 L, Q8 B, S# y
5 Z. ^& F2 \5 Y3 g- x
static void __exit led_platform_exit(void)6 j- {4 C+ Q; k, ^
{
; U+ Y/ N3 _6 b platform_device_unregister(&da850_evm_tl_leds_device);
% |# v, G. I$ s: C, B: ?. r h# n4 I5 E, @( O$ x
printk(KERN_INFO "LED unregister!\n");
3 _! j: b( n- [}
3 m; b6 U* }; o! l" H, f# }! R) ~! z! P4 i U; D3 F% s p5 i
module_init(led_platform_init);" |5 x( w0 y* u9 A( v: Q
module_exit(led_platform_exit);
1 q' }8 r2 k) t% q
9 J' t% |- I' ?$ \6 wMODULE_DESCRIPTION("Led platform driver");
! l1 G( } d$ WMODULE_AUTHOR("Tronlong");
% h$ k! ~9 L* f0 ], MMODULE_LICENSE("GPL");
9 ]( Z0 K/ X6 C8 |5 s, o5 o
/ A2 e# H0 }. ^7 d8 E |
|