|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 b d# D Q" M& Y: `5 z; d#include <linux/init.h>
* m2 {' I) \, d! S7 Z3 Y#include <linux/module.h>
; A8 B, @% `4 L#include <linux/kernel.h>
2 @$ G7 D/ e& H3 N5 n! @! |#include <linux/types.h>; D0 U$ e# [6 }6 y) R+ ?
#include <linux/gpio.h>( q5 [" K0 x t
#include <linux/leds.h>
; s; i5 n0 |7 E0 M* U#include <linux/platform_device.h>- U# E: _* ]! Z1 u8 Y
& M8 v. o. \# e4 v$ D#include <asm/mach-types.h>
) N: p6 ?5 [% E3 l) c+ s, r#include <asm/mach/arch.h>7 n1 K% d: F, \/ J( D
#include <mach/da8xx.h>
: @: Y% h a r. L: Q4 f- \#include <mach/mux.h>
0 f% [7 j# W% k% `7 [& Z6 A# T. u) j2 D. Q1 Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 R( x) s. f4 _& ? I) d& U9 A r5 t& F#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 G' {, S2 f# u3 z6 S4 _+ k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 z8 i2 y* ^4 Q3 B- c% B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 G+ ?, r2 q3 c; D! a: `
, O$ ]: c! |; } x$ L2 C8 j/* assign the tl som board LED-GPIOs*/
1 Q) O1 E* q. s) Y) \ ^6 o! L- nstatic const short da850_evm_tl_user_led_pins[] = {" G. b+ ^8 F" K/ n% ^
/* These pins are definition at <mach/mux.h> file */, E$ I, b# P: ?5 T
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# U7 J& C; ?9 k. s5 v+ F -11 D: T$ {9 Q+ m/ U# u
};
; v, A0 n$ P: d& A: b+ }/ I1 Z
$ H: m. C: P% Z0 e, pstatic struct gpio_led da850_evm_tl_leds[] = {
" R! m3 ?+ \5 c! o( \" c' i, o9 A j {9 N- D4 k$ I- u% Z7 r, u# Y6 K0 l% d
.active_low = 0,4 {1 U& i' J0 O0 Q1 s
.gpio = DA850_USER_LED0, \# V1 @1 V. x. F
.name = "user_led0",
' }2 T0 |$ Y4 |3 z+ Y; d% q7 T .default_trigger = "default-on",1 f" \+ ^% K# C# p# o
},* X$ w* q! R, j4 I
{
! ?) u' \3 j: C/ T/ J( C0 {) J .active_low = 0,$ A% Y" w4 U) ^% n0 a! D6 h
.gpio = DA850_USER_LED1,
& w! M; P, s$ V; F r& B .name = "user_led1",+ V/ s, ?9 Y( ?# Z2 u- I
.default_trigger = "default-on",+ z. W0 B" t- N- t
},' `5 R/ y9 v5 F- J6 y$ K7 Y
{+ c0 Q G7 G- w; x4 j! N, s, L
.active_low = 0,1 j/ u4 C5 _0 m
.gpio = DA850_USER_LED2,7 K% u% S: n6 o3 d/ J2 t9 i
.name = "user_led2",7 k7 F; @2 Q/ c6 [% m
.default_trigger = "default-on",7 V: K2 Y) L! @( @+ `
},
, _, i& ^% R3 ^* S3 ^" b {
% ?4 ]$ u% [1 @: Z" d* x) U# k .active_low = 0,
, z" J2 a2 Y; X1 j' J( q .gpio = DA850_USER_LED3,
$ i- d7 e( e" a. Q .name = "user_led3",3 }3 j# ]4 Q5 Y" ^2 p
.default_trigger = "default-on",
6 g( ^3 Q) j! K! f% k. S+ {: w9 ? },9 l C; X' P" B3 ]) H8 L6 i
};
1 A7 N" b$ J! ?! r5 c
6 B- S2 P5 I$ v4 U2 x6 x9 astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" I% M$ ?7 u+ b* W; M .leds = da850_evm_tl_leds,1 ]3 C( _/ ~; Z1 G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ ~: i# @/ y& n( H% l
};, q) C% w/ i6 o, p
9 A& h, b( @2 r; E4 W% m
static void led_dev_release(struct device *dev)
6 e! D2 X4 ~5 H{! H. A8 k" C! q3 k# G
};/ `# l; I; l# G) }1 i
+ B# |" g* \: W$ B) c6 \
static struct platform_device da850_evm_tl_leds_device = {
: p; r) }8 _/ H& S N4 i+ |3 l .name = "leds-gpio",
8 t0 i5 d! I3 H) Q9 E6 c+ y/ w( ]5 b .id = 1,
" u# Y9 d E. ? .dev = {- [! h! ]9 c+ v9 U
.platform_data = &da850_evm_tl_leds_pdata,
6 f# w% E6 S( m! k! u3 v* d .release = led_dev_release,$ E$ s2 ^) Z+ |$ `5 r. h6 t
}6 c+ K/ d: O! v! W) j
};
3 t$ B0 m$ g/ k1 n+ Y$ o5 B- Y9 x! s9 ~7 ?$ [. j, K
static int __init led_platform_init(void): F5 {/ Q0 n# p' }# { \ C
{
# Y* C8 L) z* R' Z int ret;
# s1 r' b- b$ O2 W7 a5 F1 u#if 0 J* Y0 o) F- d1 `8 |0 c4 a& V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; A- d$ i, Y( ]! A if (ret)
+ o8 y" ~1 S; g2 | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) T. m, ~2 \9 A "%d\n", ret);
0 e( m7 G! ?# k- D& B1 M6 @) S& S1 ]#endif
8 L2 ]$ H6 ?; R ret = platform_device_register(&da850_evm_tl_leds_device);# a+ E5 W8 I5 t |/ N
if (ret), j8 f' n+ C* ?
pr_warning("Could not register som GPIO expander LEDS");, T9 z6 x; n2 V
else! [8 i: O( d5 w& T
printk(KERN_INFO "LED register sucessful!\n");
0 _1 B4 U0 \+ O |$ h1 n3 A1 y$ C$ I3 T
return ret;0 t" S) n3 |$ O2 q( H5 G f" G
}
7 s8 z, l3 e3 w* Z+ y9 v4 N% @4 {: J" t$ c% [
static void __exit led_platform_exit(void)+ ?! j% f* A9 _$ Y3 m& ]
{: f2 v8 l( j! F4 S2 `
platform_device_unregister(&da850_evm_tl_leds_device);
' y% D# |- ]6 ~
9 L, l" H2 J1 c printk(KERN_INFO "LED unregister!\n");
# y- w) c; R" Z+ i} K% B `8 q" V% l. L, v% e
; _% K; m& |5 T: Ymodule_init(led_platform_init);
6 |2 _' _( Q/ y. |3 Y- fmodule_exit(led_platform_exit);
& w% K% x7 H- l- p# k- Z x
) Q) ^' V9 z& q! Z" f8 w) T$ BMODULE_DESCRIPTION("Led platform driver");
+ b7 F: ~ F; Q' v9 i9 RMODULE_AUTHOR("Tronlong");9 ~# P( Q5 j( U/ e+ K& |2 S! b" p" l
MODULE_LICENSE("GPL");/ Y( h/ ^# b( C- {; h0 J
6 R4 z; F) n2 G |
|