|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ H$ M7 D$ C; k2 z* V" ~9 N#include <linux/init.h>6 y' C( c+ B1 M7 u
#include <linux/module.h>9 C" h5 M; H7 b+ s
#include <linux/kernel.h>2 x' y& m9 n4 I) B9 `; g
#include <linux/types.h>" @- `& E+ j3 y+ S: G
#include <linux/gpio.h>9 O5 l* V% c4 r) F. R: y
#include <linux/leds.h>7 t9 P5 ~$ D5 B
#include <linux/platform_device.h>: Q/ l# _0 S* p% Y
6 Z7 m& s7 R4 `. c. b" Z4 d
#include <asm/mach-types.h>
1 L8 `; L& N! N#include <asm/mach/arch.h>
\1 g; p- w+ t! s#include <mach/da8xx.h>
3 @. ~4 a2 O& P7 d1 h# L7 S#include <mach/mux.h>
9 R0 u, N/ M V
0 [. F+ E4 W7 i; S5 R0 K f2 b( G2 o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! a& z4 W9 Q" s#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 q& M; t9 K2 _3 u#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ T( f# T/ G$ d3 n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( `7 m, A/ h6 ]" H0 j! y9 B, } m: K. O* y0 n( L
/* assign the tl som board LED-GPIOs*/
+ o. j0 ?3 N K/ ]# C* ^) ^static const short da850_evm_tl_user_led_pins[] = {& \% y8 ]1 q: \3 e7 v& T
/* These pins are definition at <mach/mux.h> file */
" A' V- r/ M+ m' Q M+ D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) Z/ T& }! e- \ S/ @. w% X
-13 q9 h$ K$ x, G
};1 ~% F) j" |/ A2 T) p; c
8 R! v, q, d0 h/ S/ a* n+ Fstatic struct gpio_led da850_evm_tl_leds[] = {
3 E; u/ g/ ?/ w$ [- M+ z) | {
& t/ C/ e& @$ @2 c `- K( L .active_low = 0,
. z/ n/ t3 V+ s, u& { .gpio = DA850_USER_LED0," I9 K1 |$ i& Q; f# ^; f* q
.name = "user_led0",
( s+ A! J# x: a5 N' h8 n1 @ .default_trigger = "default-on",$ }& G: e- }% `1 }4 S# I
},
/ J3 v; L1 p2 c* O% R. v/ |. k! \ {$ u5 K' k" i* e* t9 ]" L
.active_low = 0,
$ y% r# W" z' p! K" W3 G: j. r .gpio = DA850_USER_LED1,
1 }" V0 t8 Z4 g) q8 f .name = "user_led1",
5 n; A6 U ?9 k7 F' g( U .default_trigger = "default-on",
/ ~. A4 F' [3 x% E% l% k* Z },
6 i$ ^7 t& f( }' S7 {5 X {
' `: D% W0 t5 P" k# f0 M6 }/ |6 G) M .active_low = 0,
5 X1 \. b: r+ U$ }; E .gpio = DA850_USER_LED2,* n% E: c: H6 d- x( b
.name = "user_led2",5 I6 R) x" \5 P3 M# h
.default_trigger = "default-on",7 {5 _( R2 ]0 L( q
},( m! T& z6 Q$ o) m7 F$ `' _
{
1 _( {; [9 x) | .active_low = 0,7 p' L: a6 {- X9 s: I8 X. t
.gpio = DA850_USER_LED3,
( X9 p5 p4 @& U _5 ~' ] .name = "user_led3",- y; E3 n' d7 r) Y0 E
.default_trigger = "default-on",7 o; P& R) Y8 Q8 v2 u# k) E
},9 P, b k2 a; U) P" T: J
};
) a" a4 a" v8 k/ D% q5 a+ ]6 g: R% K# }, X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 t/ C0 N7 c5 c: L1 t
.leds = da850_evm_tl_leds,/ |2 y, Y. H. V6 |8 K. ^! Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 i. N5 \- k1 @; D$ a9 r
};
' O8 `% K3 R- W& x1 _, l* c7 G/ P$ F
2 a1 i. ?; d2 Bstatic void led_dev_release(struct device *dev)& z8 @% j/ S4 q8 |7 m3 W
{
: {0 N7 i' m2 n};
4 X* q9 m T' I6 v/ ]
5 r) L! b2 ]3 x! {9 C4 A) v8 ~static struct platform_device da850_evm_tl_leds_device = {
5 [* {/ s) C) ~: d1 O5 `9 ~8 Q .name = "leds-gpio",
* N; Q5 P5 F8 ?) D8 g2 r5 c) { .id = 1,) H M# c* t2 l/ \. y0 u, U
.dev = {
1 W' [7 R5 U @* ]2 V; F .platform_data = &da850_evm_tl_leds_pdata,
; O6 I. r: }1 D% H6 g, i4 ] .release = led_dev_release,! j5 j9 |6 g5 d! o; e) n3 x3 G
}
. Y4 X' c# A% b. H9 U7 _9 R1 }+ t! o1 Y};+ h( w/ E6 U5 n8 `; L' u% M
P5 q" V' P8 |, c$ |) P: T
static int __init led_platform_init(void)
# P; v) ~9 a% J% D) X{1 O9 i1 o/ P5 Z, v# P) t7 u
int ret;$ r- o- b+ P0 `, j" c5 Y p
#if 0
9 f" @& p8 k4 j4 ]7 K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# J4 h. Z1 g' C9 w0 E
if (ret)
/ ^. ^& D Z% P* q, d4 B% t pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( v" o$ t: d2 R3 o. s+ l/ a( | g
"%d\n", ret);" B# m4 A* y. i& ?
#endif
# m+ d+ m& w- {7 {+ P ret = platform_device_register(&da850_evm_tl_leds_device);
. O5 G1 S" t, Q if (ret)% U0 l h5 |9 U6 B* _, s. t- L- e
pr_warning("Could not register som GPIO expander LEDS");$ [) d+ D) K0 Q8 D1 e+ U
else# y- {2 t9 E# K9 B J% P2 { U: m
printk(KERN_INFO "LED register sucessful!\n");
; d) [1 F z5 I5 z, _! B
5 N M/ J8 k! W# ]: K; t return ret;- g! \' A+ b& v* I0 E9 K
}
, k# w- O" U% H2 S `3 P7 U- y) Y, ?0 H2 z7 o6 y+ p
static void __exit led_platform_exit(void)
) O( p5 V! K& s% t! |( i{) G7 O1 `( R. w1 f$ Y* ]3 W* j
platform_device_unregister(&da850_evm_tl_leds_device);
' K5 ?9 ` a- J, F, ^
2 I k- I' I0 A8 Y printk(KERN_INFO "LED unregister!\n");3 {( @: b$ o6 A+ E ?- i8 A
}
+ X6 j: _0 `8 N. n6 A9 L! a5 x! ?+ f4 Y9 T' \
module_init(led_platform_init);
/ k) U$ @3 Y9 ]0 lmodule_exit(led_platform_exit);, p* @; K8 R. F7 a0 T+ o
- H* {1 D% M8 c
MODULE_DESCRIPTION("Led platform driver");; ~( U. {9 Z) T
MODULE_AUTHOR("Tronlong");
9 }: Q+ h" P/ n5 f: r& R2 kMODULE_LICENSE("GPL");) E8 k8 {5 A& e4 w6 f- {
6 q, w1 ]. i. L" T0 }" B |
|