|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; v) _5 n; x, T4 {
#include <linux/init.h>! @3 n8 l9 x2 s
#include <linux/module.h>
7 E) B' k: V! D% W* ^$ O# b#include <linux/kernel.h>
5 \7 g: e& E5 G#include <linux/types.h>; e2 |) E! I( h, j" K
#include <linux/gpio.h>
9 M" o, N# F* V P5 H# v* {#include <linux/leds.h>, P4 y/ K% Z4 M, Z* ?6 S2 ], {
#include <linux/platform_device.h>1 u$ L, x1 g& \1 }, a; u
* f Q3 F5 E1 G. s1 f#include <asm/mach-types.h>
9 D/ r% S4 q& C. a9 V#include <asm/mach/arch.h>6 |: R' F5 y4 T1 Y* d
#include <mach/da8xx.h>
6 j. D! |5 n+ d2 o" f#include <mach/mux.h>$ H5 F v- j/ B/ z! u! N4 o" H
. _9 d! m' Z' z$ P- D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! \! t$ o) {- |3 M5 N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 w4 i2 y5 I' _! X9 }3 x, |& w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 N% `, n* V+ F0 E3 N( T; h) }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: \/ o2 a% ^7 K. G- `8 B7 C, [7 y$ ^) k3 F" r
/* assign the tl som board LED-GPIOs*/8 ^! v1 ?) w* V& @+ l% C. O& \
static const short da850_evm_tl_user_led_pins[] = {, E; E# @4 G# e: y) ~4 w$ {- V7 J
/* These pins are definition at <mach/mux.h> file */
3 h6 D1 W0 i6 m5 Q& g3 d) [" N5 A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% l6 e) T4 g7 `% Y( K3 L
-14 N u1 L" y% u9 P$ P; w
};
# }% g( j$ w1 h2 E
7 f. z- v a2 a5 F1 \7 Y' S, estatic struct gpio_led da850_evm_tl_leds[] = {
5 c) g6 g& e+ m1 v8 @ {
" j, P% m9 ]( ?) e% i( m z .active_low = 0,0 u! L3 U' ?% m
.gpio = DA850_USER_LED0,; |' R8 r0 u0 j
.name = "user_led0",- K$ Z( m2 a0 [# R" c
.default_trigger = "default-on",- O" T7 A+ J& K7 y& M
}, h6 z" n D* M$ ^
{) B. C; W9 f, A$ N# v$ M, i) e
.active_low = 0,
# J( i1 G1 i# z* } .gpio = DA850_USER_LED1,( j1 B+ I! @ }
.name = "user_led1",' {) b7 ]* z, \+ ~1 f# A% n
.default_trigger = "default-on",7 I3 ~* k% H: E
},
5 Q7 ^* h' L& H) {. V! o {0 B6 I4 K- u( E% G
.active_low = 0,
# E* F% O7 a" U* L7 \+ N n7 G .gpio = DA850_USER_LED2,
1 Q! U, B! K0 U6 P .name = "user_led2",7 v5 I+ D0 C \9 H% D: k9 g. J: ^
.default_trigger = "default-on",
. K' x3 w% ~* k8 T& A4 ~1 ^0 `+ u4 l' } },5 S% L3 y3 U, @% ]* P) N. F
{
) N4 _% g, Q, p5 U q J0 l' ` .active_low = 0,9 Y4 v" U, C9 b" P) j) [' x% h
.gpio = DA850_USER_LED3,
s6 V9 l1 e4 z" \) W2 x U .name = "user_led3",
' p2 h+ K! P) `4 U$ w. | .default_trigger = "default-on",
1 a0 n; E h' d* g5 z },: Y( _% X: a. t2 z. L
};
+ c* T. w5 u2 O* s1 w
. Z s; }) Z8 o1 \6 istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% i2 c, ] B* G1 r3 K .leds = da850_evm_tl_leds,
# c6 _: K) R, X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 R8 w/ a$ z: j$ n
};6 y/ q2 S5 n! I$ E, s
! f3 r$ q3 D1 J# O
static void led_dev_release(struct device *dev)
2 `4 ^+ j: ?/ e7 z; ?3 W! Y{6 ]8 [7 l j& v {) A4 k
};
u$ b8 F$ A: q
5 L) d' t4 F, ^! J: ~static struct platform_device da850_evm_tl_leds_device = {
6 ]( |* c4 ?4 U, j" N/ w2 A .name = "leds-gpio",# @" I, i; _. o# D! \5 s
.id = 1,
7 i9 q8 V' X- B7 o .dev = {
+ a* @, ~& C! P) {9 _% H .platform_data = &da850_evm_tl_leds_pdata,4 ]- r. B) C- a- v/ A- z3 ^- Q# l
.release = led_dev_release,
; r7 w# r& T r9 C( v0 Z0 n }) V' X4 A6 s" G2 ?; l1 Z) u
}; L- s$ N; n; e
7 }( {4 x& p$ ?! n ]* Hstatic int __init led_platform_init(void)
" p- `$ y( ?9 f5 ^! d7 G& z{
9 Q: I4 }$ r+ A1 T8 a) A! b" U int ret;# I/ o2 u* m7 V/ j0 X5 d/ r
#if 0- i5 L0 [ X, E$ @! J( I# D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" i" a9 D8 L) Z" ^$ r2 e" I if (ret)
: ]/ \, m9 {( z2 |5 G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- i$ ?9 q- m2 C9 \0 i4 n "%d\n", ret);
5 K0 z: V* u/ {* o#endif
# ~, L9 `0 N4 U4 w7 ?( @& _8 i4 H6 G ret = platform_device_register(&da850_evm_tl_leds_device);' x9 G3 W8 r6 [
if (ret)' a$ _3 `# j( l
pr_warning("Could not register som GPIO expander LEDS");! { d& i; `3 y8 m- U( x
else
$ g6 C B4 i) L; c: T/ l/ u* R2 A, I printk(KERN_INFO "LED register sucessful!\n");/ ]& a4 G" k1 c' q7 s) c, n5 \
5 g* W) L R8 ?- u8 s- O" K
return ret;$ X5 C( l* Y9 R) {) I9 _
}) W2 y7 Z! D) P" t/ M: ^$ S u6 M
! t, a- Q5 u( n- M6 k
static void __exit led_platform_exit(void)2 Q! @( l: z$ i! l. x/ U; x) T
{
5 c. N9 V/ Q( G# @8 T1 `, r9 o platform_device_unregister(&da850_evm_tl_leds_device);
3 |' ~% | ?. X& c
! @3 _# p4 K' Y' |! ]1 |0 m printk(KERN_INFO "LED unregister!\n");
! u0 }+ r9 m# Y; ^ z. y}( I. g3 i5 s$ Q$ d6 A0 t& r6 M5 x
3 D! E: h8 ^' i' R+ R! x! s2 wmodule_init(led_platform_init);
7 u7 }6 P/ m" ?# t3 m, c$ G) x$ Umodule_exit(led_platform_exit);+ K T, L* W. H% _1 W
( |+ F1 j. ?$ b1 u$ M
MODULE_DESCRIPTION("Led platform driver");- D. f f( o2 u, k
MODULE_AUTHOR("Tronlong");! i! |- C5 {# k* L0 e% B% X
MODULE_LICENSE("GPL");
' O" `1 J2 _( {' q+ D: W0 K; L0 z0 D, [7 s- x
|
|