|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 C' _. ]# y# ^, `
#include <linux/init.h>0 K% h, l4 y0 j. c
#include <linux/module.h>+ L# t$ W$ m' N- H$ P
#include <linux/kernel.h>
R' r- Z+ n2 q. V! j8 s#include <linux/types.h>6 M/ D: I3 E Y2 b$ t+ q% ]- u
#include <linux/gpio.h>+ x5 v+ N. p4 x* O# ~) b) _
#include <linux/leds.h>0 b. ~/ u l: V6 s! b6 E f5 w
#include <linux/platform_device.h>
/ H0 `- _& D: W3 G
) K' X2 D; T9 g8 c: R#include <asm/mach-types.h>: }2 Q( Q7 R# m5 [3 a/ }
#include <asm/mach/arch.h>
) T! D* f/ H8 V( p! d#include <mach/da8xx.h>
( { ^' q. e( n% I6 }( W3 E$ w- v- `#include <mach/mux.h>, u4 U/ b1 K0 U& b
/ a! h$ V% Q5 }0 v* Q( N. ^7 D7 Q' Y5 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( F5 V/ e% T/ v0 q2 }1 q8 A/ Y3 @4 P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' s# b9 O: p z1 N/ E% i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 E7 @4 ?( V; K# ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 w2 h, Z P. @7 t
' `% Q( a" @# S( G. A; r/* assign the tl som board LED-GPIOs*/
0 Z) r* P3 m6 b) c# ]8 u8 P6 Dstatic const short da850_evm_tl_user_led_pins[] = {
& d& b; G' R8 L /* These pins are definition at <mach/mux.h> file */
! n7 }1 S: u: X/ ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ p$ {7 B" f# s -12 z( _& a* |4 ^% P
};2 R- r5 w& }5 B
V5 c! ]2 s/ @( Gstatic struct gpio_led da850_evm_tl_leds[] = {
c2 ~0 L+ a; S% L* e A {$ B3 v9 H- L7 u' M- O7 h% `
.active_low = 0,$ g7 j( X( f% s S
.gpio = DA850_USER_LED0,
* M$ r% L: a5 f6 N! h .name = "user_led0",2 e p+ t% F8 E4 I; S ~' ^
.default_trigger = "default-on",
2 Q, Q4 C8 i3 X' x& h; ~; _ }, j0 E# G1 F) n+ w
{: j( U( D" b0 A; \6 }- L3 w
.active_low = 0,
( F4 r# L+ o# ?8 r/ N X0 k .gpio = DA850_USER_LED1,
4 m) g% L6 ~# p .name = "user_led1",
0 H& q4 u& C9 S# g .default_trigger = "default-on",
; Z' {2 E ?! \% S },2 s2 N. s j: V
{- b C6 O* u- V( n8 R' v& V$ ]/ J
.active_low = 0,
) ], B3 u% L9 T/ p .gpio = DA850_USER_LED2,$ X3 T4 R: L1 v2 H$ ^% E9 \; q/ N
.name = "user_led2",, @ W9 i% i3 o8 k% H, }4 `2 ~# p
.default_trigger = "default-on",$ Y+ y( Z$ s( u5 g9 B- v8 Q) j* Y
},; b2 }8 r: |! g O7 f( U
{( U4 i" k! \& {6 {7 J5 Y$ M6 t8 P
.active_low = 0,5 x6 s h9 Y1 H2 F! W7 q T
.gpio = DA850_USER_LED3,9 w! ~) M6 Z; Q& f" O4 E f% |
.name = "user_led3",7 h7 P2 r- x9 y, E
.default_trigger = "default-on",$ j2 X- z! A6 o1 h, F
},
/ _- @' u K/ \/ @# a$ r% x$ \/ ]- v};" y" L- h: C& {/ j7 [
6 b8 R l! e8 i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( C! B. e- ^( T5 F
.leds = da850_evm_tl_leds,
7 I3 s5 ?( T$ F7 L9 q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ `; [: O; @2 t/ ~, {3 R4 Y6 }
};
5 |% [" V1 Y) s, F- ^$ h( j2 \' Z0 `1 \6 ^8 h
static void led_dev_release(struct device *dev)' c3 I. \2 B6 }2 R
{3 O" n/ }4 y+ T+ F
};6 _/ Y" E4 k$ t6 S% Q" {% R
! B- Z# M# q# O6 B' }$ @9 _$ h1 ?+ e7 r
static struct platform_device da850_evm_tl_leds_device = {
; m" c( i% u3 l7 @ .name = "leds-gpio",* K0 O4 p s2 k, @5 X; b
.id = 1,1 d7 |# L0 }9 X( X
.dev = {" ]5 Y t8 ?9 I& P9 [ {
.platform_data = &da850_evm_tl_leds_pdata,( ?8 d! s% E! J4 X+ h! K' f
.release = led_dev_release,
( M! d2 v" L. \; F }
4 _4 F! f( k7 R4 u, k};
( p- c; D" `2 ^5 r8 C
/ w- x o+ v6 \; Jstatic int __init led_platform_init(void)% n$ b5 O H! ?0 e ]
{
7 L6 D' S$ K. `" v. f; z6 N int ret;
! o( y$ v' R7 K. C7 v; N; v#if 0
4 O8 o6 g4 i2 f' G( B5 K& Y* M" R1 b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ Q+ T0 p0 |' T1 ]) S; P; ]% D! ?
if (ret)
% k0 Z7 j' n8 V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% A7 x% {# R" Y
"%d\n", ret);
. f' g4 ^9 ^) k4 B# S6 }0 `, S! o# V#endif
, S9 n/ H2 B3 s w) i+ Q# @ ret = platform_device_register(&da850_evm_tl_leds_device);$ b, Z6 h r/ Z% b2 l
if (ret)
8 @$ t: V5 G3 \0 e, n pr_warning("Could not register som GPIO expander LEDS");" k! K0 T1 @9 f1 l) \, W0 d" K& m
else* {$ L( [. ~: j) ?1 h, S' i
printk(KERN_INFO "LED register sucessful!\n");, A0 `. J5 o+ s' I) P( O" G
- \1 d3 P4 v/ A8 ~& [* k% d# Z) {, F return ret; o" P: t* b% l+ ~/ O8 {% D
}
& d) Z8 w# t0 A
$ W- l) T) Y5 {, x. ?. ~" `2 mstatic void __exit led_platform_exit(void)
+ G( C! Z; h9 e W{7 k/ e; h' S9 q2 b2 t. c4 C/ ^
platform_device_unregister(&da850_evm_tl_leds_device);
3 J1 x- f8 q* ^; m: W
T# k6 _* J( P9 q! S- A* F- p2 H printk(KERN_INFO "LED unregister!\n");
+ A5 x/ f8 s1 p, Y' ], f7 O: P}6 Z9 p2 Z' o2 K7 \8 J& u& ]
& r; J6 X$ g6 ]! H" R' Lmodule_init(led_platform_init);
/ n. O+ \) a9 P) k+ g) Z# p! @module_exit(led_platform_exit);/ H* @* g- s/ }# [: n _
& N& r0 [, h- L0 W* a. q9 E( WMODULE_DESCRIPTION("Led platform driver");
2 V1 E' P4 }+ ?; OMODULE_AUTHOR("Tronlong");' L, W6 o' Z- }4 k: h+ ]* o
MODULE_LICENSE("GPL");
3 C. u7 O/ H4 r/ t! y3 K8 F$ J) z# _$ A/ R/ [; j7 B1 _
|
|