|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ Q6 j8 c( Z! x8 @6 Q4 P) _$ G& F#include <linux/init.h>0 ] M3 E' I0 {. w, p
#include <linux/module.h>
k9 r- ]- i, h9 B! M/ d; f8 L#include <linux/kernel.h>
( k) B& Z7 f4 N8 P) O; K1 a; q#include <linux/types.h>
4 a! M1 @ M5 [7 w$ K& j4 g#include <linux/gpio.h>, z5 w0 q; _0 h
#include <linux/leds.h>
! T; T, F, i; x8 k+ E, r. R. m#include <linux/platform_device.h>
+ E& s0 v; H* C' O; n6 A! G0 F U+ ]1 b
#include <asm/mach-types.h>
, j, l' ^+ W7 x0 { U#include <asm/mach/arch.h>
8 d u* u3 b/ [% t- ^: T5 R#include <mach/da8xx.h>% B M9 Z2 s& p; ]. a! _7 B
#include <mach/mux.h>% P" o( U% t$ v' `+ l
0 w, y/ v; R8 \3 }# |8 w4 Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 x$ i, u' `$ y0 O) M! d M8 t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 R! ~3 }- g; v% s#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 A$ L% h8 N+ }' v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): ^; d3 ]* ^' B( o- t( w0 ^' ]
% V( |/ d: K9 _' m/* assign the tl som board LED-GPIOs*/" p3 X+ y) k/ n" d6 D
static const short da850_evm_tl_user_led_pins[] = {
( a/ \9 z* \* v9 r6 s/ h. I /* These pins are definition at <mach/mux.h> file */
. G! F( D4 y* t: |2 T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 l$ b7 n2 `7 k5 ^% x5 A# i
-1! M; W, H& ?: M* ] o
};% Z: G; h1 r! n* v( Z0 t
0 I6 }8 ]/ R, _static struct gpio_led da850_evm_tl_leds[] = {
8 s# F( Y! s# y5 k7 I% r {+ `, s5 G3 f" u9 ]
.active_low = 0,
1 o1 i; ], q' L5 ]# \1 | .gpio = DA850_USER_LED0,
; P- c3 E. Q7 ` .name = "user_led0",! K* K4 S/ t3 l6 {
.default_trigger = "default-on",
( n% |- J3 M) z- Y# h4 { },: L+ |; r1 L$ F4 Y. F
{
5 A; m) u& K/ [2 Z .active_low = 0,
& \7 E& f, |0 m4 a+ }4 V .gpio = DA850_USER_LED1,; @' ]+ b7 s u
.name = "user_led1",
. x% Y7 k9 D( v .default_trigger = "default-on",
; u5 P1 t# M0 @0 o7 c8 I },
# F6 ]& `) {" |2 { {
, ~- Q6 G$ n! H+ S1 k4 k2 w .active_low = 0,6 |) f: b, z v" i
.gpio = DA850_USER_LED2,
/ r7 W* n+ G( |2 _ .name = "user_led2",9 V r- Q% @! X, q# m E
.default_trigger = "default-on",9 x4 z% V. q- c1 g- r4 {! a9 F' U
},& G' B, F; o- o! I" u1 `. W4 C8 A! |
{% E& T8 m, O$ }
.active_low = 0,
- }9 w8 L* P9 W+ M6 M1 v3 F .gpio = DA850_USER_LED3,
5 B8 x' J& ]0 I/ x .name = "user_led3",
' Q9 w9 A8 |$ M* Y: g .default_trigger = "default-on",
: M0 T% p! v! s9 n6 y$ B, q },4 `3 ?& c, \; [* K/ f' e4 s" w! _
};
, J0 s+ z F6 y6 z3 l) t# s7 ?% `2 ]6 \# D) f. w, e6 a) v4 ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- c- A# Q( u& H9 v; S4 A, s" Z .leds = da850_evm_tl_leds,+ c& R1 ?2 r7 M3 f& ^0 y. k; S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 J+ x5 D9 T! v1 j0 k, M
};
8 L7 W- N+ f. p( v7 O/ {( M, G5 P
static void led_dev_release(struct device *dev)
* \1 W9 d+ J3 ~! i t) U1 g6 W7 ]{1 k9 w8 h2 c; \8 c
};" h, a" {$ A4 q) L; e: a8 Y
- r3 O! ~+ ?+ b6 [static struct platform_device da850_evm_tl_leds_device = {( L# X9 F' E1 X' ~0 ^; C
.name = "leds-gpio",2 e: z( N$ c$ f3 d; \3 G# s
.id = 1,
: g( R4 p& u/ m% D5 ?9 p, g, Y .dev = {
2 q& J6 C p6 l* d2 z& { .platform_data = &da850_evm_tl_leds_pdata,
$ U9 R. _6 J' j. J7 v& U .release = led_dev_release,
) C1 @6 V! m' V& `3 c) h3 a2 ~1 ` }4 t: n9 [1 j6 V
};
2 u! h0 f5 i5 E& S+ `+ a7 U, A- y; s9 Y; q
static int __init led_platform_init(void)/ `; x6 j2 ]' K1 K: q" {' r) E
{
* V. y+ i' W8 l0 W3 H int ret;, Y4 x- P2 Z, p4 v
#if 0$ Q+ V6 a# `* U* H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) |7 g3 F$ c1 ~ if (ret)( j& s* p3 R* O( Z9 t: c! ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* [: I9 G1 p1 `$ u7 V "%d\n", ret);
0 Z+ i8 m* ]2 X- u6 |#endif
/ z2 d# Z0 z0 Q# L ret = platform_device_register(&da850_evm_tl_leds_device);3 D5 t) \# U& n
if (ret)
( P! t1 X8 |1 D1 P9 H: C: ^, @5 v9 C pr_warning("Could not register som GPIO expander LEDS");; ~- ]6 T! U7 a- ^& P
else
& X( M A# B }* O: a9 l printk(KERN_INFO "LED register sucessful!\n");. {4 c* o( g& J, q
. E- Y' A& |- y- C1 |" |: c7 I
return ret;' K! h! b0 R _
}8 }0 J/ Q/ m4 S7 o$ d+ P
R8 |' ]- B; d' M- l! x
static void __exit led_platform_exit(void)
: O5 V' I/ p V8 @8 ~{; o( j5 n+ }5 }6 i( z
platform_device_unregister(&da850_evm_tl_leds_device);
. o0 F$ ?5 t4 j o6 o q) d; M; X* S& p. Q' e
printk(KERN_INFO "LED unregister!\n");, x8 t, q" L% ]* H% h
}
7 }" B0 r6 c y% s. M( n
5 H: ?+ v- f' b9 W x* ~) Rmodule_init(led_platform_init);& ?; J3 k8 c7 [* T( w. a
module_exit(led_platform_exit);0 o& Z* ~: O4 x+ e% W
" d8 a& z5 h, N( E. ^- Y+ ?, a! W
MODULE_DESCRIPTION("Led platform driver");) [1 d! a5 L+ l) n1 I; z' }, k9 a
MODULE_AUTHOR("Tronlong");
/ i* I8 L" U u" dMODULE_LICENSE("GPL");
6 C. ?7 C' ^: C! H3 P L1 M7 l' G
. u4 M& E+ {" O k( [0 S4 i |
|