|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, {3 r% Q# k+ L5 x' e3 g
#include <linux/init.h>( f7 K2 l v% Q+ o5 e- o
#include <linux/module.h>/ C# ?& a, Z2 q5 f. e! j# A5 r
#include <linux/kernel.h>, e# B z6 c1 T8 I) X$ X
#include <linux/types.h>5 v- ]. u5 L4 j/ B/ r
#include <linux/gpio.h>0 Q3 s+ l3 q6 ^ x0 j: w _- a! S
#include <linux/leds.h>
- v$ X/ L3 W3 e3 e3 Y& ]#include <linux/platform_device.h>4 i: o; q. j- N- Q2 w% v- N( O
$ F7 i" Q* P5 Q) w( p; T1 D6 @8 W# h#include <asm/mach-types.h>
; R! p) C# K: Z0 e3 A#include <asm/mach/arch.h>
8 y' ^# I, Y/ m5 x$ K7 V#include <mach/da8xx.h>+ K, E. O8 N1 Z" @+ ?8 w6 q& P
#include <mach/mux.h>
% Z2 s; c8 V* J! }! |+ O
c7 d6 _$ _$ \* G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; w* r+ H5 d) q' u0 ~; B# @5 m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 i9 a# P/ I) O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 P, @( s9 a! [& v" F1 z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- i9 W3 Y4 M, c( ^- _! [5 E* i: j( {8 U3 |( V
/* assign the tl som board LED-GPIOs*/$ |2 `' I$ L0 o v5 [1 G
static const short da850_evm_tl_user_led_pins[] = {
9 C3 f! E, |5 U4 ^; ~! {% J /* These pins are definition at <mach/mux.h> file */1 p! s! G9 N$ G6 d% | e0 c) L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 C! n) [5 p# I3 O% M+ v
-14 \7 n& r. r5 |/ x1 K1 d
};8 [- U. m3 b. F3 Z4 R' j, Y
: U2 K g+ N" J; K4 D+ s
static struct gpio_led da850_evm_tl_leds[] = {
4 y3 z* m! W6 g+ E ?' q& v S {% h# _) ~/ r* \- }4 t# ~
.active_low = 0,
* H/ m8 d. M+ i8 q2 x. d) ^4 j, g .gpio = DA850_USER_LED0,! f; q& P7 p; F& ]
.name = "user_led0",
: t4 V/ r0 c! Z .default_trigger = "default-on",
) u/ {% h1 h9 `, I5 }3 D6 C- n },7 f5 B) s$ k+ T7 ]
{
8 N6 F N5 \) x .active_low = 0,& I/ u6 }. S4 M6 [" Z. d0 _
.gpio = DA850_USER_LED1,( X/ A- _) K9 B, z8 Z& }
.name = "user_led1",
3 z! i5 U6 Z, T .default_trigger = "default-on",
, n' g0 u: r2 m2 H- P5 j. a {0 E1 S },& ^2 g5 W1 S7 q
{
1 F0 u& e2 v! T7 n .active_low = 0,
: T) w, E: L( c .gpio = DA850_USER_LED2,: _: X R+ z) k8 l
.name = "user_led2",
) @' ]) P# R( \- P .default_trigger = "default-on",
3 k2 X; w8 N% |- r9 B$ _ },
' P7 Y3 R: M! x/ i- r {
+ z# T3 E: _5 m .active_low = 0,. n$ B) W8 z: n
.gpio = DA850_USER_LED3,
) d1 m5 a' w( M) ? .name = "user_led3",
0 J l9 s% }# s7 l .default_trigger = "default-on",
8 v1 A2 Q, H2 Z) O$ h4 C },% K: Q N- V' t1 i9 e
};1 Z1 W! K1 F* h% M# K- \
3 l" u- V/ D6 j2 [& D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& K6 E% o1 F4 }3 N9 l4 l; f .leds = da850_evm_tl_leds,# a# i6 X# r0 ]: s) T% t. t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, q1 [/ Q$ v/ e
};+ r4 z9 x/ C+ N' R5 b9 b: i; P
" s- f4 Z" v2 M' S
static void led_dev_release(struct device *dev)
p+ y$ O" e4 b/ S' H{' R# S4 w, c. A' L9 L- `
};" V! ]7 Z$ f5 l- q& X0 d
. J, O1 Z! t$ O. E% X% `
static struct platform_device da850_evm_tl_leds_device = {5 ^3 V& B& N9 R9 G \
.name = "leds-gpio",
2 f M9 e6 h3 ?/ z7 {* w" ` .id = 1,, u6 \' c# a( i: S- }) k& l
.dev = {2 O) j, {. R& D* m1 \* V
.platform_data = &da850_evm_tl_leds_pdata, l7 o) W' X' z2 m# T e2 ?" P
.release = led_dev_release,2 `$ O" `6 G3 e m+ E
}
) m8 e; i) x; J5 N4 Z};
' l6 R' t7 i+ G* U: j4 S' c* h
' i) n I: P9 e: P5 _static int __init led_platform_init(void); M. R$ b/ o( C, x, _, C
{" A9 m; d% U5 W7 b/ W& u0 |
int ret;& V: A7 u, M1 {$ v
#if 0
" k' d. U0 e: i0 C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: m4 F# t- `/ P! O! A if (ret)1 ^& F& f' [) X$ O4 \5 ]0 d" {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 @, l( t( b5 v "%d\n", ret);
( x+ ]6 ~/ J3 ^; y#endif8 \& `% ]! n( |7 A& G! E/ H
ret = platform_device_register(&da850_evm_tl_leds_device);
) h* |( i5 K' D% K$ K: W& R$ f if (ret)) i' m! |2 a$ \9 ^+ B& Q
pr_warning("Could not register som GPIO expander LEDS");
7 X# p$ k) F" n else1 [/ i! ^1 N5 O8 y; o: m/ H* n5 _
printk(KERN_INFO "LED register sucessful!\n");4 D0 z1 O' z5 T5 Y) @
7 i) y( @2 g# h! z! d5 j
return ret;
2 L9 I, _- d: w7 U}8 Z$ k0 l, X+ c' C8 x
9 w9 n3 _: ]' J1 ~static void __exit led_platform_exit(void)
; m: z& o) a: s9 m3 m8 G/ `3 h7 o{
8 o& O- y" a% @0 Y) n* h platform_device_unregister(&da850_evm_tl_leds_device);
- m( _( B) T+ j5 a$ @ V+ h1 E# r9 y1 I0 D5 O; Y# s2 ]- [8 T* o! b
printk(KERN_INFO "LED unregister!\n");
`, }/ R# O! }7 H" J9 G}
4 s5 l. m' r+ N$ v/ r1 f( s
4 ~' n# X2 _" {& E6 _, V) dmodule_init(led_platform_init);2 h8 B: C1 ^$ e3 k t
module_exit(led_platform_exit);
* R+ x+ s% F) p& E& M- a T' N0 |( o* P7 L* _) X" D
MODULE_DESCRIPTION("Led platform driver");: I- B$ M2 Y8 t( u! }' P6 E
MODULE_AUTHOR("Tronlong");$ P9 i" i" d% ]' a! W
MODULE_LICENSE("GPL");0 N0 X6 L3 x$ A8 ?/ T$ }2 \& a# r
9 y, n) m0 a' d7 }6 H |
|