|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( r# n4 L) h+ Q/ {
#include <linux/init.h>
& Y5 W8 j, X9 @( \! M#include <linux/module.h>7 a- k1 q) M! x% N, G
#include <linux/kernel.h>3 M0 c" v" X; X9 w3 z j j
#include <linux/types.h>% A9 c( p1 |8 L1 K
#include <linux/gpio.h>
% }- c% S" g4 Z& d7 V: X#include <linux/leds.h>- h* \ g2 L# u1 B7 r
#include <linux/platform_device.h>& Q; _% }: c) R9 S8 O
5 t. E1 @+ j0 S
#include <asm/mach-types.h>
4 l) l& P) d5 O: W1 S9 t#include <asm/mach/arch.h> S" y( [& i0 y
#include <mach/da8xx.h>& n7 `! ~, P( e9 q" j. a
#include <mach/mux.h>
7 B- }( L. \) J7 B: \ R( O: j( o% V
: }3 `1 @/ m1 }+ x( t9 ?* F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 U9 F" j3 L' Z$ r8 C* c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, }1 C8 z4 H8 H5 r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# C- c. E1 |; {$ A; O6 I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 M2 b; N$ C+ ^# l' d. h9 c
8 D# O$ u$ L6 `/* assign the tl som board LED-GPIOs*/
( F& }" R" D4 J/ b' \0 L) istatic const short da850_evm_tl_user_led_pins[] = {0 w0 N% v1 ` Z; {
/* These pins are definition at <mach/mux.h> file */
* }, C h/ D: o/ e3 F DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, ~ s+ O, b } _" F L2 B" C& s0 a; f -1
7 _% r: \( V9 s j- n1 J};
# u; g8 @! @' i {! {. A% Z5 S% r4 w8 d6 j1 Z) }8 {
static struct gpio_led da850_evm_tl_leds[] = {
/ K2 T( m9 F9 l# O1 b {2 B2 n& C0 a* j9 R) s, w- z
.active_low = 0,
X! b, p3 V" H5 X0 S .gpio = DA850_USER_LED0,
2 a( S( n! M* x1 c .name = "user_led0",4 K% x3 z1 T: W
.default_trigger = "default-on",
0 D5 W7 D' c. Z$ { },
" e8 t1 f4 q( \" p% u% H {0 }% O& Y E: o, T
.active_low = 0,: ]" C/ D: H; T8 @9 `
.gpio = DA850_USER_LED1,) N; P1 w" {* C7 Q$ S4 w6 v* w) L
.name = "user_led1",. P0 H; m6 B6 V0 N9 @
.default_trigger = "default-on",# G3 X- @; P- t& O& w8 T
},, o% Z+ i( l% [9 n3 _
{2 P' O* D- r r1 _
.active_low = 0,0 r: _2 Y k7 t1 m
.gpio = DA850_USER_LED2,
0 h# C: q4 f$ O# ] .name = "user_led2",
- g, ]% @1 b2 K$ Y, v2 L .default_trigger = "default-on",, _9 {+ J, _6 \% b; H+ l" s- Y
},* z! N' U. s6 a, l: k
{- o0 v: j/ x/ ~& x
.active_low = 0,- ^2 P! h( f% V9 l8 w: ^0 Q. ^
.gpio = DA850_USER_LED3,7 ?/ Y7 J e% j2 f1 o: U) H
.name = "user_led3",
+ I( K- }; A; Z7 B9 D .default_trigger = "default-on",+ W" ?4 ?- N7 Y% P
},
' h; H. B" _* a6 J$ \: c: U};5 A. B! u& t3 N2 [6 P( ~
% A) @/ _7 c; w- Q* l: _8 ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" r2 @, B. S- M; ? .leds = da850_evm_tl_leds,
9 X9 k# `# h- R* o! ?6 a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ B3 A- r- s* i- M};
+ d5 a( m7 W, u" e3 c3 T$ Y2 O. V R4 c t7 T$ e; u
static void led_dev_release(struct device *dev)
/ N+ @0 @6 y6 Y1 B) e7 z1 I0 w{- S- T' R" M7 ^, h; I j4 ^9 ?
};
1 J2 C% j2 R' h3 w8 d( W. ^5 l) Q7 |9 L
static struct platform_device da850_evm_tl_leds_device = {
* ~+ _. {$ |9 d- W: Z .name = "leds-gpio",7 s* k! Z& O+ ~
.id = 1,6 Y1 H. I ^& p3 z4 m1 }" O9 p: G D. m
.dev = {7 V$ n* ^8 Y7 c& B+ A
.platform_data = &da850_evm_tl_leds_pdata,$ O/ x6 f# d& E F5 G3 ?5 k
.release = led_dev_release, G' Y: _8 `% e! [4 D+ O
}/ _4 d$ f/ W: Z9 Z3 r
};
& G& M7 Z x- V7 \( B" l' n' p# @3 {+ F8 o4 g( k$ ]2 U
static int __init led_platform_init(void)
/ d) ?) O$ Y7 o7 b% z% G9 O" E& h{' B& G2 \) |' N( [% p" z
int ret;: T! w; X+ m# a1 v* i" l
#if 0
4 t- T2 H5 f3 C# m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: B. x' n9 ~0 G: C0 }* ^
if (ret)
; o( j0 K9 ]/ S$ p7 G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 X# n3 H$ ~! `8 q "%d\n", ret);
/ Q; S, c# p# c! I7 o) C) I2 a# L#endif
- F0 W( ?4 [9 |9 _0 \ ret = platform_device_register(&da850_evm_tl_leds_device);: ?- u1 k9 y- D- k
if (ret)8 W4 @7 f. T, P4 t% t3 `2 S
pr_warning("Could not register som GPIO expander LEDS");. ] S" x" @7 g- {& \% z6 c: ]6 x
else6 o- N& H' L! l9 W+ y: f
printk(KERN_INFO "LED register sucessful!\n");7 i3 z6 p3 N/ n$ c# h
/ M8 b6 D! A) b2 m
return ret;8 @* ]: n$ e. V3 H6 ]% c. e& z' N
}
1 Q: o( R2 R. F# I' L! R6 e5 r2 W) G, S4 I+ N; C+ m5 M1 ]5 ^
static void __exit led_platform_exit(void)+ G4 S7 C9 n7 m4 `: X" W( i2 E- x
{& U6 B' g5 v. O( n; P
platform_device_unregister(&da850_evm_tl_leds_device);
+ d3 y- F; N1 [: d( i O
) U2 H v, ^& j- ~9 a+ A printk(KERN_INFO "LED unregister!\n");
! D" s+ V3 M, C6 p, z% k9 G% T}
/ J$ p: G, [2 v0 P
, p' W: ?' u3 Q4 {module_init(led_platform_init);& d' S+ B3 e$ u& `
module_exit(led_platform_exit);
5 m8 Y1 K w2 E2 i7 X% h( S2 o0 c3 I% A! n. ^
MODULE_DESCRIPTION("Led platform driver");' K+ m: {0 K% y7 B. \6 w- @6 k
MODULE_AUTHOR("Tronlong");( {- w5 h8 C8 ^+ p
MODULE_LICENSE("GPL");9 U! `& L1 P+ @6 k O+ ] |) \1 v9 M
5 ?2 l* A5 k" ~- l/ l
|
|