|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 o6 j1 [( m" [+ n C! R#include <linux/init.h>' w. U: d0 `: Z5 u5 G1 [( }+ X0 _
#include <linux/module.h>
. G" c5 u. m9 @#include <linux/kernel.h>, k% r5 T/ S8 }5 ]- h4 n% y- E
#include <linux/types.h>' L. p# L: R; u- Z6 O) L3 Q
#include <linux/gpio.h># i- L4 ?# l1 d& O
#include <linux/leds.h>% Y X1 m( k5 q- H) f
#include <linux/platform_device.h>
6 `, H) ]' K: D ~+ i3 T2 E. m
' z" f! r% `; P5 k) n; U& A#include <asm/mach-types.h>
9 L P& ~7 r8 m# ^* U# K5 Y7 j#include <asm/mach/arch.h>: ^+ P: P+ j5 _- z: g4 w2 S$ F
#include <mach/da8xx.h> x5 X7 i7 V" g3 m- j1 a
#include <mach/mux.h>
5 ]6 n9 {5 i0 X* P4 J
* ]* K% A2 D# ~% N; D. U% p. v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- |6 c9 Z+ |* G5 d" P! G+ I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 B8 l1 t P& Q7 Q! b3 W8 K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 W, C% v" i! T) D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ ]: Q% n! H0 |7 z9 E/ }9 z& E/ W
* q( ?) [' @0 \( O/* assign the tl som board LED-GPIOs*/( `5 \ T2 r8 o4 ^9 G
static const short da850_evm_tl_user_led_pins[] = {
# h N9 {" E+ D% _2 w /* These pins are definition at <mach/mux.h> file */
2 x- \' i- p7 [/ z, n/ q: s$ \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. V: r4 W% E g3 o# P0 S -1) a. ]% i S* Y' l
};5 _6 Z C6 Z6 a8 l( d
( }+ t2 M2 I8 x9 X1 r8 m* o8 ostatic struct gpio_led da850_evm_tl_leds[] = {
3 U6 o, e, x" T" c8 ?! c {
& G$ X1 U# o5 h! t3 | .active_low = 0,
1 {0 D) m6 L* ]5 t& F9 m .gpio = DA850_USER_LED0,' s. }7 g) ^& ?( X& K
.name = "user_led0",
0 [) b/ f: n# A6 m3 J3 T( L .default_trigger = "default-on",
5 O. g) |% @! X2 I$ I: b+ @ },
& R9 [' t* c* |8 _/ L5 [ {+ ]0 v3 A9 R* {* U
.active_low = 0,6 V5 d6 d, z- z! G# V+ }
.gpio = DA850_USER_LED1,
. G6 H4 m8 Y5 j5 {8 [1 D$ c4 B( I .name = "user_led1",! b1 z8 ^2 {/ l' _
.default_trigger = "default-on",
1 d/ `+ H) v: d6 t },
( Z% b4 y# {; n1 G/ ]; u {! L7 P/ {+ N$ K" d# U; F
.active_low = 0,: K. T4 ]' \' q# t# e. ?
.gpio = DA850_USER_LED2,
% ^2 j- L- R4 }4 _ .name = "user_led2",
8 U& ^$ l/ \% [% X1 V6 p: A .default_trigger = "default-on",% c+ |$ d$ h6 c) @5 r1 k! I
},# z [7 t, d( e- N, Y0 J+ g$ E( Q
{5 Z3 `6 T; n. T- c$ g
.active_low = 0,
9 j) r h: V- K0 p4 K8 K .gpio = DA850_USER_LED3,% A& R3 B) |/ L8 U( m1 F
.name = "user_led3",
7 v! p% `, Z3 S1 F8 M; u* h% ^ .default_trigger = "default-on",
9 ?" \0 U7 b& d: P" D },
! p% Z2 r n) X% u/ Z3 F5 {7 [};8 t2 D4 _) D1 O" y& n
% |. {3 |5 w7 L& O4 \; m1 T$ Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 f, [+ {. W) v$ |
.leds = da850_evm_tl_leds,
2 V- a+ {8 b9 n5 j. t0 G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. y: H& }8 w- u" h/ W7 l
};" [3 ^' n. m4 X$ s" ^ W3 Z
5 y5 {" x. d% i+ D6 S: j w- kstatic void led_dev_release(struct device *dev)6 |; {1 G2 n9 O/ l0 I$ `
{3 h. k2 ]) Z- |' D1 X0 R
};
" v% Z0 _# i$ r7 ]
8 y' n [) e2 z: O$ |static struct platform_device da850_evm_tl_leds_device = {
' j+ R4 p: O7 K% _! z# M X2 Y3 b9 q .name = "leds-gpio",
+ C. Y U8 M% I" _- w8 A& i .id = 1,
# B+ S, L8 x5 O6 t: O .dev = {
+ D$ }/ c; N) P+ p+ X3 y .platform_data = &da850_evm_tl_leds_pdata, M; e' Y+ i0 e' N
.release = led_dev_release,4 D% n" p v4 s+ \1 @/ e5 I
}4 G6 @/ n6 `5 q" N5 V8 F' \' I8 S
};
: ^6 P8 p: p4 T& s% X. M+ i
% F5 v2 }" ?- f% k2 p) c9 b$ W- Jstatic int __init led_platform_init(void)
9 n, }* Z( e! D9 v8 ?7 b: x G- r{' O, e5 b# |& n; ?" s6 h0 i
int ret;. m3 q: o+ x9 s, Y2 ]
#if 0
: M+ ~9 q; ?9 _6 V6 O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! O4 G( S3 d7 k" y
if (ret)
, U' h, H+ }4 O- \; E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* x1 R2 @- R8 o: ?8 D. K& G0 W "%d\n", ret);
N7 K. i' d3 w#endif
) k- l/ b4 ^# X2 h$ D( t8 q0 C ret = platform_device_register(&da850_evm_tl_leds_device);( \! _' b$ S- o3 J" C( o
if (ret)
$ p: m8 U+ b& U pr_warning("Could not register som GPIO expander LEDS");
4 B3 u# O1 T1 G' p. W else5 s. ^7 A/ c, l0 k0 Y) c
printk(KERN_INFO "LED register sucessful!\n");
( l3 O2 I# a8 p' {# e- O% W {6 ~. W
return ret;
/ p# c( G2 y; ?0 }* E}
) s- K6 e6 J. a/ ^+ F; W" R! o, b0 B% b+ e9 P5 u$ H; i
static void __exit led_platform_exit(void)
2 x0 [# O( Z8 B{
2 A6 S2 H" i2 L' w* c platform_device_unregister(&da850_evm_tl_leds_device);- m/ x2 G' k7 ?6 ?* }! w
4 X& ]. i0 t- g printk(KERN_INFO "LED unregister!\n");9 Q" z9 E; ]% R, f2 ^+ t
}9 s- P$ F' G$ }
! `. L, n1 `) s9 p0 }- {8 Qmodule_init(led_platform_init);6 L' g: N) v' B: \; `
module_exit(led_platform_exit);
6 Q' s) a* x4 Q s2 l# \
* i/ M; w1 O! V& K1 jMODULE_DESCRIPTION("Led platform driver");& g% F$ @. V7 c) D1 \
MODULE_AUTHOR("Tronlong");( N( \3 `1 w5 \1 J& o6 Z
MODULE_LICENSE("GPL");
/ O* ?- S3 D1 L( k4 L% t5 i+ F: S8 d8 d1 @
|
|