|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 O2 r" B/ P) G2 ]1 Z' F' ?
#include <linux/init.h>3 a. Z+ }8 z# c
#include <linux/module.h>0 \6 h6 p; b3 A& v; K
#include <linux/kernel.h>
# b9 ~9 E% E0 O0 E& P6 Y#include <linux/types.h>- |# ?2 G( T% T
#include <linux/gpio.h>
- {6 `" n1 G: y- ], c9 V#include <linux/leds.h># g; Y* p( ^8 V0 n& [
#include <linux/platform_device.h>
9 b. x7 C5 ^& {0 f5 ]1 \, l8 V- N- J R
#include <asm/mach-types.h>
! u2 L7 ~( ~" l- h#include <asm/mach/arch.h>
# U1 }: Q' }8 d5 U#include <mach/da8xx.h>
0 h1 }" M" X) P' f#include <mach/mux.h>+ r9 n8 G( C+ ` Z3 J0 N
* a, k. V8 Y% S! @9 k9 _2 _: O0 T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# e" I1 Y& l {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' s+ {8 f; e+ C1 Z( N1 p A0 v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( j( k- J% I8 Y' h* _8 _& t) y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 X" q' _: \: D( k5 g% ~
" E- Z$ m8 v; l9 e0 K u
/* assign the tl som board LED-GPIOs*/
7 ]4 {; p: Y+ L( ^9 Z" ^static const short da850_evm_tl_user_led_pins[] = {
[' }* B; L( p" q /* These pins are definition at <mach/mux.h> file */
, P! E4 F/ Y j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" o1 }3 i+ F h5 i( _9 m2 V% ^# [9 O -1
0 X. S; [* }8 ?9 Z% q' S; J! v};
* C* M: r* c9 `) s& S
- n& R$ @2 m8 H! W5 Ystatic struct gpio_led da850_evm_tl_leds[] = {9 Q3 t+ J1 J0 _0 n/ W
{
& M& [9 m0 Q( k .active_low = 0,
$ Q. Q6 f7 w: b) `. Y C2 l .gpio = DA850_USER_LED0,
6 \$ d n/ w( m. U9 b, W* T7 V .name = "user_led0",
* \! L7 d* Q# [* U( g4 C .default_trigger = "default-on",- V2 Z* C/ A- c8 s7 Z6 m
},! U. B* t5 g+ H! J
{, [6 q' b3 Q( j# M# y3 E/ L, F
.active_low = 0,
; q$ G7 ?. L% S4 H+ ? .gpio = DA850_USER_LED1,
0 l9 a3 w) y. p( |* y .name = "user_led1",
& l8 c# B1 _6 H; h* x .default_trigger = "default-on",
" r" X' `' Y; s- B },% p" H7 k0 Q/ K0 ^* X9 l8 J
{
8 K+ u! N: R! \# |- N .active_low = 0,4 @1 r' N8 c4 b( {) K# }
.gpio = DA850_USER_LED2,9 J0 u4 s4 k0 Q
.name = "user_led2"," V. d( u, x! _5 ? B1 k% n
.default_trigger = "default-on",
3 x! z" U3 |$ I, c x/ @1 g2 | },
; z+ S! V# I2 D6 } {8 N5 _% Y) p5 s' i
.active_low = 0,+ d9 u# N2 d, ]5 r
.gpio = DA850_USER_LED3," M4 h1 {( U c& U, ^% k
.name = "user_led3",
- z: ^' t; N( x7 K+ g5 s8 E .default_trigger = "default-on",/ n( G# N, b5 Y& @4 y7 Q( f8 @
},9 j# O! w' T4 x! k
};
7 g+ y! O5 s; x) A( Q2 N
) E0 w% Y1 G6 U" h2 h* s+ Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ K3 [7 m) a9 G" {! _# d .leds = da850_evm_tl_leds,4 V' x C. q; V( D* ^ R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- W1 e& U% k3 Q6 H, h4 {};
2 H5 D6 Y) h5 X- A- ^
2 n \" A# O. ]) ]1 U( Estatic void led_dev_release(struct device *dev)
/ C, k6 H5 C5 f/ c{
& `7 X( d, n* O4 l% k};, [- B9 l$ { q. v: D0 r" y
1 P( k% h. g7 W, k5 i" B4 g: k
static struct platform_device da850_evm_tl_leds_device = {/ a5 w( i' f+ C# s6 l5 U, t
.name = "leds-gpio",& g+ U% v& P8 }5 F
.id = 1,
6 k" f1 [4 P( e% ~, d .dev = {
# B. D8 F# M) {' O .platform_data = &da850_evm_tl_leds_pdata,9 P2 X$ _2 v9 X# A
.release = led_dev_release,9 C3 q- k( m0 [& a8 ^" I
}9 l, l" f' q, k4 U7 H# S
};
+ p7 Z. @: H* m$ G! v( g) \; U( Q8 F
static int __init led_platform_init(void)
- G4 U+ T9 Z+ ]/ |1 h* G1 U{
, V/ a! M( h* z$ a8 s int ret;
+ i$ i: f& E! J. q#if 0+ d& a# n2 ?, J; V8 Q* _- ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 M1 p& K. l" @* H: j. k
if (ret)
% o) h( B" R' N( S! b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' Z4 k4 B+ B1 R$ A& u+ F3 M# h1 w% X
"%d\n", ret);6 Q8 Z, l0 D3 Y5 p8 E' G% J9 Z
#endif
8 M" a5 x. K. t& M" } ret = platform_device_register(&da850_evm_tl_leds_device);
, E. u1 T5 R: p \- b3 `4 [ if (ret)
$ d" e) }: K# P7 U pr_warning("Could not register som GPIO expander LEDS");
( ?3 e* _; t) ?, M8 H% I1 Q+ o else% H3 _* b! S7 j3 s% @
printk(KERN_INFO "LED register sucessful!\n");
- ?; e( P; w2 n- F8 T9 g2 q( g) _ Z! `7 h% X! V
return ret;* I7 Q& n: ]3 P) G/ G
}) [, {& J$ r1 o' x
: c: }0 P+ Y- S, m
static void __exit led_platform_exit(void)
1 J3 d. C# H. Y, [) r1 R( N{9 U8 A: f9 y$ p9 M3 {
platform_device_unregister(&da850_evm_tl_leds_device);3 E. a4 A: }1 [: x( o$ j
, ^5 B; j/ _5 d
printk(KERN_INFO "LED unregister!\n");
: ~4 G E L9 s; p( a$ r1 u}: I8 q3 \5 U6 p4 p6 a8 R
- B2 [5 t7 D6 V% ?5 u
module_init(led_platform_init);( N F b+ H/ v: m* [# Q
module_exit(led_platform_exit);2 T7 T0 T% K5 i( f
) Y1 v% c, E* {! IMODULE_DESCRIPTION("Led platform driver");7 J0 R: c# P; h8 ^ z
MODULE_AUTHOR("Tronlong");/ l; E3 h2 L" Q2 r1 E
MODULE_LICENSE("GPL");4 L0 r! m! L) N
0 |9 \& I, F7 Z5 E3 A4 f9 o4 P
|
|