|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- L# ^9 S( B/ c#include <linux/init.h>) W' l; y. c- O( B
#include <linux/module.h>
. @8 U8 A E- A$ T8 o#include <linux/kernel.h>1 b8 q6 m/ m# J) p+ Z
#include <linux/types.h>
, }4 t- k) {8 |- D0 M#include <linux/gpio.h>
* F0 C, Z G5 X2 I0 J3 }, M#include <linux/leds.h>
% Q% O" {' M1 @8 h#include <linux/platform_device.h>" q+ A" C! D9 z3 h, ~* r9 ?+ _% \3 e
1 W# H: P/ O/ r4 h#include <asm/mach-types.h>
9 `, @0 X: l: i) V- {2 w#include <asm/mach/arch.h>
" z6 n4 v8 F- V7 w B' W; z#include <mach/da8xx.h>' f j1 T7 Z* J
#include <mach/mux.h>8 u/ G% U4 }: h9 p& B7 `5 p
/ Y8 h8 G- J) `, Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" D# [* m, |) W' i- Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), V( j7 ~3 B2 s+ I P+ B1 T; Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ c u+ a) Z4 Q) m/ J3 A; b8 t#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
s, d7 M- k$ \/ T- w0 @7 S& d) z" D) ]2 u
/* assign the tl som board LED-GPIOs*/; {% V7 }# r9 @, q
static const short da850_evm_tl_user_led_pins[] = {
) p6 b9 [- ^8 P* l /* These pins are definition at <mach/mux.h> file */
' R( Q/ q) q" B( W8 f9 N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* k: I7 R: L3 o `# t$ X) e( y -1
: |+ i8 d4 P1 I1 n9 V" s- F/ _0 I};
" B d1 O5 g! |8 s- o- \1 e% m9 H1 c# U
static struct gpio_led da850_evm_tl_leds[] = {5 y; M( n& T: z* G- Y" Q
{
# `4 Y6 o8 O( R2 F* b .active_low = 0,
' l( p$ Z) @$ D: j U' p .gpio = DA850_USER_LED0,
- ~! v) Z s: p5 |+ [ .name = "user_led0",
: F2 P4 v0 j, t' F. L/ a, ^8 E0 ^ .default_trigger = "default-on",
0 ^0 _4 p$ k8 u9 f% y. S },
1 @+ U' W6 b& ~, T* E! j8 s" f3 L {! f. H: ?5 K- j0 R% J
.active_low = 0,8 G! v/ f' u# ^- f0 p/ j
.gpio = DA850_USER_LED1," Z% E3 S: }! ~ k1 R0 G
.name = "user_led1",
+ C/ |# W y8 z* w7 Q .default_trigger = "default-on",
$ o( N4 w% o2 F& P' j$ b; b },- T6 ?5 C; e) G* O4 |$ `( ^# [
{3 }4 ] ?! l6 R& [: W0 b" F
.active_low = 0,) L1 @+ ` M, X2 o+ x* G s/ _
.gpio = DA850_USER_LED2,
! Q4 x7 G8 _/ W- W* l .name = "user_led2",4 M% _6 ^6 H {& k& n' M
.default_trigger = "default-on",7 E% r& [/ f! j! d, d6 R
},# z" p1 {2 R1 u
{/ X5 u$ N& d8 X/ S2 h5 V
.active_low = 0,
; k9 k; D: q+ c8 T5 k .gpio = DA850_USER_LED3,0 z6 }# I' K% q( l
.name = "user_led3",
2 U8 k# y7 [% x .default_trigger = "default-on",
2 \) E: C% [2 {9 |5 G },
- ^6 K [5 ~( U2 Q* S};, k) m4 }% n* P! ~4 S1 m& x
0 y/ d' ~7 B5 u3 o8 m, ~" _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: c4 N$ ~- i; E3 @, n( ^ .leds = da850_evm_tl_leds,: U$ |/ K+ j7 c; l: }. Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 j1 t- c" x6 w1 O' F9 |& ]};
- }0 S8 U& g+ X5 q" Y* |( u+ m; B2 k5 P+ ~
static void led_dev_release(struct device *dev)/ Y0 n( b9 Q6 I: X" k4 }! v
{
6 I f/ x- t" K1 O6 P) m/ C};
! l8 z# }6 d6 k @
' b- S9 a; A U6 tstatic struct platform_device da850_evm_tl_leds_device = {
. A2 R/ Z( O: _2 ]3 I. J .name = "leds-gpio",
% A+ t+ x, w, D0 z' J/ T8 F! y- m% z. J .id = 1,
1 H2 K' L) }/ x2 w .dev = {) T, c2 g- z$ j+ q" t, Y
.platform_data = &da850_evm_tl_leds_pdata,
) h! @; G# H# {+ h, o: q .release = led_dev_release,
: A% D+ ?: A- | }
+ B% e; e+ p: ~0 P4 Q* h};* s. [1 N$ d( n# e' q$ e1 X1 t
$ t& t* q: k, w% Nstatic int __init led_platform_init(void)/ k1 }2 D% O4 e
{
' n% g9 _* S* h! A6 w. ~) X) e int ret;, m0 A9 K1 ]9 @3 O3 b, |" ?, w
#if 0
. v/ Z( l4 B. [! ]8 x. R4 O0 r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) f, n8 T) q1 h+ R# ^5 d G if (ret)6 L. V( g# x1 q8 z. v( m# G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 n2 Q" _* {+ l3 p "%d\n", ret);
! U% B. R* V4 ?7 Z#endif
3 b2 L, t4 t2 A2 D2 H ret = platform_device_register(&da850_evm_tl_leds_device); k( J9 e7 g( x. P0 m1 I9 k, G
if (ret)
* @7 q6 Q3 C. n" d: w pr_warning("Could not register som GPIO expander LEDS");
1 D. Q' T- M8 E4 ` else
. q4 f) M7 E. A+ V3 L printk(KERN_INFO "LED register sucessful!\n");
! g! T0 ]3 p1 h. Q5 y U
" C- k$ x3 A, i return ret;3 Q( W( Q1 U3 C4 V
}! K! ^' F! H. f( J2 G4 f: X1 C
8 }% n! l3 G! M1 F; r, k1 `/ S
static void __exit led_platform_exit(void)
. H7 w. l5 r: ~{; ~* m# Z4 Y" _ e! c. k
platform_device_unregister(&da850_evm_tl_leds_device); D' \) m% k0 J2 W% ~/ W: f3 W
4 ]3 B+ _8 T* l4 t printk(KERN_INFO "LED unregister!\n");
9 K: U' w4 D7 D5 ^2 R( P. ^2 `}
) x! _, Y' x+ J% A2 q' c
/ E/ Z! T; c8 I5 W Omodule_init(led_platform_init);
( y3 F2 A& n6 fmodule_exit(led_platform_exit); \* a7 B3 J# k% [- E3 R
' t6 r/ V8 e. Z. S5 jMODULE_DESCRIPTION("Led platform driver");
2 k$ N7 Q, J' f" |: BMODULE_AUTHOR("Tronlong");
2 p: j+ z% {* i0 P: V1 lMODULE_LICENSE("GPL");) u5 G4 t0 m5 o- q! `2 Z! C+ F
# }4 U/ [0 p+ Z |
|