|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 g1 t# [3 r/ B" M p+ M
#include <linux/init.h>
3 H d5 N) M0 w5 B1 t: M+ D& ]* Z#include <linux/module.h>
6 u3 [8 ~8 [1 L# b* Q3 d5 u, z* @#include <linux/kernel.h>
. A5 b( u a- @#include <linux/types.h>
1 Z! X, ^5 i8 t: Y2 |& C4 t#include <linux/gpio.h>1 F, }/ a# d4 U" i% l) C. {: B
#include <linux/leds.h>
2 j. {. l* V* A' ^$ [2 }' I" r2 u#include <linux/platform_device.h>9 c( F4 |$ Y, `1 M( h
/ y0 t: Y, D) a
#include <asm/mach-types.h>
% E- o, x+ Y/ G- V! d: V#include <asm/mach/arch.h>( N0 W5 \* t5 h/ [. y4 j) @
#include <mach/da8xx.h>
2 z5 _6 ~' `& `9 y! H6 {% ~#include <mach/mux.h>
4 l' ]' N% ?2 K# W# C2 k7 N9 d5 f- N' X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ @5 z& w, c: O+ N6 }, j1 y- x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 R) s/ e* n2 N1 {. S6 _( v3 p, R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- _. G# ]" z1 _) e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% e! ~4 y+ t: v9 [$ H' l$ w4 L J& `+ W( t2 s
/* assign the tl som board LED-GPIOs*/) U8 [# z- o/ K" N
static const short da850_evm_tl_user_led_pins[] = {
) {+ U) ~; m) B( @ /* These pins are definition at <mach/mux.h> file */
: c" M% j1 [% W DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 l6 |' i* n9 o -1; \# H+ V4 ~% U+ F- E
};8 X2 U( H! j( P0 y
. H1 a+ R4 @2 i) ]1 p5 r" a
static struct gpio_led da850_evm_tl_leds[] = {
! o) R& W* k; a9 I% s3 h8 M {
4 }0 t3 |* y* D- C* d: [ .active_low = 0,
# z# S5 i0 ~! h9 U/ m4 L .gpio = DA850_USER_LED0,5 q9 p: m, A* O% Q5 J& J
.name = "user_led0",
! ]2 v7 k( Y. L7 B5 U .default_trigger = "default-on",
1 I7 _6 t h! v" V. k" G0 E' c },- E, j* Z7 D. m5 G4 {
{% O0 g* V1 H$ L2 O- X5 B
.active_low = 0,0 l! D: M% @2 Y. ^, {/ `
.gpio = DA850_USER_LED1,
, H- N! a L4 K9 @8 S' m% x- W/ C .name = "user_led1",% e8 U/ r7 C: `- g+ m4 \
.default_trigger = "default-on",5 E. X( M" J, r, f" z) a6 } e6 Y
},
6 |) ~9 w% l/ v6 E- V0 U/ _2 L7 J" ^ {) G- J& I9 N! N8 [; o
.active_low = 0,! B) f+ i x$ V8 E1 I3 C }! m
.gpio = DA850_USER_LED2,- J+ y* Y! o- C. g8 A( Y3 p
.name = "user_led2",0 J# R4 Y" D* p0 m; `9 b
.default_trigger = "default-on",
- P! ]' S) g4 O3 B },2 H( _! d7 p9 s; O4 l# V
{" s9 Q. ^8 B4 N( R/ @
.active_low = 0,
F T9 a: ]' ` .gpio = DA850_USER_LED3,
: U1 U1 I0 N l8 f6 P. A .name = "user_led3",
3 t9 Q: s! P/ t6 U% c .default_trigger = "default-on",0 R$ P2 a% ~* _1 w2 N( V
},
" e& h7 \9 U1 |7 r2 T/ _};
w Y& _7 ]; D0 S0 N; H+ }: j; `5 W% {9 L7 y6 w" D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 h r) I+ U4 g1 g# ^( ^
.leds = da850_evm_tl_leds,5 s0 J# K$ {6 _" e! P
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; b- H& R2 N* S' e: T, c0 x0 k
};8 w7 l, p1 b5 m0 _# O( J: n% a( M
6 O3 d6 S) O7 q; Y% L' g8 j6 Fstatic void led_dev_release(struct device *dev)5 v; `: ~3 f; g& Q ?3 A! b( W
{
& u$ i/ I' W1 c( n0 i};9 d$ q) ] A; Y4 i- B
. d2 u% _! s( d& ustatic struct platform_device da850_evm_tl_leds_device = {& V( E- N$ A5 {5 K# A7 f
.name = "leds-gpio",
9 G, u& y |$ x* j# F .id = 1,
8 r) y4 E* E1 b0 p. t0 u9 c .dev = {; W4 I5 J1 z$ a6 x
.platform_data = &da850_evm_tl_leds_pdata,5 ]! Q) e7 {. g; P9 c) N
.release = led_dev_release,( @8 C, F3 i# {4 v- y. \( h! i
}
- w' a, L2 t' n4 a L' g3 n};
% P @1 M% M5 I% Q+ X8 ]1 D
! h3 Q8 G* o+ t" E3 D) hstatic int __init led_platform_init(void)
" N, v& S2 x# [$ f. M# b+ O{& F# B7 _; `7 e+ k3 R8 P
int ret;: K0 `3 z3 J& }. @/ b8 X
#if 0
* w7 q# E3 n0 [7 z/ _, g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 T2 F. Q# @5 A: B( ]2 a" ?8 h
if (ret)
% k3 j: l. U- h! F+ E: h* x- O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 U% }4 F0 u/ b
"%d\n", ret);4 [5 h( N' d6 ~% m6 ^
#endif
i( ~2 A4 B- E/ p$ K ret = platform_device_register(&da850_evm_tl_leds_device);' a# l7 f; a, ? }: w
if (ret)
' X: Z% Y1 n4 x* F" t: n pr_warning("Could not register som GPIO expander LEDS");% g, X) K4 s, P8 @& A2 h& ]
else
* R9 x# U0 q6 T3 r( q0 }; B- o printk(KERN_INFO "LED register sucessful!\n");/ L3 h: q+ m% B$ f1 c+ k. R. Z3 Z
9 R" V" s) p0 F" H
return ret;, R0 {4 J. c5 J0 W: J3 S- J7 L
}) i. G3 }6 i4 X' F' ]+ k( A# P1 C
0 E$ @2 |: |2 \# r6 H8 @8 u; ^2 bstatic void __exit led_platform_exit(void)" h" a& j7 B4 @/ O0 g
{
( K4 y/ \# D* T. Y/ s/ c platform_device_unregister(&da850_evm_tl_leds_device);
& F' x/ P% t# A" `+ y4 ^# h: k1 P% L# P- | N& n n
printk(KERN_INFO "LED unregister!\n");
$ Q1 I- f5 t+ C2 P& Q! J# }1 i}* A X/ z! _* X0 F3 M# F# p$ n
7 L1 o. k- n3 ?" {& D7 zmodule_init(led_platform_init);
1 |, w" [8 S3 |% m: Bmodule_exit(led_platform_exit);. y: S* d3 m& `# U0 w! C* F4 c S
& T+ F4 w$ E: b
MODULE_DESCRIPTION("Led platform driver");
# W( G* W9 x @: h2 |3 d9 {: eMODULE_AUTHOR("Tronlong");$ h" R; a9 h S. O& a4 j. _0 C7 c
MODULE_LICENSE("GPL");- ^; W( Q. K5 ^; Q2 p' M: A6 e9 d4 b
* x' @% ?" C; z) e7 e' l |
|