|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: Y! G% M5 d, d+ b
#include <linux/init.h>4 `0 Z6 O8 K3 l
#include <linux/module.h>
; s# ^6 y3 V/ R; @1 x7 l0 R7 n#include <linux/kernel.h>/ @1 P8 h6 E ]% v. {* K7 d$ _2 @
#include <linux/types.h>
7 v( F% X6 T7 i2 m8 b( }) T#include <linux/gpio.h>
% `9 y! H/ a4 M1 Z X; ?: _2 [9 }#include <linux/leds.h>- Z* k' |( _* R& C7 Q
#include <linux/platform_device.h>
- Q( H+ U0 g4 O3 |! w, B4 a6 [/ l2 V9 I5 \ O
#include <asm/mach-types.h> d4 U4 }) y; H
#include <asm/mach/arch.h>" |. R& k7 S- u) g. c" O
#include <mach/da8xx.h>
- Y* e: E5 a- s. b$ l2 a/ J/ Q#include <mach/mux.h>1 ]4 E! z5 c0 Q% A. [" V
4 S6 r' a0 c1 e- ]! X/ ?/ T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! d- ]9 b2 z. t/ f) ~5 @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) E$ V) _# C* z4 u6 |* F
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( C4 H" v+ s, j" E4 y! g" X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( [/ ^3 z- N( E) c, c) j% h( x# T# u9 P% H
/* assign the tl som board LED-GPIOs*/
- K' q" p9 P) i; \! Tstatic const short da850_evm_tl_user_led_pins[] = {
4 Y3 ]5 N0 A: i0 d- } /* These pins are definition at <mach/mux.h> file */
6 ?) [& m4 L3 H8 ~; _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ L$ s' }" N6 e& o: L
-1. L i) q1 ~# P' `2 G: S
};$ c {5 [0 r2 o9 x+ e' J
7 U2 `+ C* M) [* O# astatic struct gpio_led da850_evm_tl_leds[] = {
$ E2 p. ^" r5 f2 ? {
) k# r) c$ W( D0 l .active_low = 0,
1 C8 T: Y5 R. \8 s .gpio = DA850_USER_LED0,% G; B, F+ ]( W, O J; \
.name = "user_led0",3 y; i- }+ _8 Y* n- |' l
.default_trigger = "default-on",# n( F, c5 @5 o4 G Y0 z
},
8 l; r& L, p8 X. W% ~( O) Z {: o, S2 O9 \% H1 `! F
.active_low = 0,/ u1 `3 u b5 O/ t
.gpio = DA850_USER_LED1, Q5 J& T2 ^7 k: g
.name = "user_led1",
+ @7 p% E$ V2 q( K/ T/ p2 c .default_trigger = "default-on",, V! a" D- r! R
},
* W5 h- l9 @1 ?) w {
0 B [8 m/ N2 b" {" Z .active_low = 0, J+ K) j. B. I1 T, b+ _
.gpio = DA850_USER_LED2,& z% z: x% B6 ?9 m' ]$ s' [& x
.name = "user_led2",
( }" W1 P) e5 K .default_trigger = "default-on"," c. \& v% f4 M5 G! {" x
},4 l$ R) R/ x' Z, C: Z4 I
{ ~; \$ I! g# @
.active_low = 0,, u, D. H1 E; ?" I7 c: h
.gpio = DA850_USER_LED3,
; C: S! N9 p) l .name = "user_led3",, p* z9 c' m( O: J
.default_trigger = "default-on",1 u& C1 g& {8 L
},
4 o( _0 v) q+ p# z$ c: V};1 A3 g0 e/ t& `/ R. y( _% _
+ _ e9 D) ^3 `3 T3 |; i2 [ Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" @+ v$ _) y) T: X+ s .leds = da850_evm_tl_leds,/ Q8 y% z9 p8 S: O5 f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 v4 [. O$ [ I. E$ v! j( j};
) s/ l* Q; t4 s
1 I( f0 C( H2 Kstatic void led_dev_release(struct device *dev)7 Z* n" R9 j0 i( W+ l; G- T0 b3 }
{
7 H3 I" C$ J" Z$ l$ h};
/ H7 S% c3 i6 g( X8 T& y2 z: m- C4 C. z
static struct platform_device da850_evm_tl_leds_device = {# l6 K7 U2 v* u, B0 ~$ R
.name = "leds-gpio",
$ X0 P* A+ s1 I+ J7 g/ F) q .id = 1,
: z7 n3 T" K7 Z; T .dev = {. ~- i! s* S i; P. ]
.platform_data = &da850_evm_tl_leds_pdata,; h; r6 f) h- A) Y5 q2 B
.release = led_dev_release,9 D& e( ?0 g; W
}
' C; m% I' |+ E: g6 d: U+ _0 j* J# G};
% ^/ g. w3 R1 i! a$ Y4 q0 o, T }
; z+ p, D2 C! \# lstatic int __init led_platform_init(void)
9 s$ J1 |9 `: {) r- y$ k{$ ~1 O4 ] r4 i: p* {; \
int ret;
v0 _$ K% O: }. c#if 01 ?% t* w4 j/ K. Y. N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- t1 @0 P u! Y if (ret)
- p r+ ?: z- F% A+ o; p7 D8 X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 c7 f6 @5 t) s' D
"%d\n", ret);
, [7 X1 } ^0 T#endif$ d, C; E" q# T* A, a7 U
ret = platform_device_register(&da850_evm_tl_leds_device);
) |& c8 S' O: y( n if (ret)
( Z9 p& d, i6 x6 i1 C: v pr_warning("Could not register som GPIO expander LEDS");: g$ f- V4 V$ w5 X
else1 g0 \. c/ E! A9 O6 h! H
printk(KERN_INFO "LED register sucessful!\n");6 A4 r" S8 `- q* s. G' z
4 E8 c p3 _9 A2 F return ret;
* ~, @7 J1 ?) K7 d+ Y0 ~}
& A( {8 U2 c; z3 R O6 Z
3 ~8 E, D ?6 @# v' }* }static void __exit led_platform_exit(void)
. _ \1 L/ G& e! _5 U{) P2 @1 o' V% r6 A: H
platform_device_unregister(&da850_evm_tl_leds_device);4 d0 Z+ W( Z) X$ w
+ i$ v( e4 F9 R9 T6 i l8 D+ w% d
printk(KERN_INFO "LED unregister!\n");
4 D8 K, b9 A9 _% W" A# \& X! }% @( Z}
; K4 `8 {1 [4 x" p. b& ~) j3 e% J0 y/ C( b, [7 \
module_init(led_platform_init);
) w9 @+ t# [+ a2 S* d2 imodule_exit(led_platform_exit);
+ k! ~+ u! K/ U
! ^$ p& m6 F1 } D2 T! Y0 iMODULE_DESCRIPTION("Led platform driver");
0 p+ v5 f. i" j8 C% N1 _MODULE_AUTHOR("Tronlong");
* G" e0 N; z4 k8 PMODULE_LICENSE("GPL");# e2 Z! ` o7 M: F7 m
! Y3 I# G) d; d, w |
|