|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 O( o3 @5 K4 V# K9 ]2 d#include <linux/init.h>/ p; I% V# Z* c( E/ r4 C
#include <linux/module.h>
! m4 |7 R0 Q' z; h0 n% O#include <linux/kernel.h>4 L5 e, D" P) q; v; y; A* f2 n2 R
#include <linux/types.h>
* V3 Q& ^5 M" _2 H* G3 K0 y#include <linux/gpio.h>. `1 k% a8 E# n* E& S/ r, W
#include <linux/leds.h>
1 K/ R( i, z" K" ~( T#include <linux/platform_device.h>
3 f' a8 o0 [3 q/ f; _. Y# ?* `$ y) l5 H, s' ^6 u( x
#include <asm/mach-types.h>8 q' N/ y% F! V+ f6 _7 b, b( ]
#include <asm/mach/arch.h>
! ^6 ~4 l- x( {) o( N1 k# K/ K#include <mach/da8xx.h>
$ U0 h: u; \& `#include <mach/mux.h>
& l+ }( {! I& i: J; H- u5 h8 K* R+ N3 Q7 |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 X4 n6 c( ^5 l5 I9 V1 g$ l( e# }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" `% `9 M1 ]8 |7 {9 }9 ~2 z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 Q6 n# h& h N- F, o0 j#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 o b1 u# p- i( L3 t$ D( \# Z6 b% c1 S% q# a w3 @6 P& G
/* assign the tl som board LED-GPIOs*/
. x) s C+ x0 P& m" Nstatic const short da850_evm_tl_user_led_pins[] = {
# V' Z' P3 k; f, n- J# W. ^ /* These pins are definition at <mach/mux.h> file */1 X* Q* I4 D: w0 Q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: n/ A2 m w! { w+ F
-1" |) G. L# p3 ^+ k$ l- y0 b! s
};4 z2 U/ M/ [' d$ m" y A/ s( ]
, W1 x* d: H# ?static struct gpio_led da850_evm_tl_leds[] = {
6 b. u, b8 E2 ~! x {
/ e" s7 P p X1 b6 _3 V$ u2 o .active_low = 0,+ x2 F3 m; N4 v% G. Q
.gpio = DA850_USER_LED0,
; A5 y8 }7 S, U7 ?9 K) [. y .name = "user_led0",. n) M" Z. g; ` T
.default_trigger = "default-on", F5 A* V$ V& D) L& P8 ~1 u
},
) V, P, y5 c: d o. |/ d/ B* W {
* N' ~0 G. m/ E .active_low = 0,. m+ ^) D, ]. y
.gpio = DA850_USER_LED1,4 U9 L8 i0 s# M. D
.name = "user_led1",
2 D) c) d. S4 P& f# @& \8 R .default_trigger = "default-on",
4 p/ I- H) \% f; u },
% c6 n! d: }: w1 } {% c- @/ q3 C, h
.active_low = 0,
2 q$ ~6 c% _8 t1 V4 U .gpio = DA850_USER_LED2,# J$ X% ^3 @2 `& Q0 b$ z
.name = "user_led2",
: Q: f w! r/ S* o .default_trigger = "default-on",* {% C9 U. _, A; Z, f- O
},
+ Z- K* N! r6 Q, r( E! N' s {3 Q8 A# Q* b l6 Q4 }9 n
.active_low = 0," ^# s1 s; G3 a4 U' |& d j
.gpio = DA850_USER_LED3,
' F8 u. M0 O8 ` .name = "user_led3",2 m5 l8 ?. T' s: e; n
.default_trigger = "default-on",9 z0 D: e' |0 m' c' B% q# J
},
1 h. q( q& [, X5 z t8 R+ d};
/ l5 r% J i5 j/ t* ]& ~( s# _
1 c9 A; k; L9 Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. W9 s* B# ^+ _; m% R* Q
.leds = da850_evm_tl_leds,2 d' c$ u* J3 f! D8 m. \3 E
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- E$ s1 e) K9 R' q};4 ~9 h% k) T4 v# Z1 i9 ]+ e
1 J$ K& n- Y* d; y2 d) Y$ ]3 s
static void led_dev_release(struct device *dev)
# _" w/ W) ?5 Y! Z# q9 y{" t, a4 G+ }/ F6 Q7 P
};
$ }4 `. p& q9 K; w+ D8 c, d
V4 v1 M/ W( d3 d3 h; `( fstatic struct platform_device da850_evm_tl_leds_device = {
% a7 m4 g/ ~* Q% \0 Z; e .name = "leds-gpio",
& r) z) q1 R2 s1 x1 O$ E5 [0 Z- V .id = 1,
- h5 x, F( a+ u Z8 j' m .dev = {
/ [! ~8 D: N3 o5 E) V, \ .platform_data = &da850_evm_tl_leds_pdata,) E2 R$ ]* T- H0 o- w3 C
.release = led_dev_release,+ t* [ M& O* q
}6 A0 t8 Y p+ Z
};
2 h$ `; x) }) E% c
5 y8 C( d2 W+ nstatic int __init led_platform_init(void)" T' h, N+ T! x) ~" i0 L
{
! c$ }: N# s3 `; v O: ]7 X o2 Y int ret;
S q6 \2 B" b; v+ u#if 0& W% Z( G5 r. D+ ]6 b. u; i$ l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* _' Y8 B* |# S2 }% f9 {' J u- r
if (ret)3 h6 p, _" {6 ]" I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ r; } P3 M0 k% e "%d\n", ret);( l3 p6 V# \! ?& n1 r C1 [4 D
#endif
9 p R0 f6 X% N W8 o ret = platform_device_register(&da850_evm_tl_leds_device);
+ B! r' s" S! f$ |+ Q, t if (ret)
/ t$ V+ t2 G* ^4 g" k, a pr_warning("Could not register som GPIO expander LEDS");
2 k s, g0 B& x5 E; y else1 Q/ j) K" [2 w# w( @
printk(KERN_INFO "LED register sucessful!\n");1 `2 j" v, v/ U
! h* K b% _: ?, M4 s1 S0 P, ` return ret;; j. C9 K* z$ \5 {8 ], P
}7 K( U3 |9 d% `8 \2 r
" b) R3 g0 m$ W2 t% y1 R5 U$ wstatic void __exit led_platform_exit(void)
8 R( ]" Q5 h: c& a: |/ c2 c6 E{
4 N2 ?$ p1 ~& c3 E) R platform_device_unregister(&da850_evm_tl_leds_device);# x `0 s* R. w' C
, B$ |$ _; Y+ z9 F$ Q2 C& a printk(KERN_INFO "LED unregister!\n");' x6 A; Z) u5 x/ z' j1 ^" i
}
4 Z9 `0 i3 U5 o
- C" C/ L; ~# T9 omodule_init(led_platform_init);
' H6 @* y/ p/ z/ I" T) A$ rmodule_exit(led_platform_exit);
$ L) b# Z& z& e/ Y0 v9 }9 e3 L5 x) C
MODULE_DESCRIPTION("Led platform driver");
9 Y0 d5 t8 a$ ?/ A/ Z1 pMODULE_AUTHOR("Tronlong");
3 \5 ~4 [, p, ^5 y0 `% zMODULE_LICENSE("GPL");
" A! v. J/ J& j c; R+ ~6 [. ]) S! M3 Y8 E g
|
|