|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 j# m7 [: m4 X) Z3 l#include <linux/init.h>) f0 U5 T6 ]% C9 r
#include <linux/module.h>/ I; O1 u- F3 r# m5 ?$ J; J4 j$ D
#include <linux/kernel.h>
8 K% s* F- J' |! e6 t1 c" s: L#include <linux/types.h>
% I' t" J* F2 P/ @* _#include <linux/gpio.h>
9 G9 J- Y( m* x ^, j- Q! |#include <linux/leds.h> h$ J8 i0 h! G( s7 x% h# H
#include <linux/platform_device.h>6 f8 W' ^+ w( H
8 g: }( r- O3 |/ m& v: _# E$ ^#include <asm/mach-types.h>
$ V; x) [0 h% @( K#include <asm/mach/arch.h>
/ t! n7 G6 w+ D* F#include <mach/da8xx.h>& c; _7 z/ i( f1 F, M
#include <mach/mux.h>" ~% a& p% c5 Z, c8 h
+ I; i" y! r9 h+ N5 K+ Y. ` P9 }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' J+ R# u+ c2 e! ?' e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): y& c1 r- F8 g- ~. `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ ^. K9 e; Z. d- J( j1 j& E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ g4 C5 A) J4 D3 _ @
/ s, E; _2 F, h+ M
/* assign the tl som board LED-GPIOs*/
; G. M p0 v! g Q4 x" {static const short da850_evm_tl_user_led_pins[] = {" J- d1 N6 l* A6 B
/* These pins are definition at <mach/mux.h> file */
! m2 f/ V- U. a0 S7 t DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! o2 G/ Q1 [/ z- O p
-1$ e' r# }+ [# }1 ?+ ?
};
4 n; {$ {9 ]5 W- C# |' p, O: |( o4 A- u& W) ^3 w l# w
static struct gpio_led da850_evm_tl_leds[] = {" f) L" s+ ^; \4 D- x6 r
{
$ o7 o- C8 E' P .active_low = 0,
" o) a0 U8 W7 [$ I9 @* g* ? X0 H ~ .gpio = DA850_USER_LED0,: @9 O _: {# b2 ?% U# N9 C
.name = "user_led0",8 @4 m& v" m: ~0 X) ^' E
.default_trigger = "default-on",
: U3 }8 S2 _' ^5 O) B },- m. u# g4 b% w& N+ l# C" b9 z
{
3 I$ m1 Y' C- A& C .active_low = 0,
( g/ Z! S; ]8 n; J( B4 I .gpio = DA850_USER_LED1,' u$ y7 _6 L8 M& a9 C
.name = "user_led1", J. j5 v; o! w' D2 i) @8 |
.default_trigger = "default-on",4 R D9 c" v# _6 f
},: s4 T" ]. i% V9 l- r2 K7 _
{& Y8 R) e" T) I1 f
.active_low = 0,
7 n8 @) _2 e' g0 R' W: e .gpio = DA850_USER_LED2,
2 O; j$ N9 {0 M1 Z) Y1 H .name = "user_led2",5 L. G5 w2 ]+ S2 `, l% c' ^9 i
.default_trigger = "default-on",
. S; P( h9 G. i* m; b },' _ ^- ]; v2 x, A$ |0 J
{ k" @$ {3 `) x
.active_low = 0,
/ U% ]; C" j; H% h. }7 Y8 c) g .gpio = DA850_USER_LED3,# {4 [9 o. b% @ A6 g
.name = "user_led3",
, s9 d7 k+ x* i! T .default_trigger = "default-on",, A, p, M+ @. l4 J0 n0 M
},
9 n5 ~/ ?8 a) T% @. f};5 u7 q [% ^2 P( z! ]0 q% f8 [
& b$ m( e( g u' [( z- y# o/ I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ o* ?1 S# n% v/ }
.leds = da850_evm_tl_leds,. U8 ^9 W9 N5 ?2 f3 S9 w' a5 B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 T4 o4 v% f v};; c. w7 T! Q% X' T9 Y5 G2 [
0 A: z4 V! {: M& Z" {) V1 ?1 ^9 f
static void led_dev_release(struct device *dev)! n w+ ]0 u7 m1 q0 K+ R+ w# h+ t
{" B) q' {0 p7 h3 @
};. K' S' D3 ^6 [
. f) i; Z& x. r u% n/ ]1 Ustatic struct platform_device da850_evm_tl_leds_device = {$ E# p7 n4 Q9 D) }! ^: X; G1 N
.name = "leds-gpio",4 a6 J% {$ X4 y. g0 v8 a
.id = 1,% S& j% u, u1 ?8 w
.dev = {
, l7 ~) e( L9 x .platform_data = &da850_evm_tl_leds_pdata,
) C- c8 s/ o$ V0 {7 s# _6 k .release = led_dev_release,: v# J, R/ b/ T: H9 B
}) v" K3 u$ I( V E7 s" D
};
3 L. s$ G8 N( \( I0 n" C( t X7 Q, R2 Z% X" |7 Y
static int __init led_platform_init(void)
9 Z. I' K8 D2 d( v8 w6 m& O{
4 Q' h: E0 D5 e! G7 Z# J int ret;* a; s/ V: P5 d! e6 @& J. v3 ], A
#if 0; {9 Q4 S4 q. K, y! ]% n; ~) W- }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 `6 E5 t+ |0 ^# a5 K
if (ret)
" V; q. z5 R9 }8 O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ }, K' ^6 J& p# H( s3 O9 M
"%d\n", ret);' t: l: e; h" z
#endif
2 B7 t7 p. n7 X, A! K ret = platform_device_register(&da850_evm_tl_leds_device);
9 z7 l* |" i L1 X if (ret)8 m1 x Z; A" C1 K1 j2 K5 r* V
pr_warning("Could not register som GPIO expander LEDS");: `# t4 ]0 `' o& E
else
" ^9 r; `, |) v. K( s printk(KERN_INFO "LED register sucessful!\n");
7 ]" r8 ?! Y: U W8 O& P; y3 }9 O3 Y1 ^9 r0 M
return ret;" _! A' p5 f8 C0 X" e
}
% x' e H; p7 W- r: ]( h1 A- J6 \; Y8 k/ B, S1 b
static void __exit led_platform_exit(void)
; m! g1 S' Y( v$ N5 A{* `: b% R: Y* m# x1 B- K
platform_device_unregister(&da850_evm_tl_leds_device);
! U/ t0 B: x8 K0 r4 K" `# P' f& r6 [" B" P
printk(KERN_INFO "LED unregister!\n");
/ ]( |: q( O: C1 D}* [1 f' E7 }0 e9 L
% H. }. N1 M4 F# D- S2 z6 c
module_init(led_platform_init);& T2 f9 x: u) H' V3 ^ R
module_exit(led_platform_exit);2 `$ l% ]* J1 d$ m- }( e, p
$ X6 d8 D+ c/ b: y. k& z* i+ d+ z) zMODULE_DESCRIPTION("Led platform driver");2 s$ {% t1 R2 \. t: {) a* {. N
MODULE_AUTHOR("Tronlong");
- b( M( s& }0 @2 {. eMODULE_LICENSE("GPL");
2 S, f+ ?1 I! z) b# f5 u
5 g3 N& p% ^1 q; D) p) c9 x& n |
|