|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# }5 {& P/ R" [% C
#include <linux/init.h>$ H4 v: I) E+ q1 n7 B
#include <linux/module.h>
2 n7 e+ x6 v- {4 _6 r8 ]- `) X#include <linux/kernel.h>
" {& R, ?& i7 }$ q9 S: R; r4 p( q#include <linux/types.h> \- G5 Z$ }1 U( D" f9 j4 ?
#include <linux/gpio.h>
M7 ?9 c1 W9 a7 H$ l& G2 d#include <linux/leds.h> S* P& K& {/ t2 ~$ F- P
#include <linux/platform_device.h>9 n3 V* J% h% R
0 Q# Z3 }& ]* j" Q p* A
#include <asm/mach-types.h>
1 d' E! e, P5 j& X#include <asm/mach/arch.h>; N; T1 W) a4 d- K+ I0 f' e& q0 b$ C4 r
#include <mach/da8xx.h>2 I& j# m ^% X J4 `
#include <mach/mux.h>
( E% e! A/ J$ u; F) [8 \* b6 g; M7 [$ {3 S9 w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 ^% D1 W& M0 ^# V c: V* V T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: r7 d+ m, D4 e s) L! l) f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); s; _$ j4 N4 l; g! S( Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 x- _+ J3 `4 J. r4 |! H
+ E \; w: n0 c; G" T! u6 D4 H/* assign the tl som board LED-GPIOs*/0 s) z5 @, F' I' n$ P- z/ W
static const short da850_evm_tl_user_led_pins[] = {
3 u/ G# V2 K+ R* G /* These pins are definition at <mach/mux.h> file */% H' i9 S# C0 k& X+ y: r# ]( y! w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* `0 L M" v1 F! H7 x1 e7 N -1
/ |5 k6 x9 i8 i+ ~7 ~: r, f};
% e+ F# w9 x4 M; j8 X! m% }: t) Y. \: Q/ e0 C
static struct gpio_led da850_evm_tl_leds[] = {% O0 k2 R- Z1 \7 M
{& J9 j% ~7 p4 F) r: F: y% q
.active_low = 0,* e1 m/ |4 d6 S" [
.gpio = DA850_USER_LED0,
9 L8 Y, F) u0 T! j .name = "user_led0",
- O3 G! x8 ]- L8 j6 U .default_trigger = "default-on",
( R8 Z3 q9 r5 r( L! e$ ~# [( V },8 m H2 _* a+ k7 n" k% {1 C2 V
{+ o/ R- v- c8 b
.active_low = 0,3 C/ C j! c: l! O. ~5 ?
.gpio = DA850_USER_LED1,* A- V' m( J& D
.name = "user_led1",
* \! U) F1 F* { .default_trigger = "default-on",2 E, N& J2 G8 [9 s5 T9 W
},8 b, J2 d, `, x' d2 U1 L! i! W8 E E$ V
{
8 u- W% C* G. H6 p5 v; I .active_low = 0,
3 {/ j) N, j! y1 {3 _9 ]1 o& J! B1 W- J! G .gpio = DA850_USER_LED2,' N' l+ k! V& t o. ]. x
.name = "user_led2",
9 ~2 ~0 q9 L H- C! h9 C .default_trigger = "default-on",
. i' L* @: U% |" O6 X },! r. ?7 k6 ?- m
{
9 E1 P# X/ `# f5 f! V- w$ D$ w .active_low = 0,% o; a5 c4 Y9 y5 C, ~
.gpio = DA850_USER_LED3,/ b8 _5 E! |5 }% W1 P* N# @' R
.name = "user_led3",/ v0 c* }6 g, q
.default_trigger = "default-on",% o/ k7 }, T0 e/ w/ s, U
},. p8 E) P; ^$ F4 }) x# i
};
: u0 F/ H+ ^5 ] O6 N% f2 \
8 ], b8 C' a4 c' l/ u7 n" {0 u0 [/ g& wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 m# Y- `" p* p; D% {% U4 C; T
.leds = da850_evm_tl_leds,% y7 }# R& M2 o- L Z* S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& n# q4 q! {5 T6 L
};
2 z, t4 ^6 ?* G5 a }
9 N7 ^8 \" k1 n0 p" }+ W- R& kstatic void led_dev_release(struct device *dev)& \& O% H2 o8 z" y! w
{
) K9 Z- D5 \/ L, N6 M};
+ g, k: V: v, q) p9 [% g5 x; x) @$ A" C
static struct platform_device da850_evm_tl_leds_device = {
0 |4 _& y* t- b) R: _ .name = "leds-gpio",
/ F, p- x( E0 D T, J: H1 X .id = 1,
1 v* v0 E; y8 P! v .dev = {6 ?* r. H! p$ u7 S$ @
.platform_data = &da850_evm_tl_leds_pdata,
: x3 x5 A: _8 j2 ^/ b6 j# U .release = led_dev_release,
5 \4 W5 i& h- } I8 z }( N0 M8 d# p! K; {" m3 {
};
& [ [3 D+ Y% y0 b( `8 d: W o" y$ g1 G% q3 U2 C- f. B$ Z- h
static int __init led_platform_init(void)# u/ }5 b8 K* e5 [ P- k- I' \
{
2 m+ k2 s2 j; O& Y* _/ R int ret;
, Y/ g: ^$ e$ L8 ]- ^; P0 t- B#if 05 \# K1 h5 `1 A$ D* E2 U: M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ r/ v- A( `1 c# y' L
if (ret)) W3 k! m9 w: e+ k! z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 x' H0 T% x6 {0 x% | "%d\n", ret);2 F: C$ G: ?4 G2 G8 s* R, Q5 b
#endif
! M' |6 p8 G. G/ A! G1 Z ret = platform_device_register(&da850_evm_tl_leds_device);! Y3 E. m/ {. A) ~: ]7 ~
if (ret) r6 }* n& j( g% y9 m
pr_warning("Could not register som GPIO expander LEDS");7 G' n: x& ]& i$ T1 j/ w
else
) I! Q) H3 G2 z+ O+ P& m; h printk(KERN_INFO "LED register sucessful!\n");" L. ^. I7 \( ~* Q
$ g2 _: s1 X: w
return ret;, r r8 R- h5 e: H
}
, y6 j ?1 B# U6 U: l( F" ]. f! l( S F1 K
static void __exit led_platform_exit(void)
6 I2 Y, V% q4 z{
( _ u3 Z, @# }% B$ A7 @ platform_device_unregister(&da850_evm_tl_leds_device);
# z5 i5 d: ]5 |
* E- D6 p) h+ b% o, d9 F printk(KERN_INFO "LED unregister!\n");
h Q( a6 I; v6 g5 s1 Y' d) ?}
: P1 W0 J1 b/ _( u& ?
: ?1 K% ~6 v; i+ Qmodule_init(led_platform_init);0 I4 N, a! j& P5 J& ~- v
module_exit(led_platform_exit);
H. V+ d& C3 G2 O I6 l6 s/ |: Z7 |# z. w1 @ l# {
MODULE_DESCRIPTION("Led platform driver");5 O5 V, {4 B+ S( T# W
MODULE_AUTHOR("Tronlong");
; V ]' W& L! {- F. B, J& ~MODULE_LICENSE("GPL");, d7 }; f, O5 `3 i' ]2 N5 p
& l& Q9 Y O+ ?/ Q4 T5 r$ P- ^+ \ |
|