|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, M4 I: Q& \& s1 g8 ?7 i2 o#include <linux/init.h>
3 o- f- T6 O1 Y! a6 Y6 r#include <linux/module.h>+ H1 S' v0 F2 E) O9 Q2 c) x
#include <linux/kernel.h>
8 L4 C. o( G% Z/ z4 C#include <linux/types.h>5 m- w, u' F( e! b% Y3 w+ E" D
#include <linux/gpio.h>
2 F0 {' N8 m& v0 r& E( |#include <linux/leds.h>
9 \; y! r% W. J% U, F# j0 y#include <linux/platform_device.h>
2 k2 h/ Q9 ~, C' n+ o! w
" x3 ?' y% [( c1 D+ I, t#include <asm/mach-types.h>1 ^ G9 M2 o# C% s: q; W% o6 ~
#include <asm/mach/arch.h>
3 n( N4 l6 S$ t/ V7 l#include <mach/da8xx.h>' P" w p$ y9 [. y* j
#include <mach/mux.h>$ s1 @+ ]: N$ l, D% O, ?4 ~7 m
. m) N8 a7 d# d$ n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 @6 T6 c1 l6 C% z8 U% k! m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; g2 R; P' Q/ O5 p#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ p% m( a2 M0 n: Z6 O' ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 t+ V" Y( t9 x7 K) ]$ M3 @) D6 A/ T- ^5 v- A
/* assign the tl som board LED-GPIOs*/8 S# u& t: W& J9 J+ }7 r* k
static const short da850_evm_tl_user_led_pins[] = {
2 m6 j1 X$ X* n- @5 G /* These pins are definition at <mach/mux.h> file */
& U7 P9 x0 ^( U1 ?, T7 m2 w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ K7 {- a9 X' i$ k$ S- S7 I+ ? -1/ Q6 C! v5 j/ u* e5 Y$ _" S# M! N
};
0 \4 [- `' @* h$ `- z- r3 v( n: y$ p# x2 V( Z; s
static struct gpio_led da850_evm_tl_leds[] = {
" A; f" Y1 l. n$ y {3 Q! N7 a7 l( X. {3 `1 p% e% y) }
.active_low = 0,
: d3 V. R0 A; ?# y' L .gpio = DA850_USER_LED0,! j) A2 j, S: G, f8 k/ c
.name = "user_led0",
3 s8 i& }4 n \: l0 T! n( Q( k' K .default_trigger = "default-on",! {3 ~$ S; B% @; t$ z$ J% Z
},' s% S# f5 c# i! z; ]
{+ }4 H# C4 Q4 b U* h' U( u
.active_low = 0,* e1 y: I6 f* k3 q8 L
.gpio = DA850_USER_LED1,: q- M' J/ q- }5 X
.name = "user_led1",$ R" T7 _& h5 w3 P2 \9 I
.default_trigger = "default-on",
( k/ o$ I& J8 ?) }5 ~ },3 ~' q7 Z) ^% \$ N9 T |
{
. K' `0 I$ X% m( d .active_low = 0,. L; U: h2 B0 h2 c
.gpio = DA850_USER_LED2,. S8 ]1 n) h' o2 E/ a! r3 @; ?) A% W" }
.name = "user_led2",
2 A8 Z7 M! }: e .default_trigger = "default-on",* R( n. [3 R. B' z
},8 R4 _3 L5 p U7 [
{! }% V5 c2 E' W, }4 T
.active_low = 0,
2 p5 t( b9 Q: {) }0 ] .gpio = DA850_USER_LED3,8 v; U- T! T9 p5 W; Q$ v1 w$ V
.name = "user_led3",1 l, G* ^+ V+ F( A) Z) {0 d. a3 M
.default_trigger = "default-on",
4 \; u1 s$ L x5 b( E },
% z) Z; [$ U& ? ^! Z6 [" t. t# m, S9 }};
, {" p1 B ?$ Q" n
Y: n; E% Z! Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; n0 h' T$ s" [, F; ~% u .leds = da850_evm_tl_leds,
. e6 y y0 b7 }% w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 ]2 W0 _/ K) C$ a7 v8 a};2 Q1 O% t5 x6 K5 K" a8 @1 k
8 L) I1 l/ I" C) S P0 _
static void led_dev_release(struct device *dev)- }8 U2 F2 }5 U# d, d
{
3 @8 y$ P# ~9 ]; w) \2 s4 m- a};0 A/ K1 r1 Z0 _: y% k1 f9 _
1 k$ Q, J0 O/ }- Z3 Q
static struct platform_device da850_evm_tl_leds_device = {
' f- [" o3 a, a" D/ z .name = "leds-gpio",2 `0 e4 Q: ^% ?: p Q
.id = 1,5 w: G/ W( y# b/ q# q
.dev = {# N1 p5 B0 {3 X5 q( t
.platform_data = &da850_evm_tl_leds_pdata,( k. x' C0 M) g! B4 M
.release = led_dev_release,0 ^) g3 ]6 V4 G& s/ J$ N
} A8 U. I* Q% r* Q# @! h* m
};$ f! E9 V; d4 f
8 V0 \; c# Q7 n5 Bstatic int __init led_platform_init(void)
8 A3 m/ z+ r9 _. R{9 w* J1 M0 M; A) G9 g
int ret;
$ X0 y9 J5 n8 O+ P( a( g( W#if 0
* r1 ` m, ~! Q/ b# q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 W' _1 x5 |. @/ H; L, I0 l) ? if (ret)9 o! a" I5 a; P( z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# N, p [) X6 s( | "%d\n", ret);
/ Y3 Q- @5 w" ^9 E% [3 a7 _#endif
8 Z3 G5 c) _! ^' l8 ? ret = platform_device_register(&da850_evm_tl_leds_device);
# W% x: {4 l) K; {/ \ if (ret)# N, v: Q- R8 s9 @
pr_warning("Could not register som GPIO expander LEDS");& ]" E1 I8 j0 `1 t p
else
# X8 N" d' u/ Y; R: i9 S$ C0 } printk(KERN_INFO "LED register sucessful!\n");$ f- d# Z' Z( A
. n' I! r2 j% B# d
return ret;
; V$ A& U1 a0 [& `}
+ s$ L) [& A' g' z; Z
* K" x2 j! L7 x$ g" Estatic void __exit led_platform_exit(void)
+ @0 I9 E% C, F1 [5 z" A{. t( L; V9 l4 X/ Q$ g4 d
platform_device_unregister(&da850_evm_tl_leds_device);; J( f+ o( z+ }7 \" {3 n
; a) _" [8 A: C$ A printk(KERN_INFO "LED unregister!\n");
5 y! W: a" b3 n- o1 s}
" i+ W) G: p0 d- D0 O
" ~. R3 f, M" n. E6 ~3 c1 q7 Vmodule_init(led_platform_init);4 {4 }8 A$ r) @, L" ?0 @- _1 w6 T' ]8 U
module_exit(led_platform_exit);
5 @5 f) y# A4 C6 l9 z8 w' {) R" S$ w, o5 A* m( b' v, R# Q3 ]6 t
MODULE_DESCRIPTION("Led platform driver");/ a8 b/ ^7 k9 e, F6 X
MODULE_AUTHOR("Tronlong");
4 w! C5 u, {9 C; X$ Q* yMODULE_LICENSE("GPL");' Q1 P8 w5 [! G7 m; j& R4 S0 f" o
1 u; m( X M0 e6 T0 B% T+ J, P |
|