|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" i: b; D; j9 r" F/ c+ m/ j+ ?7 y
#include <linux/init.h>
+ F* I/ v$ H( b3 i V0 ^; r1 B$ R" t9 [#include <linux/module.h>
( J" H( }/ A- \- X) C8 A6 u4 f#include <linux/kernel.h>1 D+ T, k1 i9 l) f. e
#include <linux/types.h>% s4 @# b# m% {. ~, M. d. A
#include <linux/gpio.h>
0 E; j: y; o& Q2 s, w2 M" H4 A5 r#include <linux/leds.h>
0 t. e" H: ~7 n) j#include <linux/platform_device.h>
' |) i% O# L& _1 a4 j b
. B5 U, H, G3 w; c9 }5 Y7 o. J L! v#include <asm/mach-types.h>
; G0 l# Z. \3 [: u/ {! O#include <asm/mach/arch.h>* L# Y' H$ U, j
#include <mach/da8xx.h>9 \9 l, l0 K; D
#include <mach/mux.h>
( j3 g' q% B+ m2 }- Y# P+ L) {% z2 g
9 s2 `/ [1 \( P8 r, w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' p1 _2 q ?. X1 t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( m6 ^3 s( {) k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- E ^4 W$ r) U; ?3 x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- R- z# k. s: \% ^
3 t6 t$ j2 k' |, l! Q+ y. j/* assign the tl som board LED-GPIOs*/" J) s' T0 B/ B3 \- t/ P
static const short da850_evm_tl_user_led_pins[] = {9 [& V' X& A4 \
/* These pins are definition at <mach/mux.h> file */; m+ p$ A) U6 B8 ~5 B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 g( j/ P. y5 \/ l5 U- a6 m( ^, C7 M7 d
-1
' G; k9 q1 J K" p4 j7 B};
/ ]9 o0 b% o. |. Z" X: F/ v' J) E$ P- h0 x6 F9 P
static struct gpio_led da850_evm_tl_leds[] = {
* G6 c1 [ o g; v# q {
. G+ J- ]5 Z d& ]) [! D& s- V .active_low = 0,& A3 A! M2 `7 D s2 {+ J
.gpio = DA850_USER_LED0,
; z& Y8 \# C! D( ]8 x# Z$ W .name = "user_led0",
- N4 w3 p+ y% C ~) j; V .default_trigger = "default-on",, Z3 ^1 Q" d" z4 ~' B( q
},
& `" N) a7 S: a; K {9 X" n* x( a/ k" a
.active_low = 0,4 s4 W7 E' e2 y8 M! ~
.gpio = DA850_USER_LED1,
% K+ R% P, S7 I3 B9 p S- k .name = "user_led1",& t; O+ m5 d+ v* a
.default_trigger = "default-on",
; b( I1 w# v2 p2 S },, h9 n" I3 U2 T: ^7 T$ N2 U: y
{% ?+ B9 b, d: ^
.active_low = 0,& @8 P& T& ~5 i A+ W, g2 k
.gpio = DA850_USER_LED2,
R" C9 R# j3 x* y! {2 J .name = "user_led2",/ @7 E7 N5 Z% z2 _8 Q* \4 y
.default_trigger = "default-on",' [- R" S2 c4 j2 T# w/ A
},/ w; M9 Z9 @! ?% N3 |
{7 l( [; B A% ?7 a1 K
.active_low = 0,
5 _; q3 Q, B& Q! T+ y* L6 D) _ .gpio = DA850_USER_LED3,! C( x+ ]4 F3 x: R- F
.name = "user_led3",
$ Y- k* \7 R! Z .default_trigger = "default-on",- K/ Q" J0 ~& C! K
},
! ?( L* N8 b7 d/ R) l8 w% z};
% W. H6 X3 k- I! p7 G% _0 T/ v1 x9 ]; _% b% w! V8 t! ^1 J7 j' q4 `& z+ q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 A8 @2 O, q: G3 A8 y, K .leds = da850_evm_tl_leds,; @5 m" A; H. e$ Q8 k' N. K
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 n1 r+ z/ e/ i( u$ [- I
};
$ u8 r' q6 k: P. J. i N. L# N- ?
& B' l+ v; ^7 J0 |4 m9 istatic void led_dev_release(struct device *dev)/ n: Q& T" O; \; K. e4 S( k
{( I6 L0 x+ G. I( ~
};; C4 ^" e. ^6 B F0 {- n1 P
+ n4 |- ]: w% W0 f9 W5 k/ ystatic struct platform_device da850_evm_tl_leds_device = {
6 x! N9 C1 z n h$ [ .name = "leds-gpio",
y5 R! G. n; z T3 m .id = 1,
4 t& B" G3 P) F& J/ t- e$ O .dev = {
- K9 N1 f% m$ b L' s/ l% u .platform_data = &da850_evm_tl_leds_pdata,1 i$ V* T6 I6 r. |6 J( P- k4 p
.release = led_dev_release,- l% M5 |' m+ j8 C2 g
}+ k" ~7 L* W! h% _/ [* m' F
};
0 W) @. q/ n9 q% {0 \/ d
4 i& e! z# ~5 S" mstatic int __init led_platform_init(void)
& @9 W8 y; B' J" I* r' Y{/ l& N/ g/ s" w! j6 `
int ret;5 ~' k5 u) \% q6 `
#if 0
6 j. _# a/ p( Q% U& P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: Z( {) D" L+ |* Z if (ret). x4 W- d- R) t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 J2 J6 b1 r% p: H
"%d\n", ret);
3 _& U8 l9 D& ?' J0 _' `( L ^0 V#endif
$ o, ~+ V& A( m8 i( E% C G ret = platform_device_register(&da850_evm_tl_leds_device);! B, s& G3 N" o( K; `, l
if (ret)* q3 j; n% r1 r. B2 H: l
pr_warning("Could not register som GPIO expander LEDS");
/ ~- S8 }# N. T" v. ] else, ?! H- v V& x, V
printk(KERN_INFO "LED register sucessful!\n");
/ W3 _; G/ n) Y- b3 I( P
; f% ]* L/ P$ |3 C( c return ret;
" ~4 Q( K% e5 f5 X1 F}
! L! u1 `6 Y. H" y2 I+ p1 L7 P0 l3 U8 ?: Z
static void __exit led_platform_exit(void)
% g1 r6 @2 d# a* h, F8 q{! S3 j/ D; j* T$ S( E
platform_device_unregister(&da850_evm_tl_leds_device);: D* T0 @1 _+ \, y0 P
+ m. O3 a K8 r( V printk(KERN_INFO "LED unregister!\n");# |& l* ?3 {. ` A
}( r5 ]5 x( ~" d" J5 `+ f
: V! F, A& p+ v# M+ s3 \7 V
module_init(led_platform_init);' n. _/ Q0 G5 n p- U ^9 G3 O7 s
module_exit(led_platform_exit);: V4 Y# _2 B8 |+ z" m
3 ^5 Z7 p. o* K( B' @MODULE_DESCRIPTION("Led platform driver");
6 ?: k2 Z( ^$ cMODULE_AUTHOR("Tronlong");
, X# a! ]3 l3 J; C! u7 ^MODULE_LICENSE("GPL");
, _, `3 ~8 N/ O! u% Y6 R! q
6 Q* q" r! S: u4 x' C- t3 [5 N. t1 q |
|