|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, J/ B. j5 ^8 x) d2 S8 q#include <linux/init.h>( I: E0 \/ Y5 e) T# k
#include <linux/module.h>
4 H/ R, f( X i$ v#include <linux/kernel.h>
: Q! n2 R" ^/ q( ?# u#include <linux/types.h>$ |1 @4 @! r h5 u) U
#include <linux/gpio.h>% R) P' D6 H4 l# S$ w' J5 D
#include <linux/leds.h>0 p4 |) h! N% T$ q
#include <linux/platform_device.h>& `9 T) c$ P8 O/ k, W6 B9 a) f0 Z# B: i
+ f6 Y0 z- |0 ?7 _; T ]#include <asm/mach-types.h>
/ m1 i. y* V& c/ I6 J4 |8 K#include <asm/mach/arch.h>
& K" C8 ]8 g" |; A( X% b#include <mach/da8xx.h>
* c8 @' u2 S* T6 [#include <mach/mux.h>
" M3 M( d0 S5 Q& M( d# U' k" i: ]5 ^: B0 G: Q" J* R; i
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' z! m$ j) ] ~9 b* @6 a7 W
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 J6 I/ ~) f5 t#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' t$ b2 F9 f8 y$ j; B5 K$ K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( H! U& D( a1 z; b: E' \3 E
0 A( U+ e. h9 }; ~+ o/* assign the tl som board LED-GPIOs*/8 N' T; u, F v" d- |
static const short da850_evm_tl_user_led_pins[] = {+ X, \1 H8 Z0 T" t
/* These pins are definition at <mach/mux.h> file *// X( F% d% z6 H3 I5 N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# i7 t( I4 r) a$ `# j4 R! p -17 r/ b, ]% f( k
};
3 l- @# `5 X1 |, \* f: p
. N/ A& b" }( }static struct gpio_led da850_evm_tl_leds[] = {
- B5 @% F) }/ N1 s* k {
5 l& D6 ~- G- x2 M .active_low = 0,
& D2 L2 Z" r9 i .gpio = DA850_USER_LED0,/ w4 J2 O6 g* A1 k" w
.name = "user_led0",! s( P( f o" C" X$ @0 X" J' Y
.default_trigger = "default-on",
7 ~0 I& f$ G# \- n) L6 W9 } },
7 o5 C3 q, ]2 {3 J {
/ Z$ W: B( A4 q .active_low = 0,9 h( d' L1 s8 S$ y/ v4 y
.gpio = DA850_USER_LED1,
. y. @# X/ D' t! K1 g .name = "user_led1",
o* y# g \! x( `/ Z5 M x .default_trigger = "default-on",
$ K' n8 r! j& H8 N; ]) [ },( q+ x$ _( K% ?$ E4 d. `$ Q
{" |9 w# u9 b' U
.active_low = 0,: q" E b4 o) z8 i; X4 K
.gpio = DA850_USER_LED2,( ]) r- _8 J9 {0 {
.name = "user_led2",- ]' t, i P0 f6 {
.default_trigger = "default-on",% P8 b8 D" ?. [' F* I
},/ Y0 @6 Q; q: M
{
7 n' \: S" h# k& L3 K4 |8 V .active_low = 0,: j! f' }& B9 B$ z+ K2 ~& P9 a
.gpio = DA850_USER_LED3,
2 ^& A1 k% y6 {, o! ]& D+ [ .name = "user_led3",
& Q$ Y$ P" O0 C+ r .default_trigger = "default-on",1 B; [' v" W$ F0 d/ g4 N% Z0 {! v
},
# t0 ^! u, ?4 ~8 @};
, W" _- A3 n4 |& j; R" z, k
. @% U7 C: I6 xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! i Y1 V* U( Y .leds = da850_evm_tl_leds,
9 z. N4 r4 ]' ^0 }8 T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, N) Z s) W! V/ B& j& F};
. a* E5 E0 L t( d
; ^0 x/ b! I9 c9 rstatic void led_dev_release(struct device *dev). E) u% ]0 }" T9 i- G' W
{
( w5 J. H% I8 A, w6 C4 J}; o; x( a+ ]/ q1 [, q/ u) A
' s9 k. e _' d, u- n6 x# R
static struct platform_device da850_evm_tl_leds_device = {9 N) f; \. W+ J: m- n9 \
.name = "leds-gpio",
# R3 U& e4 i& p .id = 1,' ?, m, z+ Y9 u! u+ { F
.dev = {
& q) `4 N+ ?9 ]9 t" } .platform_data = &da850_evm_tl_leds_pdata,( I, |2 b) c$ m
.release = led_dev_release,# Z3 J5 F0 Q3 z
}4 w/ T3 s1 r* s
};
+ Q. @/ ~ F/ l3 h- }( D* }1 ?) G
4 g/ x" T# U, l2 @static int __init led_platform_init(void)
" \4 Y' m1 p u" D3 o{8 g/ x3 _+ i& L1 x5 J, z
int ret;
" A# H$ u6 b, E! `#if 0# f+ `& Z; P2 ^. m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 y$ @3 e2 K4 L if (ret). v: F x, W% j9 f
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 P: F; [) F3 Y1 A) n4 B5 v0 P "%d\n", ret);
" v# j$ s3 L1 x6 t, v& w#endif* O" h7 _+ ~8 u6 e
ret = platform_device_register(&da850_evm_tl_leds_device);9 w- B0 {8 L! O" x7 L% x; t
if (ret)
( ^- d$ c7 J1 X" {1 ] pr_warning("Could not register som GPIO expander LEDS");3 W* b, s- ]6 O
else' `" Y2 q; r, s; E! V+ X1 ?
printk(KERN_INFO "LED register sucessful!\n");
/ }5 X: D, N9 ?6 i1 r; t: J, D- \9 N4 g+ Q' a" u; v
return ret;
A) @& c4 _: }7 n! B/ M! l" j}6 b( i! q- [; y% b' `
6 e1 e6 ~! t* F1 h
static void __exit led_platform_exit(void)! I j G) b' P* e: i! @
{
( P5 B7 \; X; m+ a platform_device_unregister(&da850_evm_tl_leds_device);
0 U$ n1 P3 p! K' `; E$ N) { E2 b, M0 Q3 V8 r" ~$ Q& d- j' \1 O
printk(KERN_INFO "LED unregister!\n");
1 \' e3 q- [# B0 O; A) w}
- `6 W! q7 S H, [8 a& {/ u) J$ N. }" `% g7 {
module_init(led_platform_init);2 a* j# ?5 @* G8 e& N! n
module_exit(led_platform_exit);- y& R- E# ~/ E+ T& c/ c& d
1 v% J* S* \) z0 HMODULE_DESCRIPTION("Led platform driver");/ e2 U. ?3 d& w N7 V; J
MODULE_AUTHOR("Tronlong");
2 H" H- Y( Z5 CMODULE_LICENSE("GPL");) k- A- w8 v Z# v; Q( j9 Q
/ h+ u' j$ ?3 E, G5 Y( | h* n3 g
|
|