|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# y- n1 _( T* d3 A#include <linux/init.h>
8 ^$ n& V! z, U. k' z4 F- z C#include <linux/module.h>/ u" m* n. B8 l6 L, a$ |
#include <linux/kernel.h>
, ]9 M k! b1 k! i# F! V9 o#include <linux/types.h>
0 U/ Y0 _3 Y) f0 P& Q, [#include <linux/gpio.h>2 y. F) h' }1 d9 h- x# K
#include <linux/leds.h>2 @) C( J) |) ~ D% Q# m: a
#include <linux/platform_device.h>
' m9 y1 w5 K( T2 y x% C/ U- n \* c$ K5 q- T
#include <asm/mach-types.h>2 K. M" X: @4 B% E# U/ ~+ c
#include <asm/mach/arch.h>
. o F/ h |/ U! {7 \#include <mach/da8xx.h># w" i6 G( ~- Q9 i1 A( w
#include <mach/mux.h>4 |$ {8 n. t1 W) |( [% \, ~. R q
0 m! S9 Q; x! Y/ c" o1 J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 n* }1 w7 _7 c) P" n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), @9 [. D5 ^0 G' k# @# t& O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- ~2 M' V$ V( A* V3 _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( J+ V! j. E# ^% i
0 f0 k1 T7 n h0 F7 ]- d y/* assign the tl som board LED-GPIOs*/3 O9 ]$ y* [) m# Y- [# \
static const short da850_evm_tl_user_led_pins[] = {
3 x- I+ r7 N6 W /* These pins are definition at <mach/mux.h> file */3 a& P3 Y6 H3 F! G# z7 W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% V5 ]4 p$ A5 F- c -1* r/ S; u! W f0 P: n" D) D
};! M% F$ [3 q$ X8 X5 C3 d7 f m' q
- ^7 X$ K# N1 q0 t* N: k$ Y
static struct gpio_led da850_evm_tl_leds[] = {
- L# J' F2 ?" ^. V {
" }8 V# s( j" M8 n' ]8 X+ s .active_low = 0,
! m6 K7 O' q; D8 g8 R" Y .gpio = DA850_USER_LED0,4 O Z' D L5 A- Z' K- } M
.name = "user_led0",- u& Z2 `% v& s. i$ Q
.default_trigger = "default-on",% S4 s% J0 h- U$ k; \
},, B3 X) V- J! h4 }$ G
{5 R0 o+ r. r& o4 D7 A- K/ |: I
.active_low = 0,
. G- Y; q: n* a" A3 p .gpio = DA850_USER_LED1,
s3 P l. h+ G$ F& Y .name = "user_led1",; Z4 _5 n0 ?5 G, j+ J
.default_trigger = "default-on",
+ O& V6 l' J* Y k/ R, r },$ H' J, V2 t# ?. T) z" y; Z3 c
{7 U3 o0 n! g, w- p; b8 Q% M: f
.active_low = 0,
6 _& }# x- n! M0 |6 h .gpio = DA850_USER_LED2,3 r7 u) Z" s0 |7 e+ t2 }' z
.name = "user_led2",
" |# Z! b: t, |& B! Z .default_trigger = "default-on",* t6 g- Z- a4 ~* q* Z Y
},0 C6 c, X/ C: h3 L* c
{
4 q; Y& ~: `1 L% Z .active_low = 0,
) v5 g4 S7 I6 a$ Z" _ .gpio = DA850_USER_LED3,
0 p8 B5 Y9 S% M3 n7 }, C .name = "user_led3",
$ t" u3 f- Z5 ?( \& U .default_trigger = "default-on",( N1 y, S) T: c, g2 } X/ @
},
( R) I- |0 `# i4 D$ R+ Z/ H};
$ X8 o5 v+ g4 E, ~8 R) j" b- }' G5 y+ I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 x6 R" e7 q, J g
.leds = da850_evm_tl_leds,
9 j6 P- q- T7 h9 H" h' S$ x8 Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' ]7 P( k0 z+ T' i1 G3 b6 Z+ D
};
! f2 E2 V `, h: e. X U$ G4 W9 p$ v& e u" G$ }7 O4 [
static void led_dev_release(struct device *dev)
" c P+ S- E8 t/ S! i- e{9 }5 [$ |; [& u2 f" s
};' I4 p! V: {# `, {2 {% V
( }5 Q* b9 J& L% L; V0 F2 ?# u
static struct platform_device da850_evm_tl_leds_device = {. ^' G, L$ |8 R" R
.name = "leds-gpio",* o9 O0 `$ ~5 i. E* g8 l
.id = 1,2 i6 F6 j* e* |2 k: Z
.dev = {3 j7 L2 N/ W3 J0 x. |' f; X* X
.platform_data = &da850_evm_tl_leds_pdata,# r7 T8 Y) F" v5 o
.release = led_dev_release,$ a# }! x% G, Q" }& m' O
}$ d- i# a* j% O3 s0 w
};
% v( V# e; m9 \; Y7 X. D9 l/ w
% Y' E, p7 ^0 L. }5 M1 _/ h- hstatic int __init led_platform_init(void)% V2 T7 b- G9 ]( A
{8 l6 @2 d' N+ i) O
int ret;- _/ s6 u* t- c( b- m
#if 09 G- g: m W1 l& V. I
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ t7 ]3 r }9 a+ K- {* V if (ret)
# r( N- M/ a( x' l& b& Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ f' X" b' _4 R
"%d\n", ret);
( S: ]5 Y v' }9 S: y% S#endif% U9 k# k5 q" r$ W
ret = platform_device_register(&da850_evm_tl_leds_device);
) Q! G( F8 T b; G7 r9 o if (ret)& ?' `2 K& w: p7 D3 _. l9 f4 Z4 F4 Z
pr_warning("Could not register som GPIO expander LEDS");" F* D0 }3 M( j" v$ N$ r q
else z! R) k5 h @! v& J: |
printk(KERN_INFO "LED register sucessful!\n");" f6 q. m2 j# G
0 J) I$ A) W2 i$ H4 J
return ret;( X* I# `; h" u* x& D1 q
}" O5 l( c' a# _3 [, |7 r9 x$ u* S
5 \5 E7 a' q d8 E7 U4 i6 w
static void __exit led_platform_exit(void)* `/ t4 {( {* {+ m
{6 z+ Z* j3 c+ F( _7 |* ]
platform_device_unregister(&da850_evm_tl_leds_device);
" n) W" ?. o/ R
8 F0 t" e# J+ A0 A printk(KERN_INFO "LED unregister!\n");
% f6 W! S& F2 _+ f* y% v- z9 Z5 T& y# B}
- ^3 Q( Z6 p5 }/ O
) @& H: A; U5 w- ^4 [0 H1 D+ amodule_init(led_platform_init);+ }; ], q: \1 U6 b% Y2 S
module_exit(led_platform_exit);: [ t- q* _6 o# n! |
! \. ^' X) g) W2 wMODULE_DESCRIPTION("Led platform driver");& E8 X; T8 H0 |$ }$ r4 O3 A% B
MODULE_AUTHOR("Tronlong");. D3 ^ m- D4 S f
MODULE_LICENSE("GPL");
3 q) b; K6 e: W6 Q/ b9 h6 p
1 U% Y( x. u- B |
|