|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 \/ @0 R/ w3 ~2 }/ x' l#include <linux/init.h>7 t+ S, i6 B# Y, K1 H# B" d
#include <linux/module.h>, u( t* [& Q* l, j6 g7 { e8 v
#include <linux/kernel.h>
# q0 Y, e/ g$ D' j#include <linux/types.h>) q9 X( z; |1 W
#include <linux/gpio.h>, P- m* b& B: h
#include <linux/leds.h>1 U. _ y' i! b) S2 ?1 V
#include <linux/platform_device.h>
6 M! s, J' }7 t# d5 f1 k( y0 h" q3 [3 _
#include <asm/mach-types.h>
0 |5 ^* ^* d: ?2 f: P( Z7 t0 ?! p#include <asm/mach/arch.h>* f. R2 B9 l0 `4 S7 P1 G( h- c/ }
#include <mach/da8xx.h># `! @) f: }, U4 v g4 ^
#include <mach/mux.h>2 U3 R2 c" ^+ {# s1 Y" q$ @/ S
9 a* G$ Q1 I0 k# U) v1 z, M' R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) r4 T2 H- l5 e" x' r0 i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( j9 G; W" o) P6 @' r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): G1 R& v$ s _2 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); `- A6 E- {2 L: e0 L, g' e3 E- t
' d4 o0 l6 S1 t2 b' ]- Q$ }7 t: [
/* assign the tl som board LED-GPIOs*/
% y: b) [& e3 n' b5 bstatic const short da850_evm_tl_user_led_pins[] = {9 b: x8 C- d, a! Y5 Q ], e4 k
/* These pins are definition at <mach/mux.h> file */1 Y1 ~( r j+ Y6 c* N" {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 b+ }1 F9 T6 w; u. J- |6 y
-14 }0 ^! d1 g5 ^# f. c4 o
};3 U2 K/ E z _7 T; u: [
+ J- {; p4 T5 T/ n4 L0 F5 R+ w
static struct gpio_led da850_evm_tl_leds[] = {8 ?! `% ^, S1 t- p
{
/ `5 ]8 g; M( k/ Z5 k .active_low = 0,
# V0 [' T. n7 N6 E4 r6 k .gpio = DA850_USER_LED0,
' B& F a: U5 L6 C4 u% m/ J .name = "user_led0",
( P$ E$ {& }* u .default_trigger = "default-on",) R8 G& ~) P+ C+ g0 U! k1 I" E
},
# F7 c6 @: A6 E9 m& C; ~2 F& ~ {$ a3 @- c/ T U' u3 O+ A
.active_low = 0, d# E$ J6 D* I, W! ?* l
.gpio = DA850_USER_LED1,9 |% a# K, D5 ^: X0 c# z3 S! N7 i1 |
.name = "user_led1",
8 V3 O$ a( e* ` .default_trigger = "default-on",
) v+ e$ X6 t- q% h; [9 s },/ ?3 m: T7 n2 t: F- y: P5 s2 R
{3 O: h3 X: l+ J9 Y7 O# \
.active_low = 0,
" G3 q5 |$ J1 C/ @9 B( L .gpio = DA850_USER_LED2,
9 \" {" }% o* D* n, K$ Q- A .name = "user_led2",
1 q9 V& d; h+ i8 g J .default_trigger = "default-on",9 E% U X2 O9 d7 ^: [; |% V# K
},1 }4 V q" | H- X* A
{
1 t' y$ `! o( y/ ]% v, J. h* Z .active_low = 0,: h. H! v: \" B1 L
.gpio = DA850_USER_LED3,
. \. ]. _& b9 Q .name = "user_led3",% H; m7 A$ C( z, ]( H) U6 {/ L" K
.default_trigger = "default-on",! P- J) L) I0 V2 P* ~. T7 i
},
7 u( x2 [. k# Z7 Z X1 z' L6 L};, u4 k! a5 s9 a; i5 o
. N2 Z' f2 d# s0 P' D( Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& P/ c# R/ E! t0 A5 U* T: T2 j' B* c .leds = da850_evm_tl_leds,
6 y1 L$ q# G' x% J/ U+ j7 m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 ]$ K7 j- l; m. g Q* b- P- q};
( T+ b+ p* A0 U7 N2 [/ ^2 j+ |% O5 }
4 N- c8 s. _) x& tstatic void led_dev_release(struct device *dev)
6 U% G9 \* _8 x" d2 u4 J{# _- j7 j2 ^4 S( p. [# I/ p
};. W$ [$ S6 H% H" Z/ v3 {( `. Y$ W
( i. j$ q# R. N. P: o/ @, g! rstatic struct platform_device da850_evm_tl_leds_device = {
4 \" g4 D P8 Z, y! w' e3 b .name = "leds-gpio",+ O2 Z s' k5 n: J( m5 X" i! V& }9 H
.id = 1,' A- h# p* X4 |# y9 \
.dev = {9 Z" n4 H6 n5 U3 S
.platform_data = &da850_evm_tl_leds_pdata,
! T9 c; l9 \" p .release = led_dev_release,! w+ ]7 r+ r! u. q+ q
}
( Q0 |# D- }0 M$ j};
3 S8 T2 e5 X6 c& j" Z
$ c. c. y/ J; Y2 z8 F9 [static int __init led_platform_init(void)! I* L7 m# q L$ Y0 m/ K1 X
{
1 p5 ^) ~& b4 K$ G4 @& [2 m int ret;) X, H Z# L' _4 v2 Y1 A
#if 0
$ [( J2 Y0 g+ g: ^$ U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# k ^1 J8 u+ v& H: K
if (ret)9 x& I4 c4 F* k% V1 Q1 J0 I0 E! }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 k! n" ?, u' w( T5 Q' {8 u
"%d\n", ret);
Q4 b- g: L/ X* E) o8 G8 Z- `#endif
) Z( H8 J1 C' z: m, v5 E ret = platform_device_register(&da850_evm_tl_leds_device);
7 Z h3 G/ I1 W+ \' S if (ret)1 I) q/ L5 |6 S; v+ D/ |. S& w
pr_warning("Could not register som GPIO expander LEDS");
% l% d; l& r p) p- U# ^ else
; \( C6 t, `$ E& V& L" | printk(KERN_INFO "LED register sucessful!\n");
/ C/ N- F" i4 j3 x$ ~* |/ W8 H' _* T, { B2 q5 I
return ret;
* \$ J+ i+ W* c" B1 A}3 m U: \; a8 k* T5 T4 U
! b. l0 }* s. j& ]
static void __exit led_platform_exit(void)
7 H, _6 G, l8 Z3 {{, D; ]! l/ E, d; A( w, C! Z9 ` ^
platform_device_unregister(&da850_evm_tl_leds_device);8 U* {/ l0 o7 C; E# B. q- H1 {
3 L+ [4 C5 V% I' {6 R2 J printk(KERN_INFO "LED unregister!\n");
0 k2 A I+ | ^: M8 O. e7 }}
. b2 n1 ^& m; A( t) N. E- T3 o8 |, m8 {4 g6 n8 I
module_init(led_platform_init);- V7 L* K; X, y u4 e- I
module_exit(led_platform_exit);
0 e9 X# R3 P; T2 M' y6 ]% `3 V$ \; V7 [% g
MODULE_DESCRIPTION("Led platform driver");# C% a$ e: Q7 A6 c3 m4 Y
MODULE_AUTHOR("Tronlong");
6 |: X7 P0 P% U8 M3 KMODULE_LICENSE("GPL");8 @% r( o! O8 d8 \1 P# y: J I5 n
4 Y' N* e* ~9 [1 h |
|