|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- z" h$ x- m* y9 |1 \& i0 M5 L" F; f
#include <linux/init.h>/ E& g1 N1 ]; n0 m2 M2 I
#include <linux/module.h>
7 y0 {2 c2 \" \$ e#include <linux/kernel.h>& k' Z: i U/ D3 h
#include <linux/types.h> h+ }! V4 K$ B
#include <linux/gpio.h>
" L& g Q. j" m9 Q1 z+ q#include <linux/leds.h>
9 A/ |% I. T8 {6 m; I3 u* z; f#include <linux/platform_device.h>1 m; e" H9 U6 \0 x7 L3 N9 A
- S. }: X( x5 J% o' I#include <asm/mach-types.h>
! z1 B$ h+ p3 {/ A#include <asm/mach/arch.h>1 T$ a, F7 h1 ^: d: _; N' v4 Z
#include <mach/da8xx.h>
+ z( X) P* B1 k% V#include <mach/mux.h>
- `. _; g) x; c% D
" a P% L& J0 i$ y8 K* e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); q( Y7 e( y6 d, s+ g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 v' w8 p. E: T; T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! d! A9 x5 r) A' t; S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 S+ d8 R3 a6 `+ L7 n
2 Y1 K* I/ t1 R4 e/* assign the tl som board LED-GPIOs*/2 r/ M6 d3 `- G2 F. g8 i# P
static const short da850_evm_tl_user_led_pins[] = {/ A4 y% r# w) ~+ G& d
/* These pins are definition at <mach/mux.h> file */- F' X1 S4 \0 ~3 s- Y& x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ l& Y2 N) t6 F8 m$ w" O7 i; m
-1" r" h& B( V( ^0 @' y
};
* N& j1 W' ?9 d4 V$ L4 R' B' r7 ^. I
static struct gpio_led da850_evm_tl_leds[] = {
# U8 s, p6 `. Y% W {
& n; F2 m+ \% }/ [4 }" } .active_low = 0,. f- { Z- L$ F( Q. e
.gpio = DA850_USER_LED0,$ K. o3 p; L$ U' f: `8 v- |. W
.name = "user_led0",
' o, {0 t( \* b% n- m .default_trigger = "default-on",1 r, f9 G7 R, T3 O L6 T0 f V
},
. j3 q7 J1 c G D8 l {
3 C+ z$ P6 L( d/ j4 U; |6 I- s, m! y .active_low = 0,7 \9 p" Q3 W6 G: L0 \( |! d& P0 c
.gpio = DA850_USER_LED1,
" d5 g5 n# H$ B2 Q .name = "user_led1",, i1 j/ J' b r1 M" v/ c" O0 @
.default_trigger = "default-on",
/ {2 I( w w" W },
+ q! T, V$ l1 H' J: O# W( f {
# f8 l h% F6 g .active_low = 0,+ ?9 V+ {/ L" Y. e: H
.gpio = DA850_USER_LED2,
$ F1 F9 L/ c$ z' C5 k ~ v .name = "user_led2",
9 ~9 |# k. h; k+ E .default_trigger = "default-on",
! h; U( {5 j5 J) L1 X },# }8 s) `$ c) y
{
! o7 F) {" { o5 n) |* R/ b5 X | .active_low = 0,% f6 _: S9 z, r" K9 e. v
.gpio = DA850_USER_LED3,' {, ~. i3 g& }; x' u6 }' C
.name = "user_led3",3 s6 \7 _9 M! {% M! p8 z
.default_trigger = "default-on",
2 V; H8 f7 b4 i },
( h7 P2 S h3 n) V- B" h};
) C' Q, b/ B( ^/ I' k3 k% Q& R7 N$ [. y4 O6 W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 k8 B3 V! K" `' i, P+ S. m .leds = da850_evm_tl_leds,$ Z1 ` X" q/ V( G9 C, l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," X1 \ g9 l7 i# ^& D5 [( e
};
8 n5 |: [3 i! F9 x% _3 W$ o, U! A- F4 d1 `% W! H: ]9 P
static void led_dev_release(struct device *dev)4 W" L: {' ~) f+ l; M; ?
{
$ m" \% ?+ {0 G9 ]$ t5 b' R0 D};9 x7 |) O# j( |! O+ G8 ~* |
: a0 S: p/ s' f8 Y- I8 U( `7 U9 _
static struct platform_device da850_evm_tl_leds_device = {
% u3 U0 }; X& }; i; K( v; s .name = "leds-gpio",# Z, ^ H1 S& @0 M1 }/ }% A- o
.id = 1,. F# d9 u% d2 d$ Y% g0 ]! A! @) A
.dev = {
+ ~5 [. K- R5 m/ h) X .platform_data = &da850_evm_tl_leds_pdata,
3 q2 \' g: i% j) Y1 {; |: p8 | .release = led_dev_release,- w3 r; M/ X$ v/ [3 B* }6 u, k
}& O( R: E5 P/ ]* ~; v% m0 u
};
( \/ [$ X/ g- v+ b& a, b1 p8 Y3 S
% `/ e) t* ^9 D# s, j4 t& Astatic int __init led_platform_init(void)( h' j& t6 l" c4 B# \ p5 {- q
{
$ u, O7 M3 Y, t int ret;! k* K2 [; z6 w( v
#if 08 c) u4 I1 s8 k6 m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 w, o1 ]% F! d7 F/ u/ l2 q; y if (ret)/ G1 i# H2 Z9 J4 W- y) {0 M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. q2 _! u1 w9 }3 v& E5 Z5 ] "%d\n", ret);8 D) X q, L/ E! E4 C6 d
#endif
2 K/ i( ~$ f. l9 U# f: h6 | ret = platform_device_register(&da850_evm_tl_leds_device);; S0 \$ N3 ]& ~) ]
if (ret)
( y+ o' a8 P& s* @, e2 N1 D+ \ pr_warning("Could not register som GPIO expander LEDS");
$ f1 C, q: p3 X else2 R- { s U+ z: c
printk(KERN_INFO "LED register sucessful!\n");1 I9 u6 H7 R- V; y, c6 q6 ~5 z# r
* I; C% E% s4 }4 }$ @6 e- z return ret;
" C) Q4 N A# w9 ?0 c}
# S/ P S4 L: Z3 |- {. i
* ?- ^8 U% {6 F* X' I% jstatic void __exit led_platform_exit(void)
& j2 z* j' k6 a6 O{
$ B5 V! f3 ?7 f: U platform_device_unregister(&da850_evm_tl_leds_device);
H, h5 c- h' t4 q
) x! G- g3 L" g1 N printk(KERN_INFO "LED unregister!\n");
$ W: U) D) m$ P1 B: |}
+ J: E4 X& K3 _' x/ M1 a9 l: A4 F K5 k6 o
module_init(led_platform_init);; l& L _' \- ^. Z: [
module_exit(led_platform_exit);3 c3 ] b, o& o2 _ s- b( U
) l! }% M( e6 v$ h1 ~
MODULE_DESCRIPTION("Led platform driver");
* j* P' k9 N7 v8 T3 f; sMODULE_AUTHOR("Tronlong");
8 v1 ]$ D) r" r' M1 v( SMODULE_LICENSE("GPL");
$ p5 W2 D3 s2 u. j& C7 n& v3 w7 T2 P; R; f9 g3 n
|
|