|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, r: s0 D. o! u3 k" \3 q5 {#include <linux/init.h>! `/ H# x! L) O ~4 V+ J( j% L: ?
#include <linux/module.h>
% f7 N* H& Q1 ?! O) |% S! g) ?% y#include <linux/kernel.h>
0 t# U6 }, ^& H4 `8 F#include <linux/types.h>5 j6 I# R! ?) Q0 y5 x- m* d! a" Q/ h
#include <linux/gpio.h>
7 F# V5 V9 R6 l. P m#include <linux/leds.h>
2 h, X" I1 M% o- N( N: U#include <linux/platform_device.h>
# m! e$ }8 [+ c& s2 o; G
Q8 \* \8 V3 T/ X# D% P1 ^#include <asm/mach-types.h>
0 r& Q' B9 ^! e B+ a0 V1 @. J#include <asm/mach/arch.h>" Y# t- J& S( B
#include <mach/da8xx.h>
8 A$ S9 p" i$ V" ]#include <mach/mux.h>9 ]4 P' J* Z7 ^1 R
& |8 R" | s' ^" Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 K4 L) w) h) p+ Q8 |2 _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; _5 A% D) Y4 i0 A- Q- P5 F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 w( E6 i+ N- k6 ~6 v8 K9 |% N#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) t7 [5 j7 S8 K8 I3 Y- _ T
' `8 g- D! L- j( f, E: [8 b! ?/* assign the tl som board LED-GPIOs*/
; M) l6 s0 q& p% ^) [# }! w ]8 b* a+ \static const short da850_evm_tl_user_led_pins[] = {& f6 Y7 P# g& ]& h9 a
/* These pins are definition at <mach/mux.h> file */
& Q# O$ U: l, y/ }9 E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. f5 x8 O4 i. [6 j& ]' ?( j) p
-1
! \' H! x: [" H- n! X a o};
3 B3 N' ]2 S: ]7 \' D# c4 [* E
- Z& e; U& o5 x M: V4 wstatic struct gpio_led da850_evm_tl_leds[] = {
! X4 N+ K2 J/ ?" D; D& R8 j {
. g, d/ }. y- ?- w+ G a; u* ] .active_low = 0,& a( A" |: q/ [! s( C# }
.gpio = DA850_USER_LED0,& U% k2 l p; X
.name = "user_led0",
7 Z0 p" W7 N& a* j .default_trigger = "default-on",
8 _* O* H; c7 x/ ~" U },
+ e; U; X8 P8 w {
% @, C0 r6 g2 v6 U2 X .active_low = 0,( `1 x+ t! ]; V2 C6 B$ @' ^7 x
.gpio = DA850_USER_LED1,
6 x9 Y4 q" t0 e* i3 n# Y- X' i: H+ {) } .name = "user_led1",% Z: M# [. e' a
.default_trigger = "default-on",$ A; u5 s1 H7 q- v4 ]
},
: W+ @* C5 M) C7 g' Z. O {6 K. m/ Z- w- }1 I* o
.active_low = 0,
6 A0 d8 S% c% r4 l* N( L0 H/ D+ w- z .gpio = DA850_USER_LED2,: k" E+ e4 ?! A5 p
.name = "user_led2",
" q0 d# ?" W+ r; v2 p5 ~ .default_trigger = "default-on",
) {9 I0 G( C" r( Z },/ F+ }! `7 X9 A* \5 I' ^
{
. w) ]$ I. u1 R6 k .active_low = 0,7 |3 y# ]7 M6 K) \) Y/ T
.gpio = DA850_USER_LED3,) Q1 Z- T( V) P. W7 O; M3 X
.name = "user_led3",
* Q' T) I. L; }- }* l( W .default_trigger = "default-on",
]+ D1 C `0 G; ~$ }9 e },# G% b$ b9 Q7 p( m7 }
};
' o2 M( y3 X% b7 N7 ?
3 z! e5 Z& w2 Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 ?; \8 w( \. a K+ K) @ .leds = da850_evm_tl_leds,
8 i3 Q$ @2 J! Y1 a# c8 U, J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 a1 U. J: }7 E9 \! v5 w& i
};
- i) X8 @3 [0 W! _$ {5 O3 U; W" x- Z$ y
static void led_dev_release(struct device *dev)
7 b" [+ c% q3 R" W" h{6 f7 [1 M+ `; a6 z5 Q& K( J5 h
};# X' [; ^ Z) N9 H
1 A3 |4 V+ {. z& S8 I
static struct platform_device da850_evm_tl_leds_device = {8 s& G! ?$ u8 O: E0 X8 x. G
.name = "leds-gpio",
r+ m4 Y, f, ?. z' ~$ n+ M .id = 1,
; U+ W3 E9 M! D& t .dev = {8 A1 b; T0 U+ x0 _* G$ V/ Q+ D
.platform_data = &da850_evm_tl_leds_pdata,# K' Z) U+ B2 B5 `+ ~6 |; n
.release = led_dev_release,. _! B6 L1 Y& P" D/ K# o# t: R
}& }- d5 U2 @& B3 ~2 M
};0 ^' v+ K4 G; p; @: o8 O
# w0 h5 m |" l# [( a+ \7 ~static int __init led_platform_init(void)7 M$ m/ N% [( T$ M9 ~. U
{/ I( ^( H) ]2 K3 E1 k
int ret;
z) h4 n6 n0 G. c9 a3 o: w#if 0( g7 B$ Y$ u' b- S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! ^( Z9 I5 O6 d( }% A
if (ret), F* u/ c4 @' C7 ~6 B: q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- C7 v: q0 K7 y$ V1 a
"%d\n", ret);, I7 A& E. Y9 N: A
#endif. _) }0 _4 y2 `
ret = platform_device_register(&da850_evm_tl_leds_device);. N- @$ u5 j) V0 ^
if (ret)
, Y ]5 k! Z% o0 i5 k8 P* _ pr_warning("Could not register som GPIO expander LEDS");
" A: `) D5 G. [) v else$ l7 }4 M% W/ G# W( _ d
printk(KERN_INFO "LED register sucessful!\n");
: Y9 y- K4 {+ c$ J
' R/ C- y( E* q, W) w2 d } return ret;: k2 W* \- A9 E5 P9 Y
}# p, w- w; E& N c% c- @( N
3 B( v+ a0 q/ y7 `" M3 w0 kstatic void __exit led_platform_exit(void): U( L% O6 \6 [2 d1 N
{8 Y8 b) a4 y+ i1 _
platform_device_unregister(&da850_evm_tl_leds_device); ^) D5 \1 [4 x; T* Z' t
" b% \% `" c; K# [ printk(KERN_INFO "LED unregister!\n");
4 r8 J" L: D# [; C" w4 r: Y}8 {4 C+ r8 }4 |9 n9 p
3 c. X$ s+ s- t5 ?! `7 X
module_init(led_platform_init);
7 k; L% o/ p% U/ R+ N; ^8 {9 ], qmodule_exit(led_platform_exit);
! X7 Z) b4 g# N' z7 S$ `' q, {4 R; C/ H+ @( }- Q+ l( {$ K w" I
MODULE_DESCRIPTION("Led platform driver"); E- B: ~0 ?' k6 r) \1 W7 J
MODULE_AUTHOR("Tronlong");
/ F% v2 k& g- T* c7 H. DMODULE_LICENSE("GPL");. |2 b$ O6 s! G) H; ~' Z
; D. z* N* U b
|
|