|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 x1 n! e$ F3 L' m* b
#include <linux/init.h>
( K7 c4 V. ]- ]( K( |6 b' G" [#include <linux/module.h>' D7 K2 J3 ~$ }: B7 b7 R) y
#include <linux/kernel.h>
& P( @( y& K! V4 Z; n# v#include <linux/types.h>4 k. r5 H2 l% a7 q" x3 Q
#include <linux/gpio.h>
9 Z2 ~" v. o. r4 y#include <linux/leds.h>1 j4 ~2 L$ q; [7 n& ]/ L' b
#include <linux/platform_device.h>, e& F) F; c; ^+ w4 X( k: w
% B9 Y* Q# X; L8 u
#include <asm/mach-types.h>
0 ^& J3 Q. ~. E# l#include <asm/mach/arch.h>
* I# c5 O3 X: k# `#include <mach/da8xx.h>6 ]8 Q# K# W/ H
#include <mach/mux.h>
; \$ J; ]# J. N! A: x0 E; E
4 O) w8 ]/ I% F8 Z0 o% P" ^" u, N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. I6 _; W" I% p4 O- S& x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 y0 k9 j& j; v& E1 j4 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! I9 n4 j0 ?- k& [1 K$ Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- ~9 @3 f) \% s9 }! a9 z; D! \4 S
3 m# x9 I6 I) w. E! j
/* assign the tl som board LED-GPIOs*/ D9 M+ l7 o& d- b* t
static const short da850_evm_tl_user_led_pins[] = {
2 c, ?- U( K% J8 I& d /* These pins are definition at <mach/mux.h> file */$ P5 H6 T- M! Y+ ]# E7 e' X- j. E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," ~" a: f7 }; d- Y% Z
-1
0 J, V* E' Q7 l- G2 J2 u- d. ?};0 X% E3 N: Y7 ?) y/ Z
3 y4 W) c& ]8 M# D9 ]2 F. B1 M
static struct gpio_led da850_evm_tl_leds[] = {
4 N( V% m. V3 w+ U {4 A: Q# E; \" p& w# w A
.active_low = 0,
2 l7 [3 c! m$ j6 E: a- {1 y .gpio = DA850_USER_LED0,( W9 l$ U0 H" n% |
.name = "user_led0",) W4 [: Y0 w4 ^3 T
.default_trigger = "default-on",/ W3 P4 z6 k. e& h6 i( l
},1 a7 I- F: ?: _& c2 W, a9 g% |. [
{
1 `/ [1 ?+ r/ r& ~9 J1 d) q4 l' ~7 R .active_low = 0,
% z$ F, ]" L& N5 C+ @ .gpio = DA850_USER_LED1,) }7 V6 ?0 }/ h& P. d% D& h# Z
.name = "user_led1",! m1 j6 d+ ?+ n) z( [
.default_trigger = "default-on",8 @ a7 V- M8 b# z4 J2 [( R0 W- [
},, e; M+ B/ R8 Z! S+ J, V2 y0 p
{
5 k- W# c7 `3 m7 c/ I9 j8 O4 H+ w- K! g .active_low = 0, s' T' Q: e/ z) o0 A
.gpio = DA850_USER_LED2,
* O& g! b, d# S6 B9 x& Y$ E .name = "user_led2",
1 d+ E1 h0 \1 F* R( \* v .default_trigger = "default-on",, `& o& _0 G: U) z6 @9 t: v
},0 X. ]0 D/ Q2 l2 [' b. t" q3 t
{) T; S& j0 X& c) x _8 }# B Q+ ~# e
.active_low = 0,% C- e$ ~2 W2 n$ ^
.gpio = DA850_USER_LED3,8 h9 D5 D5 g4 K0 Y1 I
.name = "user_led3",1 L" ]4 `2 w+ Y5 v
.default_trigger = "default-on",- b- C3 J8 U2 s+ _$ g
},/ l. S+ ^" C# h6 g# R8 p' h( B, c
};
, `9 r& t0 a- M" Y) H7 E3 a g! ~! v
! }4 \. J3 u. P9 ?; s) j! Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) `6 w' z0 y! l9 F. t
.leds = da850_evm_tl_leds,
A5 M+ c3 I- p) H) y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 y$ O3 p8 E0 T' B
};3 M; p+ N3 W9 a n, O
% i, }) I- i# Q3 S: _3 Xstatic void led_dev_release(struct device *dev)
& l5 ~; x+ g. V! z# R{1 d/ |, f. l" ~5 _* i! d4 r
};
* R5 k/ f. A( H' t: [
" ~4 H; @1 A7 m0 b! i( [static struct platform_device da850_evm_tl_leds_device = {
/ M* f. x- \9 p% i \- f" P/ | .name = "leds-gpio",
' j" r) `7 q' U) h .id = 1,/ u( U+ D' F6 H# Y! {" z
.dev = {" D+ P$ S' Y$ L* h" d# c; f1 ?
.platform_data = &da850_evm_tl_leds_pdata,
$ c$ w+ ^: {6 D+ B4 i .release = led_dev_release,% ?' N2 Z1 |+ r, z& e
}9 k3 B3 ^0 m3 [8 q2 k H c
};
/ q1 T/ l* a2 C" n# ?+ w
. z- C' `4 V7 A) v* Kstatic int __init led_platform_init(void)
6 p7 h. G, X' v" w( G{
& B$ W1 m6 Y/ L" p/ J int ret;! o6 T' h; e3 G
#if 0& ^, X% z+ B" g& P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. ?2 O- G! u- v" p1 ^, E( g if (ret)2 y: G5 Q1 ?" k9 }5 [. W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
R: { W; o1 j( e0 b8 u- W7 e1 e* z "%d\n", ret);! I& j7 ]- R. |( v9 C5 F# _8 E7 u
#endif
% M) j1 }% _$ {. I4 ]- D- F ret = platform_device_register(&da850_evm_tl_leds_device);, ?% d. G, [& w4 v- i3 Z+ @
if (ret)0 l& _( U. q' E2 P6 r4 k% n/ z& g
pr_warning("Could not register som GPIO expander LEDS");4 E" l. d1 g; a( l ?
else7 A, [% C; l- |/ U; G# W
printk(KERN_INFO "LED register sucessful!\n");( w( R" I D& F. S
) W8 ]( Q9 Q. O- X! `! X; u) e
return ret;3 W# I/ g. P a" n; r% A
}% c) @8 Z! Z3 t! L
6 x5 D6 \+ ]( k/ ]$ `+ ]+ i) `
static void __exit led_platform_exit(void)
) h0 A/ j" i8 }$ T$ D; O{
1 j: x4 p5 E* e* T" _( l platform_device_unregister(&da850_evm_tl_leds_device);
- _1 l5 g% f1 b. I' m( A g! n% K8 C/ Y6 c; C8 V
printk(KERN_INFO "LED unregister!\n");' _$ {0 `8 {1 i
}! X9 j+ i8 S9 J6 p; f* ?( ~
! E, {% A1 y6 ]
module_init(led_platform_init);
, ^- `! q0 J2 ^! L8 Amodule_exit(led_platform_exit);9 c% Q1 w% v* t' j& ]8 D
/ C% s! X Z+ w5 LMODULE_DESCRIPTION("Led platform driver");, n* h* c+ P$ t: j8 z! t9 F
MODULE_AUTHOR("Tronlong");2 A" v! b( @4 B7 Z& [+ }2 Q9 g
MODULE_LICENSE("GPL");
% \7 ?, \1 k5 B7 Q/ {% n! d# S' U: C
|
|