|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 x* s) \6 O9 n6 i" u2 t# D#include <linux/init.h>
8 \- j3 t% B$ @, ~$ {+ T+ K, }#include <linux/module.h>! ?5 K) e' V0 J1 B& U
#include <linux/kernel.h>/ s9 h8 K4 O8 R, d7 u1 @/ O
#include <linux/types.h>; ]6 Z0 P) W k! M
#include <linux/gpio.h>
' l: @3 I! o+ s( d) H#include <linux/leds.h>
9 H9 g* i# e- S2 ` }0 A! M#include <linux/platform_device.h>
% }0 z4 {8 P- W. }* J J* c
" h4 y a% r; i- y; j$ G( P1 L" a#include <asm/mach-types.h>
, o$ M+ `4 n }& v#include <asm/mach/arch.h>
' _* u; Y0 x' c+ U#include <mach/da8xx.h>
2 h5 M9 b' W4 w' x7 U" a#include <mach/mux.h>
7 U# q y+ `3 l) N3 V7 O, b" i& L+ t9 @3 f+ Q4 S4 |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" i0 n' R: G) e# t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* _% `' n: o% U6 r4 a% |/ q* O#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- I6 O. p1 ?: y6 K4 Y& T' s6 z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): P, |7 ~3 t/ n
5 w1 _/ V. u, N* o/* assign the tl som board LED-GPIOs*/" G9 r% o$ s4 l
static const short da850_evm_tl_user_led_pins[] = {
4 K$ x5 Q9 }/ o' T /* These pins are definition at <mach/mux.h> file */; H- j1 E$ K6 u* m8 d# b/ M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 d+ o6 h" }- F; v" v* F -14 i, g( g! r& U. F8 Y
};
1 J j7 Z+ x, R" a
+ u, F, b' V3 b& c* ~: rstatic struct gpio_led da850_evm_tl_leds[] = {" v l, f7 I0 B0 j0 h
{
9 ]; G( f Q9 e .active_low = 0,
, J. [9 E9 `! s0 J" l. f4 I; L .gpio = DA850_USER_LED0,
8 D W1 D! \& u t" g .name = "user_led0",
% d. h6 V' e6 @1 h& C9 X5 i) d .default_trigger = "default-on",
+ u \( _2 Z& Y6 o6 \0 s0 p },
$ p1 u) j0 a+ d% O$ W, c7 f+ a {! V* {: l1 T, a% B7 W6 r
.active_low = 0,
8 |4 l6 y8 {8 Z+ e/ e; N .gpio = DA850_USER_LED1,# y# U) X4 g$ a: `1 N
.name = "user_led1",! v6 ?( L4 V' {! m2 d
.default_trigger = "default-on",
1 C3 G$ r' _ B3 b+ G0 x },5 J/ K$ ~- V! \; M* y; h+ P h
{
9 ^/ ]) M/ b2 J5 Z1 ~' u: k .active_low = 0,+ |' P" y6 x; N) h5 ?( u* Z- l
.gpio = DA850_USER_LED2,
3 o( S! v/ U: ]5 S F* b! b, O E .name = "user_led2",
& C) a8 d' ^7 M1 j2 G9 I. y .default_trigger = "default-on",: }# q" ?3 B$ s W& G- E( h
},: N4 r0 U0 V" k9 Y8 l9 g
{
$ g" T7 u: [: T V9 M O6 w .active_low = 0,2 ~0 _& O* D1 d3 d4 Y/ s
.gpio = DA850_USER_LED3, Y$ y2 n- Z$ x
.name = "user_led3",- d B, n% ~( D1 a
.default_trigger = "default-on",
4 r4 R* B% b# Q, _/ E N },; Z7 g) r; S( R
};$ j6 | d2 H% K/ g+ b9 p2 C2 J
" c6 I7 [! o9 B0 O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 t# m0 k! s2 s- l# U& H+ ], u
.leds = da850_evm_tl_leds,
1 }- r8 w5 q$ K5 ]; w7 {2 C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. ~, E- V: a9 Z% g};. j( z) I6 ]& U9 g9 d
& k+ T) a0 {$ F- \# U. n) `& V( k
static void led_dev_release(struct device *dev) X1 O8 K. ]3 F: B
{
$ Q; s0 a, d& A$ E4 M+ W};
' w9 l& \, o, w" m: \6 Q
5 j. p. g. @$ \0 e Cstatic struct platform_device da850_evm_tl_leds_device = {
4 B8 g; i1 K: x6 z .name = "leds-gpio",2 K6 W% Z" v3 b
.id = 1,
8 R0 d* ^: K+ \. L4 O& U, K .dev = {
! R- c+ x# a. P) p$ ~ .platform_data = &da850_evm_tl_leds_pdata,
8 S% k6 c9 t! |& }# I( K .release = led_dev_release,. v' T8 q9 W N6 `8 U* h4 |" U- U5 `
}
0 C' A: K) x; S* h2 o: u% K+ {};1 f. |3 l( X- d6 M) O5 N" R
, ^( s! w: H0 y5 `& _5 I9 t6 i% W
static int __init led_platform_init(void)
% J6 o- u" d+ v ^ p' D{& T3 D5 y! L/ z3 y6 X
int ret;
7 t! v" j0 H9 t$ r#if 0$ L$ M) P @$ N: Q7 C/ J$ e# i8 D1 H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 D3 ^- p) n8 `; N/ B if (ret)+ e4 O" C5 Z& {! \# K7 Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
[' G' h; T4 S% l) } u: T "%d\n", ret);5 a1 g6 x" B( c; u7 N, w
#endif! _/ z2 f: P- a- x9 Q- q
ret = platform_device_register(&da850_evm_tl_leds_device);
/ g, x7 U2 J E4 a, \ if (ret)
" C4 ^" q& K+ B pr_warning("Could not register som GPIO expander LEDS");+ @- h0 o# Q" \: h
else
' h* R1 }1 o( Z0 O% g* @, u printk(KERN_INFO "LED register sucessful!\n");
$ f2 K/ R/ D3 i8 f }2 ]2 y6 |# ]
9 B- `; r7 M0 ~ return ret;
1 k* p5 \6 Z/ |4 m6 v8 o$ R; \% C}
8 T+ H& O( P$ j/ }, C# x' {+ D% r. a9 z
static void __exit led_platform_exit(void)+ k: w9 P( f/ f6 Z5 ]
{
0 y& n( m" c& ?7 s b& g platform_device_unregister(&da850_evm_tl_leds_device);) y; z8 T) L8 B$ T/ f5 E7 E, @
* G- j2 E8 @5 Y F4 s0 }8 [& k8 | printk(KERN_INFO "LED unregister!\n");# s9 i+ Z% n7 H6 e
}
3 `: U0 w- `: [) o8 c
8 t+ d5 W4 |4 P# Y1 {, vmodule_init(led_platform_init);
* k' H8 w, h3 @' F" m7 [# a1 C* amodule_exit(led_platform_exit);
5 Y' P& k8 b" Q4 p7 E' S9 s: A
MODULE_DESCRIPTION("Led platform driver");
}4 t c% d: M$ y( P6 F" I+ QMODULE_AUTHOR("Tronlong");) I9 p8 t6 E+ k+ N
MODULE_LICENSE("GPL");
. G8 }, I9 M$ k, W/ _
3 {) {# b6 V% j& r3 a |
|