|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 m8 @; V- v, C8 A/ O9 D7 {# t
#include <linux/init.h>% B$ Q4 u* G4 M/ O, z/ v
#include <linux/module.h>8 ^+ ~( g& h6 t0 Q: I
#include <linux/kernel.h>$ K6 D/ q# w. s6 Z! F0 l
#include <linux/types.h>5 K) w# _/ s @6 @
#include <linux/gpio.h>
; d' j4 _0 s& y8 |#include <linux/leds.h>
' S1 O1 {& m$ ~# P& R8 S4 F5 \#include <linux/platform_device.h>, N9 v4 Y, \! n) I, U+ h. o1 J
2 V0 I% |- ~4 T1 o; m: K
#include <asm/mach-types.h>9 u8 X# a/ l x' G0 }
#include <asm/mach/arch.h>, u7 @; p# {+ _: J" d6 Q+ E
#include <mach/da8xx.h>
+ p0 M3 ~) N" I, a6 L, j) B- y/ i9 E#include <mach/mux.h>
6 C- N1 \, I( U+ a7 N3 P5 Y6 L3 F2 M. h! b8 Z6 y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% O1 B) ]- h6 y" Q) C. s e( d* e; ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 C$ z4 t; c( R! A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& X" d# R1 M; L& s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 E) }" I1 ~2 z) O. I: R: u7 X
& l" ^( Z; n! m$ O
/* assign the tl som board LED-GPIOs*/8 Y, F: H1 e3 K8 s8 X) o
static const short da850_evm_tl_user_led_pins[] = {& [/ @8 U0 J; m9 y) r0 @
/* These pins are definition at <mach/mux.h> file */
B K, _, i" P& f3 s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 k' n3 C+ i# t1 i: q2 J$ W -1
3 }2 e4 H1 Y( J7 n2 N, l Y};' B5 x6 p# b% y; Q9 K
' Z7 r7 r8 e1 ?1 S) [- A
static struct gpio_led da850_evm_tl_leds[] = {
$ ~( m; D! h$ n% w3 n! ~, s! ?3 z { b5 h! R2 J4 F/ T; {8 b/ R, Q ?
.active_low = 0,' N: v8 X0 W# e( g
.gpio = DA850_USER_LED0," N5 T/ I; A L t' ?* d0 k+ M! x
.name = "user_led0",
! _6 g: e5 G' N P$ F( G2 ` [ .default_trigger = "default-on",
# a8 z4 C! ]6 g* o },& N0 T. l' {0 S6 {& v3 q `5 [* c
{5 |% N6 N1 Q9 V9 A( b/ S; A9 S* Y
.active_low = 0,
3 ^0 m( u0 t# p$ l$ W1 I, P .gpio = DA850_USER_LED1,' _. C9 n8 @9 M4 R
.name = "user_led1"," _3 N1 ]8 q1 r
.default_trigger = "default-on",( p5 c& m+ x' c( \
},
, Z) A, {2 [* r5 q5 U" T, R; U {6 f: J( Q& k6 Q, j; D3 W. ?
.active_low = 0,( l2 w, p- [1 f4 i% m# J4 h
.gpio = DA850_USER_LED2,
S) d) v4 r. b9 I, ]3 a" ] .name = "user_led2",
* s' ~! g' Y) M8 m8 | .default_trigger = "default-on",2 o' o$ f5 g. @/ U
},
2 A9 @* h* Q: U( E5 |/ d {
7 B8 B6 {' ^( W .active_low = 0,
+ P/ q2 |5 W+ I2 S7 F- J5 t. V1 J .gpio = DA850_USER_LED3,
4 U# o' A3 S+ \' v" q4 f" T .name = "user_led3",
8 e3 P4 N; }& g8 p* z+ z .default_trigger = "default-on",4 m2 m; b r* `% {" P9 n$ U8 `
},
) O/ k% }" r; k- C& I4 P};" c+ j6 q T& Q$ U5 M
, L# m. S4 E. H8 V5 G) s0 _- U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 e, P7 r3 c3 A' Z( e8 k
.leds = da850_evm_tl_leds,
4 {1 O8 c y7 q* R, e6 Y1 K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: Y6 I: X9 c( \5 ~: n};) j# e, z3 r4 `& ~2 L
# s! Q% f! j8 M+ v& _
static void led_dev_release(struct device *dev)8 C9 s9 z" i6 t" L9 s. V9 |0 L
{
* k! `3 x* G! I: S, W};
/ K0 A( y- ~) k0 ]0 O" _) ^
) Y, c! j4 E6 Gstatic struct platform_device da850_evm_tl_leds_device = {
; N y9 t; J( a2 [- U% }6 \+ ? .name = "leds-gpio",- }5 Y% o8 L# Q0 S6 w- }+ \6 X8 Y" e' |
.id = 1,3 \6 K% }3 ^7 K# o G1 O- E* a9 l
.dev = {
- H9 `# T' Y( w .platform_data = &da850_evm_tl_leds_pdata,
2 G. m% z( i( {) w3 t- { .release = led_dev_release,+ ?: s; ~/ ?9 e- U3 f/ t) X
}
! {: T9 G& h( N$ I};# F0 O }! `5 M8 ?
9 k1 i% D* m' z. V
static int __init led_platform_init(void)
# c* {% E8 p: w# ]/ V* y5 a{: c4 @5 U. a# ^
int ret;
9 E2 a3 Y, S, n0 A#if 0
+ Z4 h+ P: D* A1 Q+ F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. i$ o) D6 ^; D5 h7 ^ if (ret)* o3 } ^; c5 V0 K* b( c
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 x4 t3 ^2 P f "%d\n", ret);+ J- \8 @/ g) X; D# E
#endif* [- }. J; k5 L2 A
ret = platform_device_register(&da850_evm_tl_leds_device);$ x+ g" N- f0 g: N- G) ]
if (ret)
) c4 p; D$ B6 v' @5 H" M pr_warning("Could not register som GPIO expander LEDS");
9 `2 s" P3 e% H* U# X& h6 H) | else
0 O+ `7 P9 }2 @9 j9 @ printk(KERN_INFO "LED register sucessful!\n");- r0 F- C" H3 t
4 f- G8 f' q& m8 o8 b
return ret;
4 e5 E) x9 v( p$ Q9 k% ]}
' G6 r7 S3 B. z
. n- a" Y6 l1 n: sstatic void __exit led_platform_exit(void)
s1 v5 K Y# c$ F9 f{( L9 X1 z0 `; z; N* c
platform_device_unregister(&da850_evm_tl_leds_device);
0 v2 m3 ^% L! E" `! V Z4 G- I) u) G. K5 U
printk(KERN_INFO "LED unregister!\n");4 g2 W, U8 K+ ~6 m, I0 `
}
2 E( d6 j+ e% B- { v! x
- n8 C N8 k! W" omodule_init(led_platform_init);
9 ?8 f( J5 M+ x$ b; N- z* Xmodule_exit(led_platform_exit);
! k; ]2 r A9 [& a9 ~2 S1 F1 ]( @3 o( Y4 D
MODULE_DESCRIPTION("Led platform driver"); k- o2 Z; ?3 P6 Q
MODULE_AUTHOR("Tronlong");
p) D1 s- m2 V# g, fMODULE_LICENSE("GPL");; O9 J* Z& p- X
" u6 [, R6 j8 E3 k6 v. c
|
|