|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- b4 w0 _7 ?9 r/ M9 T#include <linux/init.h>
7 b* f, e8 e1 W5 {6 P* t#include <linux/module.h>& V/ }6 `* ^; T2 }5 V/ m$ u
#include <linux/kernel.h>0 q# m& f. e: c* O' `0 M
#include <linux/types.h>
2 j! k7 v1 K" H5 O: a#include <linux/gpio.h>9 d' d) W4 `: n
#include <linux/leds.h>* j& W& K# P! E1 a
#include <linux/platform_device.h>
% F1 O' {! t/ N- v B( S1 ?% f5 {$ L1 @7 n0 O, n# k8 E
#include <asm/mach-types.h>
1 R0 f8 j' }1 i5 O#include <asm/mach/arch.h>
+ S- u) j0 h7 _, h- a2 e* H3 H#include <mach/da8xx.h>
$ S( Q) s$ |( Z5 W& z, y4 S% I#include <mach/mux.h>
0 p: {0 C0 e1 p4 a S& j- _- P! w6 ]5 |8 z% {
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ D7 N5 ]" U' w N: C" G5 t! d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! u0 @1 m8 {8 H- L/ K8 d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% L F& ?# v! M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( U& H" N/ n/ S# h: n
2 m! y @: j1 [) v% J/* assign the tl som board LED-GPIOs*/7 O# [5 W7 G& l3 H7 d* K2 p
static const short da850_evm_tl_user_led_pins[] = {' U* o, t# C) E' k- Y
/* These pins are definition at <mach/mux.h> file */
8 Q! ]* I# r3 n+ n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- l: ^# `' Z% U5 O2 r- l1 b -11 i+ ?: [2 L O( K9 R" H0 F- v3 f
};! H, a l/ g- v' ~. `6 B7 E
% e5 l% D& D3 w: V3 O8 ]9 f+ t+ \% \static struct gpio_led da850_evm_tl_leds[] = {
; E7 v- m. ?7 I- `; ~# G4 {) m. M {' w/ y* C9 i- N4 O0 U% M
.active_low = 0,; F) A2 q0 z+ N8 g! c
.gpio = DA850_USER_LED0,
- h5 c; f5 g& S+ N .name = "user_led0",
- V, n0 f& Q7 p: o7 h7 r& S, [- R .default_trigger = "default-on",& H% W: Z5 y6 U/ e/ n
},
8 d) R4 O2 r9 @ a {/ q1 I0 w& M6 {& v6 i
.active_low = 0,
1 d$ u* @( {9 g1 D& z& S* A .gpio = DA850_USER_LED1,
7 y# u6 \% @3 {. p; l .name = "user_led1",
* d) l/ ]9 J) T0 j( A3 @ .default_trigger = "default-on",& h& G7 P/ ~+ Z* J6 c% J, ~
},
# c, H! `/ B) B! B( G! V3 R# Z {7 n9 |' u! G$ t6 }/ m* N8 P: m5 O
.active_low = 0,
& J. }) J0 y8 S: `* T D .gpio = DA850_USER_LED2,
9 L% e) q* ?. w' `1 e9 Q5 c8 ~ .name = "user_led2",
+ ~. {$ U3 ~+ q9 w" R# } .default_trigger = "default-on",9 g& u/ @. l. N- s( f
},9 p4 X, p# y& J R1 q! L' c& H
{
4 {" t2 H- w5 _0 z/ M4 `. C .active_low = 0,7 [3 u3 L7 P+ P0 e* f# ]
.gpio = DA850_USER_LED3,
$ F: ~4 W2 {+ v .name = "user_led3",
* N. j' \% X& @8 r) c5 u$ Q' F- w .default_trigger = "default-on",! j) g S$ i. T
},% I7 E, x% u" H& n
};
0 s( c0 w, L+ Q4 Q% Z9 D
' f) ]; a: P+ d- g" nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 J/ z6 R: w" @ .leds = da850_evm_tl_leds,
+ U( i+ D- r( S4 I l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) P, q2 y1 U) t6 w# C
};
: g! b9 b" _5 {* E p+ w- a/ s& x+ }/ g5 U/ T0 G9 v& c
static void led_dev_release(struct device *dev)
0 P+ }. A3 Z: W6 i0 _6 ?$ e{
; ]+ ^9 X$ y L" B- `- W9 B% M};
$ j( s H0 Q; o# ], O! q7 p1 y" i0 S# M
static struct platform_device da850_evm_tl_leds_device = {* [6 V# E. r7 n0 P* b
.name = "leds-gpio",6 R6 ]5 j) l. e2 I) T
.id = 1,2 o6 h; C( R; A# W1 F* n) V. f9 Y
.dev = {- S' {# m( g% b
.platform_data = &da850_evm_tl_leds_pdata,
`# H# ?+ m; Q% `6 l/ g* n7 C .release = led_dev_release,9 q2 }3 A7 V, B% u
}
/ a% \- W7 H) q};' q5 W% f& d: P; L
& `! V1 {9 j. N, a5 lstatic int __init led_platform_init(void)
9 X+ ]- q4 R t4 p8 X{: |0 Q9 ? E3 J( j# m( I5 t
int ret;) Q( h1 z8 r8 E5 v
#if 0
# ?& x# n. a; ]. X! m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 {- x7 R1 A0 @- D' ` if (ret)
8 Z7 w( Y: h4 U# r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, a! e2 a( }) `, w @ "%d\n", ret);# E0 b7 e6 V8 ` [" {% K7 l% ]% L
#endif/ e+ ~! i; d# ]- O0 S9 p0 j
ret = platform_device_register(&da850_evm_tl_leds_device);
' p$ [" Q4 R8 R/ ~7 K! T/ y if (ret)
4 T: Q/ I1 ?, K pr_warning("Could not register som GPIO expander LEDS");
g% M1 G# o1 E* X# j else
8 Q5 |* L9 w; y printk(KERN_INFO "LED register sucessful!\n");& J8 G" W: C- Q4 ]
4 m9 C' i: i9 p: E- K* f return ret;
! `( H, i G: Z8 k0 E! ?}
9 A4 d4 P, \! |, U* r' W# w- a b: u$ [5 X
static void __exit led_platform_exit(void)) E) x% x. r" k4 F$ W5 a; |2 X
{* ~1 ]9 F; Q. \4 s6 w' K" N# r
platform_device_unregister(&da850_evm_tl_leds_device);
- h4 I* Q% j( A$ E3 J1 o7 N) t$ }: h4 p
printk(KERN_INFO "LED unregister!\n");
( k% q6 t9 E7 o6 T! L+ T& G9 C}
! p4 ^+ Y+ o* B C" o2 @$ S, q4 X* a3 Y5 l+ a# H
module_init(led_platform_init);5 g/ M7 i: U3 j3 b
module_exit(led_platform_exit);9 C; r p& E; l8 G5 f( C' L
/ h/ B# X+ ^. ]; a8 r, ~2 }
MODULE_DESCRIPTION("Led platform driver");
; e- d( k, O9 `9 _* Y& QMODULE_AUTHOR("Tronlong");
" D& c5 s8 `$ M: T0 o% {% L. y' |: `MODULE_LICENSE("GPL");/ w0 J: l' j; ]8 `6 X1 r
1 ]7 Q; k1 [' K& L* V* M
|
|