|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: \ X" `9 F8 k' L$ Y" m+ G
#include <linux/init.h>
0 E6 M3 D/ r0 t6 _8 Y#include <linux/module.h>
?9 w3 S' N9 H' c8 x+ p& ~. X( x( w#include <linux/kernel.h>
0 f" P9 i+ c8 [- [" O#include <linux/types.h>
1 Z/ A3 h) w2 X* \/ A& R7 V#include <linux/gpio.h>
: o7 c2 }. R6 D#include <linux/leds.h>9 Z# A. U& z* g, Q
#include <linux/platform_device.h>, H7 F- Z: j, N) f+ {2 @
7 P9 b( i1 q3 K! l( `#include <asm/mach-types.h>; s- T( K1 G6 U- q2 I
#include <asm/mach/arch.h>* O! B" |% |. |9 \* K
#include <mach/da8xx.h>
4 v3 i$ k% P4 ]! j2 @5 T#include <mach/mux.h>/ G0 Q: g+ w X! q
) j+ M7 v9 F9 y. V( ~
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- |9 T ]% i: `7 {7 P. x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 L, }7 g1 j6 z+ t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 X) v) {, x6 `9 E/ C$ G5 i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& n' m2 i+ V5 b" k9 J {, @3 G5 k0 S) A
/* assign the tl som board LED-GPIOs*/
' h: o5 i# m3 ?+ h# \' Astatic const short da850_evm_tl_user_led_pins[] = {
* O# c( T" z6 z8 R) o+ t /* These pins are definition at <mach/mux.h> file */
- g" j: I. {. k6 ]& ^# q4 ^ T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, `$ s& X# `4 @0 C5 X& I s: e
-1
' F6 d! T# Y. F7 i8 _};
]1 {0 |1 S6 [& j- ?" w7 W
) M4 f. f: ]/ J- Q. P. y5 nstatic struct gpio_led da850_evm_tl_leds[] = {
# w9 x7 Q& ]* f8 b {
: u3 X' T# j- B0 n& X9 Q u* d' F .active_low = 0,
* K, ?9 n @* l% ] .gpio = DA850_USER_LED0,/ O( w) X& o# u1 A4 ~3 D4 u! }
.name = "user_led0",2 `/ J3 m: N- T% Q, \# y* N
.default_trigger = "default-on",
I* E5 A' ]) U9 N: D/ [9 U& \/ y },
, d: b- P; D- ?6 \. @ {, u* O! ?1 L9 {- Z& \) m
.active_low = 0,/ p' H4 p2 q, V" m& w
.gpio = DA850_USER_LED1,
c. y3 v; |# C: f% w0 k/ R .name = "user_led1",7 i: A d O5 d, C
.default_trigger = "default-on",
$ r4 T. T1 W7 Y$ p- a* X5 v },
2 W, H( _: X( w7 ~( z0 k; N {
9 F( |% A* i" m8 I9 ~0 O .active_low = 0,
/ K, h! q; O: M- f& w .gpio = DA850_USER_LED2,% l* j, t( {+ w5 O
.name = "user_led2",* P, w: v. x/ h
.default_trigger = "default-on",0 A2 N$ y* M- d
},
( ~: t& q) R9 E6 U {7 o7 ]) K; f2 b) q! N
.active_low = 0,% o' t' V0 T* I1 N6 u" m E" D
.gpio = DA850_USER_LED3,
, ]' D7 M' f* f- p .name = "user_led3",+ h5 g w+ W% }# o3 }) K
.default_trigger = "default-on",
$ h' {! V7 ?) ^* s4 c },! E }4 F/ \4 e4 d. b
};" _- ?+ R$ E6 _/ P+ K
- U+ w( s# c" K5 W# i8 d, P9 ?; Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& ? |/ |$ I% p/ p
.leds = da850_evm_tl_leds,+ m6 M F# ~! J+ T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& B9 @; v, v# j$ `" B};
, t" E; `: B7 C/ J* K, \- A% B9 q. _/ Q6 i* W" g# ]
static void led_dev_release(struct device *dev)( T7 p0 N& w6 M5 w6 r& C+ w1 `
{5 f5 H* m% R3 e' \2 R
};
% U, m% n8 s% `1 H7 U: v# v/ K, M8 H: M3 v, e( \2 u* `/ a6 m
static struct platform_device da850_evm_tl_leds_device = {' F4 w2 k% \" A# H# K
.name = "leds-gpio",1 x; |( n& ]. I5 {! r0 Q/ o$ ^$ o
.id = 1,, o- ^4 \* k2 w
.dev = {
: R0 s) d- E/ W* a6 x' i" |4 n3 w .platform_data = &da850_evm_tl_leds_pdata,
% i- o0 E$ R! ^ .release = led_dev_release,! ]. E+ X, y8 r
}
1 B6 u0 G/ n; G) l" j9 \4 h+ v};
* @" X* ?0 L7 q3 c7 L8 e! g( W& n3 ~/ ~, V8 y0 x6 [+ U
static int __init led_platform_init(void)
# c5 n+ P, R2 Q; ]{* A& K& _4 A$ S6 U V8 U
int ret;
( }# f3 f" t8 N, f2 }6 O0 \! d#if 0
" {) j8 Y6 Z, ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: R7 |: o/ n, }; x& \) T. M7 S7 \ if (ret)8 t% `6 o! X" |/ m2 g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", U }! X1 w, l
"%d\n", ret);
3 M, I k1 b- ?+ e( A" h#endif
! z0 n. @8 T3 q, N ret = platform_device_register(&da850_evm_tl_leds_device);
. ] K/ Z" G0 }9 r4 J% x if (ret)
4 Q0 N7 s- i; @% | pr_warning("Could not register som GPIO expander LEDS");- T- y8 x7 C# e9 Z
else" O N k8 a* Z( ~! J" t
printk(KERN_INFO "LED register sucessful!\n");
0 j. B* ]3 I. }' j3 a5 q& g8 ?! X3 ? `/ J I* m+ w
return ret;3 j: A5 G3 P' L3 N1 N# X
}
$ e+ ?5 n8 X8 I( Z) ~- e- `0 X/ s) \/ ?6 A- O
static void __exit led_platform_exit(void)
/ l9 @: H+ W# a6 a/ x4 }3 r2 e{3 f8 a1 |; Q- K7 J0 V; p+ S
platform_device_unregister(&da850_evm_tl_leds_device);
: E4 C2 z" [8 }$ s- ^1 C3 r& N4 b' i# i3 ~" ]& x
printk(KERN_INFO "LED unregister!\n");
6 {# W0 C" [; C}# u+ T6 \& U* ~# N1 Z, I' L
8 @% |) j# d4 s$ f' o
module_init(led_platform_init);% d3 Q2 ~! X0 X: J2 A% J
module_exit(led_platform_exit);
. Y3 r2 M7 w3 @5 V. v9 }) S- k8 Q( u+ n+ ^% k" a
MODULE_DESCRIPTION("Led platform driver");$ r- h3 |. I7 v0 J8 K/ f I- e
MODULE_AUTHOR("Tronlong");8 P( i. R2 O' N. c* Y0 N% _' k
MODULE_LICENSE("GPL");
3 O% [+ b/ x9 ]( b; n+ H4 a7 s$ {
" J1 Z2 s3 i# J+ J |
|