|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" {" R2 x2 a- D! c' k#include <linux/init.h>
6 c+ l+ [; t' S: }7 q, ?0 Q#include <linux/module.h>
" l! v4 F: h' B1 j( R#include <linux/kernel.h>
8 \1 K) `; ^4 `2 x3 u4 |+ H. a4 \#include <linux/types.h>) t2 ~; P. F' {/ k
#include <linux/gpio.h>
" o( r2 d9 P* s9 o5 x# b#include <linux/leds.h>
8 k) c" P( K2 g. x4 @6 B4 q#include <linux/platform_device.h>- Y+ y G: U5 O, n B, M, c
8 ]7 _6 V' }, }/ w, y& n0 w; L#include <asm/mach-types.h>
2 s2 e9 g9 e- d* q. ]* E#include <asm/mach/arch.h>: z0 y1 @* ~9 j! Z
#include <mach/da8xx.h>" \) a' K( ^' e) y, q( P
#include <mach/mux.h>
. b) Z, O7 n2 h- Y, @! O1 K8 d ~2 E6 n4 A% K6 A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 h0 o( e9 |4 g; T4 ^3 `, ?1 q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- e# W( B1 Z# k" h: ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# a& |9 w( m- V#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' Q$ `! c. k5 e7 O: X
; N( U7 t d0 U2 ^, i/ H/ J1 w0 N/* assign the tl som board LED-GPIOs*/
$ ~0 E; q N) S+ p* rstatic const short da850_evm_tl_user_led_pins[] = {
6 J$ G& p6 x% L+ m) ^ /* These pins are definition at <mach/mux.h> file */' }* [* N9 ?# R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 }3 q( O# H7 G -16 |8 j3 c9 E0 c' v
};
2 W1 M, F1 X7 a, a% ^: o, Y! U, ^7 F3 U. S* w+ @# k, o5 n) b
static struct gpio_led da850_evm_tl_leds[] = {4 O$ W2 ]3 B/ I; v4 B; R
{" w* G3 @; w7 q! M
.active_low = 0,0 [: A$ z8 l- ?+ d7 n& Z
.gpio = DA850_USER_LED0,$ C1 m* i# b2 `; j* J; K' x W
.name = "user_led0",0 u( j, c" O# U4 H
.default_trigger = "default-on",6 b) A* t* V! v" M7 d6 a
},5 L+ f6 f; p$ h* ?) ?/ O
{' G# x% @8 z) [$ [/ u, S0 f% W
.active_low = 0,
9 y K X+ T+ G .gpio = DA850_USER_LED1,
2 _. }7 x$ f# D* z+ A .name = "user_led1",
- H- O" J: K# |2 u9 \+ t+ h .default_trigger = "default-on", Q f& r+ X3 E# Z' F9 L
},
- M/ Z% @: u6 V1 l6 v. C1 d+ Y {
5 v6 @3 ^7 L+ `/ x8 K/ E G .active_low = 0,
" H! c" B( ]& b! ?$ H2 T .gpio = DA850_USER_LED2,
: Z" N; U& i* Y* M* [ .name = "user_led2",3 k* M% G! S. ~1 u0 g1 {6 f
.default_trigger = "default-on",' k* @8 N5 j; m0 @! D% q, I5 s
},
, m& t/ A' N% J( L7 A {
: I8 a" b3 ?, H .active_low = 0,
- p5 X, r! t! } .gpio = DA850_USER_LED3,* R R: ~. @* |: O" s( G/ N( C# T; W
.name = "user_led3",
$ m1 ?/ n6 \' m: q1 I5 P .default_trigger = "default-on",) D4 m3 K# n, v: ?* C N
},
6 s! m% f, x6 ?9 i};& h4 I7 }* k0 Y- o
, M1 |- M6 R; M7 Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 u. z$ W+ E( _2 Y! x6 z7 H2 M8 |
.leds = da850_evm_tl_leds,
. P7 n! U* B# ?7 `# }2 ]( Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 p9 j6 h5 B, z0 k. ]};
/ E% @1 v6 f: Y9 K" s
- h7 q& f) ~. ]5 P+ ?4 i7 hstatic void led_dev_release(struct device *dev)& [0 k4 p3 S N
{
$ q' T( _" X" O5 x* i1 c& u};
+ E& e! ?) W# S" O3 L" a9 H0 S
5 l# A' h; |: I- T! m4 Istatic struct platform_device da850_evm_tl_leds_device = {+ h1 ~% N9 Z5 v; x5 N
.name = "leds-gpio",) E! v' @( ]! A. N( q! l4 J, o
.id = 1,# J6 G8 r3 A, R" ^9 e, k+ A
.dev = {
$ p8 H3 c$ w& K- _2 ]# | .platform_data = &da850_evm_tl_leds_pdata,/ R0 R5 t2 S2 {, P
.release = led_dev_release,
& q7 F- k' q7 G4 q }
" m6 ]/ h/ M; S. f: G};1 i8 @7 D. Z$ f9 S# a8 a1 h
4 O. k& C& y3 q/ Y6 x2 p$ W; N
static int __init led_platform_init(void)
0 y- ] S$ g/ ]8 @{9 l0 }; \- [* v6 C. s
int ret;$ O5 t& e5 w1 B
#if 00 v5 I: [, @- z4 L/ s8 l) t: l- h; j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! H S7 A J+ l! J* m7 l& Y/ H0 Q if (ret)% C$ z& Y, L8 I3 a& ?. w9 b3 n, v
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". R# b2 \4 b* C# {' p' G) @
"%d\n", ret);% h7 @" C; k( C! j$ w$ T( r
#endif
, I. U1 i: F# ]! S( y5 b ret = platform_device_register(&da850_evm_tl_leds_device);+ [& d- T! e; W8 q
if (ret)7 b# K( y* A5 K/ E! P( X" x
pr_warning("Could not register som GPIO expander LEDS");4 t$ Q, c* O7 I" M
else5 b, [" e" q5 J6 i+ l9 k9 Y+ M7 v9 L
printk(KERN_INFO "LED register sucessful!\n");( Q2 q* [3 P" F$ {& C9 {7 Z9 N @
) d- q& |, a: l' }
return ret;7 o7 y5 d. H7 V3 l
}) Y4 N o8 x# `/ V1 u5 n* @
6 L9 @( K( \( Z6 a2 _" o! _
static void __exit led_platform_exit(void)
0 C6 @; |. j' R6 f% `. \{
7 O5 R. ?% }# x% U ]4 F8 I( { platform_device_unregister(&da850_evm_tl_leds_device);% T4 Z6 P0 D/ R ^2 \& `: Z% j
! D5 {6 i% p1 A& o5 ]3 @
printk(KERN_INFO "LED unregister!\n");
$ I5 t# j7 r) X \: K}
5 o; e/ k, M' t6 u5 _1 C
$ V9 w8 X$ |6 G+ x$ \+ V: Imodule_init(led_platform_init);
4 T _3 w1 i0 O+ t- ~$ cmodule_exit(led_platform_exit);
6 D7 k8 y& B: Y) c% Q3 N
' d4 q- x( G# BMODULE_DESCRIPTION("Led platform driver");
2 A7 } @/ a* F7 j# A, a- AMODULE_AUTHOR("Tronlong");
k# Z" k: d: d1 X, _MODULE_LICENSE("GPL");( a- A4 s4 x E( W1 c2 }
3 c( p# P: K; v9 |1 B2 s" l |
|