|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# c5 n# R% M6 b. L. T
#include <linux/init.h>
8 U! b4 `- E: a9 y#include <linux/module.h>& A1 S2 W) C r
#include <linux/kernel.h>$ `2 q2 j9 H6 `/ i. t+ w! H
#include <linux/types.h>
2 ~2 c& R, p5 b0 m#include <linux/gpio.h>
! E. ^ S' E1 w+ h) t#include <linux/leds.h>
' z" G( r: I5 c' S I1 W) i#include <linux/platform_device.h> R3 Y0 L) J/ n* N: W Y7 [/ w4 x
' U; x& t, i% e0 v7 {% _) ?& ~
#include <asm/mach-types.h>
9 K5 m f: C: v/ v#include <asm/mach/arch.h> r5 U4 c8 C u
#include <mach/da8xx.h>$ `1 v, B8 n! t7 W) ?
#include <mach/mux.h>' [) s1 T6 H2 r
9 p8 K. x' g: N: e5 n2 c" u1 w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* y+ E, f+ n* R# f/ P4 k, _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 }- f! a8 q+ y4 v) C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 ~. ^$ a, L1 V5 p$ R#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, P& |" Z- l( G5 E! Q9 q/ H( M8 j3 e2 T. m
/* assign the tl som board LED-GPIOs*/, r2 a# x0 `% @) z, Y4 u+ `
static const short da850_evm_tl_user_led_pins[] = {5 | ^# f$ E- G. H" y& l. T
/* These pins are definition at <mach/mux.h> file */
, H8 F2 l2 \1 `7 E' E' U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ w9 r! a; D- f H% e q( S9 a -1
1 u# @9 W% t2 p) Z& A& e};
# b6 A+ R; y* r& R% H5 \4 p! F4 _2 _, C; M5 B, _# W
static struct gpio_led da850_evm_tl_leds[] = {, N, b2 h+ ^5 @" h6 M1 m2 V
{
- @7 m5 S% M) A& {* @' |$ G .active_low = 0,5 H* ` A9 N! _/ n. D( {
.gpio = DA850_USER_LED0,
" Z$ ~; F( E3 N3 a7 Q0 u .name = "user_led0",' \9 ?' C' e4 k- V6 W* r
.default_trigger = "default-on",* o& q! _% A; w! j/ Z0 ~2 d
},
: Z6 O5 r* ?- q) p. R* V$ j {
6 t- N5 @% A$ l# j, E8 [ .active_low = 0,: ]" z' U) R9 ]) ~0 m! J+ @
.gpio = DA850_USER_LED1,
* a$ m. b% `; Y/ B8 c .name = "user_led1",: t, T; V" U. f% y% Q' L
.default_trigger = "default-on",
; f# J3 ]. \) r3 l },& m7 `& L# {+ R2 n: E
{& O7 f Y' P2 ?: b2 D. z
.active_low = 0,
* L9 r6 P" e# q) M& S .gpio = DA850_USER_LED2,
5 {4 {; h& w; `$ r4 I9 T .name = "user_led2", a# l# A7 A u2 P8 g
.default_trigger = "default-on",
" z! R8 \4 }8 T& k, M+ M$ P |( V# X) U },. e2 n! R: a T3 p- c
{
U- W! ?; p4 b. \9 c3 G# ~ .active_low = 0,' i Z- d* I7 d9 Q* B
.gpio = DA850_USER_LED3,: S( }/ d4 d* r# k; C
.name = "user_led3",: H- s" n5 e# c Y j. w7 i
.default_trigger = "default-on", @# v* W. L! |8 u$ ^) D) n
},
- N. ~$ d L0 Y) D};
( a' [- G- _4 S9 g5 R2 [8 R5 p2 i/ Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) c3 e4 {8 E! D .leds = da850_evm_tl_leds,, P' t. N! }/ b$ K" y; |
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 c E1 O! R- N2 h6 j
};( y0 j9 ]0 r4 D" ?: G: P5 p/ q
: U5 i; T# P( L5 r& R( ~static void led_dev_release(struct device *dev)
8 G+ o P; Q8 r! u/ F9 }{
1 }% X- |. s$ E& k};
j. K' m& i" m! X/ P/ T5 Y5 `2 y% D2 n; @9 P$ B
static struct platform_device da850_evm_tl_leds_device = {. O5 b4 S) i/ [
.name = "leds-gpio",. ^* K! G; i9 J
.id = 1,( h, p1 c* l5 D
.dev = {
( k" I, v/ Z, H .platform_data = &da850_evm_tl_leds_pdata,
2 ~! k8 k x. [/ t5 I .release = led_dev_release,5 x2 q/ Z7 a) z1 b# p0 r6 G. O$ M
}$ T/ m, A' E* D0 n1 | [
};
' Y0 K( s$ F" [9 L' u1 P
# u2 ~+ b! M' K5 i: u6 Mstatic int __init led_platform_init(void) r1 w* b; s! ?: H8 T8 f: _
{- g3 q' {* Q+ K2 u% x* q
int ret;
' [5 D+ l% }+ w0 k& l6 U6 Q#if 0* m# |$ S+ c$ r3 A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 ^* W+ \; m7 l
if (ret)
( ?9 L Q$ {: O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) p% Y! N$ L7 i "%d\n", ret);
) G8 Y) }3 l2 g. `#endif% ^, Q1 B" R6 \+ a! l! }
ret = platform_device_register(&da850_evm_tl_leds_device);' |* h& ]2 Y/ {: d( i! Y
if (ret)6 C/ j9 S/ X9 K. C# G1 ]: n( B7 r! {
pr_warning("Could not register som GPIO expander LEDS");
$ @- K. I- w9 @9 ~% a! L. J else. G$ j9 U) l: f4 s7 ? z
printk(KERN_INFO "LED register sucessful!\n");
9 E8 P8 B/ b0 \! I q
# h+ ~# B7 W/ Y' l1 O$ H return ret;
" H7 G( Q, D! k7 K0 }- V6 ^! a}+ r, |. w7 t6 S6 x! q3 ?
2 f- ~7 d) F8 \# mstatic void __exit led_platform_exit(void)
. k# X% o( f7 W9 w, a" s1 x{
7 A; U' G% }3 M7 Y6 b0 |$ e$ t platform_device_unregister(&da850_evm_tl_leds_device);5 Y% L# B. s# j6 B9 C/ y+ b
0 Q& Z) z: R5 J& D$ @+ b printk(KERN_INFO "LED unregister!\n");! u0 Z0 E0 {3 `8 J! f! f
}" R( t+ Q3 m% O, t/ z
" h: l3 @ ^, X9 J/ \, Y" r
module_init(led_platform_init);1 v4 G h( H7 ~ k( w( |+ B
module_exit(led_platform_exit);$ s# c4 Z2 h; E5 V; p6 T/ ~. a6 x2 u
' u. p+ r; T' L# ^( CMODULE_DESCRIPTION("Led platform driver");
* O7 Q! ]7 O; E; U; HMODULE_AUTHOR("Tronlong");
X, q: K6 Q$ X7 q! r* \MODULE_LICENSE("GPL");" g8 S1 o n4 G: I: C- v. V
6 B) [% j* s* p1 u% S1 o' i7 X |
|