|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
V: f7 v% n# l& J4 ~ ?/ }#include <linux/init.h>0 u0 b M9 {( h- h
#include <linux/module.h>
9 c2 j, I) n x2 u/ C#include <linux/kernel.h>
5 _3 x. U4 k0 U#include <linux/types.h>
" @+ ]' b& J( U/ `3 o" B+ u#include <linux/gpio.h>5 C4 e! B! e4 B; C( F; \& W; [9 J: R
#include <linux/leds.h>
( A) l' f" A1 h+ w# Z#include <linux/platform_device.h>
! y$ |+ p7 r6 K* K3 r) @5 H! j6 V3 _$ I8 D: d- m9 `6 [+ N+ H
#include <asm/mach-types.h>6 S h0 G+ @- j
#include <asm/mach/arch.h>
& ]: v0 D! R8 l% Z" V#include <mach/da8xx.h>
8 w& d+ {; O& D$ x$ o2 H% A. Y#include <mach/mux.h>
& k- E( f" t/ b2 T7 r& J3 U
9 |- z/ h& G8 v' B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( Y! x Z9 D" ~. z& _4 l6 |6 d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 a, ]7 f4 _9 f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. [1 {# y$ A+ D5 L' T/ F1 i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( i; I& I- E% ~3 v7 e' Z! |0 y, n/ d& j. Z
/* assign the tl som board LED-GPIOs*/! O) G! J1 ~% p1 f6 h2 {" |+ \
static const short da850_evm_tl_user_led_pins[] = {
4 y4 _7 V6 l( L /* These pins are definition at <mach/mux.h> file */% R; n: K5 o( U: F; N% l8 \( U' S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- I; z5 V7 \# U2 C' N7 U& w4 n -1. I& @0 p+ b2 l8 E, O
};
$ B/ D1 r' g+ \( S6 R+ L2 B
6 n6 J4 ~, E5 o6 nstatic struct gpio_led da850_evm_tl_leds[] = {+ f# N; L8 T& B9 }% y# m
{
R d: Z/ n1 L .active_low = 0,0 }6 P3 s* l+ [8 `# }
.gpio = DA850_USER_LED0,* r7 J8 C1 o9 X' G$ `$ \8 `
.name = "user_led0",9 i" r# e4 L$ E2 X+ o7 \! Q+ R9 H, h! c% c/ Y
.default_trigger = "default-on",
1 ~7 S9 ^& t9 @! J },
7 R8 n7 Q- ]4 j {. r& ^1 B+ \# D
.active_low = 0,/ l4 t; g) i4 i7 A$ f+ [
.gpio = DA850_USER_LED1,
* C3 ~! c2 N% F9 n' ]$ O% m .name = "user_led1",
) z; \2 U5 w& I$ i .default_trigger = "default-on"," J$ p1 i! r6 a4 J0 k1 e
},. b0 P' S- ]" c' \/ q# B
{* L+ U+ G! g% b7 V5 {, U5 X
.active_low = 0,
/ }. B- @8 }' N" z$ l+ R .gpio = DA850_USER_LED2,
' K6 U# t# L% A; l+ B/ `& I .name = "user_led2",
" O8 Z+ A9 i+ d# t/ o% V/ K9 H .default_trigger = "default-on",
* l9 D( M8 b0 X2 z/ u },4 F: i1 _& c2 k2 d# D6 m
{
. s: ^$ R' E* H1 |0 y+ N, C) |# ^ .active_low = 0,. p- u) A% A( L9 G
.gpio = DA850_USER_LED3,
; x, G7 D: R( N$ s .name = "user_led3",
% S; s1 U" Y# {- ` .default_trigger = "default-on",- C' |; Q! q& A7 u7 `6 M9 L
},
9 B3 A( ~, F* y2 \* F% \& r};
$ U8 n3 J- T+ N4 y H4 p
7 Z" U: }' ]. z& f- ~' f6 c& g, R0 vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 U2 p9 d: V0 I. J3 p) A% h4 [+ E .leds = da850_evm_tl_leds,
' b* m7 {* n3 n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 L' ]+ |/ W+ B};6 ~5 h3 X9 Z: C# }1 S
) n _9 N' N! H
static void led_dev_release(struct device *dev)
2 I( t$ [3 c/ P{
H& @& X `2 D+ ~};
- c4 v) t- ~( s6 l6 f; c: w O
. `/ n' p6 _/ R2 {( I; r0 z' l! b- bstatic struct platform_device da850_evm_tl_leds_device = {
* Q8 o' y7 J0 E; d8 _2 h$ @3 I/ V5 o .name = "leds-gpio",
5 D% a1 ]6 N/ x3 @9 d3 t3 O7 R" H) t .id = 1,
6 D: _9 t6 r6 E# I- t* [ .dev = {6 `. I/ E4 `9 s9 s' s
.platform_data = &da850_evm_tl_leds_pdata,6 _1 }) m6 l- L& [0 {6 ~
.release = led_dev_release,6 {: S9 S* z6 \0 O! r B
}3 Y1 Z: u2 b& N
};5 U# q" `9 X3 c# B7 ]9 k" c
! @. T1 r( d U9 p" W. r
static int __init led_platform_init(void)0 T3 T( v5 r& D
{
2 t8 }- l+ ?3 w# d( E+ Y$ Y int ret;/ J8 |# o$ L4 N( [7 c2 j
#if 0
0 n' N* {+ u! s: B7 o! a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' P% W- G2 Y( m* j; X- [/ L
if (ret). B# O5 d& Z' |4 r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 n x5 P K) I3 W( h# D "%d\n", ret);
' M0 J) Y/ s* R8 m# Z, e* i#endif
1 L; R: a8 b% z) ] ret = platform_device_register(&da850_evm_tl_leds_device);
: m \; l3 C- y/ O1 @: e h if (ret)
9 G8 m9 C* a3 Y; v. B7 l# B pr_warning("Could not register som GPIO expander LEDS");7 Z2 x3 z+ N7 k7 d0 ^, I5 P
else
& D& w/ k+ v& q' h; F' z printk(KERN_INFO "LED register sucessful!\n");
: G4 Q1 ~7 @5 a* q+ \
7 j) M4 C# ?) l% O return ret;
. [4 j0 a$ i! W9 C; R5 E x}
- E+ ~/ S$ ^( ^" ^+ v
3 l, N: N+ j7 ~8 m: dstatic void __exit led_platform_exit(void)* z t- \& y- R7 ^3 `8 e" [
{# J! J# d# W1 K6 t/ c0 G9 v
platform_device_unregister(&da850_evm_tl_leds_device);
/ T( [$ Y: |- K) a- U j# s% P/ h9 W6 C5 P+ Z6 m7 f
printk(KERN_INFO "LED unregister!\n");1 k& c% \/ a( A! K- h: \
}
`/ Q5 Z: [8 P$ j7 q8 X5 Y1 i8 P
# }( b7 i/ N: s& ^+ f2 x$ B l/ Cmodule_init(led_platform_init);
2 }* I5 v: r8 Y; g Umodule_exit(led_platform_exit);1 `: Y$ Q5 I% o. x0 q
- O. d. ^9 Y! D" U( i% zMODULE_DESCRIPTION("Led platform driver");+ f- x' e( W* l( {+ X
MODULE_AUTHOR("Tronlong");" b; h% e( |9 a7 Z0 z) ]" g9 z: o
MODULE_LICENSE("GPL");
8 H8 _5 d# H) M* |" D* J0 s" T7 F6 |5 n. Q/ [
|
|