|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, g. P5 r' i& g#include <linux/init.h>
6 t( N' D) s; |( M8 g5 \' s) W#include <linux/module.h>) g: R* Z. ]. Y9 t3 r1 j% j
#include <linux/kernel.h>
7 t" |: l6 A( v, P#include <linux/types.h>$ M$ ~* c# d( y+ T+ f6 z1 k6 Y
#include <linux/gpio.h>: E1 {7 r7 d) u5 `) q( T' M
#include <linux/leds.h>
) E$ F$ \1 C. R1 u#include <linux/platform_device.h>3 V$ p7 F: d3 r4 p" v
" Z+ T# J+ U \/ d+ \; K#include <asm/mach-types.h>
2 Z6 @! N$ {( a#include <asm/mach/arch.h>" |! s3 Z* L4 [1 F7 x8 Q
#include <mach/da8xx.h>7 H& J# b6 g$ E/ K
#include <mach/mux.h>
9 G3 [5 x# h6 a$ w- b- K7 I/ Z& h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 z% G5 R( c7 u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; Y/ F2 F+ a1 l1 o7 _* v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' Y! F' V/ w5 }3 w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 M4 E1 c9 U& L/ j8 l, Q
# s4 D) {* H# @: X$ h1 k) K, V# l- B/* assign the tl som board LED-GPIOs*/8 s0 A0 L2 ?0 k9 [
static const short da850_evm_tl_user_led_pins[] = {% q. D" y3 P c) W h& ]7 ^
/* These pins are definition at <mach/mux.h> file */# A7 i3 J5 P- p% [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' |4 ~2 l" M$ c: G- Y( E
-10 z4 e! m! t7 e( b3 A; U
};
& L( n) G6 V/ F
& N( \3 _$ W: S3 Z! z! _3 u5 gstatic struct gpio_led da850_evm_tl_leds[] = {- }, x" }# W; w m' b: ?1 e& `
{
; X% F _8 v- s I. N& d .active_low = 0,
4 X3 X2 Q) @2 H M+ p' z .gpio = DA850_USER_LED0,/ J9 t4 }3 Y+ j& f% B: a
.name = "user_led0",9 Z) x4 ~+ ]+ i
.default_trigger = "default-on",' X0 y( O3 q. w& r) r
},* j% q) d8 m) C9 i; P. H" O& Q- X, @
{
1 ~7 y" O5 n# t Q, ^9 q .active_low = 0,
0 T, U+ m8 h* s8 ]) r .gpio = DA850_USER_LED1,& E3 q) T) B# s( S
.name = "user_led1",
( i2 y0 L- ]6 O/ C8 Z. z .default_trigger = "default-on",
1 s: v4 M# [+ ?5 Q; k# Y7 @) z },
$ ?6 P# }9 D8 i) q/ ?+ J {! h' O* j2 }/ p! w3 C/ U. k4 b
.active_low = 0,, J1 G" l8 f: E# K: n* C8 F3 r
.gpio = DA850_USER_LED2,
$ ]/ F# F2 B0 Z0 L* K0 ^9 r .name = "user_led2",
! s* N; R8 S5 U) J5 M& ?9 t .default_trigger = "default-on",
' L6 l) p6 v% ]4 u+ N },! x2 q# r1 S I5 A/ A2 ]6 H
{
' N" i3 [# g" ]+ r. L6 ] B .active_low = 0,1 ^% y$ Q% D% e" Q8 N* Q" [ g
.gpio = DA850_USER_LED3,: d2 O G2 Y2 e/ n7 M" X
.name = "user_led3",
$ l& C4 e5 D4 l v9 T7 U, S, U0 h .default_trigger = "default-on",
/ ~: j( C& o" u! ?$ M },' s3 o! m; ?4 F! k) l- S4 l1 R
};
; Y6 R& X/ V2 U: e3 z& @! a9 m0 y, ^2 ^8 }# F6 N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 T. K( ^; Q" }# ?# S0 G; W1 o* A
.leds = da850_evm_tl_leds,& v( m6 Y& K9 B" |! G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; @' R( I, T% {0 u) q }; k};. r9 L+ N( K8 i# j& B
0 b; u% c& A5 ostatic void led_dev_release(struct device *dev)
) A/ z3 O, ]! W+ r& n& g{
2 G5 `% n8 o+ }0 S% V$ Q};
6 p* `* G$ a3 [
' ?9 m" k1 r. x4 A$ l/ O$ Astatic struct platform_device da850_evm_tl_leds_device = {
0 h# `& h* j' M' J. i8 s .name = "leds-gpio",2 R- e1 d- f# u* x3 J- k' y5 {
.id = 1,. |# z+ g3 W0 B2 e% g# ?
.dev = {
4 \. G* e$ `# t .platform_data = &da850_evm_tl_leds_pdata,/ G# y: g. g! p% j
.release = led_dev_release,
. q1 u W( s5 ]( [, N }
2 G: ^+ O. n$ ]};1 L# t( I$ s) P% w/ s3 T
7 a# X8 B& t9 D( \2 m' zstatic int __init led_platform_init(void)
8 ^1 s3 F- s# x. a( m6 m1 h$ g1 x# M' z k{; S$ G/ L6 {+ x! W4 }
int ret;* d! m8 d0 e3 d( @% `( i4 p* R# _
#if 0
* q6 W% c6 h+ L/ m8 C9 t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 f7 d! _$ Q' [ if (ret)
7 O5 i0 G% Z8 e% G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
P8 A; g2 K2 p2 M, N0 D; B "%d\n", ret);
" ~" i$ [7 X" l' ?( j#endif8 E6 w1 [% V! x. k& ?4 K
ret = platform_device_register(&da850_evm_tl_leds_device);
* ^. b5 T4 B$ _+ _6 U if (ret)2 \0 q& l3 _# {8 U
pr_warning("Could not register som GPIO expander LEDS");8 }( I- t+ T# e1 S$ y
else
, T* s9 ^& f3 Z printk(KERN_INFO "LED register sucessful!\n");- y: ?* i4 n1 U( B$ M: k0 ?
+ _$ m5 h" ^8 {1 F
return ret;
& z/ q$ e* G! g( j7 f9 L+ N} S8 o* C3 G/ ]! B) K, K! F
/ @( G" ~3 x9 }' }2 j9 S, L0 nstatic void __exit led_platform_exit(void)8 ?$ m% u) `: ? L4 ?
{
% p$ g2 r% _9 v platform_device_unregister(&da850_evm_tl_leds_device);
1 Z5 n. p0 D* J/ g. T( P0 s/ {" r) w) G9 L7 k" T- w( Q
printk(KERN_INFO "LED unregister!\n");/ V* J: K) E5 d) `- w. h
}5 L8 D' C# m) G- j
# _5 g- i( E( r) `. f2 mmodule_init(led_platform_init);
' C8 a! `2 s+ S, Hmodule_exit(led_platform_exit);! `7 N7 C. o1 V7 p ?) g
; L3 ]3 ?1 ?% B" O/ D
MODULE_DESCRIPTION("Led platform driver");
5 q* O" @, g! F f% k# H% eMODULE_AUTHOR("Tronlong");
. A) a! c6 \+ {- D/ G* W2 v/ k) WMODULE_LICENSE("GPL");
( a. e/ {: s A, K& |
8 L1 v$ t; X. H r- K7 H |
|