|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# e% `6 E a" D
#include <linux/init.h>7 H6 ^: i+ K8 O) V
#include <linux/module.h>( e/ t* o( U0 `0 r
#include <linux/kernel.h>
# L+ G' N, T9 T$ n' {5 `2 B- d#include <linux/types.h> j& A( w {$ Z( j" b
#include <linux/gpio.h>/ ?# N3 q* o" H& n" C
#include <linux/leds.h>
# A) L0 [: z2 R$ r8 s$ o#include <linux/platform_device.h>
7 V. ]# g- Z( a4 T8 {4 A
7 g/ L' d# o# H8 v( O#include <asm/mach-types.h>
) R2 C& Z2 o3 A#include <asm/mach/arch.h>
! T& W, \- O: Q/ t- T7 I#include <mach/da8xx.h>" r C' o9 F! O; i7 O8 t
#include <mach/mux.h>2 R/ F0 F/ h# E! w$ A. G
/ E( Y* Z4 d, p. J c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( @6 r$ j% G- q/ n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- V+ u3 R+ r) x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# q- u' [* Y1 |8 T& }1 }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); n! U% D) C2 v- n
, E! \/ B p9 j- z5 n( J% C
/* assign the tl som board LED-GPIOs*/
/ [$ w& y0 |8 Xstatic const short da850_evm_tl_user_led_pins[] = {
# K. @* \) N! k /* These pins are definition at <mach/mux.h> file */7 h% r' y+ c e" U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ [. h, _3 t% z. Y) O; } -1
; E9 n, z1 I, Q' ^' a# m};& Q9 [0 C! c+ i) \! t
6 T! B7 i+ o. P3 d3 ]4 gstatic struct gpio_led da850_evm_tl_leds[] = {
( ?# f( }, n! t {
# F6 L1 J; c9 W9 l/ K6 j h0 n4 o .active_low = 0,' @/ r+ t6 ^+ U5 s& s9 D
.gpio = DA850_USER_LED0,! q# n! H4 n1 Q7 C3 ~' s
.name = "user_led0",3 f, E% g8 W" L; p4 y
.default_trigger = "default-on",5 ]- x O! @$ U% h
},
7 W ^2 Q8 l7 f4 L6 \% b {3 ^7 K, Q- P$ d7 @! }5 J
.active_low = 0,! A& T# F. |6 ~) \0 U% E6 P0 s
.gpio = DA850_USER_LED1,
3 M! v* a; ^$ e( S+ K+ A .name = "user_led1",
. V( L3 q/ z) n& `7 j: ^) | .default_trigger = "default-on",
, K6 M4 C2 M& {% g, X. i+ F },, ^( r, w- v' P0 j3 v
{4 C9 L( j) G8 U: n q( a9 f
.active_low = 0,9 y% y7 @# K7 A
.gpio = DA850_USER_LED2,7 C* D1 d- g$ e3 J1 {9 e5 j: q
.name = "user_led2",
4 M, H; w) ~1 N2 l5 m7 x! F .default_trigger = "default-on",4 ]/ M0 |. ?! E# B2 Q
},
% s2 a. i0 z1 R/ z {- u/ K7 u |1 t( _( ~
.active_low = 0,
$ t$ _: ~0 t8 x .gpio = DA850_USER_LED3,
; I- `7 M% t& B: S5 Z+ j .name = "user_led3",5 H% @% t( [0 B- j6 @9 H& l
.default_trigger = "default-on",
/ I; _% d2 F' Z5 w. d8 y1 o0 Y },8 p( M" e$ P& W& c, D" G! m' L- t7 E
};( u; k) |, ?+ N [
9 t/ C+ @- v: r. |* Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! t0 A7 D6 H$ O
.leds = da850_evm_tl_leds," d+ f7 l5 c2 K5 Q) u+ J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 x! I, b( R- k& a7 u3 n8 ~" {
};
& b6 X/ Z6 k7 B7 W+ e0 a5 p7 T: y& C1 T6 C$ E5 o0 l
static void led_dev_release(struct device *dev); [1 V6 x J6 E! Z8 K& Q
{
/ e5 M1 C8 S/ Z3 A3 w+ e};
2 d3 j- }9 R* a$ K& O" C4 X3 T9 K3 r4 h' Q& q9 z
static struct platform_device da850_evm_tl_leds_device = {0 m' z1 B3 d: }) @' Z
.name = "leds-gpio",+ n: k) `$ ?4 k
.id = 1,
! L: k9 A5 h* t8 { .dev = {
" }* Q: p! X4 w; {, o( e% P+ X% `/ m .platform_data = &da850_evm_tl_leds_pdata,+ [/ t* _8 k' {! C( w; _; B; x) t
.release = led_dev_release,
+ X4 g. b$ j d. w8 s6 ^' |$ m }: G5 y3 D) l8 |, T0 E+ K: ~
};
7 X- G* ?" m8 P
6 W! M+ j; r8 ^, {* i& l5 q, pstatic int __init led_platform_init(void)
8 P, I8 `' ]& z1 p+ _3 W2 b0 U9 E{, t6 q$ d: @$ U! n: y
int ret;1 u' P' T4 Y0 ~% Q
#if 0 X5 c F ~* C7 Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ d8 |- U4 Y% V9 j& M
if (ret)2 Q8 k7 n: ?1 Y: b) ]% w6 X
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 q$ s H, p9 I: h7 }% E$ b9 n& I+ [
"%d\n", ret);; ~8 A6 ^; Z0 H0 W
#endif- K& B- U1 [- @$ r5 _
ret = platform_device_register(&da850_evm_tl_leds_device);
8 J9 D2 Z9 J. O9 M6 o if (ret); h& I* }" M3 g5 Q) F3 k) c$ N
pr_warning("Could not register som GPIO expander LEDS");
" u0 X1 Y3 E' r" d/ G# v$ L1 O else
1 {; S2 R k" E" r9 w printk(KERN_INFO "LED register sucessful!\n");9 s+ o% r8 i/ u- N
7 r, R, c+ D; g# ?
return ret;$ Q1 e" K6 e3 k
}# {, J) V) j, [6 V& V7 A) z
5 L/ `% e: m$ J( Q9 H+ Jstatic void __exit led_platform_exit(void)6 F2 J# q& q/ D: d- s' ?8 z' x b
{" c. r B) F! q
platform_device_unregister(&da850_evm_tl_leds_device);
' f, |3 A0 O- `& c, z. E
4 _, z- h4 c( Q/ { printk(KERN_INFO "LED unregister!\n");
7 H$ T6 M3 ]: {9 l}* g) V X$ v/ q! E3 w, Q
4 j$ }& b5 H Z( @module_init(led_platform_init);
! w# k6 d E# dmodule_exit(led_platform_exit);2 Q# n" z5 S6 A& l
$ k k& V/ F" O0 C0 l$ `! OMODULE_DESCRIPTION("Led platform driver");
( s4 J% ~% F0 q! H6 O9 a4 P9 TMODULE_AUTHOR("Tronlong");
4 }1 E( |/ \& I, G3 T4 `$ q3 [! eMODULE_LICENSE("GPL");4 a8 i: Y' a+ q: Q
2 r( e5 i# }4 r. E6 i" E- ]
|
|