|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 @! b, b2 A Y
#include <linux/init.h>7 G* f- v2 }6 ?
#include <linux/module.h>
$ Z) L5 a' P- C! r: ^#include <linux/kernel.h>
0 k# l3 Y3 o' |2 \+ N+ Z/ n# K' f+ ^#include <linux/types.h>( `% N* E1 `. e4 ^ }
#include <linux/gpio.h>
) b$ W S% F1 h2 K5 d#include <linux/leds.h>$ m( T3 \# U6 |" D
#include <linux/platform_device.h>% G# X2 U! c/ B0 x$ i% V) N6 z
! X5 P6 c/ _7 ~/ s# ?, B
#include <asm/mach-types.h>0 D' J! q9 p8 @/ ^
#include <asm/mach/arch.h> H3 @) |: w* D9 N/ o# h) t1 k/ f
#include <mach/da8xx.h>8 ?( L4 j2 H) n
#include <mach/mux.h>
2 m1 c) b" S9 F# Z' Q/ m7 ^! Y( V5 ]7 K" l# z; ?0 [- w E
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* |7 c0 C2 L2 @4 ]& _2 c8 L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" b* M- T+ w! f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 p- k6 O, b. Y, D" |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) n$ K+ i g$ o# T, l K
# B; S; Z+ x2 Y/ l' [& X1 P! W/* assign the tl som board LED-GPIOs*/
( n- N8 W/ x* T! nstatic const short da850_evm_tl_user_led_pins[] = {
/ q0 q8 X9 ?1 p2 q0 j# s, ~ /* These pins are definition at <mach/mux.h> file */
2 j2 o- X J; d, ?+ d; X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 p+ x, u$ h; Q3 X# V9 T -1
% \4 R( Y; }- K& o S: _ \5 B};8 n. S* v! X4 C8 t; j
; J( s: y ^- b9 B5 @" `- z; x5 dstatic struct gpio_led da850_evm_tl_leds[] = {2 M2 E: r9 ~ x! `( J) k8 n d! h
{; g' k9 P+ X) B& s5 t. ~
.active_low = 0,
% j7 d c7 V, a7 V& i .gpio = DA850_USER_LED0,
8 A) A8 Q; |1 h! P' n o: M7 d4 q .name = "user_led0",
# {) e6 M% f5 }$ x2 U$ C9 f .default_trigger = "default-on",
5 p+ Q* P1 x: J9 _) t. w. @' { },
$ t4 A. \/ o4 s" o/ S7 g" g {
9 ]) s: ^* S8 J( j0 N .active_low = 0,
! S: r+ i4 J/ f* g; n- ?' i .gpio = DA850_USER_LED1,
5 E5 }% M6 G u2 A* t: @) W .name = "user_led1",
7 e& v5 N* r4 {( ^" S .default_trigger = "default-on",0 v) p" y; r0 j9 M2 _5 |1 g
},
/ x, J& m" x- G1 |8 T- B9 g {
2 M5 T) n; h0 V3 P% r .active_low = 0,2 r7 D \4 e. o
.gpio = DA850_USER_LED2,
0 L" A3 d# x3 m .name = "user_led2",
) E% ?' S% z+ o* [ .default_trigger = "default-on",! {* \9 d# A3 q6 n" n, {4 I, m: x
},8 f* Q; T; Z4 b$ l; N2 [ v# a1 G: v
{
8 D; q" m- m, X6 L$ } .active_low = 0,
2 ~% G% M p8 t$ x% x .gpio = DA850_USER_LED3,3 G4 P$ F3 K6 o J' d5 q7 |$ X
.name = "user_led3",: J9 w6 N% p! x9 n
.default_trigger = "default-on",6 Q+ Z1 g3 y( N# K- I* ]; }
},. |! t& E5 o2 W0 r5 ~1 w4 g5 X- m( F% o
};
8 X$ b8 g+ G+ |1 X; N- J8 y. U2 g- p: r2 M4 t# ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- f: Y# [! Q2 T4 L- l6 o, D, Q+ P0 K
.leds = da850_evm_tl_leds,0 O6 _% O+ F; V! @1 {* ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 R0 {8 s" D( {" { g& S' h& {9 w
};+ B7 T( {: v( D/ m
5 O; y. ~7 p1 Bstatic void led_dev_release(struct device *dev)
# N( m6 | |, y6 P{
6 t9 C/ a9 I. B+ l9 ]1 J1 u};
' t0 X! G. _+ `9 d: b4 J7 x
" _+ U: r; s7 h4 V, wstatic struct platform_device da850_evm_tl_leds_device = {
5 [# ^- N5 Y' b/ I .name = "leds-gpio",
" i$ Q4 F c; G" }3 } .id = 1,% r3 f0 y/ F, }6 Q) _
.dev = {$ ~3 E. t! W' _4 {. t! P
.platform_data = &da850_evm_tl_leds_pdata,
0 Q! B, N/ T! G .release = led_dev_release,3 c8 | R! y% S0 @; K8 _7 h
}2 r* A9 m$ r" ^: {1 v
};4 U& B8 T: K) P7 }9 ~4 G
8 t( }6 W0 j" c/ m& p* e
static int __init led_platform_init(void)
% m6 b8 u t- L$ [, z{
# X7 m( R# V8 u# K& ]4 G4 F2 b int ret;* y1 H: M G Q" G" J& r
#if 0
) t1 O# W7 ~* j- M/ K6 q" U& S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 e! z6 W; n/ p if (ret)7 o# t' O1 K7 o9 h+ i) P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ o5 Z* W3 I$ D! J" L$ F5 K" i6 t
"%d\n", ret);
, W. ~6 i: `# M#endif
, P; c& T7 }) X u# r5 k' A ret = platform_device_register(&da850_evm_tl_leds_device);
0 Q8 L- ~9 Y. k) j$ P if (ret)
3 A6 C( E, _& v# c5 } pr_warning("Could not register som GPIO expander LEDS");1 q- u6 v, ^% g6 g( L' S
else) Q1 x0 }( K$ G7 W1 Q: {6 x
printk(KERN_INFO "LED register sucessful!\n");7 B# k x; A% D) o% o/ m! h# {
- ?: q+ g' \6 F7 B
return ret;. `! _# \9 w, E$ H9 k
}
8 i8 Q5 p/ P, G& `& j, B1 n) a6 J2 B1 L# Y! G& H
static void __exit led_platform_exit(void)
& {0 u2 v% o8 a0 U{ J/ X/ X, Q! `: _1 d. q
platform_device_unregister(&da850_evm_tl_leds_device);
; j( S* @6 `9 I1 C. T
5 } S. w: |& S2 p printk(KERN_INFO "LED unregister!\n");" O2 _0 x# E6 L1 X& ~& n- _
}
% N" Q9 m( M& J5 K+ v; J% @
1 I! ]% j: L0 H, A1 T3 Dmodule_init(led_platform_init);
1 N, {$ ~: C: d. K# y( i& Mmodule_exit(led_platform_exit);+ n2 p$ Y/ G; Z# O( s) T g F# G
, D' t- H2 C X3 E( b. c" o9 J1 eMODULE_DESCRIPTION("Led platform driver");
( z& V3 r! W p% A6 f& S) nMODULE_AUTHOR("Tronlong");- }) h ]' U9 Y' B1 R: D+ ]' x
MODULE_LICENSE("GPL");7 ^' H/ i! a9 j6 K
a/ K: W1 P9 L% }7 d8 \3 g' Q
|
|