|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
s2 x8 P$ Y' n( w6 V#include <linux/init.h>& ]% S( r7 Q4 Y: h/ q" j
#include <linux/module.h>
3 N: v5 @1 K1 u8 _* }/ e& Y C% R#include <linux/kernel.h>- s/ k* P2 k Y/ f; Q
#include <linux/types.h>
^) j T0 x1 j#include <linux/gpio.h>7 U( Q: S( ^: ?6 g! x
#include <linux/leds.h>
S+ Q; _, V, a+ b4 s X#include <linux/platform_device.h>; W. q U# k5 J2 l
; l: e. }& @, j#include <asm/mach-types.h>
5 ^/ p m$ C, c* T#include <asm/mach/arch.h>6 I% b0 R) g& Q. x/ q: \/ I, @9 c
#include <mach/da8xx.h>9 x) m; w: Y4 g
#include <mach/mux.h>! _& c* D$ L& S9 D i# D/ [& g
: P' t! K2 N2 j) r) _- i# n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 d9 a7 [% }6 X8 `) ~# k" s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. M1 z& y( f' c, M3 P1 r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): K7 H$ y) F8 c3 I$ _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 B% R2 R& @6 e; _/ q' X2 Q$ ?, o1 {+ |0 l# D: `6 S
/* assign the tl som board LED-GPIOs*/
0 N6 u% ^- _2 v bstatic const short da850_evm_tl_user_led_pins[] = {
/ W! d1 v' M/ l8 t) ^ /* These pins are definition at <mach/mux.h> file */
9 V- D. t8 |) ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. ^4 ?' c7 B" l, J. E, G* a2 Y6 t
-1
" b4 Y' M) ?* Q7 I7 Z" `& }# o};3 a! K: j* t/ H } b3 T; U1 t" X
5 N7 f) h/ n" I: }: fstatic struct gpio_led da850_evm_tl_leds[] = {7 a( X; ^1 R9 G5 d$ O6 B
{! z2 V* f$ @2 F3 K
.active_low = 0,1 d. n7 G% F7 L) T
.gpio = DA850_USER_LED0," v9 a* d9 v) O; k1 S( q
.name = "user_led0",
3 f7 Z5 M- J% K) M, \ .default_trigger = "default-on",
# n! ? n* f6 U6 v1 I/ ~7 M3 X },9 ?- @: W; {1 @* A3 I9 J
{
4 e/ F$ p" b' \9 r; L% J1 N$ F .active_low = 0,
5 l: d0 v- @) L .gpio = DA850_USER_LED1,
# C) @; R# g, I, q5 P; K .name = "user_led1",) X( E' i Q; \( G/ d0 C
.default_trigger = "default-on",
5 {5 c& p! B$ L9 x9 ~( ? },4 M# r9 k5 m: S+ Y5 F" H
{
) q6 O/ x4 n5 g8 m% J$ L .active_low = 0,
! i% m) o9 h' ]6 w, r .gpio = DA850_USER_LED2,
$ U* h, H* u" w .name = "user_led2",
1 h- j1 h6 `( }. \1 H3 P% v .default_trigger = "default-on",
/ ?0 W% O( P" V. U% l9 s8 X: s },
0 }' O& v" t: a% j0 i$ a {" L5 [7 d* v; `5 s2 I4 j5 H
.active_low = 0,& [+ `. Y7 v& |# f0 I( d
.gpio = DA850_USER_LED3,
4 O4 _0 u9 O5 g S" i .name = "user_led3",3 B* `. N0 ~5 s! Y- H% O
.default_trigger = "default-on",
- k) \" U( H6 Y0 p: ]# F4 \ },
C) F9 O) L( y};' Z! ^. n1 C2 j/ q
; W( |* y! V' g/ Y2 S7 a& N* Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; u. I. Z+ {2 _0 p5 H7 G$ z
.leds = da850_evm_tl_leds,
" T( O( B; K& g8 l/ A& z1 _( G, k6 p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- b5 n. W$ b0 P3 M& j0 Z+ @! c
};. b( E, E) i; {2 h/ d2 ]5 }
, ], Z( v2 a3 M+ }$ u, h1 w
static void led_dev_release(struct device *dev)- C; C2 T4 V+ I" ~8 L/ w
{
# P7 A7 }! D+ S: ]. L) j" @};, D9 ]8 o! Y9 O4 E
7 r& q- m6 {$ M4 b! ]& z4 mstatic struct platform_device da850_evm_tl_leds_device = {3 W* s p+ J4 E: j$ ]; Z+ R
.name = "leds-gpio",
2 C. K; o. e% `8 ^ .id = 1,# V7 S6 \6 k6 i; B' i8 B! X6 h
.dev = {7 H. f" s2 c* t4 u5 u' L
.platform_data = &da850_evm_tl_leds_pdata,2 `7 O( \6 ]8 D
.release = led_dev_release,/ U+ W2 l; f* I1 a
}; H! E' V* W; `! s* A, v* m
};; {! b/ { C' P+ k8 `2 {( w( P
6 N& g$ ~! m0 f* R* ~. H/ ^
static int __init led_platform_init(void)+ S$ G, f* v* D% T4 E6 Q# F8 E
{
) B! @# U$ T) I' L3 o7 v int ret;1 F2 o) q" x7 [! Y n% X* R$ `! B6 ?
#if 0
/ p7 Y* u+ v4 h9 Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% ~8 K3 N0 z! v
if (ret)' V+ a @- y" W0 [3 u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% h9 T% ?* H9 m$ e D0 K6 I: J: C "%d\n", ret);# v) m9 @) f+ f
#endif2 x9 `; g0 j3 x- ]
ret = platform_device_register(&da850_evm_tl_leds_device);
( O9 f, i @3 y5 }% v if (ret)9 v/ n8 o) t: o' K1 P
pr_warning("Could not register som GPIO expander LEDS");& O- B c; K& }( v7 C O6 K/ n
else
. N+ u' }4 K s4 ]' N printk(KERN_INFO "LED register sucessful!\n");& {) C0 R3 }7 x4 P* K3 Z( N
7 v1 |/ ~4 p: d( w+ d/ r0 ^" r return ret;
( G c9 b; g: Y2 ~, S}3 R- [' G. {. Q" `' k- U
3 H9 {# |& {# v* I4 f
static void __exit led_platform_exit(void)& @5 g0 [9 r' ~; ^) U
{0 x' u1 I; t4 O3 e& F5 a
platform_device_unregister(&da850_evm_tl_leds_device);
# U: P e. F- w+ L( s! a' l
8 c- J6 z/ h! V printk(KERN_INFO "LED unregister!\n");* _4 ]6 z" X8 x' N% W
}. G r4 p5 Q9 j% A
" E7 {: g+ r/ P% _7 ^
module_init(led_platform_init);
# p e4 S4 z z- @. W$ zmodule_exit(led_platform_exit);
3 n [% a( F; u; o% W" _2 @5 V5 ?1 F( J/ Q& e' T
MODULE_DESCRIPTION("Led platform driver");
5 a( |" Y' }% l8 } U" AMODULE_AUTHOR("Tronlong");
# Z1 E- V0 [1 y F9 \ n$ I! a; yMODULE_LICENSE("GPL");+ F3 R/ D7 E" b% E. w
# Y4 M! o& g, u1 U/ C
|
|