|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 p5 S- ^* t9 S4 B4 j
#include <linux/init.h>* A# H2 S7 p( J4 u# N
#include <linux/module.h>$ Y/ {: @4 a" O, E
#include <linux/kernel.h>
0 B! p! Y" @! C; S/ Q#include <linux/types.h>
" K2 H& s7 R0 y#include <linux/gpio.h>
1 [' A8 f$ e& O8 I1 l# l#include <linux/leds.h>
( |0 I# c& G5 y7 v# A3 |#include <linux/platform_device.h>
0 W0 [$ ^. n- z! F) s
& n. o1 g0 ? V+ A, z# p. m#include <asm/mach-types.h>1 f; ]1 z7 j7 P/ a* l
#include <asm/mach/arch.h>
' t5 R' U6 h% z. i& s E1 _#include <mach/da8xx.h>
1 l- k; e) j5 z% x#include <mach/mux.h>
?6 C) @! x+ r% u" E% c
! h! c1 e% ?* g* C: z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# k1 }; {* ]5 N8 a2 b4 H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 o5 P% R5 `& k+ G: ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 Q' O$ }$ x1 Q* C1 `- L* a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: Q: F! g( ^, i! ~! B1 O- g' |3 j# F" y: e$ I+ u9 s# V9 P; Z
/* assign the tl som board LED-GPIOs*/
% x$ ^4 {7 z! d2 }, N5 Xstatic const short da850_evm_tl_user_led_pins[] = {
1 k1 {) _' b, k" S2 L /* These pins are definition at <mach/mux.h> file */
% v2 y- M0 [3 q, e8 t7 B' d0 D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 F+ d* [5 ]3 B% s) c( e8 ^5 S
-1
. I! L( O, y! g0 T/ R# y};
, m/ S; w( ~$ J0 O+ d/ s/ g+ f$ ~7 t1 n* ]; X" S% ]; A
static struct gpio_led da850_evm_tl_leds[] = {" g1 L8 s) w. T, M* V0 P
{. U& h* Z% b1 F! T0 m! n! a; |- `
.active_low = 0,
1 Q ]/ w; c9 B .gpio = DA850_USER_LED0,2 ~. f( w( p' {) D0 |8 c
.name = "user_led0",
2 C4 K5 y/ O6 Y5 Y .default_trigger = "default-on",7 [5 z+ e1 `: X8 Z! D
},
9 z7 q$ J: ]( _+ h# N {
% j: O" j. h: Q; w& o .active_low = 0," L# N$ e) e/ ?# X1 V
.gpio = DA850_USER_LED1,1 O; A: x3 d( n$ p
.name = "user_led1",
* J4 K- C e7 _& H" U1 u/ g" m/ S .default_trigger = "default-on",
3 C& D/ W8 x* L3 p B1 ?$ _5 e& V' _ },
9 {8 f% C% u. `' x6 L6 g9 S$ W# M {! A8 b) O( z9 Z. ?2 F: H1 \7 \7 e6 P
.active_low = 0,3 t! P8 O2 I7 w# I! l# ]
.gpio = DA850_USER_LED2,
' k a4 \, p% E" A .name = "user_led2",! F$ `$ x- U) T; T, a+ u" |, c* Q" o
.default_trigger = "default-on",
4 A2 y$ O( v3 r* _5 J },
3 z C \7 F9 y3 c( s- B! n {% L+ @( J2 Q; W+ y5 ]5 i7 p' `
.active_low = 0,/ s' e7 Q& j9 j
.gpio = DA850_USER_LED3,
9 [: }- g6 @5 N6 r1 I! n$ M) k .name = "user_led3",
, P" A. j9 @) @8 D, Y7 G .default_trigger = "default-on",
4 U" K1 N9 ~* l" G! r* ^ },
5 P6 `+ r& m% n. j8 h( y0 W; g- t};- R2 T2 C5 t- w' m4 w3 U
* {5 f! s$ C7 \- i# S2 x3 y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 E- P# q) N9 G5 _4 R/ X
.leds = da850_evm_tl_leds,
. B7 B }! y2 n) B0 I9 J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 x# l/ [! Q8 ~3 s- ^' {};
, s3 f$ J. `. w8 _7 ]' h
* j4 [1 j: m. ~( B+ X$ m) A, n3 ustatic void led_dev_release(struct device *dev)3 i( b k2 a$ e/ T
{0 G- ~# v8 x/ ] _1 Y* X3 e1 H
};- m1 j6 J* L& f4 p( V' K; Z& l! D2 ]0 ^
' G6 N% O J, N' v
static struct platform_device da850_evm_tl_leds_device = {6 z4 ~5 O' o! J$ l0 ^! R
.name = "leds-gpio",
# ?; \5 l; ^7 R# R2 @' W! B, g .id = 1,: a# m2 n6 A$ \
.dev = {
/ N5 r3 S. s7 a1 C .platform_data = &da850_evm_tl_leds_pdata,8 h& I8 C( \( f9 U1 S) u) ] |
.release = led_dev_release,4 |; `' o3 X7 c; T0 L' H( Y
}, x I4 x' G6 x- C, j$ W
};* M- [* {( ^8 a$ B u9 L% }/ N" B
% G: P( o8 H# t. r; ]3 @9 qstatic int __init led_platform_init(void)
) B8 X: N; Q; N" I6 T. T* a2 Y8 p{* U Z& N& @" E$ e! q9 Z6 }
int ret;
1 F- h' k1 k1 ]# R+ `#if 0- L8 ?4 H) q& P: H6 i) g
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. P8 w/ {: R4 z$ f1 F- `8 ] if (ret)
# Z. Y; t, K5 `1 N' @1 K( ], u1 b$ @ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& x9 J! W8 e) B; ]0 f: H
"%d\n", ret);% q& u2 O8 l8 ]
#endif
- c2 x3 ?) q! w4 _ f ret = platform_device_register(&da850_evm_tl_leds_device);' ]* Q3 }, Q& K% r$ Z4 f; l
if (ret)) i& n$ Z0 _. h/ w/ f, b. R( k
pr_warning("Could not register som GPIO expander LEDS");
: F! G w5 n& m5 P else
0 S! r/ J9 q, \) G: F printk(KERN_INFO "LED register sucessful!\n");8 l9 R/ _/ D" @* j: r/ }
' [) B; k' \# C return ret;
7 t+ r' v7 x/ _: N' a}
# F5 L# Y% ]( x- ~; B: m4 M3 M+ Q h0 ~" G9 F) [+ z+ r
static void __exit led_platform_exit(void)
: a7 V D. n& \$ B- S+ e{5 v0 x+ }: b% v3 X% q% d9 Q
platform_device_unregister(&da850_evm_tl_leds_device);
/ L# [, O$ G1 [; d! ^5 r9 C4 J7 l* q1 t, G7 J
printk(KERN_INFO "LED unregister!\n");+ V/ _7 @5 V6 f. @6 r8 Q' ]
}
a; Y* h3 O( y8 [7 Z4 E- [) q5 m+ U9 M: n
module_init(led_platform_init);
! K( b+ F2 n. |0 I* b; A; qmodule_exit(led_platform_exit);
6 E1 {' g% U- v# g) `; u( H# h% g& S0 P+ h$ w3 N
MODULE_DESCRIPTION("Led platform driver");
, Y9 N6 j4 a6 ?( X/ h& b rMODULE_AUTHOR("Tronlong");
. E! z0 o- f) yMODULE_LICENSE("GPL");% B: Z7 `3 z7 q7 Y
( e1 Y4 q. R' r0 B4 S# P+ {, \ ^ |
|