|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 E/ F q4 \0 l#include <linux/init.h>1 ^! A/ S# A% ]
#include <linux/module.h>$ A( P9 f; _( C/ C% P8 \ P* r
#include <linux/kernel.h>! b, r$ R; F* O: j! n4 ~( A! ]3 V
#include <linux/types.h> P" d3 J5 v2 ], `2 m% g
#include <linux/gpio.h>
- g- d: K/ E ~#include <linux/leds.h>7 D5 k. e; l# P4 s9 w, W
#include <linux/platform_device.h>
1 A6 v) _+ v/ @ S2 @3 `/ Z3 }
% Y0 r5 \- Q* U% T$ c$ p% ]4 R#include <asm/mach-types.h>
4 x. U/ N) u5 _ p ~#include <asm/mach/arch.h>' E# e7 W: C% n. Y4 g- H0 m
#include <mach/da8xx.h>7 L( w* C J# M* _. E$ e* D
#include <mach/mux.h>
# |8 \% s& `8 ?( R2 i. Q1 A' z
7 I/ P+ G* Y! w1 `2 g$ n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' V. s; M1 T, I- g- g0 z/ m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* `$ j6 B9 r* G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 }; g# L6 Y* f; w+ f5 h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 v8 N! t f7 r$ e9 y
; g1 B; R' k6 n/ b9 a9 `, d7 N/* assign the tl som board LED-GPIOs*/% u- I: |4 ~; i0 T6 N8 F5 y) M/ s" r7 d
static const short da850_evm_tl_user_led_pins[] = {' s2 E) Y" V# I: k, T5 w
/* These pins are definition at <mach/mux.h> file */1 o5 a! T% d1 u7 N1 X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, n' o2 r6 I5 E7 ^& H -1
# l; v/ r O! g2 b. v' S" d1 c/ e};
4 t, A0 w* _( c4 L% ~! Y, V* j9 r9 x: y2 G
static struct gpio_led da850_evm_tl_leds[] = {+ @( U; w4 `! `1 g/ h% f" I& V+ a
{5 g0 v* C$ b! i+ J8 P+ t2 O
.active_low = 0,* s0 Y Y7 {! e) M" l, [
.gpio = DA850_USER_LED0,3 k- \, q0 j7 D9 x7 @/ g
.name = "user_led0",
6 p; y2 i O( ~3 J9 c$ L .default_trigger = "default-on",! O3 _& r+ G0 I; ?
},. q1 q* C2 U1 ]0 f
{1 F8 v" r1 o! g7 q6 x
.active_low = 0,' \/ ?9 m3 }, H: V5 ~1 Y4 E
.gpio = DA850_USER_LED1,4 f! v7 h# C3 V+ u; `) q
.name = "user_led1",
! D6 ]* l( x( |2 | .default_trigger = "default-on",
+ W v; T+ m4 ~5 b/ X3 L& { },
) L. q5 I" \; f {
) R$ e' Y' ^0 y1 k9 W .active_low = 0,
* a5 F8 H- I [ .gpio = DA850_USER_LED2,; Q6 V. a- o1 W
.name = "user_led2",' s2 f# V$ s8 f. q
.default_trigger = "default-on",
, T6 p4 s, J2 ]/ x$ a, ], ~ },) X0 \- h/ {9 S8 K+ O
{9 n) j7 j) @4 r; s5 l& x$ y
.active_low = 0,: s- w. S" w+ L. s3 b3 \# Y. C
.gpio = DA850_USER_LED3,
! M( [% u1 O. y' f .name = "user_led3",8 I" L) W3 ^- w! F( I+ }* x
.default_trigger = "default-on",
l6 }0 i5 g! z& ^ }, z" `6 h; A* K9 Y, a# O
};6 n4 \- m% ]# k6 o2 H2 O
/ e: a) s1 F* |# ]: Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ }0 P6 A% I- s8 U+ q' u1 R; T .leds = da850_evm_tl_leds,
[& B3 T2 z2 A p, p( r0 q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: }( G9 {) c( |3 x! \0 \% ~6 P
};- [7 c e3 C+ ^7 P6 U
" a7 p0 B' W- t$ n! i/ k% N2 u
static void led_dev_release(struct device *dev)
0 o/ k- I* `* [0 A. p: w{
! {0 Z$ Q; K1 @, k8 N( n! C};
% M7 @$ M' e- k6 T( ]: w2 l, A, I6 M8 V7 o* U6 Z
static struct platform_device da850_evm_tl_leds_device = { N/ F3 Q; B7 `! m/ C) ~
.name = "leds-gpio",
3 c9 N0 o ?- P, H4 Z* a .id = 1,3 h( N. Q: N4 p, W6 j
.dev = {3 v# f4 y% x5 L2 g+ s# x6 @
.platform_data = &da850_evm_tl_leds_pdata,. O s. E X2 a5 m
.release = led_dev_release,
1 L* e1 {1 N% c4 j }
8 A5 m8 h) N/ M};; a4 S1 i8 ^) `
; x, p3 B5 D* I% H" V. Wstatic int __init led_platform_init(void)4 B, {/ ^ }9 h! u
{. I: z- K4 S* I! v
int ret;5 W. ]7 L" Z* V+ x8 l
#if 0 l. \" m- [' `9 u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" E' l D: s/ N* q+ h( f' K' H$ B
if (ret)! M7 e0 G4 F/ Q5 T4 X# O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 O8 Y3 L4 m! T T: N "%d\n", ret);: B8 r: a' {. T: S. U8 X
#endif0 X Z8 `7 O: _9 Z3 a# L
ret = platform_device_register(&da850_evm_tl_leds_device);
$ u; H/ j5 m8 S1 O, X if (ret)% H- x" b- u q4 O9 ?; ?8 v
pr_warning("Could not register som GPIO expander LEDS");
8 B9 T2 W) N* L( ^$ c7 q else9 J1 e$ {+ F: p* S8 a) [1 U
printk(KERN_INFO "LED register sucessful!\n");: v+ P& g2 @: z0 S7 _& k1 I! L
3 @$ g1 q5 h" s' b$ Q" R/ _ return ret;3 k# V% _6 ^& M) [) p) r: Z, b
}
?7 |0 ]; f$ w2 w: u- M( A1 a! y. K+ Z) Q
static void __exit led_platform_exit(void)
: e! w+ a: q6 m9 K! ^2 j: m{
/ h) ?% x! w" [/ x' a1 }: Y platform_device_unregister(&da850_evm_tl_leds_device);
Y8 r" B2 w$ U. I( U8 R! ?1 S
; s2 @4 @6 U6 B7 {& z8 f" B( t printk(KERN_INFO "LED unregister!\n");/ K' v7 ]" j. w0 B9 t. b
}+ T; v7 k# r6 i* `' D, w
! j% H) H! R$ j( _0 h- x' G$ c8 P3 U
module_init(led_platform_init);
+ D4 I( p: A9 Y+ D5 ?module_exit(led_platform_exit);
) v/ p8 b+ [, |$ m/ B e! h
N! l9 a# d8 k% M: pMODULE_DESCRIPTION("Led platform driver");5 I1 o( _/ E2 ] g
MODULE_AUTHOR("Tronlong");0 _* x" u+ X: ? m1 f+ W
MODULE_LICENSE("GPL");' |3 r4 z( B! ]3 S2 r% m
* V7 R& n; n7 M |
|