|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! P8 a; r% P: b4 }#include <linux/init.h>5 E* m0 Y8 F* e" R0 a% d6 g1 G
#include <linux/module.h>
7 a6 Z. x' O" }$ \#include <linux/kernel.h>
1 x8 U$ @: B$ p: P; B+ b#include <linux/types.h>' Y. q; \& \. w* p* Y5 ?
#include <linux/gpio.h>/ E: S9 l9 f7 U2 O
#include <linux/leds.h>
. b; E6 g$ c) u" E+ r9 ?5 Q- A#include <linux/platform_device.h>, k; _, r0 ], C1 \
% Q6 U$ T8 N0 E8 N, ^: s! |6 {1 J: [#include <asm/mach-types.h>
$ I# Z4 L0 w: H3 P#include <asm/mach/arch.h>4 h7 Z3 I" b# b5 J' \ u
#include <mach/da8xx.h>
8 Z" I& P' c! ~! D#include <mach/mux.h>
( S% @5 u5 U# b7 |7 x' D& ^# U: D# E) N0 G1 U( K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' E y0 S! J w5 Z3 Y$ o/ [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); V3 H1 @* M2 u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ \/ p* c7 `6 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" e& l+ N5 P" q7 R- [3 H' _- l* f$ E5 _% `
/* assign the tl som board LED-GPIOs*/
2 f5 O: F! n' ?0 f2 F. Nstatic const short da850_evm_tl_user_led_pins[] = {
: v, V0 k5 M- D' l /* These pins are definition at <mach/mux.h> file */
* d" w# L+ e) F% L4 C) K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 C6 [1 p2 x! Z ^9 h N; G -1( B& S, U# D8 @3 l9 ~4 b5 L6 R7 N
};! ~* G/ ]+ d4 ?5 T
% P* r! C. s4 I: J4 c6 Z/ y; ustatic struct gpio_led da850_evm_tl_leds[] = {3 P6 ]" z5 A! ~
{
$ U+ R8 a; t( b' K9 r% a .active_low = 0,! L5 n# u# U7 c3 U8 ~* K! o
.gpio = DA850_USER_LED0,
$ g/ b2 F3 A: x5 J& r, y .name = "user_led0",' h# B$ E/ V1 p- O# X, X0 I$ I1 P+ Y' a
.default_trigger = "default-on",- U& b& @3 c8 o
},' h8 u9 L: q& i" c
{
. z% R- H6 ]6 [' A9 W7 O; C. S$ Q .active_low = 0,
( D7 j/ [/ T" W9 Z .gpio = DA850_USER_LED1," |' D, X1 R8 }6 Y" D. j3 W
.name = "user_led1",& ^: D$ e2 N. x2 _2 J8 Q: Q
.default_trigger = "default-on",$ Y) w) w: f) H3 P
},
* W2 H) x: T P+ n {* [* C% O0 f7 s/ B
.active_low = 0,
1 e. _% L% ~! f1 v3 v0 u' e: F8 Y .gpio = DA850_USER_LED2,
( j. `1 z; K% F! t5 ~, W .name = "user_led2",2 W6 O8 u/ Q8 @
.default_trigger = "default-on",* C' Q2 w( F6 q! A5 L. M, c# v8 j0 S
},
% a* U. G& M7 t" T$ } {
/ o7 p/ b a# r/ p& l- `# `4 X/ q- B .active_low = 0,
( n% r- Q# Q) b .gpio = DA850_USER_LED3,1 ~. q) z) {( B
.name = "user_led3",. x8 f3 i7 _, v) W: F
.default_trigger = "default-on",- Z# V. e$ k: T
},; P0 j2 }5 Y7 R! s) c p8 n2 {
};
( x* v% F/ J; u9 D9 U S- r6 S3 Z$ N3 E2 ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; a' y+ e- m# e- | q# M
.leds = da850_evm_tl_leds,
) z- p' Y% M4 Z3 q+ l, i- b, G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 P: @& P" q0 ` `* i* q
};, e) W( U! H5 [) i" c$ x
9 ?' i$ F* F/ C% V7 h5 t2 A0 Bstatic void led_dev_release(struct device *dev)% E! ]0 ^$ x) T- x* O/ M- Z
{+ L7 x- R( h. v7 t( [# K( J
};) i6 ~$ S9 v! K
5 D1 q( } q" R0 rstatic struct platform_device da850_evm_tl_leds_device = {8 n% a% ^/ Q0 ~: N8 d% P, r
.name = "leds-gpio",- d. L# V! w* D4 s( I
.id = 1,
% P$ c9 a- o7 Z! n( i$ } .dev = {8 C& R' |6 h, F: `% N* W# k% H9 w
.platform_data = &da850_evm_tl_leds_pdata, m) z/ I! k. X3 l. K
.release = led_dev_release,8 t! \" D& z# l6 g6 i6 @$ |, P
}
! P! ]0 V4 W* l3 L" J8 S}; f2 t4 |0 V3 G7 H/ p4 L
; |& }, O9 |: a/ E3 o1 z( B0 z) Y8 x& g
static int __init led_platform_init(void)
- t) G, _1 l2 X7 ]( w/ ^{& M! Z% d1 C- Q
int ret;0 t% n7 t+ S5 Z2 ?5 [+ [
#if 07 }' i, t- Z; b6 N$ p! p* d, U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ a7 ]5 Z' h m0 B$ P
if (ret)
8 V7 _4 n' Y9 J0 K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; M9 g' J" m* r ^
"%d\n", ret);. R; j$ n7 A- p% `
#endif9 L; w u% `. T4 N
ret = platform_device_register(&da850_evm_tl_leds_device);
: h2 A0 F1 |/ _% X3 g- W if (ret)
, |$ j' Y% `( E: S! x, c4 s! Z/ v- a3 Q! s pr_warning("Could not register som GPIO expander LEDS");
7 @& j; V7 ^ I5 ^5 r else3 s. [% v; C/ d4 H% z% w0 |0 {. L
printk(KERN_INFO "LED register sucessful!\n");
$ H/ m2 J$ ~. ^ N5 i2 s$ T+ N/ K( i! w8 z: ?3 O
return ret;
0 C* v" I p/ L) q}5 k8 {7 h, |0 z0 \# P \) ^
1 F# `+ R& o9 ]3 K! Z: Q$ S! U) {' Kstatic void __exit led_platform_exit(void)
/ V- z! k8 g* H! m! Y{& v3 e& K; N" h8 B
platform_device_unregister(&da850_evm_tl_leds_device);% K3 R: l. g6 L$ m2 O
" a, s z2 }* O; C5 T printk(KERN_INFO "LED unregister!\n"); b* `! U! a8 a! x; w4 `
}
, u: i; u0 Z1 ]" b' r- [1 c
( J; w% B! G- |" X% u" }# e# Hmodule_init(led_platform_init);
8 `: ^- Z+ h$ k# m4 umodule_exit(led_platform_exit);
% }0 }; y f1 q$ j7 `5 [/ ^* Q9 @& |; p
% d: z4 D3 Z. IMODULE_DESCRIPTION("Led platform driver");+ ~3 y0 ?; @# E0 {
MODULE_AUTHOR("Tronlong");& r G+ }- E% S, ]) S0 o
MODULE_LICENSE("GPL");& C4 R) k8 R4 G0 q; E8 ^
7 M$ n7 |% |) t: p$ D |
|