|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- I0 h0 M. a4 Q" L#include <linux/init.h>/ P" h5 `2 O3 g3 d$ S8 L* k
#include <linux/module.h>
3 A! I3 L! n3 g( | ?#include <linux/kernel.h>
0 C0 [! a: B1 a* R6 v1 K, H* a#include <linux/types.h>0 b: y- P/ d9 Q$ X5 I7 f* c
#include <linux/gpio.h>
/ { [2 g8 W! |( Q6 ]0 `) q% N#include <linux/leds.h>
5 D' x! F# x$ i7 ?( j#include <linux/platform_device.h>
, @; ~3 u! Q; J
: y/ s l0 ]) |. I#include <asm/mach-types.h>
. t* t# z3 @. ], g k7 X#include <asm/mach/arch.h>: P. Q! c2 i! N. B- O6 [( ]9 h0 x$ {
#include <mach/da8xx.h>
" X7 `: Q0 M& o2 k7 t. E# C( p) o#include <mach/mux.h>: P4 h! ^9 V7 d; Q1 p0 u$ \6 c. ]7 N, ]
/ v* u. b7 _8 m$ l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 w0 q8 I! C3 E. Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) p) w, S' t4 [7 q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) L4 Z+ E! l7 J, q- d& q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! h( r7 }" o) w: S$ Y1 y" i4 o0 I$ ^- G/ q% t; x& t
/* assign the tl som board LED-GPIOs*/
/ T8 e! n( p8 g* n) _static const short da850_evm_tl_user_led_pins[] = {* r, @5 r% W1 S5 Q; F& c0 a, S5 K$ h
/* These pins are definition at <mach/mux.h> file */
4 I' }, o5 v, { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ ?' A( I$ @0 W% u
-1
% n U; f' v$ Y, E. Z' [9 \- \) `};8 S) i7 n+ L9 q r
; S. g' [7 s3 a1 G8 U Dstatic struct gpio_led da850_evm_tl_leds[] = {
5 D. c8 X0 L* ]: o, P: ~& R {
3 }1 z& w4 @2 U5 D .active_low = 0,
' a; {4 N: A: L z .gpio = DA850_USER_LED0,. |( K7 [: R: _4 [8 P
.name = "user_led0",
0 G6 Y% l& g6 n .default_trigger = "default-on",. T) b' g* h9 V* _: |( K1 x ^
},4 y6 W/ q/ A0 ]7 v! N6 g9 A2 }! F
{
0 s/ R8 g5 |2 m .active_low = 0,
. Q* [( f* T5 Z5 J9 M .gpio = DA850_USER_LED1,& [# {4 `9 _. ?: w. Y3 J3 f
.name = "user_led1",
1 A2 s w+ s) Z .default_trigger = "default-on",
, B* o7 O& E5 g$ R/ _ },' A! {" T& A6 k* {5 i- T3 ?
{4 R" Z' \" y7 Q6 W" a
.active_low = 0,: S3 K3 ?! p- J: s
.gpio = DA850_USER_LED2,
' y3 k8 ], W4 E .name = "user_led2",' T9 R* E G, g+ }) C
.default_trigger = "default-on",9 `. \( |; g+ }- [9 E) R! B; \
},
1 o6 ]; I; S! F& u% S {; a q. J% o( {& n1 Y: s' b) q7 s& L) P
.active_low = 0,
+ z: C A# M$ Z0 |2 q" d- t .gpio = DA850_USER_LED3,! o3 ^" D$ ^$ s2 G
.name = "user_led3",; E- G5 e* `% I1 U# b! a
.default_trigger = "default-on",
. t" A7 H& U0 s },
* O8 O* G% K( z' l8 x; @6 t};
1 r' n v% F4 f
; L7 P+ `8 y; x" F( V8 {& Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; f E* s; y( W
.leds = da850_evm_tl_leds,
8 _5 f' p0 b6 \; a# N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 R. _! p) M1 s& P
};2 [$ b) p- J l' q s# `0 Z1 P& x
" N' y5 }0 \6 m" L% l
static void led_dev_release(struct device *dev)
; {, ~& a9 S2 L" ?/ h# t+ Q( x{! f/ `- X# X; B4 d# I9 Y- Z3 x
};
. M9 y {/ j$ k( t. C# ?8 Q8 L/ x6 V6 G( x; O8 J. b
static struct platform_device da850_evm_tl_leds_device = {9 o" w# L( Z) x
.name = "leds-gpio"," Z9 e/ {6 ^! e* x4 ]" m, \# C3 P
.id = 1,
' z* `5 A' l1 x* t, w .dev = {
3 B/ z* O3 p+ g$ B* V6 Q .platform_data = &da850_evm_tl_leds_pdata,) f3 U* {! }, I% _- ~
.release = led_dev_release,
X5 B+ @# g- h: A2 e d4 o }& M* g6 U4 L# s7 f/ N
};( w$ Y3 r4 p4 b3 b" F( C
" l, y2 f/ u" m2 astatic int __init led_platform_init(void)- l7 m* v% E4 Q. k1 C& g' l8 X* o
{+ ^' o' o: h/ J' j$ q; D G
int ret;& K! {4 o; \& N L5 o7 h5 g( d4 L3 U G- Z
#if 03 o6 `+ [( M) T9 Y. C u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" o; [0 K5 m: G$ g
if (ret)' H" f* M8 ^; L: h8 ]# A! S( D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 Q- H$ I3 _+ R) [6 j "%d\n", ret);
' O3 O& F. i# M#endif
6 X. k1 a8 ?- g9 T7 `; L U' d ret = platform_device_register(&da850_evm_tl_leds_device);% M6 d0 I p" ^ [* N/ n
if (ret), B0 _; W- s5 d& z
pr_warning("Could not register som GPIO expander LEDS");/ e% ^6 y% ]" c
else
' ^5 Q5 x" ^8 W0 j, [# p printk(KERN_INFO "LED register sucessful!\n");$ R5 D$ A! X, E: n
- @( M- k* ?" F4 Q& k return ret;3 N3 C& ]6 Z9 k" O. g& ]' D
}' \1 X/ @& j# l* X. D, B: E
2 ^4 ?) i/ X9 |; r, e, ustatic void __exit led_platform_exit(void)
' f9 E. x/ q0 P0 G0 U( M{9 s4 G! C, u: a$ P! J! {, L
platform_device_unregister(&da850_evm_tl_leds_device);
1 B( O& A) J* N) ]% ]* d' \. |! j" b3 c# J, ?2 w; ]/ {% \
printk(KERN_INFO "LED unregister!\n");0 R. q- ~, v! Z P w
}- b- r# d/ n# e8 k& h
, `8 i; F7 b" R3 e) H2 j6 Hmodule_init(led_platform_init);) i& [. N; r- u7 k, A* `
module_exit(led_platform_exit);
?1 E2 s' N }; |. ~; C5 e4 j" T$ Z$ u
MODULE_DESCRIPTION("Led platform driver");
4 R e3 H n. yMODULE_AUTHOR("Tronlong");! ]0 B f- r# i3 W, ]
MODULE_LICENSE("GPL");
/ K, `) k" ]# O' K2 b6 S& \' H7 z4 E( V+ G; z& ^; @7 r
|
|