|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) N, J1 ]. ?# m' o7 v
#include <linux/init.h>' u; G: f1 R5 i) z, B2 I* P
#include <linux/module.h>
* p! q* i# I, e) ^3 |# n#include <linux/kernel.h>
! `' x) E, E4 K3 M2 C9 B" @#include <linux/types.h>; o% |! I" [ G. y, u5 h ?
#include <linux/gpio.h>
( j) V N4 C, {, b#include <linux/leds.h>$ Y! ^9 M0 v: Y7 b! w+ z) X" |
#include <linux/platform_device.h>6 W8 |3 M* r6 i0 R( E
, O! R+ Q. q, f7 U
#include <asm/mach-types.h>
' h8 _; x; v' k* r; D$ L% m/ s#include <asm/mach/arch.h> i( C9 m( `. S7 S% ]
#include <mach/da8xx.h>
2 i5 g. Z( r1 q+ Y. U#include <mach/mux.h> F6 p) Q( q/ r9 w$ u
' n1 @8 s: d }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) h: U% d) W) E% K! Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 y) |3 r. @: X4 S$ Q* b
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 F6 u% l7 c( k5 x `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 E$ N8 a/ [( ]2 w) G s9 ?* R/ r z
8 Y0 H( o* c4 |% I m/* assign the tl som board LED-GPIOs*/$ l" V8 h' |% P! M6 p. Y4 j
static const short da850_evm_tl_user_led_pins[] = {3 _0 p. x% O% p
/* These pins are definition at <mach/mux.h> file */$ a. D: R" K" R% Y7 D! d
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# G; c+ j# d1 P# H -1# R9 _& h) \8 Z# S8 W5 |! _. c
};
; p1 C: ^. k9 q! l
5 `8 A4 l" [; z6 w1 w3 Ostatic struct gpio_led da850_evm_tl_leds[] = {
1 w, H+ k/ s/ P) S# n- u9 T! C {5 s% u- n& H3 Q- D/ v8 ~5 r
.active_low = 0,
# s% W) M) N F' ?1 p4 P; J1 I .gpio = DA850_USER_LED0,
( T2 A/ `% I4 q; y .name = "user_led0",
X3 k( D4 ]' N3 G .default_trigger = "default-on",
, S4 p, O, ]% s7 q1 `# f4 o },+ K+ ~; j- y. ], p4 c
{ H& C6 d' x) u8 e4 E
.active_low = 0,2 s# B' K! Z, ^! n3 V4 t" a# \8 R) Y
.gpio = DA850_USER_LED1,) e5 A7 i' D( P2 O9 V
.name = "user_led1",( S: [) T* h9 j f% `' ~* c& c
.default_trigger = "default-on",
: B) g' K6 q, Y3 k },6 R9 s' _0 m# C
{
. P2 E, H$ i2 o" g3 E. {' w2 ~ .active_low = 0,
, x( J H. c; F .gpio = DA850_USER_LED2,
5 K1 U% h3 @; R8 ~1 r$ _ .name = "user_led2",
' Y4 m$ h% | Q# G) G6 z4 x .default_trigger = "default-on",
8 b3 q( {4 }2 s0 L# h' U },: @% L5 k" P4 T, V
{& _7 |9 [% y, Z
.active_low = 0,
3 f2 |5 c8 X# d( o* l" Y. a, | .gpio = DA850_USER_LED3,
1 C! M% S2 `3 X7 J( S .name = "user_led3",4 l, C4 t) e' @5 _4 N0 u% a$ M5 b
.default_trigger = "default-on",4 i/ k- R1 p' W& T0 x
},
! |2 F7 l+ Y( |# M};
. F6 D) o# b; Y+ z
: c* W) e; h' b# X. s3 |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! Q! x, V+ w, d2 p
.leds = da850_evm_tl_leds,
' r) s2 H/ p. B8 Q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; B( }5 K" Y" X; C};
Y' j1 x! G/ d8 H- T# R! F& K# [1 ]1 y1 R2 s$ b2 n- F, _9 ^! H
static void led_dev_release(struct device *dev)& p) i: Y& `" L' J( \1 W, y
{
& f1 p( b4 H% ?# e! Q};2 `# s+ X0 I' u! S3 u( Z) B, H, F
4 N1 E0 A/ p4 @; N' T+ [
static struct platform_device da850_evm_tl_leds_device = {
3 i+ J+ Z: d- C1 o. c1 J {1 s .name = "leds-gpio",7 `" z: j9 n6 f" n* W1 e9 f* L
.id = 1,' N" }2 x9 T# R& _
.dev = {
}+ J9 c/ m" \$ K9 W8 J2 B+ X3 X .platform_data = &da850_evm_tl_leds_pdata, b6 S0 |3 L! {, a
.release = led_dev_release," Y* @5 V# r: G t$ k
}3 O6 Y) c6 T- `; k
};' E% C5 K! q7 E
, P' T! J" M/ R
static int __init led_platform_init(void)
' L; G `! s8 K{ N, k( N* R/ O( @- r' f: _
int ret;
1 n% F# ]3 O; y0 H- \9 C+ S% h#if 0
) q2 J0 L3 t# x1 W+ l6 a2 S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
X Z: K/ t% e9 a9 Q& Y if (ret)( V/ f8 b& a( R8 i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 z) h0 P8 i7 w; g4 q7 S+ h% U "%d\n", ret);. L: V2 B4 A/ X. f. u) o: ?" n
#endif
7 B W1 o+ ] X! y) ~ ret = platform_device_register(&da850_evm_tl_leds_device);
/ J8 y* Y- N% q if (ret); }* Z' ~- ~& {6 x" W5 Z6 m
pr_warning("Could not register som GPIO expander LEDS");
/ e$ D o! L$ W" P else. M9 I# i2 _' }- {: U" A
printk(KERN_INFO "LED register sucessful!\n");
O6 |( z7 n1 ` U5 Y! F2 B2 Z5 L4 H8 X+ D/ o) n
return ret;+ k1 i; z5 B- }
}+ a5 P3 n& i7 f! Z( o6 d+ Y
' F/ D" ~7 b& \4 R' V" [static void __exit led_platform_exit(void)
% G6 P F, u8 J8 _( b{
, C/ A# y" r* O# s6 D/ y- W7 ^ platform_device_unregister(&da850_evm_tl_leds_device);
. [) R+ b- s1 p- ]" F
9 i" R. E/ }! W; i5 |6 ]( v# A printk(KERN_INFO "LED unregister!\n");, V6 X' Z7 ~2 H1 b0 g" F
}
# y) ] V- f9 Y# [7 ^& W" s5 d' h4 y. ]6 X3 V' M; n; b
module_init(led_platform_init);
3 \ L3 E6 E k. {module_exit(led_platform_exit);
' n( I2 z+ \0 x) _2 Q: L0 H& }0 v) O
MODULE_DESCRIPTION("Led platform driver");
, Y. e( _7 ~ m k+ q3 Q8 o! aMODULE_AUTHOR("Tronlong");: _8 O2 A7 i- Q! J& \
MODULE_LICENSE("GPL");
4 x' f6 T7 ^' e# |2 E7 w( y4 I3 J. Y. g
|
|