|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( s4 f9 z9 C$ V' R, c6 c
#include <linux/init.h>
7 m Y3 Y! A$ c0 l#include <linux/module.h>
, Z9 I/ k% S$ v+ V0 P5 e5 X8 G#include <linux/kernel.h>& b$ A6 C. C, T8 L
#include <linux/types.h>
4 S4 K. K5 v; _9 H#include <linux/gpio.h>
5 {4 b# \, _2 \. g+ q# ^2 Z4 O#include <linux/leds.h>
, T3 l2 ?( H5 t& n( @#include <linux/platform_device.h>
0 _ [; o# e- W0 Q: p
: {4 V6 y+ d, m t4 U6 }( Z#include <asm/mach-types.h>
( {3 r" S- |+ y E8 G" a* @$ A#include <asm/mach/arch.h>
- V, v' R3 o5 z! q#include <mach/da8xx.h>, k( b4 l; h& T+ O% o& ?7 l9 J' A. w" b
#include <mach/mux.h>" u6 }3 A/ ~% }
+ n" G9 u) Y Y) ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 c2 R& {% v2 Q/ ?4 y' T5 f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 G" D$ c; d$ s4 g9 I: @$ M% H! I5 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# q) A0 R% r" J, V9 k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 z8 c5 y0 y" @6 X3 j3 S |' Q
7 v d0 x4 A8 `7 s1 \3 g/* assign the tl som board LED-GPIOs*/
1 B: n+ [; v5 P. [* `5 A! Lstatic const short da850_evm_tl_user_led_pins[] = {
7 u. x9 A. S/ E8 _8 ? /* These pins are definition at <mach/mux.h> file */
8 L% R0 l+ L6 W* p! b- p6 ~7 ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. K- ~$ A/ R$ j0 c% T; X/ J8 T
-1( _# }' T( U3 F7 o6 R. s
};
A, \+ Z# `" j; Y) N4 e) {/ b0 @1 q
5 K1 c8 ?3 }" \$ P Y1 Cstatic struct gpio_led da850_evm_tl_leds[] = {, y( u4 o1 C5 W$ g, D0 N
{4 z4 ]# a( b9 ]( Y% C
.active_low = 0,
& w- r- E" z* ?! E .gpio = DA850_USER_LED0,
% q! ^. R# o: I4 h. C .name = "user_led0",9 D: l+ ~. k! k' m+ w4 h6 S+ @+ ?
.default_trigger = "default-on",
$ d$ ~% |8 h5 w },% b7 N$ x* y1 l+ N+ a! T6 |
{
& k/ h$ G# W7 N0 P/ v8 m2 e' p5 u .active_low = 0,' b+ [4 C# L5 Q+ \& j- m4 X8 m2 E7 d4 p
.gpio = DA850_USER_LED1,
- p7 t! \, E/ s0 ^ Y" N .name = "user_led1",: r# U$ B/ ~; v, j0 w
.default_trigger = "default-on",
3 [% F# W& q P% I. t3 P },
* r' j, r1 }, N* y {
) y8 u7 i, L. x# z .active_low = 0,
4 v& j. d" l& g+ Q5 R$ d. Z4 j4 ` .gpio = DA850_USER_LED2,* t. Y$ n2 `4 |8 \% A: Y, {* _4 n
.name = "user_led2",# u; a1 W; M' y6 f+ [" L5 Y
.default_trigger = "default-on",
3 ~' b7 D: g; v1 s3 E& y },3 w5 U$ H1 i) a1 [; o
{7 V/ [$ p. P( ^8 ?0 e" R( i( I
.active_low = 0,) O( T0 k' }4 x$ B! L
.gpio = DA850_USER_LED3,. H% ^/ j8 K+ W# }
.name = "user_led3",
' p' _7 M- X4 m! \ .default_trigger = "default-on",
, d# G" G+ C- U: w* V1 L },/ u1 \: f& @$ `+ o- P- G: Q6 e: M
};) }% z8 _) s+ h0 E. p# C
+ T& K% o! {5 ]7 A& N+ S! pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 d0 z# \% R5 l; c! d, Z. V& c' s .leds = da850_evm_tl_leds,) y; s. S' U+ ^1 F% P7 Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; D0 S+ ]$ R/ z: q6 i
};
3 m7 t' ^2 @* H, X8 o9 I1 r9 j5 Z
; P; W$ `" G) H( u( A$ E: xstatic void led_dev_release(struct device *dev)
7 Z! b) y+ Y! @: \( k; I{6 K; A! `8 \+ C8 A
};: [; K: \. o. W1 ~+ E
( D+ f. b' H7 b# ^static struct platform_device da850_evm_tl_leds_device = {
5 A8 P1 i7 x- l9 q o3 {3 c- y$ ~ .name = "leds-gpio",
) U$ L2 {. y: G" S4 u' N/ d .id = 1,
' I* S" s! B# [! w$ [& X/ C4 K .dev = {$ W. d4 Z; N5 m% K
.platform_data = &da850_evm_tl_leds_pdata,0 Z& x& j7 s. |. |. S7 O) x5 h3 ^
.release = led_dev_release,
0 I3 D- ~# ?5 I% ^9 o% a }
6 _. k( u% Q8 E7 O) c1 f9 k};
; {8 H3 U" @6 ]" G2 g0 T
' H$ A) Y+ g& @; N/ d0 S1 Lstatic int __init led_platform_init(void)9 [" Z |6 o. T% m. l0 @
{
' F( x$ _* {+ [# T5 g$ K8 B7 N int ret;! m8 A4 H% W+ x! `9 w: E4 y3 U& h
#if 08 S7 `, K1 T+ G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 o7 c! C3 C% U5 i# P: N( a- ~
if (ret)
. i$ b* Z$ w3 H4 S9 ~& F9 G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 R9 H7 y5 E4 S$ s0 t& N "%d\n", ret);3 n/ h. y( }! u" o1 V# k# x
#endif
+ c/ r, @4 H# U9 t2 Q. m; i ret = platform_device_register(&da850_evm_tl_leds_device);
+ J, @+ g3 Z; }" N) p if (ret); X4 k2 B0 T5 w; G% s2 J/ H; d
pr_warning("Could not register som GPIO expander LEDS");. p$ A- h) T& r! R+ Q: N
else. X* g' Q1 h/ |
printk(KERN_INFO "LED register sucessful!\n");
: Y: q, {8 a4 r. k) @8 G D7 j
; ]' }4 E6 F- e n5 Z return ret;
& h+ j$ P. K0 y, M( v s; L}$ E H" v2 U$ | }
- N+ m# ^& R' L+ D
static void __exit led_platform_exit(void)
$ r `/ o1 W3 i( g6 h{
7 A/ l1 }! d! Y# M platform_device_unregister(&da850_evm_tl_leds_device);
" b1 o# O* E9 J& O0 p) I4 M$ `0 s% h" G* \3 n d
printk(KERN_INFO "LED unregister!\n");$ @9 l2 ~$ D! r% z( C9 \! K
}
- I# x& r: k z# [& Z+ K% _9 C4 r
, j S. N2 f" }# o/ Q* q0 y( D) F! ^module_init(led_platform_init);
1 j% j v6 W' Q" d Q9 h8 Vmodule_exit(led_platform_exit);
; C: I5 K$ A: ^" B. r" z# w& U4 E/ D# w
MODULE_DESCRIPTION("Led platform driver");
1 e( M6 ?# f7 J$ ^! V S% kMODULE_AUTHOR("Tronlong");
$ B% j9 _8 m4 ?5 PMODULE_LICENSE("GPL");: A8 X; L/ U" B( Y" m7 j4 S
, s7 [9 g6 A2 w6 Q. w8 ~& R
|
|