|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 R: U+ o7 |4 G
#include <linux/init.h>+ X/ q0 m) [& V3 |& F8 \" I
#include <linux/module.h>. g# H+ v" V! B3 @7 ]6 p
#include <linux/kernel.h>
& |7 ?) h' x% W; u#include <linux/types.h>
+ U9 b: k. W: C& M b+ ~#include <linux/gpio.h>
7 [+ O' E B; z6 X- [. l; @1 p#include <linux/leds.h>7 R- V0 Q( P& t& d# }
#include <linux/platform_device.h>- T5 W" r6 n. J& g' |6 ~
! `: B5 V7 Z# E9 u5 g9 j
#include <asm/mach-types.h>0 j6 j+ L) _; r: i/ O# I& j
#include <asm/mach/arch.h>
% I4 h/ L6 s( b" S2 Y#include <mach/da8xx.h>* |* K& z- g9 f8 s8 u+ ^$ ~
#include <mach/mux.h>
5 M! R& z/ Q8 y) J0 _: H% t; _! E5 N n& |: t0 x: \* i
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" b4 A- ]. ]/ W4 f) w& i
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 P9 B- ^" S5 p \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- w o( E9 R" f* _+ n8 ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ S8 L* f4 E. v5 v9 E& J+ _
6 H+ K: [. F$ k- o s
/* assign the tl som board LED-GPIOs*/
" d2 S( X# w0 l6 X+ a; n/ bstatic const short da850_evm_tl_user_led_pins[] = {
1 J: N, N( |* r /* These pins are definition at <mach/mux.h> file */
. W1 i) Z; K' ]; J! H- t: P( Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: d1 h, z8 j- D; W
-19 W4 Y! h% ~/ a+ z( r9 S
};
9 Q: @. Y/ X' S( w0 r/ k5 `: k" X; Y" D" T
static struct gpio_led da850_evm_tl_leds[] = {
6 j2 `! x) B8 z f, k8 [, o* x {
8 ^' ?. z6 D9 s& s; Q3 e! U .active_low = 0,
8 V% W+ y$ U; |' T .gpio = DA850_USER_LED0,2 a8 t( r5 P! d; l
.name = "user_led0",( P' n* q/ @: n: `
.default_trigger = "default-on",
) ?' q9 Q$ e3 q0 V. w },3 m- w$ D9 z& ~8 i; ^
{
0 ]) K4 h) B" s9 v* G/ c .active_low = 0,
$ \9 G6 J( u2 ?, ~: ]/ ]6 e1 m .gpio = DA850_USER_LED1,
! w2 N8 P [ V; V4 _# M .name = "user_led1",+ B. |8 G% h& Q, }1 q+ i, c3 U$ `
.default_trigger = "default-on",
4 M4 ]# S+ }6 H) ^( m },
# _, E2 z: H% l8 Z) P! u {7 h) p& ]1 G3 U9 a$ I5 S: C( X
.active_low = 0,% y4 `* }* z8 }& z# y
.gpio = DA850_USER_LED2,, ?# @: P1 g& T" R5 a( w4 I
.name = "user_led2",
7 e) p6 R; i1 I6 j; H/ t2 G .default_trigger = "default-on",: ~8 ~% ]5 U4 Y: ]8 S
},
- ]. H8 W$ n& k {
6 G6 A( G& f1 _, [+ \3 C' D: m) G .active_low = 0,
+ u* Q2 F8 n- J .gpio = DA850_USER_LED3,6 e& L& Z' h' g" h5 A
.name = "user_led3",+ f* _1 Q* t+ M, t# [, s3 Y0 p
.default_trigger = "default-on",) W% \4 s/ M3 G X7 r4 N
},( B* h& u N# k& w) k, \2 V
};
4 {6 N9 G' C8 X4 }2 |2 O7 G
H/ x5 m, E+ ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 y* s- J! Y3 M7 k .leds = da850_evm_tl_leds,
4 p3 Z% M# r6 O; |2 x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% t/ U5 O G3 W1 ^# U& y# O5 c" @};
% N* n3 {3 C9 w+ N c; r1 P0 j$ d9 V9 Y% _0 g+ Q+ X3 T
static void led_dev_release(struct device *dev), R" J ?+ \+ D2 Q
{
. i- }% ~$ u% ]( m1 H};
& }/ H9 p$ N+ C# W+ c2 M+ F9 F0 z1 j' m) _# c9 P8 Q
static struct platform_device da850_evm_tl_leds_device = {
( o) U7 A% D6 I% w .name = "leds-gpio",; |0 o, a* E( t5 V, F% K
.id = 1,7 u) ~- a' [6 S3 @. O# D
.dev = {. a. e; b }( T1 Z' b
.platform_data = &da850_evm_tl_leds_pdata,0 J9 |! {" T* l: \
.release = led_dev_release,1 ]- M' F* x m' ]- N' J$ j
}
# e( R, v' ]8 `5 a};
' `, f6 p6 b' z( `1 j; s# n9 o1 M. ?2 g
static int __init led_platform_init(void)
% n8 ^- P" P5 _. u5 j' o$ W{, ]" c' G i$ |1 B) o4 s5 Z; M j
int ret;" I* W# r! E5 p" J
#if 0
, o7 z" `( I2 r3 F$ @1 f' O' ]+ P4 c ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" h3 S# c7 |! R; e if (ret)
3 \0 ^* ]5 O. N! g2 A6 y& u6 S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! y$ w) V: i/ W7 A. j1 o( y% R "%d\n", ret);; R2 q4 ?2 x0 K! [( ~3 Z& X
#endif
2 c1 q8 B) Z9 z( l0 B* M" k9 x ret = platform_device_register(&da850_evm_tl_leds_device);' H% i! o7 Q" {$ v
if (ret) m/ u ]' t) _
pr_warning("Could not register som GPIO expander LEDS");! N: _* H" q0 b# ~/ T+ P3 A
else: _2 R8 [& V! ]1 E2 q* H
printk(KERN_INFO "LED register sucessful!\n");
+ S) f, k1 I. E& B+ M% l
6 I: S# e* x2 o& i) x return ret;: j! d; A: z, |& Q Q/ j) O
}
; Z u9 @ j0 A! {
6 {9 W8 ~& C# Q8 H1 C- Kstatic void __exit led_platform_exit(void)
! r) k9 |* g, k{
- T' H* N! e% W platform_device_unregister(&da850_evm_tl_leds_device);
. T6 L; F. b0 w x) ?3 |6 y1 e) I: E3 v; }# a) X* y8 N; R4 h6 ?( L
printk(KERN_INFO "LED unregister!\n");
& l$ l2 I. i3 y& f9 Z! H9 m}7 O8 M8 U% @7 j
9 x9 z3 Y6 H+ {7 n9 I: zmodule_init(led_platform_init);
9 n @- V8 S% Z, l9 |2 lmodule_exit(led_platform_exit);/ Q2 A( _8 V3 h2 V: s
) H8 s5 g- P# ^: }5 q
MODULE_DESCRIPTION("Led platform driver");
: _5 {% O D a& M" VMODULE_AUTHOR("Tronlong");7 n/ F7 l q7 G) R- J
MODULE_LICENSE("GPL");3 v2 L3 @! O+ z( L1 O
' s1 k" |# a3 _, m$ C |
|