|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# I$ M) b: Z2 }; Q8 T#include <linux/init.h>
* Q! j9 x9 x) E3 ^4 b o#include <linux/module.h>
* w) g: n& ]# Z* ?/ J#include <linux/kernel.h>- }* a8 l. n( H5 b5 A
#include <linux/types.h>& g4 B, M6 C7 x4 G1 K5 F* D
#include <linux/gpio.h># k j. m g y( u
#include <linux/leds.h>! ^7 K2 q2 |1 g h4 R' p
#include <linux/platform_device.h>
, s3 Z% ?" e" S+ F( n$ W* O; p$ s! Y4 W& |# y- _% Y
#include <asm/mach-types.h>
: R% R; R/ o; T0 B- W1 r3 E" P# |( Z#include <asm/mach/arch.h>
, R" s `+ e/ H8 @( s) {#include <mach/da8xx.h>/ s" O9 H" u5 }- T3 |
#include <mach/mux.h>
$ y6 A" ?' n& b4 t; R7 s% D7 T3 a* F9 K6 S* @. E8 C. i; U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 b; h0 b/ K7 d- m5 [" d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" p; h" t: v: ]: @$ a% X* _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 Q6 X; t4 m* v+ I; k4 C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' J9 N4 F. i6 y- p) J& E6 {( G+ [6 Z7 Z
/* assign the tl som board LED-GPIOs*/% ~& q9 ` b% d* J
static const short da850_evm_tl_user_led_pins[] = {
6 z8 _7 s! Y% E3 W1 K /* These pins are definition at <mach/mux.h> file */$ }% f+ m; L4 }4 n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 b2 M5 Z6 t- c/ M( t0 _
-1
6 S- B! b% R7 e};
4 g9 p! k* i B. V0 T1 H3 F' d0 @* h8 f( S5 a5 `* b0 N. Q( x
static struct gpio_led da850_evm_tl_leds[] = {
' d. a5 k8 w7 W {
2 a) |8 w$ Q, F2 ^+ w .active_low = 0,
# i9 w7 f) J# z6 M+ V% L$ W* ~$ r& R& V .gpio = DA850_USER_LED0,
' n! v3 f8 x: W7 T1 c) x: E .name = "user_led0",; V3 L# d: L* z1 O4 y: K# U
.default_trigger = "default-on",. y0 B; z- ~8 y5 ]4 [& f3 }. o
},
3 }) S! ?& @2 S5 ]- x, B' j, Y {
4 `9 C5 z) H/ Y( d .active_low = 0,
$ g/ l T3 w% a# c+ Q .gpio = DA850_USER_LED1,
, e8 L' G8 |" Q% l. p .name = "user_led1",
$ ]7 m1 M5 \7 e, u9 Z( o5 e1 [# u .default_trigger = "default-on",
! `$ d1 X, S' c0 B* I& Z, m1 R' X9 Z },
9 S4 C. Q& }8 ?4 V {
7 f6 J9 g1 ^. x6 |& t .active_low = 0, g# | I/ n% K3 [# w2 A
.gpio = DA850_USER_LED2,
5 w; V+ T" @$ L2 d j( r4 s, o m .name = "user_led2",+ J. s+ |: A( {0 G' s# J
.default_trigger = "default-on",9 {, S+ [9 L. j6 s" r# V
},
" p; j4 `7 X {0 A$ t5 t; W {
) I5 Q1 {# j( O* ], A# N .active_low = 0,
0 ^3 @4 Q2 o+ u! A2 \0 ^. D( S3 | .gpio = DA850_USER_LED3,6 t, m+ r4 r/ ~* n5 g! }
.name = "user_led3",$ T; ^2 n$ R8 X( Y8 p, W+ R* R5 {. G
.default_trigger = "default-on",
* g$ u% K9 k+ I0 S5 y },
- W! E- Q' H7 |; o( E$ [9 ~+ ~};
" m; F* h) j, ]1 d* n- u( ^ ]" Q
/ o- m4 ~+ ]! W; U% h; X6 x1 @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; F8 V- s: f+ H* b, Y; r4 p6 z
.leds = da850_evm_tl_leds,
P6 j/ C0 d5 |% X3 v1 l3 g- U9 A' R+ B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- p& Q: l; N T9 w
};
: a- ?9 {9 w, q$ S# O. Y# f7 L8 ^+ I( Q* @
static void led_dev_release(struct device *dev)7 q/ m/ w3 m% L& S: `) N
{
7 ?, f* m0 k. h' g& F};" e/ l( N; c. [3 f
* E0 d/ i7 d' E/ mstatic struct platform_device da850_evm_tl_leds_device = {
0 Q& B/ d5 i! q; s3 Q .name = "leds-gpio",
% Y4 ^7 w3 @' P k* y# ?5 o2 \ .id = 1,
9 B- J" p; y1 O E2 R% Z .dev = {
' X: ~ I: r8 p% Z& \2 p4 V .platform_data = &da850_evm_tl_leds_pdata,2 X0 t: R, C ~6 y H
.release = led_dev_release,; f5 ^( c6 }: V( S2 O& s$ D9 _# H
}
5 W* Y l* l2 t3 }6 I3 L7 ~9 o};" G+ x5 X( K9 u& v/ s
9 F" `! t" J( Q" \
static int __init led_platform_init(void)
8 Z9 v; T2 `1 y( h7 t8 m @8 t. v7 h{
2 }9 L1 ?; N% L+ [ int ret;
: p/ L1 k3 w. s6 u0 E9 y#if 0
; G' S# N; b$ k5 M, p5 B0 K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: C& _% D0 ~: }; O! C' B' K3 v
if (ret)
1 D n5 E. m$ O+ v pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ I! a0 `5 q! e( u "%d\n", ret);
' E9 V A" B9 Q0 Q0 P/ N#endif( |# U+ g5 S: o5 I8 m
ret = platform_device_register(&da850_evm_tl_leds_device);
c% ~$ y9 {! V/ F# ]/ u" i' J( P. r if (ret)6 Q2 E7 z! } q6 S( C
pr_warning("Could not register som GPIO expander LEDS");! @0 g9 d( l% \5 _# E4 x
else. P. j% \) H v; }1 a+ s! A2 ~
printk(KERN_INFO "LED register sucessful!\n");2 @1 U- }5 u, N1 d/ C0 @
$ Z. O: w; B0 v$ M return ret;
" d/ n+ O9 m; h. o3 J s, r}
- T2 m# r) ?" l- _8 w( ^- c) F5 F- q4 T
static void __exit led_platform_exit(void)9 M. B% ?% u/ X0 Y
{( ]( U3 }: T0 W3 g0 r: n, P6 U
platform_device_unregister(&da850_evm_tl_leds_device);8 K6 h) Y9 G3 D! I3 {* _
3 l' {# B* x) s+ L0 k printk(KERN_INFO "LED unregister!\n");+ W* b4 O% Z6 G+ o+ x; U
}
- v0 J ^- O, z) O" m% l7 I! h2 Z' l! f- O
module_init(led_platform_init);
, d. `4 H7 I1 x& zmodule_exit(led_platform_exit);
, Q d0 V) j0 s( F" B- M0 Q& B; Y2 z: ^' q. s3 z
MODULE_DESCRIPTION("Led platform driver");; i3 }$ F2 H% u' }
MODULE_AUTHOR("Tronlong");0 `6 d7 u" D6 y. t0 \$ o
MODULE_LICENSE("GPL");
# Y4 i \# K8 [
+ Y- ?5 {0 B8 r/ \# o& Q |
|