|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. U8 w; n1 }5 I* q9 n#include <linux/init.h>
& K% c5 J4 }5 C#include <linux/module.h>
+ {/ o( ^1 {( Q, B& J#include <linux/kernel.h># @2 A& y* D3 [9 r
#include <linux/types.h>) [, u) y. E1 O6 P* L1 L. G( K) m
#include <linux/gpio.h>6 q2 l9 p9 q# A3 M
#include <linux/leds.h>( r! } k' U; L$ ?. p; {6 X
#include <linux/platform_device.h>
" I6 C) M4 J& w2 \( v/ N7 U' M* W# t( _) K
#include <asm/mach-types.h>) m6 h z' E4 C. {! D
#include <asm/mach/arch.h>
* C7 A/ V7 O$ T V( j, m4 |#include <mach/da8xx.h>) |7 m. C0 a% L8 N/ Y* g7 G
#include <mach/mux.h>, R7 ^" v1 J* D& ~% Z
' b5 i; I. X- G! [: v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 j/ [5 S5 F8 Z% E/ R" _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 ?! C: M+ t" ?" W* e: V7 ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( Z; Z' u& r# {) c, Z8 y- V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 Y- `. I* B% {* m5 u( }" K1 K9 P8 W- G# h
/* assign the tl som board LED-GPIOs*/
& \7 `& U( v+ Q( zstatic const short da850_evm_tl_user_led_pins[] = {" E" g+ X* f1 }, e% b1 {; Q
/* These pins are definition at <mach/mux.h> file */1 ~; B& D O5 G
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. x6 j0 j6 @$ ~2 B- Q/ h& N
-14 }8 }9 k( p k- d
};+ s; e+ V, Z$ |& P8 ?5 q& \
; O* }3 K4 c# R2 R5 K9 Kstatic struct gpio_led da850_evm_tl_leds[] = {
% l3 P" d- ^/ k) l C+ i {" K h* F5 a7 F' ^) `
.active_low = 0,
1 B2 H6 Z2 u" R3 X" j& J .gpio = DA850_USER_LED0,3 |% k ]* R$ r" S, m, j* W. w
.name = "user_led0",# V9 I, d( V3 A5 {; ?
.default_trigger = "default-on",$ Z2 [- D4 u0 Z2 p' y) b4 D0 s
},1 r3 R5 _. w8 W& q) H+ ?
{4 l) ]8 g6 p/ l- I# j i7 `; R
.active_low = 0,
+ u$ i" e7 M6 B! M7 Y .gpio = DA850_USER_LED1,6 O! P" u+ `6 ~ T6 k, x0 F) C/ T
.name = "user_led1",8 l0 H" x0 q; o3 ^8 S
.default_trigger = "default-on",
h1 Y) E a ?% y' V7 l9 P+ ? },
; V6 `5 L0 X) |5 ~8 y# l( k. p/ ?. F N {9 r1 a' I3 c2 C G. ?
.active_low = 0,. _( C/ R6 c4 x$ L
.gpio = DA850_USER_LED2,1 g9 U( E' p p/ M/ R* p
.name = "user_led2",
3 k" N% O ]% t8 g% h+ L* f .default_trigger = "default-on",
. h- J5 V x q+ g },' I" q# v1 I, Z: Y$ H& q" g% F8 `
{3 [" o& o: ?* x9 w: `
.active_low = 0,
' L& \$ a! z# D+ v; F .gpio = DA850_USER_LED3,
1 n. a2 z: O( s- [ .name = "user_led3",
5 Q9 m7 T/ p# ? \0 G" R .default_trigger = "default-on",
o* Y- D6 w y- E },
: }; I1 F1 x& W7 c& p+ ^, D};
6 u" D( _. K9 \& ] U* `
5 [3 I; t! P( _* l# Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 E+ U, c/ [# R# H* q5 [. E; @# y .leds = da850_evm_tl_leds, k5 _2 c' B F' t* h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ D) s b0 N- M' r( i7 k};
5 h0 N9 q* V+ y( X& o/ N) S8 g) g$ R3 `9 B6 Q. `+ F4 O
static void led_dev_release(struct device *dev)% i% I7 k* P/ {! {* R
{4 W% @4 R) T8 {2 R& M! L
}; V8 ]: `+ y {# c; U: o+ G3 ?
4 x: f/ W/ x5 w% F, c/ ?
static struct platform_device da850_evm_tl_leds_device = {
8 }: \( \; A7 A( a" y; N! n .name = "leds-gpio",) {( [2 u9 ?, B8 x6 m2 D
.id = 1,
3 z3 t. G- d- _0 h: R0 z# }2 } .dev = {
5 `2 m# |0 ]" V/ d7 f/ { .platform_data = &da850_evm_tl_leds_pdata,
- W3 g' W4 L9 h4 N" [ .release = led_dev_release,9 {6 E' o' m' H( J+ F1 y) Y
}* ?, _* d! e/ f! K( C
};3 `0 }0 `0 S) E' ]
/ ?4 C( ?" |( J+ v+ k ?
static int __init led_platform_init(void)
& C( ~! R- [" ]- m% z4 h{
3 d) m. h! t# s0 [ x& j8 ~ int ret;
+ z) C3 [. f3 { A A/ V3 y#if 0& ~. m9 W( p; o# |4 z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" o# T0 O% }4 m( T3 q3 q7 \, |5 a if (ret)
0 K- j6 g' H g2 D+ U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ C' A. V7 h1 W5 Q- E. P: C. O" O, U
"%d\n", ret);6 t! `* N$ H s
#endif
, {6 r6 s/ l, e) ^; w4 | ret = platform_device_register(&da850_evm_tl_leds_device);/ z) g. ^ V( P
if (ret)
; H' H! Y& a& K) B9 ~4 X pr_warning("Could not register som GPIO expander LEDS");. _: S& G3 S; U5 e; C l
else
! I2 q; Z! j8 I F) d printk(KERN_INFO "LED register sucessful!\n");
! v) ?# }3 h( I9 z" B
6 f1 h' Y% @7 R6 D! _( W return ret;, w+ c% }6 U6 B) m y+ H
}
/ o4 z3 C" V, U/ O8 O% u8 g; j% ~2 g8 |3 d% s' h
static void __exit led_platform_exit(void)
[! F6 l$ f. q{
2 O, B! v3 D) R8 k, h$ L platform_device_unregister(&da850_evm_tl_leds_device);
, X1 U" Z; c' D6 a( B
) [) A" \, q6 U$ Q: }; @ printk(KERN_INFO "LED unregister!\n");
/ S' n2 ]' L6 R5 y- N( G9 ^+ T}
' D5 f. }+ d$ I
. i$ X+ P# z. Fmodule_init(led_platform_init);; N. c* T) t1 D3 B& \
module_exit(led_platform_exit);1 }% Z( c: \) j6 `& [0 x. w
" U5 }3 z# l* j/ n0 E2 P4 JMODULE_DESCRIPTION("Led platform driver");1 Q, E L, V- f/ C
MODULE_AUTHOR("Tronlong");% T2 G2 `7 c6 [& K2 U
MODULE_LICENSE("GPL");4 [1 F# B% Y# {7 K1 H( o( F* [) l
; C! x! O( O) b' J# m( c' L
|
|