|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! U- X0 F3 Z. C- X) \#include <linux/init.h>! V2 [$ ]" x8 ^8 W% p. h
#include <linux/module.h>/ |. i1 _5 p5 N
#include <linux/kernel.h>
7 M, P' y; |4 e. w2 x/ m& |#include <linux/types.h>
& e& Y9 g% f; G#include <linux/gpio.h>3 y- v0 L: ~. P7 D
#include <linux/leds.h>
+ m# m. e7 N2 o5 G4 X/ y#include <linux/platform_device.h>
4 ]/ Q' F% h% l3 j! w. k2 S9 v6 \
% J! M. p. ]5 K1 e( f' O' W/ o, g5 N#include <asm/mach-types.h>+ Z4 k" u% u& O$ ]7 c+ X' c
#include <asm/mach/arch.h>
# N! T" ^/ W3 e% j/ t% w' U& r/ G#include <mach/da8xx.h>) E( |1 }/ a8 c* M- F
#include <mach/mux.h>$ o, K8 D; @7 Q6 N: C' t3 V
: u9 \0 K/ C' f" Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). B9 O b$ Y$ k
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ m- }& f; b* {7 e6 |5 ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( f4 @) K+ M+ l. c. k, s' D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# K2 `" p2 ^3 l+ T/ E+ s) R9 N
( U: B# f0 @; A# N
/* assign the tl som board LED-GPIOs*/
6 {) \5 p8 M7 s: v; b2 p$ [static const short da850_evm_tl_user_led_pins[] = {# P: B2 l" _& E* f, {1 _
/* These pins are definition at <mach/mux.h> file */! j/ @; ^+ z5 L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- U9 R) r) G: M -1( Y9 b5 {0 O2 M7 l+ F
};
. k8 F8 q8 R; M# @7 [6 V2 E, C
5 G5 r% F+ S% q: Y6 D& g. T* r# bstatic struct gpio_led da850_evm_tl_leds[] = {8 O; V8 D0 J. h2 u
{) @5 F1 K% `$ `% a m; p f
.active_low = 0,* z8 S: L* f- p9 \2 [
.gpio = DA850_USER_LED0,) q9 h& n( `. ` o
.name = "user_led0",. m4 a! i( w6 j
.default_trigger = "default-on",
- m8 @# I, c! o5 _4 A8 Z },
$ d& R8 r2 D! _ E8 f+ Q1 f {) U; w; u+ [; q" L# }! e! V
.active_low = 0,
& \6 s- h+ a/ C& i7 O/ V .gpio = DA850_USER_LED1,
5 X* R7 u) k0 Q) T, O `8 q .name = "user_led1",' F0 F8 T+ {0 L* Q+ w# J) P
.default_trigger = "default-on",7 |3 @6 G1 D* l- J
},% _) x& ~0 V5 t S
{
7 u7 j) X/ T/ g .active_low = 0,
& |- ~ O3 `; G# G2 U2 Y .gpio = DA850_USER_LED2,. t; h3 p2 |/ W7 F3 E
.name = "user_led2"," o( z2 F y! u0 m7 s; s8 a# ~
.default_trigger = "default-on",) H6 D; ^2 `5 E3 l) M8 Q+ u
},
; Z- ~8 t+ i# L7 a, f8 k9 { {
! P7 d: S8 b/ R, K' k* j7 r) B .active_low = 0,5 R% E& v. R O" z* P1 s
.gpio = DA850_USER_LED3,
/ K( A( `( \) w, {) i: m .name = "user_led3",' }7 B- X' P& |0 Q7 P0 O
.default_trigger = "default-on",! g* M0 ^3 M; L O9 P- H L
},4 w. S$ B/ Z; s8 [% o9 P* z
};
- q1 E) I. ^# K2 W @5 Y2 r- u
& u! Y+ Y& f1 Y k! d3 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
i3 d; Y! v+ \( ~. D0 ^9 l .leds = da850_evm_tl_leds,: c8 s6 _4 d2 u3 f1 Y" j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. O: \1 @/ F+ Q; Z# j};
# d0 g% v- f# Y$ Q5 L. l3 i& z3 V/ |) l/ J1 ^- N5 z7 m7 I
static void led_dev_release(struct device *dev)
0 R2 E. d7 `$ c$ ~$ O{
4 `7 K O' _, P. C};& A6 s! q) l' O3 m4 Z6 }# i
$ }6 Q2 y. m0 E+ f! @ y
static struct platform_device da850_evm_tl_leds_device = {5 N" b, u- z+ }: x- B
.name = "leds-gpio",6 ?( S7 s2 _- N; P' t H
.id = 1,
* h9 C$ G$ ?0 ]. l) W0 S$ x! L .dev = {
6 `9 P0 V2 ~; p .platform_data = &da850_evm_tl_leds_pdata,
$ z% U, P2 H% j: B$ J0 t+ k .release = led_dev_release,
5 C5 g Y: T. _! _# { }# e) P: |5 W6 J1 y$ X. p1 S
};( q2 b7 v8 [$ z9 F; @. ]
. z z2 f8 k7 Q* ystatic int __init led_platform_init(void)- ?6 a9 ?- E5 v, p+ a2 ?- o' h: b
{
, l% |1 A* d$ f% b9 p5 j. `9 ^6 y2 h int ret;
' u% g! C7 o( L. `$ L#if 00 Y7 ~5 P) l, q; N) ~ I( X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 T" o+ w/ R4 @5 Y% W+ `- }
if (ret) H/ H7 H3 i; {9 K2 S) ]. u w
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! v' ^4 u& p! B; S& { "%d\n", ret);
! Q0 P) B; C0 |9 r/ n# i#endif
4 ~1 B8 U- P$ o) ^$ _8 E ret = platform_device_register(&da850_evm_tl_leds_device);* X& I. C7 f" Q% c8 r
if (ret)
O( Q! v; b6 ` pr_warning("Could not register som GPIO expander LEDS");$ r9 a2 T! W9 k, O4 J) L
else* J2 Q5 i) i9 ], ~
printk(KERN_INFO "LED register sucessful!\n");; o0 }7 e) F( {
% F: b. T. K6 _! B
return ret;0 I' o: ^1 P& o* U/ k% U& s
}/ l3 u/ | O4 h4 b4 f
, I( D7 r4 \& J( v$ L0 Estatic void __exit led_platform_exit(void)% _& _) D( q( i) z$ I) L# b' T- l
{7 B4 ], L+ L; b
platform_device_unregister(&da850_evm_tl_leds_device);* R, D1 E f9 B5 a7 d) P6 m
; Y& N; M' L% h. { printk(KERN_INFO "LED unregister!\n");
# Q8 f% E2 \! L2 K1 L8 X}
5 e+ C% ~. j, g) }3 f7 N9 x, u! Y' N1 n6 v/ r. s1 [3 b- S
module_init(led_platform_init);( n1 b# M. J0 [. k; j8 \" W
module_exit(led_platform_exit);8 Y" O9 J& M4 \6 _" B; W ]7 U4 `1 j
5 \ C, I+ H' j: BMODULE_DESCRIPTION("Led platform driver");6 r4 t, C/ t( m8 [1 M
MODULE_AUTHOR("Tronlong");
# v( E. t! { I4 L4 r, J UMODULE_LICENSE("GPL");/ ]+ R9 \: A3 m' t9 H' i/ W3 k- t4 w
. K; D( j' M* L |
|