|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 o3 d" e- x+ o9 x2 |$ }
#include <linux/init.h>! H& C. s1 G" `& h5 Z
#include <linux/module.h>
0 q1 b6 a+ X( s2 G' w& ]+ B#include <linux/kernel.h>
# s. `* G& o* ]8 f9 B* B#include <linux/types.h>
4 R+ D: _# ?$ F" I#include <linux/gpio.h>
9 v: T. ?7 D' z' }$ u#include <linux/leds.h>! Y" E- W7 I! l
#include <linux/platform_device.h>. y6 Z" |* h6 D0 m3 S2 ]6 W
/ V: v1 G2 l: v; a
#include <asm/mach-types.h>
7 r) c8 G6 i4 g. H#include <asm/mach/arch.h>
0 @6 V6 H0 m' s3 U% K+ r3 D: Z" _#include <mach/da8xx.h>
; L2 R6 w ^4 Z/ Z: @4 |#include <mach/mux.h>
( }$ p1 @1 L) ?- ?9 P
% ~+ ~: Z D5 b; t/ l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 T6 d5 C0 n( O6 D' o* P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) a! e. c5 g4 t#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& V/ A. z, f8 ]) u9 j7 }3 z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% k8 ]! E3 Y/ t8 T2 Q. ~
; T& p& g, m& w& d1 Q/* assign the tl som board LED-GPIOs*/
3 Z2 H2 N0 Q6 z5 fstatic const short da850_evm_tl_user_led_pins[] = {$ W6 Q" _& v/ R* l1 v$ h/ e
/* These pins are definition at <mach/mux.h> file */# q8 g( P' C5 p1 ]* I2 z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 ^/ g* G& _( J: k2 _
-1, h3 e( v/ F5 }
};5 q; a; P0 Y. A6 O& n1 X) ?7 P
; Z7 o7 C2 r; A) t, Q0 ~- F
static struct gpio_led da850_evm_tl_leds[] = {
; r- q$ ]) ~( ?; e9 C: F- h {
; n$ u/ y8 O6 f0 y. z .active_low = 0,4 b( N5 y* M) @# f3 W( z
.gpio = DA850_USER_LED0,
7 A3 X" J7 ~; n& E3 z% s; F .name = "user_led0",$ z3 a1 F7 y7 Q8 r
.default_trigger = "default-on",3 Z* u5 V1 [+ @2 M: v( O/ z' a
},1 k* V8 W4 M8 m9 M# w' {0 W! v3 @% f
{7 A s' D1 ]4 n8 I1 M) t0 E4 f6 x- J
.active_low = 0,
' q4 D; {$ b! l+ G .gpio = DA850_USER_LED1,- t8 s6 C" S7 M7 X
.name = "user_led1",
% o1 u' G% S- L .default_trigger = "default-on",: l% x! D4 i( D5 v
},
) ~+ N7 `8 `4 ^& ? {
7 k; o2 b( t0 C .active_low = 0,0 L9 m4 {2 ]% b/ H2 j' l
.gpio = DA850_USER_LED2,5 ]" [: n! s' {3 }
.name = "user_led2",
1 D: S4 S5 t. G. {" Z .default_trigger = "default-on",
2 {8 J# H7 X. u },, p6 W: B5 S' r8 P- n3 L+ K
{
% }1 G$ K( @3 S7 t( c .active_low = 0,9 l6 `3 _* E9 k, c
.gpio = DA850_USER_LED3,+ s* k8 L2 n. [ p
.name = "user_led3",
/ z. }- E, I. r$ }( O) C .default_trigger = "default-on",
; _ v9 a2 ~( c- o) a% g2 ] },: |3 v; ^6 N- t% T' r% t K+ W
};
- e" u7 h' Q8 L2 D! s+ F2 X
$ \9 ]( d( d' W2 _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& U+ ?& y( r% b. d4 ]4 m .leds = da850_evm_tl_leds,
: C' R6 S m6 ~3 j% X/ s8 Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 i0 S0 \5 Z1 W; m' l. O};7 w' m; B5 E' \ Q5 J7 O8 _
- V! O( h" b" a' Astatic void led_dev_release(struct device *dev)
- z: m- _; J) b{6 D; i" _& k$ G+ {: R
};
' A# x: @: N& X* Z8 h
0 T; N/ N* J( o1 cstatic struct platform_device da850_evm_tl_leds_device = {
8 _" j4 I0 Y/ E3 g& R .name = "leds-gpio",- E! d5 j6 k/ l9 R0 O
.id = 1,' I/ Z: p2 I Y9 _1 D/ B4 n. ~
.dev = {
7 V( s" R$ A5 N1 l3 D' X .platform_data = &da850_evm_tl_leds_pdata,
" \1 A0 Q' c! Q2 Y1 d @ .release = led_dev_release,$ T3 t5 D' Z& `9 S/ _
}
" P+ g: q; A% E};3 M7 s7 ~3 g6 A' q" u2 Q3 m8 ]- Z
f9 x: H4 U$ b I; F8 Rstatic int __init led_platform_init(void)
1 j3 A1 U8 a$ g: {7 [{
- s3 S. D% T5 t int ret;( U f: X, X( |6 N
#if 0
4 i, }, e, M- i! ]+ w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% L! C9 v( q6 Q if (ret); H7 C5 I$ M9 S8 j0 r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 X7 P# g% D$ x( V2 G
"%d\n", ret);, n+ p0 R- C \- ]: K' I( X
#endif9 w3 E; R* w% v* u
ret = platform_device_register(&da850_evm_tl_leds_device);, Z/ T1 M, P0 S1 V8 m
if (ret)
$ a# q$ W3 y- C; w4 ^" n pr_warning("Could not register som GPIO expander LEDS");$ B% D3 }. ^+ Q" U8 }
else7 A/ c) G3 J; s/ D
printk(KERN_INFO "LED register sucessful!\n");
. Z& C7 r" I" y' C! N" L7 F. g$ i+ } Q; O
return ret;
- k- e* j! o- ]* q9 K}3 k1 v H* F. P; {
; e+ @4 r0 I' K, }$ Q9 A( U# ystatic void __exit led_platform_exit(void)
7 V* |+ q+ `& E: l: a{
! j& ]" n& C8 i$ ? platform_device_unregister(&da850_evm_tl_leds_device);' L& X; g$ g$ k* H0 `) o# v
! q- c6 o1 C; b. t printk(KERN_INFO "LED unregister!\n");
" J' ] `$ b6 w}) N: l! w2 Y) f
: u$ `% D4 S: E0 X( `module_init(led_platform_init);
4 P$ e( d- m- B+ Q$ @module_exit(led_platform_exit);5 N! x; Q& X; Q7 K+ d V8 @
0 q4 o; p! z0 r7 L& Y; U# S
MODULE_DESCRIPTION("Led platform driver");
' G0 q) z: H. M9 J( o1 KMODULE_AUTHOR("Tronlong");
6 J8 H' E; o {+ i+ v/ n" nMODULE_LICENSE("GPL");
: C! l( K) ?, c0 `0 }4 N3 x( f7 R: B' `3 A
|
|