|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 l, f `* d7 t5 V: G2 R3 U$ F
#include <linux/init.h>
, M" K: P. |5 ]1 j& k, W#include <linux/module.h>. a# L0 w: Q3 G0 K
#include <linux/kernel.h>+ }4 k* C2 \9 R$ m' |
#include <linux/types.h>
- y& u4 R) W6 v; E. Q/ e#include <linux/gpio.h>9 h V% L2 I" l5 @0 t' @- g% L: C
#include <linux/leds.h>
; n( W6 e9 c0 g5 _) V6 t#include <linux/platform_device.h>% e9 P7 Y5 @) Q) p2 V
" d5 I8 ?4 p# f& m! Y& C#include <asm/mach-types.h>
$ t9 c: g/ J1 Y7 g( ~#include <asm/mach/arch.h>, E% Y* c. w- {' E% w5 [( ^
#include <mach/da8xx.h>
) d7 s( L3 t9 g7 q5 r#include <mach/mux.h>
# Y" k+ ^" y2 M( c- _- K8 N2 B- H7 r2 S! k; X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* u p! a' M3 N7 k3 i/ V4 ~7 c1 f6 z* a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ ]: r6 w. q, t+ E5 W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- z- D+ S8 Q. g$ D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% H; F# b/ e3 T' `& b- p2 K
' v/ I4 Y# Z) |* F# `/* assign the tl som board LED-GPIOs*/8 Z2 r' _5 N0 v2 j
static const short da850_evm_tl_user_led_pins[] = {
& a+ R* H9 O3 K: x+ M% h /* These pins are definition at <mach/mux.h> file */
& N1 g9 p8 {% v" v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; g. F3 G4 b7 m -19 d: x$ l0 k0 Z( V- A9 P- e
};
9 }0 |. [. d. v2 J
! p2 B& J. L8 }9 O' ? ^% R8 T) O4 ystatic struct gpio_led da850_evm_tl_leds[] = {; K0 v. g" p) d' `3 }3 s
{
$ V+ m% b0 T# l( I r& {1 {+ `: O .active_low = 0,
! C+ R5 N( _, y. t3 [ .gpio = DA850_USER_LED0,$ k, F* v* M& L! l7 z# B
.name = "user_led0",4 L; @* z1 G7 I) Z( D& \
.default_trigger = "default-on",. B8 }2 B( O' p/ ]+ v
},
) |2 @, v9 m. l# R { A7 F5 t0 H) Q" O$ T: @4 c
.active_low = 0,0 u# e( W3 W6 v Y0 q
.gpio = DA850_USER_LED1,
) v+ ?9 Q" S9 K2 v' T9 X1 b .name = "user_led1",# P" D% f! s a0 Y
.default_trigger = "default-on",- o8 N" r: }2 a8 j/ s5 e- [: \
},
, m8 @& X3 i1 | {* I8 {& Z# w6 Q3 k m
.active_low = 0,
) [5 b# E. L* R% J .gpio = DA850_USER_LED2,
! @: T# E" e- Y# ] .name = "user_led2",3 \3 Y7 t5 q; K4 a
.default_trigger = "default-on",4 b# r* X7 H# C: H4 M I! t' r m/ I
},+ R2 i7 v4 Y7 {7 G
{! J: x1 s/ r& U
.active_low = 0,
4 `- K Z6 U+ N/ x( \. Y* j+ A/ Z .gpio = DA850_USER_LED3,
5 C# _6 f2 T4 ~' V5 ^% a0 T# c* Q' { .name = "user_led3",0 P# L: E- H$ X6 ^
.default_trigger = "default-on",* F6 A B0 q- A; @; K% O6 w+ l
},
. f% B8 S+ u# p2 |0 K4 a};
1 T$ M' H9 ?$ |4 v. s
0 @# ^* m% T* c* M8 F; Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( T" _+ g$ T' R- n
.leds = da850_evm_tl_leds,2 p! i, ]+ C3 ]( I4 t0 ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ U& T% v! l6 @; w9 k& `};
8 B8 s# S" P& H8 D- t1 D
& @/ y/ S ^2 n8 ?6 dstatic void led_dev_release(struct device *dev)
/ Z* n g4 Z7 u0 N8 q{
! X( B7 m! S7 C5 E. R};
: y& Y# O- G+ A
/ C/ B# ] B; lstatic struct platform_device da850_evm_tl_leds_device = {
" y# Q! i( L) D .name = "leds-gpio",3 i. U0 }8 R0 Y' m4 y& y
.id = 1,! e: x) S0 a- |8 \
.dev = {& x+ q% a- B, F
.platform_data = &da850_evm_tl_leds_pdata, P( A* s% A& f$ w; W$ I7 J; j
.release = led_dev_release," y- K! D+ e: U5 i
}
& H. C1 g8 y5 i: {7 m};6 d# @$ w b+ H
# g3 \% {0 A5 @, f1 R
static int __init led_platform_init(void)( K, m" R9 }! g2 y
{4 \; a* d2 n1 h
int ret;
+ ~# H6 d# ?6 g% \8 q) D; t#if 0
/ c2 |3 k( A# y! r5 l, A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# p) r- i) f( g4 D
if (ret)
" [" d- e+ a: o) ^0 z2 N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! @ J. E! N; Y% ? "%d\n", ret);! u @7 N/ t* ?) g+ m8 q' V. a
#endif
3 \ w8 b1 y) m3 I ret = platform_device_register(&da850_evm_tl_leds_device);2 U6 t8 Y7 D' d, \
if (ret); e. A2 T1 S5 O Z( T ]2 E4 N
pr_warning("Could not register som GPIO expander LEDS");7 i5 w% z5 W0 D O
else; e) S$ v- q; p2 J5 J* e- H/ ]$ M
printk(KERN_INFO "LED register sucessful!\n");
4 ^4 N6 B% j$ u3 a1 Y' q. O/ a# A" |% L) {
return ret;
4 m; L! V7 ^: P/ @}
" k n% q5 V% J6 O& X- b3 A! o5 m! @* f0 P$ |. i) v7 S& d
static void __exit led_platform_exit(void)0 z, W% o( f3 o- f0 f
{/ B: ^: c$ K, G. O+ R* G( _) a" v
platform_device_unregister(&da850_evm_tl_leds_device);
# B# l: k+ x8 |2 A& d
3 j; z l' x: a printk(KERN_INFO "LED unregister!\n");3 o5 a4 K5 O$ h9 c+ x! [
}; G) x0 K; o2 @8 O1 x8 |5 v
. q+ [" L) r* o1 U D1 w
module_init(led_platform_init);
, a8 J/ s! H- Z' J# [8 Bmodule_exit(led_platform_exit);' e$ W7 \- R, C9 }, f
5 G* w/ V8 y( S. S! W2 ]
MODULE_DESCRIPTION("Led platform driver");5 l2 T( H6 e) e7 K
MODULE_AUTHOR("Tronlong");/ m& ^' Y! W1 U/ n6 y( N
MODULE_LICENSE("GPL");; [9 c# m0 n0 R( M* P0 {' ]7 P
4 }. i& S4 B! W1 X4 L |
|