|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! w' X4 Z) n& X/ J2 v$ ?4 @: E#include <linux/init.h>. l3 K0 y8 \7 F, d% E. @6 p0 c
#include <linux/module.h>
: j( t% C( ?1 V2 q6 {/ Q#include <linux/kernel.h>
% v& w6 {+ {+ S! }#include <linux/types.h>8 F9 C# |3 {7 Z! D# K
#include <linux/gpio.h>/ `7 F0 s( Y! [& }& O& [' Z/ I0 k
#include <linux/leds.h>
0 ]; Q5 R0 h0 l- z#include <linux/platform_device.h>8 {$ {' _/ m! ^9 U8 L0 Y
$ ], a* |2 @! A+ ]#include <asm/mach-types.h>' W, @$ v7 G$ t
#include <asm/mach/arch.h>5 F* U% j# D4 W. b
#include <mach/da8xx.h>) ~+ O i) j1 |
#include <mach/mux.h>1 P7 m, b" |& k- G
. g: E6 u- v V g" Z" O7 o: T$ W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); M5 p; [4 q E% q% O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 Y0 y$ k( k7 Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 R1 v& ?+ Y+ ?4 V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 d# a* l4 h' p5 I+ R0 ?
+ F' \; V5 {1 `9 j/* assign the tl som board LED-GPIOs*/: s2 E6 @* _0 h, U9 V
static const short da850_evm_tl_user_led_pins[] = {
/ @$ Z+ F/ w0 W8 R3 U2 F8 e /* These pins are definition at <mach/mux.h> file */
" U R/ k; X; w% _: l6 Y7 V) u& ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 H; T* n' A `2 g1 ]
-1 h* E. `' |7 R, g- `* J
};- u6 _( R" B* E
2 Y8 X) F: R( Hstatic struct gpio_led da850_evm_tl_leds[] = {% Y/ G* p( h" R
{3 _$ L( Y) _8 q; A. ?( r8 V+ ^) Q! F
.active_low = 0,2 B: c: Z( X6 N: d4 Y. _% |+ F
.gpio = DA850_USER_LED0,
% S5 O# c6 k4 r7 G8 R( \, j .name = "user_led0",$ `6 I. e& {, ], C3 S
.default_trigger = "default-on",
; e: @8 R& [: k; X" O4 E },
/ ]6 P' O9 K1 _& D! n) S4 x {& z. F6 D5 o& c* P# O0 B6 s6 `
.active_low = 0,0 E/ I/ V# H5 X
.gpio = DA850_USER_LED1,
: _+ l, t- w6 |( s6 ^9 T! F .name = "user_led1",; y8 I) D8 S3 {: {" ]
.default_trigger = "default-on",
4 e2 c( @8 h. A* q },, h0 c2 r' Q$ p* _
{, |- b2 ~! O9 X) {
.active_low = 0,
5 b( L# j5 W# a3 b, M/ C .gpio = DA850_USER_LED2,
. ^- ?* T G" X9 @ .name = "user_led2",
s8 q' [% M8 F- t: T .default_trigger = "default-on",
5 f$ N" N; O- d2 l, U; r },! j) M0 F: @0 X$ J- R
{
+ O# X/ | V; Y1 z8 f .active_low = 0,- X0 X1 Z% W4 f9 ?1 W+ M$ V2 S
.gpio = DA850_USER_LED3,+ z! r" J) A/ Y' t3 `4 U* C
.name = "user_led3",
7 V( b) g* X7 m; b5 ? .default_trigger = "default-on",
+ r( P" Y4 L6 B+ Z, x }," N9 H% t+ Z# v2 W
};
/ p6 W# U d: A2 }" W2 `# O$ g" v3 F; }3 r/ E$ J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- ~6 ^, S, l( C4 o( K0 B
.leds = da850_evm_tl_leds,
, W _! e9 N, s& @" U0 ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 X0 J; p% p/ ~; }};
- p' {, E6 x6 N9 m V8 I" Q4 m
" v% `% e& r3 f, y4 p' ^static void led_dev_release(struct device *dev)/ h1 ]6 d( V2 l
{0 t3 X% D& H$ G% @3 O, L/ W
};6 I' l# R6 q( O: M! s! b: L
w* Z: B3 K% P4 ~$ J
static struct platform_device da850_evm_tl_leds_device = {- A, P/ t Y4 Z5 p) p Q$ ~/ j# s
.name = "leds-gpio",
/ T* ]5 x1 E1 w+ i .id = 1,0 X) A5 P3 m# }+ O
.dev = {! f0 u! Q: q/ p
.platform_data = &da850_evm_tl_leds_pdata,1 x- x% W0 D4 t4 l. B8 l3 w
.release = led_dev_release,3 t1 w/ G! J K B: W: W2 L
}8 o. E E3 O7 L& ^
};- f. C5 P3 {9 S& b; ?
. ?% S1 }1 c. _0 D2 g+ v: f; d* wstatic int __init led_platform_init(void)" I1 R4 k c% V
{$ b. x N7 L! U) G- P; A9 J8 ~3 x$ C! \
int ret;
. c: l) `9 ?' X4 @#if 04 A! Q' Z) [( j: h6 ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
@. M7 n y [2 Y* t2 R, ^ if (ret)
/ s4 w( |! x# @, R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 r0 \- p3 u z
"%d\n", ret);
) y) M5 y( Q- w% z5 ^, g( e#endif1 v Q$ u2 [2 w3 N
ret = platform_device_register(&da850_evm_tl_leds_device);! u3 x" W0 \$ q5 ?5 m1 R
if (ret) Z0 B$ t) C4 t; t7 y$ |7 k
pr_warning("Could not register som GPIO expander LEDS");
" v( x# w* B3 J5 t4 T Z! p else- p" t8 ^+ N* C+ [
printk(KERN_INFO "LED register sucessful!\n");& K7 f8 L; h8 i' M
^. @# k9 Y) D3 z6 Q
return ret;
& R3 K5 i3 q. I& X2 D8 Q* q}
! c* x: S; t7 [+ M
( D( c' W- K4 j! T& p8 Z' d) xstatic void __exit led_platform_exit(void)
) O: R- ?- ~ Z" m3 `' Z; v. A{- P7 e+ w+ I/ Z# |' S! L4 h+ C
platform_device_unregister(&da850_evm_tl_leds_device);
* ~7 O6 C3 w! C8 G
3 b" M8 K! a# F printk(KERN_INFO "LED unregister!\n");2 ^( Y: I" Z N& J: z! a, P7 }
}' o5 I" _) G' j6 M( u/ L
# ~% t0 f- U: H% v% r1 e& U2 S
module_init(led_platform_init);
1 j* i* _ t/ X9 T- Fmodule_exit(led_platform_exit);9 Z/ S/ r9 p/ |" \5 y
+ [ u' A2 n6 M* H1 X( c
MODULE_DESCRIPTION("Led platform driver");! P5 ~8 j+ ^& v8 Q2 }
MODULE_AUTHOR("Tronlong");
4 [2 T8 W0 @0 r8 X' F( XMODULE_LICENSE("GPL");9 W( U' T8 }( }( x& n9 H: L
+ T% o" R% C5 s* j$ M3 D& e
|
|