|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 \" O2 ~2 z( w$ S5 D% \) n
#include <linux/init.h>
$ ?, x: h8 `) h#include <linux/module.h>/ o8 B* w1 ?* z8 G' B
#include <linux/kernel.h>, F5 X0 v) D( P" K9 r" b4 s0 w
#include <linux/types.h>
$ T/ Q9 Z( W6 y+ p! J#include <linux/gpio.h>
7 f" x3 Y2 ]+ b1 g5 O#include <linux/leds.h>
# Y5 @7 J% U6 R" R$ T#include <linux/platform_device.h>
0 o1 j! e7 i. @1 g1 |) C
# E3 {% F# _7 ?#include <asm/mach-types.h>
* }# z: x% B, C1 ~7 w3 a#include <asm/mach/arch.h>
" c. t2 E; l q& q+ D1 ]#include <mach/da8xx.h>
$ g0 m7 n- X& X, i; o7 g#include <mach/mux.h>
1 N9 F' F0 I/ G& _; V
, T% d. ~$ ?4 H& J. R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- \# |4 B1 w# L. a/ ~% I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). M9 v( j" c9 D; h& `1 L4 e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 Q% ~- n0 M, ^" D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# E: Q0 g' Z' y U0 e9 n( n+ o, U5 _5 i
/* assign the tl som board LED-GPIOs*/
7 b: S/ E) j9 c) m- o/ Y4 estatic const short da850_evm_tl_user_led_pins[] = {
0 e5 }4 e: [7 j. P# i0 e /* These pins are definition at <mach/mux.h> file */
* M1 o& g4 g% } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" ~) S0 V8 l# w, a: y# G -1
4 _6 d* N# P, f1 E7 Z: l( b' J};2 W7 r. J2 G) d( A! {- L' I" r# _" C
5 s& c& E5 C& I2 b+ s
static struct gpio_led da850_evm_tl_leds[] = {; R& w& I. v! q; _& b. o
{
! r/ \$ F9 |8 o# e1 f .active_low = 0,) G' {! c2 {# D
.gpio = DA850_USER_LED0,# X' w' e* J M- e+ V2 N
.name = "user_led0",4 U5 p. l2 \6 F: Z% L2 e9 C
.default_trigger = "default-on",
5 R4 z# T9 p2 M+ E2 d$ | },1 f: B( K4 _, ]( _: f# K; r6 @
{
1 N0 o/ t( {5 k- U) t- L% q, ~% i* M .active_low = 0,
6 k8 |+ H' T/ t4 h, {4 l; ~ .gpio = DA850_USER_LED1,
+ b4 z2 {, f2 A, |+ o' ? .name = "user_led1",6 H g1 _/ ^7 o" n. b0 R/ ^, f8 f) f
.default_trigger = "default-on",
' E5 |& ?5 a8 L9 F4 l. _" F* g },( B4 C. W7 ^) P3 U v( x7 n' j/ F
{
# O$ |' |2 M1 |, ^5 J6 r) U .active_low = 0,/ [ m, y( M* z, r9 X
.gpio = DA850_USER_LED2,
8 {5 J5 [ h7 j/ S0 ], Z! w .name = "user_led2",
8 x; }: n7 e) k .default_trigger = "default-on",
7 }, _+ N6 Y) H* T$ n },7 a" Z' g7 K5 s
{
8 D) ]8 V9 W2 i9 [ | .active_low = 0,6 l+ b4 _9 r( d* t3 t8 \
.gpio = DA850_USER_LED3,
3 F; y, b( _( B3 H; a+ D( a6 i; q .name = "user_led3",2 o9 c; t: o9 C# m
.default_trigger = "default-on",
4 [/ H& @- e9 r( j* ~1 W) Y: D },9 h# {* Z6 ?) X y, H9 h
};
: D$ \! @/ S# c
+ R; ~' p* l1 y7 T1 W5 ] `! q" tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ N7 G% p0 |# e7 ]. T
.leds = da850_evm_tl_leds," v* @+ X- C( o1 s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 [8 ?- L! W9 w" h4 E6 |};
+ i( V/ m( V% Y, ^: v) c- u% u; \5 }. p
static void led_dev_release(struct device *dev)
: w# ]! n0 L2 C8 _% D0 A; T{1 R$ z& [9 r( p0 \& X9 n) p
};+ {1 B5 Z' x6 a& A. x7 y8 } A
# q& H* n+ U# A! gstatic struct platform_device da850_evm_tl_leds_device = {
: R, \* A# T5 ~. q, q3 Q* D .name = "leds-gpio"," S8 h# M- u3 ]8 B/ L7 z) q- p
.id = 1,
, y5 M; Q6 F- k t; J! p; N: H .dev = {- }6 U: f/ P: x% Q8 @
.platform_data = &da850_evm_tl_leds_pdata,
- \4 `. X5 W4 m, [# N+ f+ I) n5 T .release = led_dev_release,! L% ]+ N/ q2 K; A
}6 a s; [4 E% Z1 k; O4 I
};1 C) Z5 Y: _' m
6 e2 t; I4 |9 T
static int __init led_platform_init(void)+ t( R$ {; U2 I6 y3 K
{
( G6 R! Z2 M; g- ^3 V int ret;
1 ?& H. W7 ^, q7 e$ s$ d: T8 I6 a. d#if 0) Y7 A/ }3 T/ `, k$ C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: y8 [) F% ^( p6 A# m, H& H if (ret); D) v0 X- V2 m0 p8 j7 S) ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ t3 P/ c4 K- F "%d\n", ret);) \/ V; S+ z! q4 E9 \
#endif
, q& }/ @% t6 j, t+ M; K ret = platform_device_register(&da850_evm_tl_leds_device);5 X5 q7 F& T) K5 C! Q
if (ret)
: T' b; n2 w8 N# R5 l/ E! N pr_warning("Could not register som GPIO expander LEDS");0 b' p: I, W) N. H* m! o
else- G$ l8 Y- [5 l8 O$ @. ~! q
printk(KERN_INFO "LED register sucessful!\n");
7 K7 \2 W* r, |/ P3 N# `* y: [! k( A8 o* b
return ret;
: ?/ Y% w1 D% c- u" G6 }( h9 M" i}5 E3 _+ c% {5 ]5 Y5 G6 b
, _4 ^4 G* @% J2 T& p3 _- i' w
static void __exit led_platform_exit(void)1 l4 A$ {; |1 N2 A$ s9 l1 N" t9 p
{
/ [1 ~& S9 z8 X/ o platform_device_unregister(&da850_evm_tl_leds_device);
7 m8 Y5 F N/ A! B
: _' X2 Z' Z9 V; b c printk(KERN_INFO "LED unregister!\n");, p! G) e3 B' `
}
4 i3 C( X0 J& P) s* C! h r5 c( W6 E. g5 N/ U6 W5 Q3 z- R
module_init(led_platform_init);4 u' f+ W/ a, \
module_exit(led_platform_exit);1 I( x8 v% Z+ y2 a* j
* {. n# i' J$ U0 X/ oMODULE_DESCRIPTION("Led platform driver");( ]) p. x1 Z7 S9 C/ ?- E
MODULE_AUTHOR("Tronlong");; z( T% Z+ a0 B' p" z
MODULE_LICENSE("GPL");
( f% i/ X$ H, ~5 U; x$ j
) b0 v o$ L% G# U3 n4 W |
|