|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ |6 ?+ u5 M; E- d( x- K) l4 N: J0 J1 V
#include <linux/init.h>
( E; p$ J# @0 r/ F$ {& U#include <linux/module.h>
2 ?2 q: F- W( I) q0 @' e#include <linux/kernel.h>0 u4 p5 d2 _ `6 V; q4 l
#include <linux/types.h>
J. q# g P3 E0 t) t#include <linux/gpio.h>3 s% f& Z2 @- y% s5 e/ ]) C0 y
#include <linux/leds.h>
* B; W, `2 Q. J) _+ m. u4 k$ |& g#include <linux/platform_device.h>) d1 h, B0 e9 c7 I% y+ x; n8 Y
3 `- @. A! u3 d7 ]
#include <asm/mach-types.h># g4 B: H- M/ i% a1 u
#include <asm/mach/arch.h>
0 `( T" E* ]' r8 e; w#include <mach/da8xx.h>
& k: z% P1 E( |. b% f0 @#include <mach/mux.h>) x" q4 `8 B: P( R3 k9 P
& N: n4 B: E, E* ?2 l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 R+ e2 Q6 A3 f4 K8 I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: w n& L e9 I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): c& v. `# l+ [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; t% x& q5 |% \. Z8 N; u( E' d2 H' c# Q
/* assign the tl som board LED-GPIOs*/
, a8 G. ? O/ Q5 C! k$ ]static const short da850_evm_tl_user_led_pins[] = {3 w. x8 A; N4 ?
/* These pins are definition at <mach/mux.h> file */
$ \) G# o# B; o# b! S8 Y! H/ o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% E& A2 z; g/ ?- ^ -1
! j) i. m/ Z* t: h% j6 W};; E6 T" f8 n/ }# ~
+ Z, `, H2 B( \3 s$ O( D* L
static struct gpio_led da850_evm_tl_leds[] = {- x5 m$ Y6 K5 R; h' c* e
{
1 n+ V4 y4 V) [; a; [ .active_low = 0,
" W0 w& @8 m3 a/ } .gpio = DA850_USER_LED0,
5 l4 h& `8 a4 N2 I5 G .name = "user_led0",
0 g2 ~4 e. b% F. A3 M9 M8 Q .default_trigger = "default-on",
" i& N R5 [! U7 i B2 i9 T. h },
4 G5 W" ~, G* y& r9 l9 d. `& Q {
3 m& k1 E! H( L .active_low = 0,6 G2 q1 f: U' o4 y
.gpio = DA850_USER_LED1,/ m: i' z9 j) W, _. G8 j
.name = "user_led1"," E. K. J) J# f
.default_trigger = "default-on",
2 f" ~' G% {) w },' h3 ^' [4 T! J+ [# @
{
/ {; x4 A6 s0 v8 W" ^- i( L .active_low = 0,
0 v9 a& Z, ~! Y1 d* G+ C- r .gpio = DA850_USER_LED2,
7 w, Q& A7 K/ q .name = "user_led2",
+ X+ g& i9 W5 b9 ~% A4 [" D, `4 h .default_trigger = "default-on",. g& ?* d9 j. s; T( _ i
},
$ D+ d3 s( `9 h S1 ^/ e+ F2 N Z9 G {& b: T) q) L3 f" o" @7 O/ i
.active_low = 0,. }2 Y0 t- [ Z% W7 ?
.gpio = DA850_USER_LED3,. L5 A1 d0 W2 L( w
.name = "user_led3",
. D. T8 u, k X4 T. i .default_trigger = "default-on",
" ~9 s2 ?2 z/ G% l8 L% H },6 {1 U9 @9 D# s. u" o
};; i8 | G, ^% M% I
- E& z1 }! x. R+ D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& ~; s$ J8 ]& v N .leds = da850_evm_tl_leds,
' N l) h3 Q9 B/ P, ]9 R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; x3 k0 e* B# _- [+ K5 V
};# Z8 T8 u; p( A- q a) V) [) |) W+ o
" j8 \) ~8 a8 R+ v2 r1 Q* xstatic void led_dev_release(struct device *dev)5 L( Q' w5 X, o, K3 E3 S6 t3 N
{& T4 ^; Y* A. {
};
) p. O5 P( I; u0 e6 ?0 Z9 M5 B! f9 {8 L& X8 Y% Y4 ^2 p
static struct platform_device da850_evm_tl_leds_device = {1 |) ]1 S! `# d: } F
.name = "leds-gpio",
6 D: }7 n( E! u( }$ |2 ~" P6 Z .id = 1,- J% a% s: g! s( G
.dev = {! ?" S- [8 Y6 B' r. p
.platform_data = &da850_evm_tl_leds_pdata," e* v2 S. P+ A2 {3 }. u. B
.release = led_dev_release,& Q7 S) E# G# l, {" `3 {( u" l- l
}0 Y' H, V4 f6 I7 X
};
# j; I+ j1 g0 B* s
. F! z* N- t8 i7 D; R3 }static int __init led_platform_init(void)) p$ d0 ]" B* N8 W, d5 Y7 U
{( K& o" t) @! n; `8 a! _
int ret;
6 v8 l$ K4 q5 k/ z5 q" B#if 01 O+ [* i, u! R) Z1 ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% m# n/ }1 m w) y
if (ret)' t6 H8 L* i# r0 ]6 G) B$ `4 Q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 U3 C" n4 f: @( g
"%d\n", ret);) n+ c/ f% S3 q# X$ f$ y; T5 T
#endif
- A1 D& B& s5 @5 b" R+ Z ret = platform_device_register(&da850_evm_tl_leds_device);( C! l* b/ }) H# U
if (ret); m! l* ~3 m+ o2 g. h
pr_warning("Could not register som GPIO expander LEDS");& W9 S, S Z5 K @ f- v1 Z
else
- [6 Q' P) U' u, E, ` printk(KERN_INFO "LED register sucessful!\n");. k9 m4 B2 @/ c) |; X( Q' s
) l9 m7 e, @" N
return ret;4 K* ~& O) V9 w- B: F
}0 J4 V9 A$ X% ?8 k' B- K9 y3 H: e
. o) u' x, }" t1 z7 Rstatic void __exit led_platform_exit(void)6 o& u7 p2 t6 Y- h1 N+ l H' ^! N
{
( z5 |" z p0 t, x. j8 w5 {+ p platform_device_unregister(&da850_evm_tl_leds_device);2 Z2 A- O3 @- ?* Q2 u* W {# h
% v1 L) ~0 h. _
printk(KERN_INFO "LED unregister!\n");
0 M9 s2 x" H: {}
d- u. o2 r7 @1 | y$ }0 r( v! x7 j
p6 k3 g5 c, R& a- }module_init(led_platform_init);
% E- [4 P: x/ [8 p* o. V* c; {module_exit(led_platform_exit);
* y0 ]. f2 ~! E* |* Q( u0 O }% k
. s4 c% W+ f" q% j6 x0 oMODULE_DESCRIPTION("Led platform driver");
$ ~( M4 a- p% [& S, \1 Z. aMODULE_AUTHOR("Tronlong");
/ l; \& C% \+ gMODULE_LICENSE("GPL");8 P9 c' m2 w9 s, ^% ~/ \
5 N9 v5 k8 t$ ~* ]% @3 e% |' U- k
|
|