|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 P- |! f+ Z1 l+ a$ `; S#include <linux/init.h>
# d! `, I3 c; {#include <linux/module.h>
9 [1 r* g5 s, t6 g' w+ S! P#include <linux/kernel.h>6 F1 [& P0 ~, O
#include <linux/types.h>" R8 C) g; D( Y3 q
#include <linux/gpio.h>% v/ u7 C( g; e4 y
#include <linux/leds.h> Z* Y" N$ g; Q' e5 u% X
#include <linux/platform_device.h>: l. ~7 u0 v4 b( v' _9 m
z& B7 d4 ^5 u! |( {6 W& c
#include <asm/mach-types.h>
; ?# X2 I# [ S$ O4 E t! E#include <asm/mach/arch.h>
# P V5 P2 U9 K/ K( B& a) t#include <mach/da8xx.h>% c1 d" s. |+ ?+ U2 n/ Q
#include <mach/mux.h>" {+ o$ D f$ ~; P( k! \+ S- B
% r& Y& b8 k- ~3 f; Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 G5 z7 l: @. X) m/ X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* d% J% L! E0 T6 c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 E, i' \3 L4 }: R6 ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# N( m! k# L+ ~! K! D2 Z$ p& P
, P6 V y! v3 E- Y9 z/* assign the tl som board LED-GPIOs*/1 Z% |* o) W# z% [3 f
static const short da850_evm_tl_user_led_pins[] = { m3 p! ^5 {, H1 ]7 a* S3 Q+ b
/* These pins are definition at <mach/mux.h> file */6 R+ r5 C/ [. V$ k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ t# t7 Q7 x+ F n m -13 {: l$ J% s+ [* a6 y
};
: D8 X) y; M+ X( w) f
" o1 @" _. J) ?static struct gpio_led da850_evm_tl_leds[] = {. O5 W: z' p$ `( V
{
: b' T- M) x8 T6 U+ F. [& k6 t+ b) I .active_low = 0,, W0 [8 g# B7 j) C" ^1 @
.gpio = DA850_USER_LED0,
3 C5 z: l6 D% Q* g .name = "user_led0",$ a0 i$ V# M# @) k
.default_trigger = "default-on",9 ^. \- {5 K1 [6 C K% R0 c
}, Y! h# ^- h- \
{2 y+ x, d% u+ C0 D- a
.active_low = 0,
+ n* B$ k4 b! b4 o/ Q M+ M .gpio = DA850_USER_LED1,
* F; e( G, Y- s9 Q5 [ .name = "user_led1",
6 b, S7 V+ A3 B( W( T& | .default_trigger = "default-on",- M6 q/ P) U+ @0 i# z3 Y
},7 ~9 T! {8 G* Q [: {
{
; I! A+ {, v V! q. q- O .active_low = 0,
1 P; K: c1 x" [ .gpio = DA850_USER_LED2,) h+ }/ t t: b% g) X
.name = "user_led2",
R2 r( t4 S' f$ L: U .default_trigger = "default-on",: }. f# D/ {2 Z; k
},( w7 D* h8 a. e
{
; S$ Z+ y) @7 K* w. n7 m .active_low = 0,9 @7 e' A i4 Q
.gpio = DA850_USER_LED3,, B) }, |- T; k, x6 i' i0 |9 A
.name = "user_led3",6 }& l3 [9 i6 P/ u# H8 k* t
.default_trigger = "default-on",
: A& ?- I: Z" h; z" n4 z },2 e! ]0 C8 b6 x/ [* h- D
};. B* r- s' p& P2 T/ Q! m9 y" z
- n" D- _! x9 k" g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. N: D6 @) k/ C* L2 L* o& W! C .leds = da850_evm_tl_leds," B6 f* P0 u( W3 \* V
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* |* }" f1 a3 F) u+ _3 b};
, |3 Q2 |# ]' c1 ~! z7 C2 c- D* F0 ~9 `+ }. \! _
static void led_dev_release(struct device *dev)
/ l8 z1 ?* d) o; l1 W{3 R9 B+ M( B ]6 c, Y
};
& W' Z% x, j2 B& M6 H# J
8 U! h+ B) @# j1 Sstatic struct platform_device da850_evm_tl_leds_device = {: f1 S) Z8 N" d t% U: X7 B
.name = "leds-gpio",- n0 y- `5 r, B7 c# q& D! S$ {
.id = 1,
1 P4 |5 I, P s) | .dev = {) T+ w0 Z+ y/ g2 m+ k5 C; b$ N
.platform_data = &da850_evm_tl_leds_pdata,, F" d& G. y0 T4 n$ M
.release = led_dev_release,
$ a" H1 i# Y, s7 o }% S6 U# l8 M4 O
};
+ A4 A' U9 ^; C: @* x- S: K
) z) K! o! T5 t( |static int __init led_platform_init(void)# N% b9 t) c% T% `0 n
{
0 r, T, v2 {* ? int ret;
3 V8 U$ y4 |0 r% s: p7 v#if 00 K5 s6 Z; ^: x# p; F# v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- u: V1 g' K$ w
if (ret)/ i( c6 E3 m' T- S$ Q0 m
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 v" O8 K4 k1 |+ {7 [ M/ e3 Z "%d\n", ret);& W# |7 J7 O7 H. R( n4 n
#endif3 b9 L# O/ ^# [$ p2 c' F) `- C
ret = platform_device_register(&da850_evm_tl_leds_device);
W0 j, g( I( r* h% I& V if (ret)8 h: I0 ]' p" A# f1 b
pr_warning("Could not register som GPIO expander LEDS");" Z; P# r1 c, P p
else
4 S5 d1 v! s8 H7 S6 y8 n! f printk(KERN_INFO "LED register sucessful!\n");4 Y1 q& ]3 b! j8 p
% T+ g" v# b, Q4 ]. N0 U& `
return ret;8 J: {- {9 v0 U. @3 w
}* f8 K8 M+ n. k8 z
4 o9 q% J' v G: N0 r0 {
static void __exit led_platform_exit(void)
( j5 G, ]& r+ q+ z8 O, n{2 y& H! \3 R" J% }
platform_device_unregister(&da850_evm_tl_leds_device);
6 S/ A* j# t; o8 |, N8 Z( k& ?- D5 O; {" ?& r4 e7 L
printk(KERN_INFO "LED unregister!\n"); Y0 V7 V, e, a
}* ?* d: y3 g- Z. U* l9 v
1 t7 M- ?' A4 o6 ~
module_init(led_platform_init);
5 e6 Y. A+ c- o, Smodule_exit(led_platform_exit);
- r. {; K/ r( a& U3 V3 d7 W4 v1 [# ^
7 W1 A) P* i6 [1 t3 Y: gMODULE_DESCRIPTION("Led platform driver");
1 o' F! D6 f6 r- s) cMODULE_AUTHOR("Tronlong");
& r ?0 S0 q! ^' SMODULE_LICENSE("GPL");2 U7 C, z2 B [
[5 D) i% ]6 j' i) R7 X0 T
|
|