|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 W4 |( ?2 \! T/ l8 H8 d; g" S' N# o#include <linux/init.h>
. d$ ~$ q( K5 h#include <linux/module.h>
$ k) y3 [8 {& \+ x9 g#include <linux/kernel.h>( E# n. U( a" x5 M1 ~. t. q0 |
#include <linux/types.h>, r7 N8 p' h8 U9 h
#include <linux/gpio.h> h U5 d" J; L8 ^
#include <linux/leds.h>
0 f8 Z0 a t" t2 r#include <linux/platform_device.h>
2 I$ l" b- n7 o# `- c, U# y4 h
: P& s, N, }4 ]5 X' |5 Z2 T K#include <asm/mach-types.h>$ v, E( G0 e0 z8 J" ]' W; S
#include <asm/mach/arch.h>
+ N. C/ m1 w5 Z1 r4 n+ ?3 i9 n7 V6 u#include <mach/da8xx.h>
/ K5 R" O) `) R3 W0 T#include <mach/mux.h>: |& ^. O" w0 n" X! u/ O" W" O
. ^. x5 z% t' l% W2 U" r* @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! n+ Q# e4 _" H0 y# e9 h7 F#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% ^8 F# t( D* E, f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) u; G9 u- l; Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. r' {/ s# ?% W" K& Q+ C" i2 q$ k6 t
/* assign the tl som board LED-GPIOs*/6 E* B u P4 y F/ r G
static const short da850_evm_tl_user_led_pins[] = {7 w# s& ~, F2 ~5 O) @
/* These pins are definition at <mach/mux.h> file */; V& g h- D1 X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; K1 |& N9 F" Q -1" B0 e1 u/ M8 F; P1 w' y) ] B6 N
};% f/ z1 E3 P# d9 ]/ N) q
1 D9 q/ M Q2 x" b5 q
static struct gpio_led da850_evm_tl_leds[] = {) p w& w4 P: G8 {' `
{. B% ]: [: q* o# ]
.active_low = 0,, `( [7 c9 [4 ^5 B9 w) B
.gpio = DA850_USER_LED0,6 P; |4 P/ E6 a; W* H
.name = "user_led0",0 E0 [; |" \4 ~
.default_trigger = "default-on",
: `7 S+ A! }, ?1 t2 \# n },
2 p. X8 O6 `/ S# a) q2 |6 N' n {
3 T5 Q' P5 n# {8 M" U& {/ l .active_low = 0,
* N& I* a9 O2 E. J .gpio = DA850_USER_LED1,- Y2 E' X% i) \" ]$ v! I( }
.name = "user_led1",3 _+ u8 ^4 t6 Z0 e* n8 @
.default_trigger = "default-on",# N6 O7 V1 d! l' j! v8 V
},
( K' H0 d4 b1 }4 C7 h" Z {0 E* e+ }: w: C9 y; K R/ U, @) B4 N
.active_low = 0,5 g% n& z) h- U. {- ]( l( o! k) v
.gpio = DA850_USER_LED2,
$ e2 L. l) E& ^/ q2 w .name = "user_led2",% l$ W: D O5 e
.default_trigger = "default-on",; a N) b& H/ E* \8 k
},3 d' R( d3 U( H8 f7 c% U" B4 T3 n5 o
{
- d/ z6 C) a! X, y v .active_low = 0,& [) @7 ^6 M: u% @2 w& g
.gpio = DA850_USER_LED3,5 {9 _8 n- H0 b; c! ]5 p9 t! _6 e
.name = "user_led3",
$ m- I9 F7 z8 L+ V/ c: I .default_trigger = "default-on",, X- {: u7 m1 H* O0 z; Y( Z
},
) j+ G3 h' q7 s6 ?( z0 e: h};
6 V- G- G1 n- R0 w
6 u% ^( q$ r8 c' W0 N0 {2 Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 C& R9 y" d1 y. @
.leds = da850_evm_tl_leds,
0 x4 U) S0 M* G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' G9 ^. r, k% G- W
};1 x! u0 `4 }' r& G
: n, e: t3 ^% }/ c! \6 }
static void led_dev_release(struct device *dev): m1 W( l# n r5 S* ^. f5 o
{
6 J& F! T# a4 S$ {$ b0 q2 N};
$ W f1 P4 Z! k) z/ ?! {- F7 L" ]
static struct platform_device da850_evm_tl_leds_device = {% X. U& v. J$ C* v$ Z
.name = "leds-gpio",
: F# G" F6 a* O, { .id = 1,
) n! F- t4 ?. i% N9 q3 }: a& ` .dev = {* Z/ `! B% S8 i: C
.platform_data = &da850_evm_tl_leds_pdata,
- Z( F- _% D7 T4 G% a3 S, R .release = led_dev_release,# c4 y0 m" G* Q; O6 ~7 \+ z2 l
}
! C! @) _5 f" ^};
2 r5 A# I, Z$ E' {8 r' o- T( b3 a, i3 i, w
static int __init led_platform_init(void)
4 v- ^2 R/ B$ w# v{8 ^- q( q; C, U0 _
int ret;6 L" R( m3 Q4 P( `. H& Z/ d
#if 0
7 `% c& a+ }5 e6 ?' F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. X" I8 M0 q$ O6 p' }$ W, j if (ret), n9 z2 }; u) S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 m( T* T# b* T "%d\n", ret);
7 Y9 Q I9 E" R4 q#endif$ `5 _6 O: d8 H5 m! I. {1 D
ret = platform_device_register(&da850_evm_tl_leds_device);
+ o- P! E1 z+ `, {8 W% | if (ret)& H! W6 `( \ G" N
pr_warning("Could not register som GPIO expander LEDS");
% G" I" V1 P. M; H& O9 N- Q else% Q" j- {: O* j$ Z3 v. |# W$ H# ^4 M. g
printk(KERN_INFO "LED register sucessful!\n");% { d" C# E$ n* K/ A( O: x6 \
7 q0 h' Y! }( p) X5 n, s. D return ret;
( u6 n' f- \2 R$ _& R$ ]$ g# a}
$ |, L) I* P1 {, ^1 r- u0 n
' {: X+ ^. ?, pstatic void __exit led_platform_exit(void)
: V2 |5 `* d( T{
& M9 }: B( D5 P+ g) V& w platform_device_unregister(&da850_evm_tl_leds_device);/ G K5 [- M9 A" R5 [; B. w
( o; K4 x7 W7 Y4 ]1 a
printk(KERN_INFO "LED unregister!\n");
$ Y9 V" a1 N: J( x) y' A}
' I2 a* d$ I" n
% a/ D) ]7 F4 X3 v# wmodule_init(led_platform_init);
2 K( R t9 A: ?% V; Z. \0 tmodule_exit(led_platform_exit);
1 S; y$ x9 I( M" f# h; b, n& x5 L0 O: H* k$ `
MODULE_DESCRIPTION("Led platform driver");
2 N4 H) t& [- ]" b1 }+ o" q* bMODULE_AUTHOR("Tronlong");$ L! b/ W) u) G% p, @: N. k m
MODULE_LICENSE("GPL");8 A7 j* O, U4 g, o w
# Z/ D5 N. i4 N5 ?5 n3 K2 A |
|