|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 r- j5 S4 z- y3 [; T" n
#include <linux/init.h>6 D7 |( ~) e5 p9 M( K2 s, w5 O
#include <linux/module.h>
# _# m; y4 P2 s( U3 ]#include <linux/kernel.h>* `0 Y4 h2 P4 u$ N
#include <linux/types.h>
6 _- D7 `6 d$ b4 h: l3 E& P: u#include <linux/gpio.h>% H& H3 v+ i0 i; l$ B1 o% s1 l) m
#include <linux/leds.h>
( c1 C3 W2 Z4 s( O# L#include <linux/platform_device.h>
' n9 G" D3 d; X& H' E1 P
* a) W6 d2 _. P2 ?" C M2 W6 G. n7 A#include <asm/mach-types.h>
5 v1 E9 Q) ?; }1 I, a+ P# e8 v#include <asm/mach/arch.h>
+ [* D. O& ~+ _& x. R1 z B#include <mach/da8xx.h>. d3 I: K7 [4 J% b
#include <mach/mux.h>* [9 b1 l2 N9 O& o1 K/ w& G8 M
9 c7 }7 R4 b$ R; N7 z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); H9 O: z4 E8 X2 N7 k8 \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" n+ J$ C q# `# T8 j& @! I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 e/ s" b9 q1 _, z7 Y, b: S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; g5 x" j) @* s/ M* `) C% O" @" P2 b" W4 c0 b
/* assign the tl som board LED-GPIOs*/
1 z; {5 | a k% o4 O9 Ustatic const short da850_evm_tl_user_led_pins[] = {
4 f. H; q0 m7 L" m /* These pins are definition at <mach/mux.h> file */7 k6 |; y. D7 L& M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% ?2 q. n. q2 h( E5 | -19 B$ i9 e' c/ E
};8 f H3 [2 S" X% D2 ]$ }4 B
& V+ t, o: u* M$ estatic struct gpio_led da850_evm_tl_leds[] = {
d3 B# q, B' f3 U {, ^: U2 h; p! ~9 p
.active_low = 0,
0 _$ o& V* v7 H# x! c6 S .gpio = DA850_USER_LED0,
0 d& b0 S( I# O8 g .name = "user_led0",
- u$ x' H; g5 T& a# r* J. _7 m .default_trigger = "default-on", a/ R! C5 w8 C$ ]6 J) g
},
( a7 n# b0 [/ i' ^' V9 f0 } {0 Y2 a5 g, v5 `8 d5 K; w3 I
.active_low = 0,
% B0 g) V# Q! ^4 F( _* X .gpio = DA850_USER_LED1,
9 w0 ?) f' |+ J6 S: p7 A! [ .name = "user_led1",% R [ N3 v, |) ^
.default_trigger = "default-on",
; o) h5 B9 d7 l5 t# I },
8 a1 j( T- J: K1 t, A3 h: E {0 I7 l }7 W/ i: J. O
.active_low = 0,
/ s& K" K% A6 d .gpio = DA850_USER_LED2,
) b( l6 s8 d( y" t/ D& c .name = "user_led2",: W3 s1 J; q5 J3 L
.default_trigger = "default-on",
- g" W- F* f8 O; }% Y9 u; G },
( O7 A$ d* c4 |# N; O" t' [ {* R# v* m! g, E; a4 {
.active_low = 0,' A+ B. w. s, ~% N9 x6 Z
.gpio = DA850_USER_LED3,
: _8 D6 f; p( i4 A3 _8 P' m) N .name = "user_led3",$ C( f9 |$ H! K8 E! v0 u
.default_trigger = "default-on",: s( L/ G* m! W8 ^* S* K, ?
},
7 e; B6 ?& t9 g& k' Q3 y};
5 i3 f7 h7 Q2 [ i8 P% ]/ D( K9 `+ a! D, c$ j/ y: A* f$ ?2 ~+ o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 T& J3 S- c* I7 `6 N$ Y .leds = da850_evm_tl_leds,8 @8 ]- E1 r& A& O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 x- P4 u6 e5 _4 N};' D) l" n, j- s
- s L1 J9 `; @8 F8 O
static void led_dev_release(struct device *dev)7 J: m' j7 k) d+ Y" O/ k/ c
{
6 L0 b' b1 G5 U' O; h};3 A1 o2 V% J- o3 N
* s& o }+ g3 F
static struct platform_device da850_evm_tl_leds_device = {
% t# G: z) f6 q; g, F+ d0 G" ? .name = "leds-gpio",
. {+ p5 O0 M* H( ~ .id = 1,: Z4 e, |' M. t' J
.dev = {* H1 e4 c6 S3 H+ f: M' R# [' [
.platform_data = &da850_evm_tl_leds_pdata,2 G, H R/ D8 D7 o
.release = led_dev_release,' z3 c) y2 j$ N/ L$ t$ T0 w6 }
}4 c9 F& {+ }: J7 e
};
, I4 L' @5 b) O% i! u! e* d
5 R. P6 @3 @" {% A3 r2 Ustatic int __init led_platform_init(void), g/ u0 t8 `/ J1 U$ u4 M/ V: j; H
{
7 S2 e: ~! r, q0 j% [ int ret;
9 x" M" [" D G) D#if 0
& u. H; V+ ]0 N$ c ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' C) Y; X! B5 B, T9 T ?/ Z if (ret)
; ~4 y; y% h1 [8 z+ C8 R1 p% f" I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! h, y6 j2 c5 e5 f6 _% ]5 m
"%d\n", ret);
. ]+ `( P H3 o$ z#endif
8 q# l& i. I. K* F0 F/ X( E7 e ret = platform_device_register(&da850_evm_tl_leds_device);
M' c5 O) L6 Q if (ret)
. j* X9 k0 S" D pr_warning("Could not register som GPIO expander LEDS");
: L. J( c4 h4 }1 E- Z$ m0 |) T else
+ I& q5 m, N+ t$ r+ e% O' G5 p printk(KERN_INFO "LED register sucessful!\n");! y/ ^" X* O+ k6 ^) N
3 o0 B( x! C" J- J( N return ret;
+ A7 w: O/ U+ H5 k}+ F* O) E8 U1 R& f% t3 L5 a3 |
! J1 }, E" t. @2 C9 lstatic void __exit led_platform_exit(void)
; o. m6 }* [1 E: m/ p! U c3 X{# I- S) V- a" [3 F
platform_device_unregister(&da850_evm_tl_leds_device);
' Y* S; V* R9 Y) l" U: N( K( E& @5 n# O& H% E0 w
printk(KERN_INFO "LED unregister!\n");6 ^; o1 F/ J9 y3 K' V5 @
}
9 E) v/ q7 @! }: m) Q# Y' p: |" C* b5 T8 c, U& y3 f+ V' p
module_init(led_platform_init);- D, I+ n, |- ]0 I
module_exit(led_platform_exit);1 m# q0 R3 |7 s* `; r% d) H
$ v/ q( I+ W: ] T) sMODULE_DESCRIPTION("Led platform driver");3 I- |6 R; m6 \
MODULE_AUTHOR("Tronlong");
7 R/ [2 @. ^ {( J T' c$ [/ oMODULE_LICENSE("GPL");) I0 T0 z- |, J4 q, @9 g& l5 P
: l( c2 x6 O6 E1 l; _ |
|