|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, Y- }! ?* ]$ Z7 n0 [
#include <linux/init.h>
2 d+ M* e$ `+ f5 W9 h- J3 C#include <linux/module.h>
3 a7 i: h0 P& r; Q% C# v" Y2 I$ {#include <linux/kernel.h>
b3 V5 d2 s$ ^" p! t5 D5 u/ c$ `/ p#include <linux/types.h>
- r. m; Y$ }3 C5 K; n7 Y- ~#include <linux/gpio.h>' W- ?' D: c% ~+ ], ^! g- X
#include <linux/leds.h> Q1 r9 K& U6 w
#include <linux/platform_device.h>
2 N( g% G/ i" E7 `8 b0 S; ?% l _1 q
R0 ^* B7 D. b0 B! w8 F7 I#include <asm/mach-types.h>7 y( n9 G: Y5 x/ [1 t. ~4 ]' K
#include <asm/mach/arch.h>" v1 o `" y# E& p
#include <mach/da8xx.h>
/ P7 l1 L. p6 x1 ~1 m& X& S: f#include <mach/mux.h>
$ _- l6 U" [, {- S- g9 A W: y2 I$ U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* l8 r @4 U, }6 G; @# J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): |0 t Q0 t+ |& U1 n" I: k' z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ q* M: ?) l, A% N, f& u4 F- f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' \$ {) z4 _* i7 N; M# R& p
/ t# \, e6 ?( M
/* assign the tl som board LED-GPIOs*/$ K, @% t2 w$ N8 A B3 M
static const short da850_evm_tl_user_led_pins[] = {% I* O' u8 ~% M
/* These pins are definition at <mach/mux.h> file *// V1 ~. o1 ?9 R# E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
y8 R w) \9 [. Q* j8 ^, C -19 J( o/ t6 B/ W+ h( R
};
. {/ T( t* i+ b$ a+ ]% o S) s. w0 _1 M; U7 W, C. `
static struct gpio_led da850_evm_tl_leds[] = {
+ c1 L1 P' Z7 a, |. p {* T6 m8 N' m7 J6 j: K
.active_low = 0,
6 G" K& c$ r( a: B5 J .gpio = DA850_USER_LED0,, z# V* r; x: `0 ?
.name = "user_led0",
7 D' v% Q/ o+ O" ?+ N% f .default_trigger = "default-on",% I7 B( F+ g# F# P$ V: p
},
) S; l! [* n/ T7 [+ J2 H3 @% d7 ? {- V# g. n; _7 @) k e; V
.active_low = 0,# ?6 w9 {; r( ~- l
.gpio = DA850_USER_LED1,
; U3 _1 m0 b& {- R/ M" F .name = "user_led1",
7 f: A: `7 y" g1 s .default_trigger = "default-on",! P3 E$ a3 M t, K
},
/ H/ B# Y a5 b1 O! y& e. f {- s6 L8 F1 l' D- a6 a, J# S- K+ R
.active_low = 0,
# p# f2 u* ^. ?+ y .gpio = DA850_USER_LED2,/ C6 r) q! b! ~8 W9 O
.name = "user_led2",
, j( {5 R) E0 o .default_trigger = "default-on",, I5 K4 D1 Q. j) Q1 J) T; N: i. A( w
},
: A7 e( d" d# R4 N* Q) ^ {1 g! `4 u% q0 G3 ]% ~- H: g
.active_low = 0,
4 R2 w' i5 V3 N! C5 t# \6 L .gpio = DA850_USER_LED3,
3 H' m! O6 J# U: e3 z .name = "user_led3",+ p. ~: [$ q8 g* r' M
.default_trigger = "default-on",( |. E8 G8 }" r' Q
},
' _, P' O3 U' u/ m8 `9 c9 H l}; J. D( W1 \! Z+ X: R8 d% H
0 h" }' K& {' K1 n& L2 I* ?9 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { ^, T' `8 A# e, c/ t
.leds = da850_evm_tl_leds,( M0 G4 c9 z' l2 R# ?7 N
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ h* }8 b; {7 y, g: o- S
};% |' t2 Q6 `; c( B7 j
! g- Y. B2 F0 Y; f' q4 d/ kstatic void led_dev_release(struct device *dev)
6 [1 Z& [! U7 o: f) J{
; w0 q$ y& {; h7 g6 d3 H; m! j& a};
- J/ H: Z# B4 i
( Z k* s G- Jstatic struct platform_device da850_evm_tl_leds_device = {- o7 C5 t- O) X, b: B
.name = "leds-gpio",# P0 l, \ i; f( z' w. ~
.id = 1,
7 l3 m% } w& w. l" T9 ]% q .dev = {
& f! k" s5 A' w( x4 }. w .platform_data = &da850_evm_tl_leds_pdata,
0 G9 Z+ D* {/ L }$ f .release = led_dev_release,
9 K- K2 L8 W. y- D/ F" W0 o/ i }1 s; m: p% P" d. o$ P8 y' j! X
};3 v5 t: v1 @+ t
5 B0 r- H/ s8 `0 K( P3 Q: S
static int __init led_platform_init(void)& ]3 l1 l8 Y& B) L$ f o2 u6 ^
{
- [) e) O9 F: o1 J8 ~ int ret;7 T' T3 {0 q% `0 A9 p* [
#if 0
" Y, R& I+ T' w0 ^! o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- y4 Z R; N6 B$ H4 u5 z
if (ret)
) E$ @7 u. P0 v pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& m6 p& O/ x. | K% T "%d\n", ret);2 m- ]+ x, S; k
#endif8 }+ p. u+ Z9 G( W k
ret = platform_device_register(&da850_evm_tl_leds_device);
* V$ F" Y a" j1 O/ \4 {1 W if (ret)5 P# ~$ A5 E1 s# ?9 N8 |
pr_warning("Could not register som GPIO expander LEDS");
- n) r5 t6 C. t9 ]' Z5 R8 I else
3 m. o5 h c* A8 ` printk(KERN_INFO "LED register sucessful!\n");
: s6 V1 M e) ]( \; E
0 @! k5 a7 {+ W' C0 c return ret;/ I% ^9 F( ]+ s0 K2 }9 T
}9 n7 u5 @1 B6 i' ]3 F
* f# l7 `5 M k1 U
static void __exit led_platform_exit(void)
: A! A! ?) N i{$ g: `; R6 y# g. B- P! d
platform_device_unregister(&da850_evm_tl_leds_device);
+ t( M: Y- V# e. F1 b* Z I& j u" q# ]& G7 W
printk(KERN_INFO "LED unregister!\n");
( o2 r' n( @) y0 D' K' L' W; x}2 t) b7 z4 y- _+ }
4 ?0 o" n+ ^$ ]module_init(led_platform_init);: T; ?& F: d+ [: L H/ T! Z
module_exit(led_platform_exit);% B. b& g3 `" J. ?
! h, ^ Z7 b; J2 g( x1 s' D
MODULE_DESCRIPTION("Led platform driver");8 S0 H' k. U& v
MODULE_AUTHOR("Tronlong");
; i. w F* F+ j1 s+ B6 a8 Q' NMODULE_LICENSE("GPL");+ \! X9 p: y) g3 Q% T
2 ?% _# e7 i& j4 x; X
|
|