|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 B. S6 q! A: a; ]5 j6 N" [+ _
#include <linux/init.h>
' e. i0 R! x w2 e#include <linux/module.h>( s+ R) @3 }& M% a% O( {
#include <linux/kernel.h>
g% d q5 }1 _1 f#include <linux/types.h>2 [' v- o$ j; u# N- p/ d2 x
#include <linux/gpio.h>, ^) \+ H% C0 C/ P5 j1 j! w, k
#include <linux/leds.h>
6 @# A( f; c7 |9 h$ K1 p#include <linux/platform_device.h>- a7 J8 B K' }" @3 F/ n& P
) F$ f z ]4 V8 k( N( p: H
#include <asm/mach-types.h>" z; |. f2 F/ M5 ?6 N
#include <asm/mach/arch.h>% O& E& ]# S0 l3 B- z
#include <mach/da8xx.h>+ j: ]% c. _0 e
#include <mach/mux.h>
. m. Z% W; s* h9 A% S; o2 C# ?* |3 H/ S2 X4 p( Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
}8 w2 {, ~1 x9 ]" Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& D j; v: N" g7 u3 L#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 j7 J4 }! `. M- d+ t( u. }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), V, k( N2 {- w1 |' i L6 b* q
- E% X2 d; T6 K! Q/* assign the tl som board LED-GPIOs*/
; h' I8 g2 O+ ]9 b( Nstatic const short da850_evm_tl_user_led_pins[] = {
4 S: u) Z0 M- ~, X9 D% k W( ~ /* These pins are definition at <mach/mux.h> file */
: Q7 w' D8 Q$ l8 o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% F7 @3 u0 F3 i9 X
-1
# |2 @3 z( B4 \+ B};
" D l5 b& H- s4 p9 I
, S9 G2 T( ]0 o5 B+ kstatic struct gpio_led da850_evm_tl_leds[] = {' j# J2 h3 Q6 O: g' p& H4 O! L
{
+ u* b/ X6 `7 j) ~ .active_low = 0,5 p$ N1 x. b* V8 Y
.gpio = DA850_USER_LED0,
# R1 X/ I% {3 L .name = "user_led0",7 D x( W. n; k# V
.default_trigger = "default-on",
. R' ~! i' S }7 [8 f/ R },7 }* s8 ~) a5 \& J1 S9 x' a6 w, j! h
{
! J/ n3 S$ j3 ^1 O .active_low = 0,+ _$ G) b8 t S1 Z9 b
.gpio = DA850_USER_LED1,, s, s5 _* F3 ]- y2 t/ M$ U T7 |" U
.name = "user_led1",6 c) C, o9 H7 D1 _2 H0 r8 ~
.default_trigger = "default-on",
1 m3 J- j: C. J+ c: K9 ^ },* j p! J1 e9 P8 U* j
{
3 r1 a( @$ I {% u7 P; _3 y9 O .active_low = 0,
1 q. B' g6 }: _- g8 ?) P .gpio = DA850_USER_LED2,
6 U% d' k7 {, g& V$ N, P .name = "user_led2",
" m. w- v, r- ?, V) t .default_trigger = "default-on",
) a1 S. q2 r, m: O4 Z },
) D* Z. R% G9 l8 n {
t3 A8 \+ ~! R, E* J; r5 C& L .active_low = 0,3 ]8 F4 M5 J9 R* U
.gpio = DA850_USER_LED3,/ ]/ `# d+ b1 h5 T
.name = "user_led3",. `+ m2 c# P& T4 c& c" l
.default_trigger = "default-on",
: l# O& F# v/ a9 v; y# V }, T) k8 I1 s3 \4 S' o8 ^7 N
};/ _1 u6 I" l, o8 X- F2 \
( x4 K. x/ X# f' u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ R' t6 E- J& B2 c3 K0 }7 J .leds = da850_evm_tl_leds,- P" Q# ~9 D1 S2 Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
v! l- ]% Z: r' V1 P};( `5 ] p& C T! @
1 ~: c$ q# i0 [static void led_dev_release(struct device *dev)2 y5 G# |. q4 \% C) M! ~4 E
{
) t9 b3 K6 C" P+ @2 ~ ?};6 c& k9 J0 i; t, W2 z
' o" |, \0 a# M8 p+ Astatic struct platform_device da850_evm_tl_leds_device = {
5 t: ?+ N% d7 c! [: [4 S: N* p3 M# X .name = "leds-gpio",. t; p; u/ q* g- l' J: V3 b
.id = 1,% R- G: k3 W: W5 F% K
.dev = {
2 K/ F# O4 w2 H+ p7 U v" ~. }) B .platform_data = &da850_evm_tl_leds_pdata,6 |5 `4 W% g8 R6 B
.release = led_dev_release,: l% Z0 C: o+ {0 S- S- T
}
; z; v# A7 I* H% L( O};6 _' u) @5 Q; F5 P# W
7 G9 y/ \6 s% j+ sstatic int __init led_platform_init(void)
, b9 r2 Z$ [3 V# ?6 q{
8 F- t4 R/ }+ W/ c/ G6 T8 Z; U5 b O int ret;! G: V3 [, h2 q$ P; `
#if 0
0 D5 k* l7 U+ q$ d. B8 C4 p9 J } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& s H6 {, | F; z) W
if (ret): n# z# T# ?2 U2 i# [0 |! \% J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 M* G. u0 d1 p7 n* D9 } "%d\n", ret);
( O9 I; x7 O1 ]& u0 k; n! i. l#endif: f, ^4 J: o, d$ V* `" C
ret = platform_device_register(&da850_evm_tl_leds_device);9 ~" }, P7 |) f5 y
if (ret)
5 z9 a4 Y5 K. [& i pr_warning("Could not register som GPIO expander LEDS");, ~: a u4 z8 H; H
else
: T4 o4 _9 f( P1 j2 P printk(KERN_INFO "LED register sucessful!\n");
& W# |# h/ n- E1 s* D1 V f
# a; M( ?. m' [7 n8 j4 Y7 J return ret;
; g" W2 L$ h% f}% z" A9 L- D; O
# m# a$ ?# i o/ s, s
static void __exit led_platform_exit(void)$ [0 Z6 J4 g! E' F* {4 i; ~
{) v, Y% f0 K, M9 A
platform_device_unregister(&da850_evm_tl_leds_device);
8 p% { P* K7 O' L# ]: R h g6 W h0 r9 F
printk(KERN_INFO "LED unregister!\n");1 f) [8 p3 S0 ~4 B, u
}$ [- i' [# \# D! |" M% O
) C' o: G1 j- I6 R8 I" Ymodule_init(led_platform_init);: M( }! z: h& x2 ^5 s4 I% d
module_exit(led_platform_exit);
- a8 n5 ~0 h6 P8 |0 r5 ?1 g
& b8 p& o' M- Q3 t4 ]MODULE_DESCRIPTION("Led platform driver");
, [5 ] g* s" n0 `; AMODULE_AUTHOR("Tronlong");5 j0 N4 S7 X" u [0 x& E
MODULE_LICENSE("GPL");- L! w2 a# D7 s1 a1 O$ B
' U) e) O1 m* ?- f, f' h& U
|
|