|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 u: n) t$ ]& L#include <linux/init.h>3 o$ n I" t/ D
#include <linux/module.h># q% j* E3 q" @" E8 K
#include <linux/kernel.h>! X. I; _3 s3 L4 M% P
#include <linux/types.h>9 c7 L) s& J$ ~; c( m" E
#include <linux/gpio.h>
$ Q& Q+ M8 I# F, l! ~# I#include <linux/leds.h>
! z$ k8 j+ j4 S1 q#include <linux/platform_device.h>' D, v! i8 }, f( H
5 u1 C* f; h% K) C8 \#include <asm/mach-types.h>) i# k' y7 W$ I# z I
#include <asm/mach/arch.h>
* @/ a. r4 u4 I c( w' H#include <mach/da8xx.h>
8 ]: _' `. ]+ r. z9 q" T! A: Z8 i! P#include <mach/mux.h>
" d1 g2 A+ G* j; ]. J" a) U$ x- s4 `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 P# Z; l+ }( K* @) h" j# V) B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
Z4 t5 U: t- |# F8 x" `- I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* ?$ |/ o- ]/ |% _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 c- V8 K. @2 S4 p1 p
; m: a/ S1 L2 O7 o: |
/* assign the tl som board LED-GPIOs*/, b7 h* R. O* a5 y
static const short da850_evm_tl_user_led_pins[] = {
4 o4 c: C: x% z+ Z* K; q6 d) N /* These pins are definition at <mach/mux.h> file */7 ?* ]! Q4 R1 f7 _8 {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 z- u) y Q" V' N) g) ^ -1& R$ v% E" [) T3 \& _' _
};5 e4 H5 W: c# P; ^4 v
) W& x' j/ c7 p) c% `, F# T. B
static struct gpio_led da850_evm_tl_leds[] = {9 z0 @: P8 [( m1 U
{
9 R# S9 l x" ?. H+ j: y) T .active_low = 0,3 K g O/ G% e# J6 o
.gpio = DA850_USER_LED0,; E% `! I2 p! M1 ?6 m* P
.name = "user_led0",
5 C0 p/ D$ Y( n" a: P) M+ ^* F* I6 A* z .default_trigger = "default-on",. M2 c" R( R" t! Y$ i
},! g. x3 R: c7 b7 s; i
{
# K; c) `" L# f* i$ h .active_low = 0,3 o$ e, d& v& d) c/ ]+ F7 |
.gpio = DA850_USER_LED1," H( i( ?# ]. Y: c" M4 a, K
.name = "user_led1",; r; k; K8 O l! h( D+ [$ u" F) R
.default_trigger = "default-on",
7 j% i: p. p5 v- _; @ },
1 G. X7 m6 J" g- M1 ~- B {
5 x: T: u* Q8 r& X' w$ R$ K6 N( F .active_low = 0,
& Q" `5 u2 E8 O; a0 \7 d/ T .gpio = DA850_USER_LED2,
! {+ ~: \& U K2 C: @, @) r2 c .name = "user_led2",, k0 L8 @% G5 ` I" c+ U
.default_trigger = "default-on",# N8 [. ^6 ]8 i
},+ V# l2 q# X" t7 N. p
{
# |9 b- K$ C) ]9 c% E7 X .active_low = 0,
3 i2 d. ^1 y# f4 q" G- J .gpio = DA850_USER_LED3,& n& O- C* H2 w7 x y; l; b9 {
.name = "user_led3",5 J) N9 @, j& J! q8 p
.default_trigger = "default-on",
# X3 D1 T% m u" k: @! v; A },4 s) }( K; X& n/ d6 [! r! P
};
' v$ M0 q0 A0 A5 q, R; @8 o) @5 o- B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 Z0 e+ I; L5 z; w& b .leds = da850_evm_tl_leds,
; f% x5 k. L* U" _1 O4 m: a0 h7 m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 C- ~: \& W# t; W};
: I* ^$ l9 \% T7 S" a. [4 D5 z8 Z7 D* K; g2 r' i
static void led_dev_release(struct device *dev)+ g) Q% M- c- E( T4 L
{/ B4 H0 u2 w; a9 h* ^0 ^) B
};
" @, a, @3 H9 ~. [- D
% q4 [% R+ Y& f! T% m: g7 Fstatic struct platform_device da850_evm_tl_leds_device = {" O `: H% w }3 S. A8 v6 E j( P! ]
.name = "leds-gpio",
& {5 M- [- i# c2 [) N7 j .id = 1,6 J' ~) C! U2 M. x. h4 x w
.dev = {
' p! C1 F/ a4 C .platform_data = &da850_evm_tl_leds_pdata,
3 A# ?6 h+ u. {/ z! T7 c, j- s/ J .release = led_dev_release,/ [& a6 k, a, H' a
}; [% [# i2 M6 U' c9 d5 S5 ?: e
};
' [4 Z- s( T2 s- ?. H* e$ ?8 s: h3 @4 a& \% f
static int __init led_platform_init(void)6 T/ d5 C. v( A
{
5 t2 b5 p. o( T1 g int ret;" K; {/ S R; Z& h9 B
#if 00 W. K% j7 z* v; L/ y$ H' B; i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: y ~9 F8 M0 Y7 ` if (ret)3 \: L, n2 N) O8 r6 \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 p8 m* o" }3 o8 t. H9 _) B/ }
"%d\n", ret);
- q5 f" }/ r* [ `#endif0 v3 z7 f) w/ s7 z
ret = platform_device_register(&da850_evm_tl_leds_device);
& F8 B0 k1 P3 _ if (ret)6 {+ K5 L2 e- p" A) `1 }/ _4 V
pr_warning("Could not register som GPIO expander LEDS");6 r3 [8 D7 Z* o" z3 I J8 P7 ]0 E/ Z
else
) a$ S/ t3 X1 f9 I* J# t% y9 u& g printk(KERN_INFO "LED register sucessful!\n");3 P7 u3 C; y' u( E" K9 b
& f) G8 H: _* B$ x
return ret;
4 z$ T- c8 c! q}
( J& h2 z0 U& U3 @1 _( w7 @# S4 |/ O" _0 \
static void __exit led_platform_exit(void)
% e* E# H8 |) k% v{; Q# ]8 \1 e. ~6 O9 e
platform_device_unregister(&da850_evm_tl_leds_device);
: Z1 A. f5 C; p2 {* Z/ W; b' ~/ G$ w
printk(KERN_INFO "LED unregister!\n");$ h9 Y8 `8 v3 P, t8 a2 F0 d* l1 s h! i
}6 z. r! P' m" U4 H- }
3 a: i% u; ]3 o" Q6 G6 x
module_init(led_platform_init);6 ?' g$ S- f( {) v5 w
module_exit(led_platform_exit);1 l$ G2 ?+ n( q7 v* o4 k: N0 s" ~
" c" k" Y/ f' A0 k
MODULE_DESCRIPTION("Led platform driver");
8 _/ X* q2 E9 s4 m3 D' m$ C$ YMODULE_AUTHOR("Tronlong");, o- S1 S. j5 w g
MODULE_LICENSE("GPL");
, @9 g' m: I) k& n
, r# l6 M3 j% Y. B# {5 w |
|