|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* d% y! y' \2 r4 @#include <linux/init.h>
: Y Z/ q! V h1 ~( s#include <linux/module.h>
& P7 \+ s9 u C; m/ m#include <linux/kernel.h>' F' S5 B: j9 r) O* a$ n
#include <linux/types.h>3 ^9 A( m* K) }. z4 @! u# I
#include <linux/gpio.h>! s, s0 R% Z$ R$ i2 \8 C; s8 h7 b
#include <linux/leds.h>: w g2 |! H& G; i4 j
#include <linux/platform_device.h>9 ]6 X) E7 y$ r. N* g7 P, G; K
: U9 m; I0 _; v& s; s
#include <asm/mach-types.h>
, o$ S3 G/ ?, Q8 O- m#include <asm/mach/arch.h>
/ h8 `$ m# {" T# e; J8 Q. Y1 B#include <mach/da8xx.h>( \* L G$ I* c1 {
#include <mach/mux.h>6 v# n( G7 k P* t5 N; B" Y7 F! u8 ]
4 O+ |* G" X* X/ y* O& ?$ X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. x8 o- f6 y/ l' B" ^# _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: V: R4 Y; L0 O/ S( k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. p) h& V1 f9 N* U+ p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& ?1 P) g7 ^% W( ]; ] K$ n4 Z; ^7 @ ]" ]3 ]: w
/* assign the tl som board LED-GPIOs*/
/ A9 m0 V$ I9 y8 ~static const short da850_evm_tl_user_led_pins[] = {# ^4 V! o" J% P+ @( L r1 V
/* These pins are definition at <mach/mux.h> file */# {: [0 K* R8 ]4 C2 m4 X5 o8 R# u
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. N4 Y9 [2 x7 m. ?
-16 ]: P2 n1 a9 z9 H! s
};2 H7 Z& u* r; q& j( s2 R
- l+ i$ K/ f. _3 g9 I/ I
static struct gpio_led da850_evm_tl_leds[] = {6 i) c+ w& w( C6 C9 w
{
, h, S6 p7 _, |: | .active_low = 0,
2 G0 Q9 i- d. Z( m7 y .gpio = DA850_USER_LED0,
7 O& m, @% f9 ]) I1 ]+ d .name = "user_led0",: X7 P$ t- x- Q0 e: C$ f$ J, m. R
.default_trigger = "default-on"," b7 W5 X4 x, i* b
},
7 V6 ?: Z+ U; c {
/ Q7 r0 L9 j+ o3 [% K3 O .active_low = 0,
4 F* a S1 m8 O/ @& }# V7 r .gpio = DA850_USER_LED1,
% {, B8 {2 j1 W4 s7 a .name = "user_led1",
3 k; V0 R6 |+ O6 R& |. O .default_trigger = "default-on",
" U- T' F% e! U0 e2 h/ d# X7 \ },+ P5 l% g& P4 X) p; u) c# d" Z
{4 Z" w2 _6 [( X; w! B9 G; h
.active_low = 0,
9 R* M' Q/ p! R% M" @ .gpio = DA850_USER_LED2,
- m3 I2 K5 I6 t$ w! c" t: O .name = "user_led2",+ t5 J0 Q. x, E3 }3 {% `
.default_trigger = "default-on",3 L4 u' P- Q& d8 G- M% Z4 C
},
1 b# x$ ]* |1 B# L5 t {
& E% _" \/ Y3 @7 O1 h .active_low = 0," Q8 o. {5 L4 {. s
.gpio = DA850_USER_LED3,
5 A% h9 L$ r1 D( R* q$ S; T .name = "user_led3",
/ J; r. g: M x7 l .default_trigger = "default-on",
, E8 d% w: X' e# C- M, m },) H: b& [8 y4 q
};
0 w% b$ i7 P ]1 `. W6 C K b4 z; o$ P! P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 v0 n" V* ]! P, j6 p
.leds = da850_evm_tl_leds,
' G. ]( T B E; e, R% w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 q4 D9 n' x/ [4 C" R5 r5 `' Q
};% C) R$ ? S4 Z/ }4 l( N
9 G$ R& ^' r& `static void led_dev_release(struct device *dev)
, y" V8 M& m" k1 {: X2 H6 A{! n4 X; d4 {$ B$ w5 z7 [: b5 y
};
1 I7 G& l6 b% L- t
1 L2 E0 x2 f+ B. A! r m% @static struct platform_device da850_evm_tl_leds_device = {0 q- @: c# A a5 a
.name = "leds-gpio",5 _$ c: P( Y1 b4 j+ f
.id = 1,
3 C; l5 j9 h- i/ g .dev = {. A' i" t4 Q3 S% z5 W1 H, B
.platform_data = &da850_evm_tl_leds_pdata,6 e) ?# o7 N' v! b) f5 M* b2 R
.release = led_dev_release,! H) z( a9 Z$ m- H
}
3 q8 K3 s( P) t4 h2 s) E6 v};( {0 |- n# d5 s" T1 x* q
( Y7 e" q: J$ Y) d2 ~ }static int __init led_platform_init(void): H! g; H3 @1 `) \: `! _# o
{
2 ?) C) B. h& Q: c7 P int ret;
6 R3 e/ b! V: R: E( F#if 00 C3 }+ \/ {; m, K
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- c1 e+ n4 i3 ~0 Q if (ret)4 b, F) z' x+ X5 F8 |" s* p$ U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( F8 H0 l) W; m" Q& p( S5 \, } "%d\n", ret);
* K4 l" D% A. y6 L3 E/ U9 ^: E#endif
- Q Z5 M& z' L# y! B) f! U ret = platform_device_register(&da850_evm_tl_leds_device);, P: B% p# c; W( K! c' M; U
if (ret)- K3 ~* N8 G$ ^$ R1 g% {0 q
pr_warning("Could not register som GPIO expander LEDS");
: x1 b, A7 V* J5 ^& ]% {7 N/ i7 O else
$ Q; d( {+ A" r: E# K printk(KERN_INFO "LED register sucessful!\n");9 Z6 n7 D8 W' m7 s& q! w. T# p: L" S
: m. ?$ G) Z* d: d$ z- J: t return ret;' E! V ~) }# {7 _6 U% V& I' q
}
9 [* h+ s h8 y! T
% ^! R% x2 J4 I4 }* V- Y( x( ?static void __exit led_platform_exit(void)
Y+ j" }/ j+ b/ \( N{
: g! q& a' \6 {6 n( k2 p6 s platform_device_unregister(&da850_evm_tl_leds_device);7 Z2 M/ K0 I1 _8 Y4 X, R9 t" D
! X) o- t* F1 u- f
printk(KERN_INFO "LED unregister!\n");2 p7 V0 f% N x7 c r) o
}
. J& R/ X5 E! j7 ^0 G& |/ {/ T0 h/ P1 @1 ]. i" T+ g0 H9 {
module_init(led_platform_init);, Q. E. |3 x6 t }7 S: y3 z( v
module_exit(led_platform_exit);
# q6 t8 Z5 ?- K" A3 c! C
4 V# G+ ~7 ^! N+ N# D1 {MODULE_DESCRIPTION("Led platform driver");5 }/ B( _2 ?. b
MODULE_AUTHOR("Tronlong");
% v3 c; j }3 n& fMODULE_LICENSE("GPL");$ v- R: H% y8 | ]6 H2 B8 G* q
7 y/ W& z }. B; h- I- f
|
|