|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 X I3 ?3 A0 w#include <linux/init.h>
' L9 h; U3 a; j/ ~$ ]#include <linux/module.h>2 o7 m, H+ r: p" E, Y
#include <linux/kernel.h>
5 J3 B k& X7 d" h% _! k#include <linux/types.h> z& M3 T7 b2 L
#include <linux/gpio.h>
6 S. o* E5 p' }5 Q/ e* j#include <linux/leds.h>
2 j7 X" O7 O3 _9 D. Z#include <linux/platform_device.h>* {) j1 M+ R7 O. e
# j5 t3 k& Q0 x1 ]6 _
#include <asm/mach-types.h>" x* r6 f+ o1 M2 M: D* M H
#include <asm/mach/arch.h>
. M5 H0 J1 @: w7 n. b#include <mach/da8xx.h>
5 S7 _- ~% N8 n. X& p* [#include <mach/mux.h>
1 A6 S8 _1 C5 I/ w5 q: ]
k B" b/ [# g( J9 ]) a8 e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 i5 a: T2 r$ E, v2 `# x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ R9 p2 {+ P ?0 H% \. ?#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 E# z9 T( I1 M8 L# k3 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" `) \5 _+ S+ l5 q4 h# r
( e4 x, a; b1 o7 ]) }* j2 B) t, t
/* assign the tl som board LED-GPIOs*/
# |$ G) ^3 A! Q* `8 dstatic const short da850_evm_tl_user_led_pins[] = {
6 F7 o* \$ E& u/ T* {. I M5 C /* These pins are definition at <mach/mux.h> file */
9 v0 F9 x7 g8 P* a) T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ c' Y- ^) x" s6 U3 r -1) n1 i; [: o, Z5 A' _* D1 p" t7 _
};5 c6 h6 @4 x# S s4 o
* @+ d9 j! E4 y. {( U( } U8 d- Q
static struct gpio_led da850_evm_tl_leds[] = {+ z# A" k" U, J$ d+ Q, s6 e2 y
{1 W) k! A' X, N" H, o( w# {
.active_low = 0,
# W" m0 B) i; z$ |9 d .gpio = DA850_USER_LED0,
0 L9 Z9 K* a& H* s .name = "user_led0",* u2 A) k& m8 N) V
.default_trigger = "default-on",
1 |# `. N8 o" M },
+ K1 R0 U. N8 y' q& N { s; D/ a- A0 |7 D
.active_low = 0,
8 X0 x) l- ]1 Y5 Z* o .gpio = DA850_USER_LED1,
4 ~! t: e. L- }, A. D- U5 T- t .name = "user_led1",
' F7 H, j3 y2 d .default_trigger = "default-on",2 g! ]- [* I4 ?, z) E- a
},7 d9 f$ h( a- ?: v& o+ _5 J# A
{
1 u2 T8 N* e0 L n/ v .active_low = 0,9 F1 l1 K, E/ K
.gpio = DA850_USER_LED2,
4 B! e3 k u" H" A8 P$ J& _3 s .name = "user_led2",, a7 w/ s/ [. l0 d8 c5 h
.default_trigger = "default-on",5 W5 u; O1 p6 C6 u/ |
},: q8 W0 Y7 x* r, @" l
{9 [+ h( m/ V9 }( \, Z+ H- w1 e
.active_low = 0,
& c9 V4 v+ F9 Y5 r, |$ }9 c .gpio = DA850_USER_LED3,# U1 q" t0 Y: ]8 A
.name = "user_led3",# l, Y9 f% u( J L8 ]: U& n
.default_trigger = "default-on",
7 `+ H9 S5 v( l5 l# B },
! ]* m5 M7 S7 N};
6 U( N# L4 E9 z: @0 O( k, g; o( N4 k& f( M8 I8 E% _) W' g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 @ Y2 O' c" Z) o. L/ a- P( b
.leds = da850_evm_tl_leds,
) ~; R2 _+ z' q, D( p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ j0 t: I8 W3 s" O3 R" {0 _
};
3 O3 ?; |3 W& c9 r- K
7 c8 V% \+ k" M0 \ K/ C" r# m4 Q1 T2 ]static void led_dev_release(struct device *dev)
& q f9 d5 J8 ^! M2 R7 z{
' m) O. h( n2 }3 h/ a# b+ ~; h# d};
, Z! `! I( u6 f: `0 o+ ~" B& |
1 B3 u0 u+ V; P) q4 Y( z+ k7 |static struct platform_device da850_evm_tl_leds_device = {
0 I/ Z7 I) }7 {2 Y) Q .name = "leds-gpio",
0 x+ @- N; r& c .id = 1,
# I& g H& f3 n4 M( Q7 p; A6 t .dev = {
: t- J. ~( r- p .platform_data = &da850_evm_tl_leds_pdata,8 |$ S/ z4 }. i
.release = led_dev_release,' b) |5 V( A, E* T/ }; R
}; r* v/ k9 V( v( q! v; i% m
};
$ g! F1 u8 Q. s% S; H& h- m e1 [! b9 P: p4 I8 J
static int __init led_platform_init(void)
4 _. y1 b8 m% F- ?% [; y{
; Q0 m" Q# }) Y# ?% l$ B* V9 p9 R int ret;
0 c. ?" L3 r8 |0 F: S/ x#if 0
& `% g3 h( F) F% } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- ^& D8 u: h3 `2 N5 K" ^ if (ret)
; G6 e- C; {; @ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* q6 u$ h# ^& f "%d\n", ret);/ }* j( _7 y' D7 J* T% ^
#endif/ A+ O6 W% R2 m
ret = platform_device_register(&da850_evm_tl_leds_device);
+ {% A9 r$ U- a/ K' s if (ret)
7 b5 V; w2 W: k- [1 m pr_warning("Could not register som GPIO expander LEDS");& R* `: N8 Z" x/ ?
else) ^9 B# X% t" ?3 I% h0 V
printk(KERN_INFO "LED register sucessful!\n");
4 b& g/ ^# T- q% A2 ^) y9 C: w7 w0 ?! A+ M1 H
return ret;
/ W# A7 H0 M( D% W6 Q}
2 r; X$ r& J( l( h w% ^
5 t/ |: G+ l" ystatic void __exit led_platform_exit(void). U( U$ v8 s( U7 }& j: S
{
, ?. T7 X) l9 X0 k) M platform_device_unregister(&da850_evm_tl_leds_device);
- G1 R1 g/ i1 D" H3 x& U K4 N' _4 J/ n! b
printk(KERN_INFO "LED unregister!\n");+ D5 Z6 ]5 p p: h
}
3 E1 R2 ^. s: O5 N9 ?9 O
# x+ J2 J8 g! r. Z ?module_init(led_platform_init);/ Z9 f4 g, |8 ?3 T0 z
module_exit(led_platform_exit);6 ^8 O. A9 \7 y j* G+ h
) M9 a1 J2 b- H% X0 q* {+ }& }9 o
MODULE_DESCRIPTION("Led platform driver");3 M! w, R+ g! N
MODULE_AUTHOR("Tronlong");
$ N( v: U3 y8 o6 K; v" ^MODULE_LICENSE("GPL");
" J# X' _5 v1 O) |. P4 f
, Q) W6 ? p0 @# V3 S |
|