|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 d' _: p, _) V) c4 w* U
#include <linux/init.h>
% R6 q/ T% T# Q# W3 u. a! }#include <linux/module.h>
3 b# I! x, Z) x3 B+ K$ L X#include <linux/kernel.h>
: ]* I' d! }1 I! y4 v! q#include <linux/types.h>$ a; v9 R6 {* t/ [- S0 v' v
#include <linux/gpio.h>
) b4 a/ m4 I9 ?3 j& k F8 Y, v#include <linux/leds.h>5 L2 B. D9 h5 J. q/ ?
#include <linux/platform_device.h>( a. {# X3 j/ l c
! Q, i, f, _2 S1 T( I$ V#include <asm/mach-types.h>
$ g5 h+ C3 @7 u$ y#include <asm/mach/arch.h>' O+ Z. d$ F/ g( @' l- I
#include <mach/da8xx.h># r# ^. P9 O, n! y; ]2 G
#include <mach/mux.h>! d2 {' N+ o0 f( p- }2 K. e7 P Z6 L
5 C3 N7 d$ }7 p# d9 U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ h; H* Q. | |. T+ r$ T5 |! T: {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% d& ?- Y5 N* l" a# o- |+ c# q. {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 m: h+ L' i& `) h9 R$ i. H5 V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# W- E4 h3 t$ d9 C" I% L& F
9 D5 w2 C, H1 G* N2 W& @
/* assign the tl som board LED-GPIOs*/( e x# \/ T& \. `
static const short da850_evm_tl_user_led_pins[] = {3 I% K! e1 f7 l/ I! q, r: V
/* These pins are definition at <mach/mux.h> file */
' Q n& h! D0 e4 o+ \* \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 K0 n g* T% y. C
-1$ d2 [* v8 e5 E
};: {: P$ I4 q5 m
& F* g7 o& t; o: }1 p) Sstatic struct gpio_led da850_evm_tl_leds[] = {7 o/ b. U: B5 ]* _2 P! i v7 S, S
{$ g; D- i' R7 i- J- N& y
.active_low = 0,
" w! `5 r) a5 Z' Y .gpio = DA850_USER_LED0,
- R. d4 {/ K% M! A& | .name = "user_led0",
3 ~ X. t& c7 X, U* R! ^6 N2 m .default_trigger = "default-on",! ?+ A+ y5 ~ G. X- l; P
},) \, @# i4 ?) u# b3 w$ w1 Y# |! c) \4 C
{: d5 B2 i. _! }' N& F
.active_low = 0,4 t8 Q- g Z/ C9 M
.gpio = DA850_USER_LED1,
) R" ~8 W" o( | .name = "user_led1",
" b" u; c. \6 w* D4 c: ~% K* ?% F .default_trigger = "default-on", x# y" Z9 w) O4 D5 c! X
},
; f/ I3 D& }* R, s" B( g; ?, W L {) T0 ?- f. v, c) L) i
.active_low = 0,
8 H2 g3 O) ?+ m3 d7 ~, y7 q8 u5 x8 z .gpio = DA850_USER_LED2,
$ C0 w$ @7 ?9 B; R( \8 o .name = "user_led2",5 F# u9 [/ ?8 c! s
.default_trigger = "default-on",
5 J+ c& F+ O" m& o# Z },# m, M( H ?. F, V; A- ]# E# k+ O& {
{; V! T- B9 V6 g. n% R
.active_low = 0,, M! {' T3 v! t5 v% K% n
.gpio = DA850_USER_LED3,
5 A( C, B& P9 u) w: e8 x .name = "user_led3",
5 e- @ A0 e; @6 f5 O. C .default_trigger = "default-on",
& a a/ m! ? d, _0 q" t },5 l; g! F; M" D" ^2 R: Z
};* |( M: _$ u9 _" E+ S) u
: p d1 W, g) G- Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 g' {: {7 O% h2 b+ r .leds = da850_evm_tl_leds,5 a& k2 y9 X3 f" ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ Q I, u+ r+ R( l5 o0 \! L
};
/ _1 i' o' ~. e
& J3 Q* Z# ?, N+ S4 B2 pstatic void led_dev_release(struct device *dev)4 b8 D5 T) w. ?, ]9 r% i& x
{% L3 P9 H( {! I2 X
};
0 d% K2 T1 J; z& f
) Q w. M( ~% p8 x: qstatic struct platform_device da850_evm_tl_leds_device = {; n: e& X/ D' r" o& t
.name = "leds-gpio",4 N9 j3 |! N3 G
.id = 1,
4 |" c' ^( O8 y! ?' f .dev = {; _" [! ?& N1 w3 i; h
.platform_data = &da850_evm_tl_leds_pdata,8 Q1 r5 F) u$ U: y
.release = led_dev_release,
: d, q8 v1 q, |3 ^) }7 B# P/ d }
6 c8 s8 A6 U- M' x* M" u& o2 V};! ^! T8 n7 `! d
+ S8 c: e* j0 g3 N, S- Wstatic int __init led_platform_init(void)
6 J) A7 E2 U" m% r% S{* n: B$ D, V) L2 @- l+ W
int ret;. b+ U6 n5 T/ ~6 g! l
#if 04 {3 [/ q- K6 R2 j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 A/ d5 n Y- U5 t/ N2 o4 M% ]" _
if (ret) Z* |7 s5 _4 T& j2 g& {- T' y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ L$ R$ L1 }+ G. h
"%d\n", ret);1 k1 h3 m+ x4 i- z" D
#endif
^8 p c% h' q9 O8 `$ _1 ? ret = platform_device_register(&da850_evm_tl_leds_device);3 {. }7 w; ?' d# a* D q; L, x
if (ret)$ r% x- T O. Y I7 M/ s
pr_warning("Could not register som GPIO expander LEDS");
$ E, g% j) k- K H# |3 S5 a0 G j; u else, L. x( d( i3 q2 ^
printk(KERN_INFO "LED register sucessful!\n");+ o7 C( H# x; z$ Z
; K0 |' y- @6 D
return ret;" J! l. d. k. O. F, t
}
) p3 u2 |" r6 x; R
( o) Y& [: m Estatic void __exit led_platform_exit(void)
+ C# P1 d: [% r+ l{ X i, l" J- _# A7 P
platform_device_unregister(&da850_evm_tl_leds_device);
0 s# t: p; |" s$ p: W* \4 L7 g+ L K& p: Z' @
printk(KERN_INFO "LED unregister!\n");
5 f" W, z, U z3 s" Q( S1 i7 o}& R0 X L% a% q, d1 U& ?6 }
1 {* ] y8 u' I) @' P' L$ r }; w& `
module_init(led_platform_init);
$ H; @. T7 {$ }module_exit(led_platform_exit);. v+ p7 [' |, E; ^( V
* V5 {2 P- v: |! f
MODULE_DESCRIPTION("Led platform driver");5 g# C& y' J. A2 J" X
MODULE_AUTHOR("Tronlong");4 H* C' q5 |# x4 |
MODULE_LICENSE("GPL");
" k) I9 f+ B4 M5 |* y2 W- w! N2 B, }: q8 Z
|
|