|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ K L9 t8 l# z: A% ?" H#include <linux/init.h>
! y" u* f! L6 m2 Y# ^#include <linux/module.h>1 S7 \$ X2 m1 `% Z9 \0 ]7 x
#include <linux/kernel.h>
6 M0 d2 `& P+ T, d#include <linux/types.h>
- \& M2 [4 O( F/ S c0 ~/ C3 ?#include <linux/gpio.h>( e) H/ _/ M' S& x
#include <linux/leds.h>! \: s5 C( O @2 V
#include <linux/platform_device.h>! |. \+ @8 q7 ^5 w3 N
5 ~$ E+ ~; @9 g; P#include <asm/mach-types.h>+ C* i/ s9 N d" f8 ^
#include <asm/mach/arch.h>2 u# k+ `1 s3 s
#include <mach/da8xx.h>9 y L3 g" y5 m
#include <mach/mux.h>
: `; D% c0 o$ a7 w- A& v3 R* R' P+ o+ q9 j0 t( Q% J$ N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ j; \+ l: i7 [/ Y8 Q) {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 ~, `0 T7 d" ]8 t; ~! s#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' F+ r( {4 O" o# a! O$ r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 n( L1 P4 k. K4 p6 c/ k: T; y& P) V: P6 i: O. W- ^
/* assign the tl som board LED-GPIOs*/" f! g$ W2 ?( F- M v0 W) e9 J
static const short da850_evm_tl_user_led_pins[] = {5 |) \" e. b7 l! c* o
/* These pins are definition at <mach/mux.h> file */! c2 n$ F! e/ L6 p1 Q; B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ P2 `, b- }4 I. T
-1
- ~( D# d, y* Y# ~6 t& C; ?* G};0 [. K# Z6 p$ d* \: V
4 i4 Y8 L. S) P& i* v C
static struct gpio_led da850_evm_tl_leds[] = { `. @+ H* [+ B- [6 D: Z
{! C% a0 g7 B5 Q5 F ^) c
.active_low = 0,
4 @& k, P9 L. O% t' d4 d ~ .gpio = DA850_USER_LED0,
" C0 D/ G! _) J7 A6 h. `9 U! L .name = "user_led0",
1 C* y. x) v' o& O, a" q; I7 Y .default_trigger = "default-on",
" `- O9 s5 ]1 d$ t( r },, k9 D0 y7 \2 I) w% c2 O% |1 F$ {" m
{; Z) Y9 x3 @6 n! R" X l( W) X3 K
.active_low = 0,' V8 h6 H! G9 u& L- O% K2 o
.gpio = DA850_USER_LED1,
( \" L# C' {6 t* R: z1 z .name = "user_led1",) s d& x* _0 L; a
.default_trigger = "default-on",$ e) G( N: H- i
},. y7 k* \9 X* L& a) V) M
{. M. q- |9 U- j2 T* F; f
.active_low = 0,
! D8 g' C6 R, a6 s2 B. I/ k .gpio = DA850_USER_LED2,
7 b6 `2 E3 B: X: |3 t n: n .name = "user_led2",
. b6 L7 k- h) H( u+ c$ y, H- U .default_trigger = "default-on", ?6 R; p/ D% g2 D- p
},
) J/ v/ X, O5 \7 j {& X- b) v/ x) s2 h* P
.active_low = 0,# p* f4 {% p) k0 c% A
.gpio = DA850_USER_LED3,
+ s2 [# b4 l9 C2 Q) b .name = "user_led3",
p* h- }# y! X" ? .default_trigger = "default-on",5 M6 Y3 C% A- A$ k+ C2 G% D: B9 K6 `
},. `% ]& C1 o5 p: x" @
};( ~( q2 Z7 Z7 P8 `; i$ |2 Z
3 _- G. [ J! N3 Z" D n( z, istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ e* g0 Q- w3 X .leds = da850_evm_tl_leds,
; @* a0 v5 x' h, p) L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 R6 x" i* s# @; w};
( [( e4 j* I& o4 _0 R1 a1 }6 j( P- i% T" V- Z7 m' ]
static void led_dev_release(struct device *dev)% w7 x; v+ {, p" P$ x
{# {1 z( g" t! ]/ h6 R
};
7 S2 b$ y$ o) V* L
+ B; M. b) K- Q# {7 j4 ^static struct platform_device da850_evm_tl_leds_device = {6 S* r* u* F1 F3 G D
.name = "leds-gpio",
+ P0 R5 e' o" u( b .id = 1,2 i# y: a8 B; `( U0 W) P
.dev = {
* P/ J4 Q6 g4 P x .platform_data = &da850_evm_tl_leds_pdata,
2 S' q( X/ G& I6 Z" Q: L K .release = led_dev_release,2 k+ ~8 D5 h0 f) z3 Y: D
}
b1 C0 Y# {5 ?0 o+ I, c) i) C8 u7 m};
5 B: ]9 j: d$ U& l0 Q% |! |# A6 l% J( p: x2 E, I8 ~$ C2 ^/ [
static int __init led_platform_init(void)
6 T3 Z; J, H9 }* ~6 _' k{
2 Q# H" S* T7 b. W int ret;: F7 q0 T! j1 U1 d# } v+ k- Z
#if 0( ^/ o3 d _6 \3 W, L# d3 t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 @0 a3 H/ l; T* {2 _ if (ret)9 m6 P/ L+ y! B2 Q7 t; D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 k% t5 L0 x( y( l
"%d\n", ret);
- ~9 I$ {2 H" B% O: S6 s3 E' Y#endif; }* d# ?7 Z; `7 ~$ u* S6 M; [: R* ~
ret = platform_device_register(&da850_evm_tl_leds_device);
2 { X3 C Y: U- A; { if (ret)
2 i/ |0 `( G( i pr_warning("Could not register som GPIO expander LEDS");
4 J$ ^- E c/ b: D7 f else
8 _: A( d9 B9 Z; ] printk(KERN_INFO "LED register sucessful!\n");' ^& k, z$ f q
$ u. o% }' y0 I+ ^, D6 q return ret;) M3 H8 i! [5 `) d* t) d3 Q" L( D
}
7 E1 n1 q. b7 _
$ p) K) |# \* Cstatic void __exit led_platform_exit(void)
! a; U, H" r, k8 i* d{
) c" l7 u# T3 r! [" P" t platform_device_unregister(&da850_evm_tl_leds_device);
' n! V( P8 n1 D3 K, j* ]! T* e2 q; `. Z
printk(KERN_INFO "LED unregister!\n");
6 A* w0 s5 z6 a5 y5 t}
' q3 d- m4 ]- T" \1 Z3 \& Y/ p! J# h2 |' c( p/ g; V& g
module_init(led_platform_init);
2 R9 p) _6 ] i G" wmodule_exit(led_platform_exit);
( _8 l( u8 A) x0 v
: s$ ^. @$ f3 |5 L- c% `MODULE_DESCRIPTION("Led platform driver");
+ [ m2 O7 F+ [/ e/ BMODULE_AUTHOR("Tronlong");
5 m. g1 m" V+ UMODULE_LICENSE("GPL");
1 }- V( H0 q$ w9 E% U7 d
, S5 a# Z0 q4 r; d) n1 C7 Z$ N7 d0 c |
|