|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: x0 d4 Z$ Y; k0 d2 [% d4 q#include <linux/init.h>8 i+ F A$ I$ z2 F3 u' F( U0 h
#include <linux/module.h>
* Q4 h* x9 `: |#include <linux/kernel.h>; a z+ T* i) x0 e* G5 s1 G6 ?
#include <linux/types.h>1 m* x) |: Y7 O" \1 B
#include <linux/gpio.h>
. V, P$ T" d# ^ n2 u& k+ ~* O" H#include <linux/leds.h>! }4 Y5 _7 y8 h
#include <linux/platform_device.h> V* n" p" J0 U; E; d/ H( n- N
( [6 u+ g# P9 D$ O& P#include <asm/mach-types.h>
. v3 O1 _8 s: |6 q( j' I#include <asm/mach/arch.h>
- {: ^$ Z* X0 Y9 I3 I! u- b/ j#include <mach/da8xx.h>
; x4 g0 H6 |9 f#include <mach/mux.h>! m0 t Q' S/ s3 m4 D! b2 J" ~2 U
5 u; P& M5 n F0 a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, T" A: N. _ D( g5 r/ t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ U$ ~5 q2 a |% F$ E/ f: x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); P/ x h$ j# R7 }: ~$ K. X) S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 i4 H8 o% e% B9 B4 @2 H3 P
$ H) d3 R' X N$ u9 O9 o/* assign the tl som board LED-GPIOs*/
7 ~0 m/ C" F4 I# p0 @! \/ istatic const short da850_evm_tl_user_led_pins[] = {, i* @" B" ? h
/* These pins are definition at <mach/mux.h> file */
! Z" t+ g7 E5 O7 F1 c& L+ ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 Q& z. d+ g5 G/ R
-1
4 q' g W5 l: d( J3 K/ y9 w6 _ q! U};
. L; I8 b$ p% h% Y
( G* R4 k- e8 v) C6 }static struct gpio_led da850_evm_tl_leds[] = {( T- g2 ?# o" m, y7 a
{
) q6 @$ F+ w+ h! R .active_low = 0,5 a2 n; J; t4 C1 P" y0 m& D2 V
.gpio = DA850_USER_LED0,
* d/ n1 Y) l1 k .name = "user_led0",' H% U. m9 |: W
.default_trigger = "default-on",0 A2 r; V* G1 d
},
, \; A/ r! I7 l9 Z: t {$ P2 q. H$ p- ^, Z I0 H
.active_low = 0,! N. I1 k' I4 Z% v$ ?) p
.gpio = DA850_USER_LED1,
) A! T" n) c" I$ ^ .name = "user_led1",
+ d( k& |+ Z9 G: Y4 k# t6 X( y .default_trigger = "default-on",- _; k' V* ?- I$ ?% `
},4 F' o! n& ~5 b" q% A
{! O0 |8 E- ?' \ U$ l
.active_low = 0,9 `, G! v, G3 E' P P. |$ F7 ]
.gpio = DA850_USER_LED2,
: t9 d1 L. [6 x! u$ m .name = "user_led2",
( D# y# p- s/ [. Z1 r .default_trigger = "default-on",
7 Z9 g+ A7 |9 [ X; [7 M5 [8 V8 Y& R },5 z1 j' p' U6 y" t
{
( w' u! h( J+ y .active_low = 0,
0 B$ H$ c T# l1 I0 Q( a2 I .gpio = DA850_USER_LED3,) T0 V% F/ O& }# s# j! T
.name = "user_led3",7 \ ~; M3 y" a% t( w+ C* \" p
.default_trigger = "default-on",
) w" g0 S$ N6 t O" ^, x' ] },
5 }$ O6 |( Y% D1 X. ?* _0 G& l};
* z# m' w+ Q9 D4 X
% B" |* s# [" s/ G' Q& ~4 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 b) a( P: w m0 G7 X/ a
.leds = da850_evm_tl_leds,
, n1 ^0 D: ^$ {8 t- o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* z. R( ]% }! w% ^
};
s5 j2 d: X% H
0 o, Z7 X5 o, ]$ }, S) D8 qstatic void led_dev_release(struct device *dev)
* ]7 R* b+ q, w- G8 q{6 |- D* _/ D! e8 \6 `
};' z: A2 }$ N- W
, `) W* z6 b) Y4 V4 K( Rstatic struct platform_device da850_evm_tl_leds_device = {2 \# B, C# Z4 I5 E2 y- h2 V& f
.name = "leds-gpio",6 T5 u- H1 l( Z% g
.id = 1,2 c. Y5 ?) Y; }! I! F
.dev = {" b* @. U: L9 H0 e0 C' P' r
.platform_data = &da850_evm_tl_leds_pdata,# V* Q( H; J1 ?, M) B( o7 x7 R1 b
.release = led_dev_release,0 y# T, }% v [5 H$ b" _- a
}
- i% b# Z; S- l2 Z* F' s};+ ]0 M- i* h- G3 R' Y
/ f4 X/ h# X/ B: {
static int __init led_platform_init(void)
; Z+ P, ?# [% G* x" q+ w{
5 O) T4 e6 r+ q5 ]& F int ret;
: q r' X* g% S* f( X4 W#if 0
) h3 Q; u; s+ L4 {# [' b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% c! u$ ]- g) @ if (ret)2 Y, p( B2 b% u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# y- G1 H' |7 v" _% Y9 {
"%d\n", ret);3 n. H8 W7 X C2 R3 X
#endif! G* b( O$ \& G1 n6 u! A
ret = platform_device_register(&da850_evm_tl_leds_device);( R6 E1 n! a/ @. `
if (ret)" P" A; Y' n$ L* U1 |; s9 D
pr_warning("Could not register som GPIO expander LEDS");2 j E |5 q7 ^) y" C
else% g& A( e2 _# q# u4 y! G+ ^
printk(KERN_INFO "LED register sucessful!\n");( w }" ^0 `0 j/ g& F2 I' u
\/ l; _ l' T, j; g
return ret;9 b! j+ Z! D( M( ~* r
}: _ R% |9 f$ u5 e2 {" I; k
! p+ p k* K- C' \: bstatic void __exit led_platform_exit(void)4 f7 D. N4 I3 E1 F T; D. A- I a+ s
{
, w% L' A: y, t! z' @' ]) F platform_device_unregister(&da850_evm_tl_leds_device);
! E) g3 M& f. y* W& t$ [' k' z o) ~% [, ]( N
printk(KERN_INFO "LED unregister!\n");
* e! V8 ^' s4 |8 Q6 F' i) x) \7 _}6 J/ d |+ u% B- O
9 l: U3 t4 ?" Z! x# y e$ H
module_init(led_platform_init);0 f5 T) I9 {$ K
module_exit(led_platform_exit);
$ M2 K# |* N+ ~8 t: o- Y$ ?1 K- p( ?5 g; f, V, L: n2 ?
MODULE_DESCRIPTION("Led platform driver");
; k! v7 J# }4 NMODULE_AUTHOR("Tronlong");" q( Q" c8 b9 n1 @+ Q
MODULE_LICENSE("GPL");
_% H) {( X# A; T( q+ I
1 h$ x4 q! ^' f3 w |
|