|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 B+ I( ]7 z8 U6 ]#include <linux/init.h>
% f. T- B) ?+ B" o#include <linux/module.h>
" G1 |; o$ `5 [, X#include <linux/kernel.h>
6 {1 \7 i0 [4 u- O5 M( ]% ~/ f#include <linux/types.h>* z9 X/ r M3 X# K/ D- x3 ]; h
#include <linux/gpio.h>
) }; ]5 U( H+ y5 F. X5 F# U Y#include <linux/leds.h>) D+ o/ r4 t2 W$ c
#include <linux/platform_device.h>0 z }. E; S& t1 a$ K1 A
$ h; Y' |9 ?9 ^) d/ L3 N, f#include <asm/mach-types.h>
( N |- \4 Z% K/ T- r: U#include <asm/mach/arch.h>
2 }! U, H; _' }+ Y& N#include <mach/da8xx.h>
* C0 A- M X& j9 s% o#include <mach/mux.h>% W1 @! n* ^; b1 h
8 u. b1 a; z- o, q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 ?( t" B! Y: x! X/ Z: Y0 @ k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- b! }- R1 a4 S4 |/ n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 J' H5 u8 @( v* ^6 f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 r1 d, f- s; j( `( c" z' b
' `5 e- A/ E! B* |# C; D2 P/* assign the tl som board LED-GPIOs*/% B* _, \$ N! u+ @
static const short da850_evm_tl_user_led_pins[] = {5 r% C6 p* _8 B5 o9 \
/* These pins are definition at <mach/mux.h> file */
' o N8 Z2 R4 t+ t, P/ {$ L; f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* Q3 y3 M& o* P o -1 D5 g; E# O; c% T& l2 {- x+ Y
};
, _5 ~' K4 {7 q n+ b+ x! @% W3 o; Q& b% K1 t
static struct gpio_led da850_evm_tl_leds[] = {
/ ?) d. ~+ R; |) ?* a {
2 F$ L: E5 H) m .active_low = 0,
8 l$ S/ E! n+ z) w .gpio = DA850_USER_LED0,. B9 _9 J2 r$ V' C3 N
.name = "user_led0",
9 R: Z1 t9 C* G# m' o .default_trigger = "default-on",
; p3 w/ S! T% V8 ` },1 \& y. T( l% G' ^! S
{8 Z) G( g4 r4 }" ^5 c1 ~. y* _
.active_low = 0,
2 X% t/ o, g9 t! i9 z% W .gpio = DA850_USER_LED1,
3 G$ `1 N0 ~8 u+ e .name = "user_led1",# x) w( x7 |1 J+ x
.default_trigger = "default-on",
: |' f/ u: i1 ~4 @! S },1 p4 o- N+ C8 a& m, }6 s
{
; k3 g+ D& z- Z$ O5 K, F .active_low = 0,9 @0 T0 `* u* i+ d2 |
.gpio = DA850_USER_LED2,$ ~* }( V5 N; n j5 \
.name = "user_led2",
4 |6 N7 O7 z- s! y, u .default_trigger = "default-on",& t* S! J+ e9 s
},& V X3 g: l* n9 q: }2 I; m# ~- w3 {: y/ C S
{ }( N& o" N: i& s8 Y* y
.active_low = 0,
- U; ~& ~- q. o* s9 l, c .gpio = DA850_USER_LED3, |& d. c( C6 w% d% f$ [- ]
.name = "user_led3",
5 c* A9 I% @" M8 D .default_trigger = "default-on",
/ \( N9 P5 t' k6 ] }, I9 |* l! R5 d/ L" C
};
: b4 M; I/ w9 p1 n; W/ E* `% }4 E: d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" \& u! B: @! U: x( g$ `$ P4 O( H .leds = da850_evm_tl_leds,7 ^3 U7 Y- o9 ^# Q! S+ ~' K& F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 L0 D; C) @* M$ y};
; g( ]/ v* v$ p' A
% D% Z$ |, N. _0 Pstatic void led_dev_release(struct device *dev)
: l# {1 s: a) t* m0 \{
|# \3 y0 t% X7 N# R! [}; x7 V* l, }+ \5 E
/ t8 S" o, Z4 |& d2 D$ M# U- E
static struct platform_device da850_evm_tl_leds_device = {
0 F0 B: M% a& U& @# f: b .name = "leds-gpio",# v4 c$ P' d A f" F
.id = 1,
7 f! Q. S$ v* P T .dev = {! _! R6 o7 l, R
.platform_data = &da850_evm_tl_leds_pdata,
7 ~8 o2 N/ l; A& _ .release = led_dev_release,
5 M+ e0 q$ K' X+ w }
/ a# n( _, h& Q \" ?' t3 }}; {. Z" ], @1 S. k; b2 E
% W4 i; S8 R, |static int __init led_platform_init(void)! v: s6 s; f, n5 Y# G+ p
{; Z& P! C; j& R' t' I6 p
int ret;2 j6 L5 ~1 @6 {% S6 u9 Y
#if 01 p1 D- h" j- n k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# D b- `; \6 @2 c" e if (ret)
8 f' d' G$ y0 S, |, C: @; J" V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' t, Z8 Z i R a' [5 ]5 l "%d\n", ret);3 h9 G0 s9 w) W% x
#endif
) W' k h0 o0 i6 T# C! U ret = platform_device_register(&da850_evm_tl_leds_device);; \) T- o! z9 R5 H$ u% V: y
if (ret)% k! d O2 z; `# g, M
pr_warning("Could not register som GPIO expander LEDS");
8 E8 ?( G$ c) R! U else
6 N, S( r9 ?0 [' S S printk(KERN_INFO "LED register sucessful!\n");
0 X$ _: R, x5 t8 G3 f6 J) W1 J3 ~& h: i" Z+ g
return ret;. C% Q3 A; T- s B2 k% v) i: [+ V
}
! q& P' }' j8 |$ w7 _# Y/ W
1 |! d! w* I: l) j* R, Jstatic void __exit led_platform_exit(void)7 e. I. t: ?0 }" T. h+ B* a
{1 V# ^/ C4 ^+ w# d2 [% @. \
platform_device_unregister(&da850_evm_tl_leds_device);+ E) _& y9 N; }1 L$ i
1 N6 x2 S1 k, T. r* y* n' o8 ~
printk(KERN_INFO "LED unregister!\n");1 \9 J) R6 H5 D9 B
}+ K" r, [- J7 F7 B
0 G4 ?6 h6 m% k9 \' \' Kmodule_init(led_platform_init); D1 Q# N, A: w8 u' U$ g# } E( q
module_exit(led_platform_exit);9 K; o4 @8 W' q, `& ]+ G' }, Z
: O X$ t# B. R, c3 hMODULE_DESCRIPTION("Led platform driver"); @$ Q# S" G9 p" q$ @2 W3 q% _: c
MODULE_AUTHOR("Tronlong");
$ H1 I- h; A- O1 \" i# YMODULE_LICENSE("GPL");1 w6 z; L( s. d
) c3 k; [2 V# t. v2 P' E
|
|