|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ w1 |; ?4 Z* }2 t7 h. W& o0 R#include <linux/init.h>9 c& f2 ?/ f, Y
#include <linux/module.h>( `% z( n! D3 }! r4 X5 i
#include <linux/kernel.h>! ^4 b% v$ [, h' K; u
#include <linux/types.h>
2 ?' n+ }$ i" J2 s#include <linux/gpio.h>/ j r s4 |, w, f9 [4 l' s$ ]/ [1 W
#include <linux/leds.h>
& ^9 _, f5 @5 `3 t# P0 m% X/ M6 t#include <linux/platform_device.h> v/ I- J Z% @2 Z7 h
$ P. o. Q6 |" P7 X) E- R# V#include <asm/mach-types.h>
& H1 e* S. L* P6 T. f, s p; h! t! o% a#include <asm/mach/arch.h>
/ Z4 J% g, T2 N4 ?4 _) ]#include <mach/da8xx.h>
, U- `( L; A9 v0 u. N8 r#include <mach/mux.h>4 z. F8 p- L) w' c0 S: \
. f! {, d ?: V+ A1 w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 w# e( F- N" S) @0 c) A6 y b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 o3 s; o) _7 Y& m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" j0 y0 G. n* K1 K0 H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ F' `% c5 B, t5 K: q0 J) ?) f% o6 M$ w( R- z. k# Q: O
/* assign the tl som board LED-GPIOs*/: b) F: z/ M# w/ _6 X; M# d
static const short da850_evm_tl_user_led_pins[] = {( j8 {! S L! ] F4 h' }
/* These pins are definition at <mach/mux.h> file */
9 b* F" x- ~6 y) H6 |! ?% @1 ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 Q8 c4 I0 z$ t9 t
-1
* z" V1 T& Z* i) [- b' \};
5 c& }2 x" w0 L0 C1 X5 \
V% U6 B: \2 u6 `1 ~$ [* ustatic struct gpio_led da850_evm_tl_leds[] = {4 i+ F* E' A+ N# a
{+ w4 ^* |9 R& k+ H, M
.active_low = 0,( w$ o, S! P4 {9 d0 D. J7 v
.gpio = DA850_USER_LED0,- m& j, i: Y8 @+ R m, B. v
.name = "user_led0",
( T) F' U; m+ j V' T3 ^+ V .default_trigger = "default-on",1 F; a# W1 s& |9 i$ U
},
6 a! q v6 H: Q. C }4 n- N( i9 g; O {, }& h% R- f7 i/ Y* K9 Z
.active_low = 0,
4 \ m1 b, ?; O( J7 N( K* X9 a .gpio = DA850_USER_LED1,1 x+ K/ g) l; z4 u' R3 I- e$ C
.name = "user_led1",9 F5 V/ G* R! ]3 S$ k! K
.default_trigger = "default-on",
. W1 z2 g4 N3 I5 k },* V" O. U" `9 j& Y$ {/ G
{
- w8 C& B9 j4 A+ |+ v4 l .active_low = 0,; O, Q: D. e4 n" ]6 S" d o/ `
.gpio = DA850_USER_LED2,5 S* }3 I# ?# }3 |# |' w
.name = "user_led2",0 z! K1 W" O8 m' |* k1 w
.default_trigger = "default-on",
! |+ P; a" _' r, r: m! R: c, m* O" W },
m# F7 M, y3 C0 F0 \8 Q {% l* a) J; ~7 l7 B$ j3 m: v
.active_low = 0,
: w7 d' ?* q2 \0 }3 S .gpio = DA850_USER_LED3,; A* L! q/ E' f
.name = "user_led3",
; o+ }4 b) v6 y. j .default_trigger = "default-on",
6 v% d0 ~0 |+ K0 i4 Y) w3 j0 f( i* ^ },- x2 r3 W5 C( X6 U
};/ }4 n ]; m% S9 p. o
( ~" A8 }5 c; G) U% k/ o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 g g" l, U2 n0 I7 y3 W, a% _ .leds = da850_evm_tl_leds,
( u( f+ k# d, {6 M5 k/ K8 h; g .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% K$ d, ]9 z: d9 L, h
};
4 a4 |" a2 x1 v4 E. K2 J7 h
$ V9 M( ?) {2 C: K: o' _static void led_dev_release(struct device *dev)
! ?5 _) R. `! W& U" w. X{
Y% F* Z9 w& M* X5 t};" L- U8 ^$ T; }3 ^
9 P1 \3 ?7 t) s$ H6 N2 y
static struct platform_device da850_evm_tl_leds_device = {% }" d- S0 l$ G5 A
.name = "leds-gpio",
- \. _4 m& `$ v4 H .id = 1,+ |/ s2 O( n3 o
.dev = {
& N& c) W& y, S# S( i9 K .platform_data = &da850_evm_tl_leds_pdata,
" m' T! g5 ]! {9 e5 F& Y7 V O .release = led_dev_release,/ W' H3 q7 {4 W3 R( }9 y
}8 j P5 D w; ]% S; t$ |
};* _+ Z; _) J. y! N. m; f
_) s6 _1 H2 Y6 {- Ustatic int __init led_platform_init(void)
. n0 w& L$ j8 Z( Z: n( h{# Q6 p8 g; N5 y: e+ j R' c6 o- W
int ret;
. K* D5 ?7 }% a" b#if 0
' u) S& B8 C% D1 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 q1 E1 l( `6 r0 S, Z
if (ret)
) e3 q* [; Q) j# ^) n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" ~5 M4 K& e; t* E$ j7 @! w( W "%d\n", ret);
% G7 |+ K: A2 c4 h7 U#endif
* M: M! E8 V W, U) r ret = platform_device_register(&da850_evm_tl_leds_device);. l. V' U! d; ]( J$ j! C7 a4 r/ `
if (ret)
|& Z+ R# [( C/ e1 |2 s pr_warning("Could not register som GPIO expander LEDS");
y$ Q8 e) Y) E4 P' ^* C else! X- b& q. Z# Y8 S
printk(KERN_INFO "LED register sucessful!\n");
$ N6 I5 `: K4 }
* R. s5 ?! R* p3 s7 J return ret;( V/ x. h- @: X: M4 E
}! s; _7 I+ a* i# ]9 W
5 }: _4 e$ W+ z' f
static void __exit led_platform_exit(void)3 R, W, H8 M1 q* v8 X$ V+ G
{2 V" D$ I8 U! c
platform_device_unregister(&da850_evm_tl_leds_device);
. V1 u7 ^! T& Z* u
8 X8 F1 x9 L F printk(KERN_INFO "LED unregister!\n");. ^% r" L) s$ y# I4 z$ U# k# n
}
6 m+ C5 M) h' X( \0 i1 m0 h1 i9 k6 u2 D
module_init(led_platform_init);- ^: D: y& Y# s
module_exit(led_platform_exit);/ T* }/ P6 {' c) N- X. `8 u% \' h
# r) }. M2 L" l! C8 a) [
MODULE_DESCRIPTION("Led platform driver");
3 h) I0 _' T& g5 |MODULE_AUTHOR("Tronlong");
j, m3 h; F- @$ u9 A# k% v: FMODULE_LICENSE("GPL");
/ u, E- x9 T' U7 o7 f y9 B; h; `. o0 A3 G
|
|