|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: q; e G7 I& b c* {" F0 p#include <linux/init.h>% j# Z5 q7 o0 ~5 F6 Y( y7 }
#include <linux/module.h>
# a Y0 n: e2 F z7 f- O$ s#include <linux/kernel.h>
2 U: K, N$ w- y#include <linux/types.h>3 J% v) B8 B2 b6 S/ a
#include <linux/gpio.h>& {& ~1 C: w c" e" o! A
#include <linux/leds.h>
0 C8 X' T( B0 P! B1 P: }% c#include <linux/platform_device.h>3 C+ ^" t' F7 f4 h
" @2 k4 o" @, S( z7 H" a9 P" Z: y#include <asm/mach-types.h>
z) w& M% f! i; K; x; R#include <asm/mach/arch.h>
7 R+ v1 |& K w#include <mach/da8xx.h>
. r& b. g, m' g: D% ~$ z7 L#include <mach/mux.h>- t$ F, R2 S! t9 W
* t" G+ Q! p4 i( s" I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 C8 j! h% T# l- Y: F#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ t9 Y' s# Z- }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( Z+ v7 x @8 ~% F7 g
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" @6 c- C$ z1 J! I4 j
; I. @$ I! {6 C5 G$ m& G2 o/* assign the tl som board LED-GPIOs*// Y; O+ ?$ w0 V4 E# B8 F; ~
static const short da850_evm_tl_user_led_pins[] = {
( r# ?( g$ ]# H" U* f/ Q /* These pins are definition at <mach/mux.h> file */2 E$ c6 ^ W0 q4 ?+ N1 _. H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 N1 z4 ]0 A- z( f7 ], S -1
x, t: {* i( U' K/ _};% a! f! F3 t# r* u `# { }8 _
0 d/ K. S' d3 W7 p- Mstatic struct gpio_led da850_evm_tl_leds[] = {1 O" m2 _9 i* |
{
) @! z: h& v1 p; t7 j .active_low = 0,7 U) @4 L4 o k5 h7 t- r$ o
.gpio = DA850_USER_LED0,2 D* |1 h" z! A4 h
.name = "user_led0",
\: B7 t( m9 K/ P. C1 }, ` .default_trigger = "default-on",
3 Q3 T/ P% y1 l' s },& F+ ^. U) c% e K4 D% R, Y
{
0 N. B3 |5 X3 B3 S4 P6 L2 y8 e .active_low = 0,
w7 e- P. g) x# R+ S. a .gpio = DA850_USER_LED1,
* M5 _+ S) U+ B" I .name = "user_led1",; c. C* ]$ j$ M7 N* I; X
.default_trigger = "default-on",2 b* L1 T+ ]! J1 u+ Z: `1 r6 Z
},3 q7 j4 t8 {5 A9 o
{
; @8 b& m' S. s# \( l8 J .active_low = 0,
! a y. U; U9 z; L) G, f .gpio = DA850_USER_LED2,
1 K7 d* d9 o5 b8 s' q' N) Y; B( ? .name = "user_led2",
6 R+ p7 v% k Y- C .default_trigger = "default-on",
" v* d3 h* ^* Z' |, p },
, h) J) Q6 T6 Q z! c {
6 |* Q% u# r( r .active_low = 0,
2 N; e: {. @6 H s9 k" [ .gpio = DA850_USER_LED3,
$ f, b C: @9 \9 b2 D .name = "user_led3",
4 [' {* @3 H- E0 e .default_trigger = "default-on",) Y5 b5 X9 |. r+ X2 M" X/ d0 {
},0 p% \7 k5 ]9 _7 p
};
9 o: |2 o# C3 R. a/ j5 o. l I X1 f# A* Q, S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" ^9 B) b- D( R, J
.leds = da850_evm_tl_leds,
$ \' r% H; }% M4 m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" S- Z( l6 k. D4 O9 ~};
7 t2 [& }. }; ]4 l$ |/ n/ N0 u/ S z. [& ^$ m) a+ I
static void led_dev_release(struct device *dev)0 O- @# V q3 B0 j7 H d
{
2 L% H5 j- c5 `' g* U};; R1 [5 w% F3 L& D0 m V0 O8 L* m6 u
E7 N( p: J% b: I% X! e8 e" jstatic struct platform_device da850_evm_tl_leds_device = {" N" f4 W6 y: h: W5 l8 b* B( k! U
.name = "leds-gpio",
) J; E s5 l, B! Z .id = 1,& I# n# t8 d2 w
.dev = {
6 Q! J& F! _( w& t* R, i- J8 n7 i" a4 Z2 x .platform_data = &da850_evm_tl_leds_pdata,
% v, g; n3 W: q: G, v .release = led_dev_release,
; ?1 x/ M% P7 e# h8 `3 @3 w, p }1 L* j9 q( z' F$ S( \; B& [
};1 x6 s5 t4 F9 h
, `* \ k4 G& H5 ^: ~+ {static int __init led_platform_init(void)
& ^5 d! X& |. s/ y1 t# N{/ `9 }! D! x* `2 s9 m
int ret;
. ?: h m3 y: D& n7 X! B#if 0( |- a8 @* H, t# [2 k/ T$ Z" V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, n2 S) y/ s6 Y3 B( c
if (ret)- E+ D% y2 H6 i+ n0 F% `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- a4 @ x( }- P2 L7 P+ q; W
"%d\n", ret);
6 n1 W, I% r, @0 F; J#endif
4 B# m2 u: O- Q4 W! ~+ |+ B ret = platform_device_register(&da850_evm_tl_leds_device);
! v4 @" `1 L# P% u# r if (ret)
8 w! s1 d3 |% d6 r8 Q% j8 _; F pr_warning("Could not register som GPIO expander LEDS");$ h- T0 k7 ^1 y1 F* W! C
else& P6 s6 A: S! j+ E6 ~ W8 z
printk(KERN_INFO "LED register sucessful!\n");' A. Y- D' Y- w5 K; x- `+ h, N
1 l9 k6 b( T9 p. B8 w return ret;' s+ S/ w; h7 j1 \
}& G* @/ C- ]" m/ Z
) ?, z4 d5 l0 K) k# V7 f. p0 ?2 {( ~static void __exit led_platform_exit(void)
2 m, I9 P$ L& F0 c1 w{
/ X0 R" o2 [# B4 z- y' ^1 f platform_device_unregister(&da850_evm_tl_leds_device);, @# Q4 n& m# f6 V
: r, Q. j1 L( \7 x5 k
printk(KERN_INFO "LED unregister!\n");& g0 e, F$ O& y) l: h
}
$ g# U4 d5 a) J% G: [( [& t8 t3 R' j5 a: x: C, ^
module_init(led_platform_init);$ g0 n( u% w3 w% z1 j- a+ n
module_exit(led_platform_exit);, Q& a- k& K9 `" ?
3 I( |) p1 e) ~5 {7 Q+ ?- R- U
MODULE_DESCRIPTION("Led platform driver");
9 G/ Z4 B. b. B7 V/ yMODULE_AUTHOR("Tronlong");. {- |; r$ F* N0 U" g& F9 c
MODULE_LICENSE("GPL");& d5 \/ G1 b$ U0 R$ P
9 R$ p% q$ M) }5 ~3 K |
|