|
求大神给下面的程序做注解,请稍详细些,谢谢。4 K% }- j7 F8 i" _( q, x
#include <linux/init.h># W0 N+ c" z3 K1 ^( t6 Z; ~$ Y
#include <linux/module.h>
! F, L3 [$ y! |3 i, x, S' i& m#include <linux/kernel.h>0 ~3 ]+ ~7 c* ?1 @/ w' G3 Z: c3 @
#include <linux/types.h>) c d e) W8 k1 Q6 e0 ~$ Z
#include <linux/gpio.h>$ V0 C) V. C- A/ |( h
#include <linux/leds.h> \' G9 H7 ~( C% ?; U+ j
#include <linux/platform_device.h>( `1 O! t7 Z, }! Z+ S' E/ t9 i
$ e9 ~* d' _5 `$ Y# N
#include <asm/mach-types.h>
& e' b2 [% q0 N5 C3 D( t& r#include <asm/mach/arch.h>
4 r2 ^; C* V- }. X% P#include <mach/da8xx.h>
( d7 n. m" ^$ p# C#include <mach/mux.h>4 l6 E7 @$ P- b0 l/ J# @8 `. ?
/ X7 i( o$ q9 a* ^. }7 t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 X- {/ I; j, r#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: V8 q [- o* r W+ v ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# x1 }& I0 I* a6 r, f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) l5 `3 w: v, V/ X/ R, ~; ~
3 R" G( l: j3 |" G. V9 S/* assign the tl som board LED-GPIOs*/
7 W* H: J: M6 z9 J6 T8 u( Jstatic const short da850_evm_tl_user_led_pins[] = {
/ F+ [/ O4 m! v! O) T /* These pins are definition at <mach/mux.h> file */: j- f1 n+ s# E! U7 B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' |: l: J) Y2 w
-1, {1 t( C7 o+ d4 |
};
' \+ o, Y# ?- m; z# V5 m$ e5 c1 }8 s, j7 }$ t$ f
static struct gpio_led da850_evm_tl_leds[] = {! W; b. g6 a( a" K
{! @" a% G% X4 A0 l- z# z
.active_low = 0,
% y2 X. [# g+ B" o) j .gpio = DA850_USER_LED0,
: _7 N3 b& l8 B* T2 U .name = "user_led0",; g$ p4 ?- L) f0 G, O; ?
.default_trigger = "default-on",
3 [9 k5 a% u5 F- W/ G, V },7 a, ]9 E# Z& B+ @1 P, B4 y! O
{
0 p0 w: l( E9 a) [3 w .active_low = 0,
# ?# G% v- @; {! @% F .gpio = DA850_USER_LED1,7 t/ _4 x9 N$ A& P: G0 m% I& i
.name = "user_led1",# ~/ q" Y0 }0 i. v7 K: S
.default_trigger = "default-on",
1 U9 U" ^! f0 y( U. X u. h! { },9 @# ^) ~& k1 B! M' Q. j4 R+ ^
{
9 Z) X: n- o# l6 e& s' r .active_low = 0,. f0 X% S) |) V1 \( G/ E
.gpio = DA850_USER_LED2,+ b( R4 `& \+ T3 h
.name = "user_led2",- B& c! }# P2 V8 Y2 D; ~* J# J
.default_trigger = "default-on",' G4 Z9 g# \2 X2 U' B6 z6 S3 {! i# d
},+ }2 G. S. L w3 p/ X
{
5 I+ K9 y% Z$ ]/ ~" \; F .active_low = 0,$ z- V7 e9 l2 X& F
.gpio = DA850_USER_LED3,
8 t* y+ n. D/ n5 @: i .name = "user_led3",
1 C+ |( v( v& e) @6 m' [ .default_trigger = "default-on",# D- P; g$ q+ }0 {
}, d" ]& c% w9 a$ q& p1 R
};/ v1 {) M6 w& Q3 q" { d7 Z
: w$ F8 b5 k: N7 ], j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" O, C) ^ N" O+ f, A .leds = da850_evm_tl_leds,# ^/ { `& a" N! A H0 w8 q! l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* V' p( `6 z$ v- U9 l4 ]
};8 m8 p) J! j$ e/ P) ?- _+ v8 |
: z/ Z8 h3 g4 W0 `- Y ~' Y
static void led_dev_release(struct device *dev)
) @; c8 F$ h& T6 c9 d{
7 k$ ?3 ~" \2 ]+ |( T3 _5 `};! i9 n! m4 G9 l- q) _5 G
7 Z# C6 Y; F# d8 f# H
static struct platform_device da850_evm_tl_leds_device = {) U% J5 x5 o( ]9 \2 l
.name = "leds-gpio",
" P2 r: {& m" c9 m K( l, I, Y .id = 1,0 c4 K5 o4 W3 h ]
.dev = {( |9 I8 T; C0 n, C
.platform_data = &da850_evm_tl_leds_pdata,
0 D7 c% v" P$ B .release = led_dev_release,
4 W% g& Z- E5 ?2 {* r0 U }
8 h& x2 l/ s5 `# e, c8 j};5 Z. w: X$ |, w( a. [
, X5 b- H) I: n9 W* A# s
static int __init led_platform_init(void)6 t3 L! O4 L# G: Q
{& p" ]$ |. ]: R% X) I- ?% z
int ret;) j2 g8 K$ z7 s$ N. d0 @! I
#if 05 ]* _. E& _! C( y9 E1 @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# F; z2 s& i. F if (ret)
& [0 L( n- ~- R1 I+ c/ R* F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" J% q9 r& J6 s1 L, Z
"%d\n", ret);- M' j' Y+ y' ^/ h
#endif) N" f2 \$ f& p A
ret = platform_device_register(&da850_evm_tl_leds_device);. T; I# g' |. _$ B
if (ret). k/ Z! @) V- k* F: {( k5 S4 |
pr_warning("Could not register som GPIO expander LEDS");' j) |8 m8 z1 e- _/ J
else- X$ ?9 u& ` |. ?: s; m' V
printk(KERN_INFO "LED register sucessful!\n");. d3 C% |! ~3 X* T7 q
. C* ?* P$ \, q& k return ret;3 L& P m! Y" @ J% h/ {
}( V1 L4 @) h4 k3 u$ K; P
4 f9 b9 P! p2 \# f/ r4 P l3 a9 astatic void __exit led_platform_exit(void)$ H- v6 w% J0 o
{
! R! g8 x( h/ s* B& h: {6 | platform_device_unregister(&da850_evm_tl_leds_device);
5 w# O/ j9 I4 g; {( o9 r) K2 x+ |- F7 i' ?4 N
printk(KERN_INFO "LED unregister!\n");
7 H) ~0 W$ ?$ p5 H& @8 G}
) o: s, y8 w; H: W, W! L/ c3 d3 W) F
module_init(led_platform_init);0 S ~2 u! y: C3 g: {0 j
module_exit(led_platform_exit);
+ X# g' T+ O+ h. K" t& S
( u8 _0 L+ p+ Z: aMODULE_DESCRIPTION("Led platform driver");
) @- x8 A. o+ b' E4 v6 sMODULE_AUTHOR("Tronlong");
! w N3 R& }. C4 C$ S0 e. LMODULE_LICENSE("GPL");
# y9 L+ N; b& |7 J f
c! V" q1 k8 q% W2 p; v+ [ |
|