|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) F% u/ S" T6 T; e' F! k, q
#include <linux/init.h>
/ G- J0 _4 D& d% t#include <linux/module.h>! S0 m' K4 G! m- Q7 S/ i; s
#include <linux/kernel.h>
+ |; l3 d3 a" C# N#include <linux/types.h>
" K' W8 f) n+ F$ ^( I/ c! T& E2 R#include <linux/gpio.h>
4 n* \% a: z8 w; Z4 t#include <linux/leds.h>9 L8 W# e" f+ M9 o# B& {) u
#include <linux/platform_device.h>, ` U! o j$ D A
: @9 c. t" x& J2 ~- e#include <asm/mach-types.h>3 a, K+ s3 h$ j/ l- w$ l
#include <asm/mach/arch.h>1 n, ^- X! Y" U* ~/ a
#include <mach/da8xx.h># ]5 V3 U. f ]3 ?) M
#include <mach/mux.h>
% D& ^8 O1 m; m
9 N7 g5 A- w; o H8 T' D#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 z# u0 z& p8 M; S; a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% s* X8 G3 X8 |/ o. ?0 p#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 a& m9 {! `) G2 F% |2 @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( i' ?& ^ J. x. p! Y# C; O- Q: H+ _# X4 T3 _' W
/* assign the tl som board LED-GPIOs*/
* j0 P9 p' o4 P% ^) G) a+ Qstatic const short da850_evm_tl_user_led_pins[] = {- {9 [0 k( e, D" h. d
/* These pins are definition at <mach/mux.h> file */
1 R+ h5 ], j$ T5 ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) V# z( L8 K+ V/ D
-1
; p( T& P5 f: T; T- F1 J};; [! N3 C0 Q+ U/ |! F0 X4 Z! [( Y( M. y
) A8 L4 | r( ^9 j5 mstatic struct gpio_led da850_evm_tl_leds[] = {" L+ ~# Y( v& I9 m
{
. N- b1 c6 u& A: a) t .active_low = 0,- b$ B5 w3 @$ F# y+ ~
.gpio = DA850_USER_LED0,6 T! k5 H" x! P* j5 A7 H
.name = "user_led0",
# w. ?. j# U6 _5 Q- J5 n6 ]" k4 v; e .default_trigger = "default-on",2 \. a* `8 I& z C, @/ Z6 q# d8 X7 r
},
1 D4 s) d+ W: V8 q: f% u, Q( G( L {
8 `$ R/ Z7 F# N' g" e+ [ .active_low = 0,
+ H" }+ k6 f7 }8 q .gpio = DA850_USER_LED1,! d& X4 ^1 t; _7 D
.name = "user_led1",
; f: `5 ?1 s. O .default_trigger = "default-on",
+ w, _- v! Z! p6 w8 \ },
, a. e7 W1 T u4 [; y% g Y {( J% j7 q2 N, V
.active_low = 0,
. v! R8 d+ r& ]: o G, F/ W9 T .gpio = DA850_USER_LED2, _0 c. D d( m& `6 U7 ]+ i
.name = "user_led2",
, m8 }' ]1 W4 u) k O, p .default_trigger = "default-on",
Q2 X3 r0 k4 b7 A9 r5 B },
9 q3 {3 |' E6 b t8 u* w3 E {
) K: G% a S, A) ^& M. C .active_low = 0,0 R# w$ _, A! M1 h: y, }
.gpio = DA850_USER_LED3,
# s( b0 i9 m" ^6 N# N .name = "user_led3",' |! d' M& |) B0 [1 ?' H) ^6 g N
.default_trigger = "default-on",( J7 D, M, e1 ?4 `
},2 U+ k& Z4 f% \7 `% I
};
0 v2 h2 @/ ~1 x1 b5 f( R4 r
# r) Q& R4 n9 w/ g9 W9 Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ B. Z/ ~; l" c9 [, b5 K" Z .leds = da850_evm_tl_leds,
2 x# d6 Y9 w {; i4 g+ Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 |3 P; A b5 ~( G9 y/ X
};0 K+ K8 V) C w% O: Z: a
- d" S& W; u" D! m! ?$ t A
static void led_dev_release(struct device *dev)
" O2 d8 O, O! e; q" ^% x{5 k9 d8 A C# s
};
; e9 r9 a9 L% p/ Z7 q8 U0 x p$ H5 G% \) t
static struct platform_device da850_evm_tl_leds_device = {
) ?9 Q. Y; [8 O, ]9 r( ] .name = "leds-gpio",
/ y' D7 c0 [ Y8 G: Y4 |$ x6 n .id = 1,) o/ j; d0 D* X# b% r& O$ l7 y
.dev = {
9 X0 `* d2 ]3 U: @( @ .platform_data = &da850_evm_tl_leds_pdata,
2 Y, q+ k( S( C4 r .release = led_dev_release," [6 w8 c: V. K
}9 N3 H, H m3 v6 ~
};
2 t. Y5 T. L# x4 x" M: K9 L' y# U- Y4 V$ V1 x' h
static int __init led_platform_init(void)" w' n3 Z1 V: r
{, g4 m1 s+ ?( C' K% ~" b! V
int ret;. _! E3 @# S0 j4 i" M; S
#if 0
! y* t( E- ^6 W2 M; R! \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% I; u5 P J! m, g
if (ret)
; Y; g; s5 @+ H8 C7 N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ s# a8 ?0 l4 q; _5 d "%d\n", ret);. F/ Q; }/ Y0 F2 q
#endif
* S* o+ o$ c$ w" ] ret = platform_device_register(&da850_evm_tl_leds_device);- m( ^6 z+ o- F3 u: P! \
if (ret)* q7 A/ ~) Z4 g6 B7 x! D( x
pr_warning("Could not register som GPIO expander LEDS");4 G6 C+ o6 P! M! c' i4 K9 P; R
else7 s$ T6 D5 U& B* `$ ^4 j5 A
printk(KERN_INFO "LED register sucessful!\n");
7 @% z5 I. E, ^3 U" e* N) }9 Z% y% Q
return ret;# T% I I1 u$ I: x+ R$ ]" X
}9 U: y, R' F9 n( A) O% y8 v* ]
; m2 U! Q/ W1 ^# s
static void __exit led_platform_exit(void)
& H- k; w" J% _5 z{& c' {) \; ~" F. A) G4 ^" g* z
platform_device_unregister(&da850_evm_tl_leds_device);
& T* I9 B, @9 J# {3 _. M" v1 u# D5 z9 ]1 C* B! f
printk(KERN_INFO "LED unregister!\n");
8 u. W" |8 J- {* C3 T( S}7 o. N6 P! u+ K: j$ p: l
( {- Z4 N; j7 q0 q
module_init(led_platform_init);% d( z" a$ d- D' @4 J5 @
module_exit(led_platform_exit);- @; u: h/ @% w; H* M5 a
+ ^; w( C, a2 i1 E6 F/ n: VMODULE_DESCRIPTION("Led platform driver");; W M& X4 @+ n9 S1 E- S
MODULE_AUTHOR("Tronlong");4 d8 [. q5 {- I1 \( P1 W9 {6 b' b
MODULE_LICENSE("GPL");* g6 y! c2 w1 I( R
' |2 w! D5 B, \& }) C |
|