|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 E* u5 J/ O- J* I) Q
#include <linux/init.h>
& C) e# m* n4 v) U- x. k! \( e#include <linux/module.h>
j' L! M) ~! u4 L" O5 v% J4 u#include <linux/kernel.h>7 D+ A6 H! {) p* ~) e) U" Y
#include <linux/types.h>
1 v5 Q7 B, E4 G }2 D( g#include <linux/gpio.h>
3 I# `; @- {' {! j7 ~#include <linux/leds.h>
5 p) o1 N% W# K% ], g#include <linux/platform_device.h>
. x: C I( I% P$ u4 t4 g! w# A& {' K* T
#include <asm/mach-types.h>
% _: S* ]8 X9 I7 }& d. S/ U#include <asm/mach/arch.h>
, [" M, D: I0 ^" E' j7 ]' O$ l#include <mach/da8xx.h>) }$ N% y1 u1 g4 w& j
#include <mach/mux.h> d3 H( P% |& h) g9 A% |
$ ?& [8 }- k- @, p' b9 w4 q( T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* r' R) Y( f F7 q* \' G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! O7 l* Y5 \% A" F, q$ H5 m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) p; ^! F- m! ^5 }7 A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- Y! N- o; R8 y2 S, S* t, Y; O7 ?9 [+ B& O) `* ^
/* assign the tl som board LED-GPIOs*/
+ F& i( G" r* r' H& t8 R6 o0 e- Jstatic const short da850_evm_tl_user_led_pins[] = {
* C' h9 O, c0 v9 C( h) C. \, h /* These pins are definition at <mach/mux.h> file */
E2 M! Q: J! n; K( }7 T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" g3 K8 Z, P* \( C+ W& H. \( `; }( e( K -1
4 e; r7 n7 F0 T9 ^: F};, V0 v% u9 A( v' u; ]& J
, q. q) J5 i7 vstatic struct gpio_led da850_evm_tl_leds[] = {4 ?8 d; g' _! X2 q% i. @6 f6 @$ ~
{
, Y' V, U& \# r- B6 k# b z .active_low = 0,, g, G8 t4 K0 a
.gpio = DA850_USER_LED0,; A4 O: T9 K) h! ~9 V
.name = "user_led0",' {$ h6 _ i1 i# D
.default_trigger = "default-on",
. D6 U' s$ V( _+ ~ },- e2 y5 D5 k0 g5 {- K
{
: V4 y& I' U+ M; t .active_low = 0,6 Z) D% d& e( H
.gpio = DA850_USER_LED1,7 @7 _0 R, r2 q8 x- p
.name = "user_led1",
1 s0 M; y1 Y5 a& B6 X& ` .default_trigger = "default-on",
* x7 r* T6 L# Z& L },
9 r0 h; I- @/ K: Z2 ~7 Z- Q {2 z) u+ Y" _1 w0 ^1 X
.active_low = 0,
( W# O" ^& a0 K5 e3 ^ .gpio = DA850_USER_LED2,
; d4 m2 D8 p" ]) Z .name = "user_led2",
% i. r* t" K" ]5 P; t .default_trigger = "default-on",! Y0 b5 t$ u* G3 @( g8 ?
},6 F/ I. ]' ? o
{% w3 P v+ }, @& d
.active_low = 0,$ z+ ?- J/ Q# h- t1 `9 b p8 Y2 O
.gpio = DA850_USER_LED3,
% n5 X/ i6 v* q1 M0 n2 `+ ` .name = "user_led3",: Y# j0 |: x% K n5 X; c. r
.default_trigger = "default-on"," L. d. }- a7 o0 U) Q! W5 E* p! c% W
},7 W$ |4 O& Q$ L: t7 Y
};
t/ q" F: e. k( f- b) j, f, O0 p, Q0 T9 f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 x1 o/ G5 K8 m: w I; ]* H .leds = da850_evm_tl_leds,
% X F$ i- }" }5 S .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," R; K7 E6 X* X* a
};
( G. q' G2 Y! j9 C; V' @& p1 b( `$ Z' O* o
static void led_dev_release(struct device *dev)* {7 Y- V. }8 {$ F5 \ J5 U
{9 `4 h0 Y& l" |
};
( w2 T7 W" f: E4 g9 [& m
. Q1 D+ C; h2 n4 dstatic struct platform_device da850_evm_tl_leds_device = {8 c9 q j7 U8 C3 i- S I+ J( M
.name = "leds-gpio",$ ]* q$ j1 s' G& b: e
.id = 1,
- p/ l2 N$ b" p7 f v2 i" C .dev = {7 i( e- k7 r R8 _, H& T
.platform_data = &da850_evm_tl_leds_pdata,9 c# c% i" l$ {; a. O
.release = led_dev_release,
) O5 K2 ^) l4 \* j) w/ c; p }
- M) E. E5 R" h};2 ~% p" W5 z* V: ^& a! b- i4 c
9 o# U. l3 \. G. l( ^
static int __init led_platform_init(void)
1 d) P4 ^, R P4 h{
/ F" H7 M* {5 u2 S int ret;
$ A* N/ g% |8 P; R5 l! k$ F#if 04 s& s' d) f7 t2 [7 e) w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 d6 L5 Q+ b \ G! V3 P7 d if (ret)
* x7 [3 S& ~$ W2 C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* J2 A# t0 z. `1 I4 d/ {. o3 y "%d\n", ret); [) ]8 T* Y' x. Z
#endif
" M( B5 m% I: G0 K+ F ret = platform_device_register(&da850_evm_tl_leds_device);
, I* n7 f* A' y1 r% G0 _0 K0 c( l if (ret)% E# {0 t* E: J* v/ l& k
pr_warning("Could not register som GPIO expander LEDS");
1 h8 B5 ]- H [; p8 ?; J! \ else$ g9 Z7 k/ c8 l: {
printk(KERN_INFO "LED register sucessful!\n");
L3 Q8 u1 }# `/ m1 O, O# B9 x" n. c* f8 A
return ret;) j" ~9 g% ?' b7 F7 z6 j- a
}8 r1 d, y2 |4 g0 q& h- c0 b
- }$ S1 Y, S9 z5 F u) X3 m7 D) @static void __exit led_platform_exit(void)) l: M' K0 j# T
{* J4 g3 ~# O( \1 t# W
platform_device_unregister(&da850_evm_tl_leds_device);8 S$ O& O: J1 H; g2 X
1 t% S9 M+ r0 n7 A9 a& |+ R printk(KERN_INFO "LED unregister!\n");$ }- ~4 y7 _, g6 x+ Q
}
% n7 X3 z. ^' s- u5 \+ M7 B
$ R! e0 T( x8 \3 nmodule_init(led_platform_init);
& g5 j4 C+ n, T* |* R+ D* }) E5 Qmodule_exit(led_platform_exit);# }8 D7 ^5 `. o) N% R/ H4 p
2 L, M# i# w9 ?
MODULE_DESCRIPTION("Led platform driver");4 _7 x+ ^) x2 A9 c
MODULE_AUTHOR("Tronlong");: o. B$ c1 S/ m8 f2 V
MODULE_LICENSE("GPL");
* C9 c$ {* k7 G0 P6 j# E6 N/ d# |0 z) m5 d6 S; T+ V
|
|