|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 W2 u w* C/ n( s) M/ m8 s
#include <linux/init.h>
2 Q8 U+ i+ \6 H' V% ]: ^#include <linux/module.h>9 v% i6 N0 v6 H4 z
#include <linux/kernel.h>
+ D4 _4 x. T7 h1 `' ?- Z#include <linux/types.h>
3 g+ F" f* i0 l#include <linux/gpio.h>3 w1 L' y, p- O" c2 [6 O
#include <linux/leds.h>
( A) m( V4 l: B( z8 N) c#include <linux/platform_device.h>
7 w0 S! K+ ~% I3 L4 I
- o$ D& q' f+ n- S#include <asm/mach-types.h>7 s7 B* l; L: _: h% n3 U6 a$ O$ B, |
#include <asm/mach/arch.h>, [: U8 F1 x* V j" `& G( z
#include <mach/da8xx.h>9 ?! j; Y- j0 g
#include <mach/mux.h>5 V; ~) x5 p- h3 x+ @
3 o9 W9 }: B$ V# P0 q3 Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 B0 E" ?' W7 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ F1 ^7 P/ P5 V5 f/ C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 d* D4 \4 o! w) n J+ ^! P! S7 L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& z# P9 ^# z; d2 O" J
+ n9 ?& R2 W2 H! K" r/* assign the tl som board LED-GPIOs*/
( y2 h. n$ x+ c. Ystatic const short da850_evm_tl_user_led_pins[] = {
S# i3 ^* s; I /* These pins are definition at <mach/mux.h> file */8 ?1 e; T! x+ A% {7 z( n' z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, b: H8 K( \% ]: e, e/ Z3 u
-1+ j2 B) [' q9 q! {4 F7 S
};
8 ^: s* B/ O2 s/ u! {% M, X$ w) a: i; T8 C$ X1 i6 Q
static struct gpio_led da850_evm_tl_leds[] = { L- g- y" s# m1 j
{
$ Y* z- v3 w. Z5 O0 C .active_low = 0,
& ?" S- n1 f6 u% d1 s' |/ h" y# X .gpio = DA850_USER_LED0,+ w( K, u5 y' H
.name = "user_led0",
4 H# c# k2 b O .default_trigger = "default-on",
' `! _$ }7 ~+ J/ ]+ q( O7 g" m4 C; J },5 Z/ x$ d/ H" l+ a; I8 K6 c9 y' h
{; X& [" `" ~5 Q' I3 q
.active_low = 0,+ z. p* e4 a4 x0 f% H
.gpio = DA850_USER_LED1,% P' y. r: ?! `
.name = "user_led1",# ~# b# j% v% X
.default_trigger = "default-on",+ n5 Z- i% f5 J6 E2 X, @. N
},
5 l$ f# ~( j$ g6 V+ ] { y; M. E+ Y" h: p( ^& P
.active_low = 0,
0 H7 V- R: b5 T5 K; F; a, y5 ]9 m .gpio = DA850_USER_LED2,
" [) t4 E; b p& \/ u* c. i( l ^ .name = "user_led2",7 Z0 T6 L3 R* Y( @2 t2 P
.default_trigger = "default-on",
/ t$ }. x% L, ?& K0 a. W( v6 H },0 G- C! ~* [7 ^( \: u: X
{1 V1 ^4 o+ Z9 o: G8 I$ i0 O3 H# ?
.active_low = 0,
) g$ ] j! a4 H1 Z# t .gpio = DA850_USER_LED3,& W& c. ]6 A$ L. S
.name = "user_led3",
8 T6 Z) H7 u' `+ N$ f2 y( | .default_trigger = "default-on",
2 q# M3 V' L ]7 d3 b },4 {( s# f' F& x- H3 D' b) U8 }
};8 H3 H9 |9 U! f$ o9 o! c9 N
3 ]% K! p {- n8 n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: m- T2 K" {* b, j* g .leds = da850_evm_tl_leds,/ e/ @/ G3 [/ [ _7 e: s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),# F" i" G4 R0 W
};
2 `/ W# G5 V: B! a$ o, c4 O- ?% T* I6 d. l+ A ~) C/ ]% e. }
static void led_dev_release(struct device *dev)
1 m3 C6 |" ?+ x8 a# Y! a3 G/ q{
. M! y: Q( Z8 [};2 Y- @! \# R) i* f
5 N5 h" r+ r) N" O4 t2 S' Astatic struct platform_device da850_evm_tl_leds_device = {
) ?2 ?3 m6 s8 Y, F& X1 N .name = "leds-gpio",
/ T; h1 V3 x; g .id = 1,
( o4 w0 h9 d) l7 b# U* Q( J# p .dev = {
* e( I+ v) W; {! o .platform_data = &da850_evm_tl_leds_pdata,1 U+ F. X( T6 D6 i3 Q6 ?
.release = led_dev_release,) N. {3 \# T3 O, N& _
}
& a7 J }0 M, h" `1 O3 x8 M};: f( m% v$ X4 f% D0 R
, Z2 C( ~/ u- P5 T0 D' U( T+ z' istatic int __init led_platform_init(void)6 ]4 K, P1 {! \1 r; V( L9 X- I
{. c2 T4 m; H/ I3 k/ ~6 l
int ret;
# ?. ^% P& _* S8 I; C#if 0! o1 _: G# G! e- e* U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 m8 z9 g8 `+ V: x if (ret)
* W) s) O% H6 g0 o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' F: Q" q$ b: N. `" |
"%d\n", ret);
, N* B5 T) p9 H m* S#endif
0 {2 L! H. X6 `' c+ G ret = platform_device_register(&da850_evm_tl_leds_device);% \2 {& P. h" j, }9 q5 I
if (ret)$ b% k z: l* d
pr_warning("Could not register som GPIO expander LEDS");
( E' n0 X) l& J* p else) v' q4 ~0 X& O' B
printk(KERN_INFO "LED register sucessful!\n");
8 c; I$ z3 t4 N8 n. B. A! _1 G. T3 w0 y1 T7 _
return ret;
/ F8 a1 q. ]. p0 ]}
4 j2 l: Y. G$ m8 q, n8 ~" N
$ C7 p- Q. i3 P. x( _2 x* ?( U! @static void __exit led_platform_exit(void)
/ k" C$ `) G# _{: v4 N/ _3 X3 u) r8 N
platform_device_unregister(&da850_evm_tl_leds_device);
& A( J l8 \2 i' L; b7 h) X( [# w0 S
printk(KERN_INFO "LED unregister!\n");
. a- U' f4 Z( s+ l" |, ?}
9 ^; U' E3 Y3 B/ E) J" v: b2 u. `
8 T; G! a+ o5 d0 Smodule_init(led_platform_init);5 W, S% |$ N9 O$ B4 x
module_exit(led_platform_exit);7 J' y3 P) n8 ?5 U
) v0 E- J! d; j- H
MODULE_DESCRIPTION("Led platform driver");
7 @; ~8 A7 r0 hMODULE_AUTHOR("Tronlong");4 K( q; b- S+ ^
MODULE_LICENSE("GPL");
% P% g$ H$ t& m% d7 p6 F- K/ v1 @! K$ f* S( c7 K4 m2 ~
|
|