|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, M+ t# l! | p1 x! l; d#include <linux/init.h>) I. e3 `7 f4 L3 m& }( n
#include <linux/module.h>" j. f. M, _/ J. a- {- R6 P
#include <linux/kernel.h>
4 J2 e* q, ~5 o5 |1 r#include <linux/types.h>
' Y- v, P6 ^- W#include <linux/gpio.h>
6 n1 h H) Y# X' t) I) _" U#include <linux/leds.h>3 [4 G1 `7 n9 V' E% {/ B
#include <linux/platform_device.h>
m3 M6 g* `4 t9 O |( m
; d3 s4 \7 I7 Z/ j' D* @#include <asm/mach-types.h>/ V3 T/ W" y( j' F. v* q( _, z
#include <asm/mach/arch.h>' F1 [: x' D) C9 [" P# V) D5 T% z, i3 Y
#include <mach/da8xx.h> L" I5 z! E5 H4 j
#include <mach/mux.h>: V: M. @; ~$ [( L
$ V9 G6 S9 J5 i3 E. [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' u6 G% t$ j. i2 ?4 P2 ~, H) E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 w% ^6 q6 {- C/ i+ E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 |4 n6 [- d! `+ v. O) ~/ C/ W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 i( A& P/ D5 ^: h; X ]& c; K* Q/ b% C4 h
/* assign the tl som board LED-GPIOs*/1 }/ v' V: O# _1 @( y# D5 G" ?& l4 X" I
static const short da850_evm_tl_user_led_pins[] = {7 J2 J' ]4 H+ w" x
/* These pins are definition at <mach/mux.h> file */
. p6 ?3 c- y0 | ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# L1 e; t: W4 E% ]! Q- x -10 A2 G6 E0 I2 u4 X0 L2 T
};
* [( o- p2 o9 t9 B9 L2 a
d8 T& N; r$ N) u0 N' c2 u. R1 `static struct gpio_led da850_evm_tl_leds[] = {
/ p% m! L% O0 d {
u4 N0 v$ j5 ]' H, {; N( Z) b .active_low = 0,3 c/ H' b% Q9 ~- ^3 O/ P
.gpio = DA850_USER_LED0,
$ a- R. G$ s/ I# n' _# K .name = "user_led0",
" N3 C) g7 E' M3 m) a .default_trigger = "default-on",% U |- y9 P4 u
},
) @+ l) F0 X' a$ k8 J; [- z" R8 w {
2 G0 [8 ~5 ~9 v8 b+ L .active_low = 0,% W; ?$ A+ y5 b+ |+ @. G, T
.gpio = DA850_USER_LED1,
$ k, U" \7 Z; L( T& J* q; ^ .name = "user_led1",+ n F5 Z2 a! C* L( W
.default_trigger = "default-on", q$ o; [4 F' Y+ ? i
},$ U; ^% `& W Z
{
, e. ^0 q9 _- a' b% g+ I5 U .active_low = 0,
3 N. {$ H. l0 N2 d& s' S .gpio = DA850_USER_LED2,, T& _# ~; T2 c- M7 H1 t
.name = "user_led2",
1 {3 q% d" C- v {5 C) A% i .default_trigger = "default-on",
+ j3 X% J' J0 M4 R) |( a# c },
' W+ ~$ G" z7 z [ {4 {. @, B. t; K+ J* H5 z
.active_low = 0,
" b) l& V9 r8 m. N( c& \ .gpio = DA850_USER_LED3,
7 E1 [8 U. k+ h% V* ] .name = "user_led3",9 K6 w; a1 J7 g# X
.default_trigger = "default-on",- j/ c. O- O, i7 Z( y p
},
+ t8 H6 b! N( j. O+ j- O}; d+ A3 k1 e: t& c
/ w f' R- W8 e Y1 L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 |1 e/ I9 B7 G# a$ \+ F: {
.leds = da850_evm_tl_leds,$ ~. p$ ?4 h" i+ m! v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ b( Y+ O6 K" k9 M/ }7 W+ C: W
};- I# Z. y. o. [9 w
( A1 q+ r; ~: {# D9 X5 x$ |7 G
static void led_dev_release(struct device *dev)) ~. `5 s) J7 i0 r" \# }: {1 {
{
7 @5 t8 ^, a% {};# n/ Z% \) A; }1 s% Y
' x6 I. f* C. l3 F+ U; T; q `! h7 f, fstatic struct platform_device da850_evm_tl_leds_device = {
% a6 h' T/ E6 U. A& F+ |' F, t: D .name = "leds-gpio",
% C& W0 M8 g0 N3 r, m$ r .id = 1,, U% G5 _# p* O
.dev = {* s- t6 p$ B, C9 s
.platform_data = &da850_evm_tl_leds_pdata,
% n# q' J* ]) Q& b- P7 R .release = led_dev_release,- m4 U' ^* R9 j
}: w5 e1 B0 m- l% e
};- [! X) u/ n8 {4 m' E$ t. m
! d" A9 \) t2 F$ p, g2 k4 i6 Q5 @static int __init led_platform_init(void)
, X. k7 Q* W% s9 Y5 _* f* T{. z$ s& ]( U# y0 v2 o& C( S( r! K1 r
int ret;
4 s8 ?2 I. J3 ?) H4 D#if 0% z: B( L" e; V/ [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! S+ M2 q% k( d7 r# f1 F
if (ret)
! Z% o9 d8 j6 V y, U+ {. I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* D* b1 i; ^. G$ S" [+ A "%d\n", ret);
) {( y$ ^1 v) T" r9 r( w! a#endif
- N0 H% s' Z0 f E6 ]7 z9 | ret = platform_device_register(&da850_evm_tl_leds_device);
- \: Z$ Y( o5 D& r! w! v if (ret)2 ~; d0 f' a/ N8 n& I
pr_warning("Could not register som GPIO expander LEDS");
4 ~" }/ B$ y# T6 G) L7 N0 `: O$ | else
, j+ d: e& ^$ q! P w# ]7 \6 p printk(KERN_INFO "LED register sucessful!\n");
8 ~+ x( \0 ]/ l$ v: i& Z
# O( b- G2 m$ b* K! E6 E5 t return ret;) ?/ t6 S5 \ j& i
}
. x, r9 N! E' Z, a5 S5 Q; b( E
0 Y% P' p& N8 C% e y0 ^; u, y0 g8 Mstatic void __exit led_platform_exit(void) ^- V/ Q+ p8 G* s5 J4 x
{% H7 Y/ H0 q9 B, A/ y
platform_device_unregister(&da850_evm_tl_leds_device);* F3 P. [( f3 J: F0 s- Q2 G5 d& ~
' b2 p4 n& U3 q, N5 |' \
printk(KERN_INFO "LED unregister!\n"); x: V, s4 f7 _$ D$ }
}6 u5 w) }( N: T' ~2 r6 R* e
( w/ n% h# L6 F& {* s5 b+ Y
module_init(led_platform_init);7 v' B& q! t/ V4 r
module_exit(led_platform_exit);
" a/ t: t5 R( e7 ?9 E4 ~; k2 Q
MODULE_DESCRIPTION("Led platform driver");# }. c. g- z, Y i {
MODULE_AUTHOR("Tronlong");
+ e; Z# j; S9 U7 d3 g, iMODULE_LICENSE("GPL");
3 H U% _/ h2 E# r1 C& V; {
' S; G4 j$ `6 ~0 | |
|