|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 U) T; J& _) `5 S#include <linux/init.h>
6 e! ?- R. L7 Z8 X( d#include <linux/module.h>& d) ]% v1 n. L1 g) l
#include <linux/kernel.h>& x. S% q+ Q8 } b' W" Q: K6 ?
#include <linux/types.h>
, U& w/ o/ l; w4 V7 c/ P' E& L4 O. y#include <linux/gpio.h>
& }8 B8 g9 n9 O! o' R#include <linux/leds.h>8 v: r( |3 e0 F* Z7 A5 y
#include <linux/platform_device.h>
# O3 n& g. K: h$ ~) z! {1 n4 z, b- V6 p
#include <asm/mach-types.h>
3 F: a8 n) J9 o# Z/ Z2 ~8 R#include <asm/mach/arch.h>; b, i( n. j( V% C1 Q0 W
#include <mach/da8xx.h>$ J& w) a: Z; W% t$ p9 G3 }. V2 l
#include <mach/mux.h>
" j8 C+ g1 X7 x& j2 ?% M- S# U; p5 {1 V7 T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- C/ V+ q. q3 r# c3 |: S7 \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% X+ P9 i3 A/ W- U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), _1 @9 W$ M' I- P4 ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 V0 T" A3 q6 k' T& q$ K/ O
/ T# |: I4 h/ b( S0 k/* assign the tl som board LED-GPIOs*/
# }& j3 k7 Z. ~$ g2 a- b4 Fstatic const short da850_evm_tl_user_led_pins[] = {
; e3 p7 B# j+ ~' E /* These pins are definition at <mach/mux.h> file */9 A) p3 b8 u8 ^4 W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 H" B7 d1 k; `
-1
' e/ R2 y: \* U. Q};
' ]: `3 J; R2 S. ]7 ]7 ?
7 A. W4 R6 i- Jstatic struct gpio_led da850_evm_tl_leds[] = {
* Z5 }+ x' s- A, q- w* h {
* M3 W% o4 y3 P) F .active_low = 0,+ Z& d: h# R6 W0 y2 N2 }6 b( n
.gpio = DA850_USER_LED0,
+ G' C m; `$ O+ a .name = "user_led0",4 I( E% A* p, [$ q) t' K
.default_trigger = "default-on",
6 ?# Q2 Q6 d6 B8 P },
7 h7 f( ]4 ]6 p/ T+ Y% h8 H {
& L, l6 I! V" }' E .active_low = 0,1 ~0 f+ z5 E- g7 _+ E5 B2 ]0 {0 D" z1 U
.gpio = DA850_USER_LED1,* Y( L. X; Y3 l- ~ f3 W- C
.name = "user_led1",' z& S# D1 C9 K& R" s9 E+ S
.default_trigger = "default-on",
7 l) u. n4 `9 i },7 r4 F7 {$ X/ h$ A
{
1 S0 l8 j" }- Y .active_low = 0,
3 \. n* @" t! `& E .gpio = DA850_USER_LED2,
& m) C9 f. q E+ w .name = "user_led2",) g, I. m$ V1 c$ S
.default_trigger = "default-on",
# B, L! M: x$ c7 ~0 ] },
" U7 y$ S2 J" U, W {
! |( W! f3 a4 V( @+ X& r G .active_low = 0,
" w% o# R" g% g .gpio = DA850_USER_LED3,
5 f# q3 w6 L: D2 J1 a: m4 g .name = "user_led3",2 ^* W Z$ U1 e$ O6 c
.default_trigger = "default-on",/ z; {( i: O& B
},
% [; J, u& F2 {" |. I- L};
( T9 t! \; f1 o& ?& K
5 @8 Z5 m; \- ^0 Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, M. f9 a; ]7 p
.leds = da850_evm_tl_leds,
' Q, D" Z$ r5 K; p0 Z4 X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ ~. f) U! L; R9 e/ K7 |
};! V. U" O; ?( X! [
" K+ }' Q, W, @7 i' k. |$ cstatic void led_dev_release(struct device *dev)+ U7 u* X# p- \2 y0 @5 Y$ s8 [) K
{% b8 G( V" q8 W3 l& _- c4 F4 r' D
};
' i0 v* M3 Y- R- D9 Z9 q2 V9 H0 N$ T7 M7 }+ E
static struct platform_device da850_evm_tl_leds_device = {
5 w9 r% d) ~; I8 O" A+ L .name = "leds-gpio",
: a% W! y3 {1 p' ~) s3 t .id = 1,3 h) p4 [" p3 h) `7 j' @3 _% I6 A
.dev = {% v' X+ O; X3 J9 z$ A) i+ e
.platform_data = &da850_evm_tl_leds_pdata,
6 b# d0 [+ Y8 R! o# k .release = led_dev_release,
/ K' K. d% U0 b& z( ~; t }
, q' v2 d7 N5 z* T: E};. y [) d% ~1 u( A2 [
0 L+ l5 c2 w3 R4 zstatic int __init led_platform_init(void)
% ]/ g) Z' A% V( W2 M{
1 U0 j$ Z5 Y( q# i1 \ x int ret;/ F0 R& D( j F; I) k
#if 05 Z) ?9 j! N- A# H/ _1 Y) z$ s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 a: G" f6 B% ^8 a) p if (ret)
6 G& c9 t' h$ r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* m- {, O+ ^' u* o; u J( S9 d. o
"%d\n", ret);# p" I" t7 X f2 g
#endif4 p. [: E% u4 j9 x
ret = platform_device_register(&da850_evm_tl_leds_device);
" H3 k. H+ ?- \$ d( ~ if (ret)
* ~; V' E% j1 q# i7 @8 J pr_warning("Could not register som GPIO expander LEDS");" w6 J7 t( o& w
else/ k! s& J5 b2 S# C s' G* K
printk(KERN_INFO "LED register sucessful!\n");6 @, M) [" m6 d0 }# |3 R# M( L
! b6 M; ]6 I' Y- S! O h return ret;
" T9 w4 q& r8 k1 Z8 N' M}0 u% U, S1 M/ @' }
" i, k- E) f8 f# r
static void __exit led_platform_exit(void)
+ G8 `: P" I3 S{0 l: ?: i3 f r% \. J* {: Y
platform_device_unregister(&da850_evm_tl_leds_device);- _* Y% x1 R) |5 Z7 X( {0 K6 M
$ c4 V# Z3 z* d! u x. i4 t
printk(KERN_INFO "LED unregister!\n");
+ i: E0 @: i F% S3 g3 Q}$ m6 i3 X* u1 ?& \4 i' E
' i1 y" w$ ~5 R& ~- k* H2 t, H
module_init(led_platform_init);5 {' y# L$ b; c8 P+ i- I$ T) S
module_exit(led_platform_exit);5 ^; [- u) W8 U5 [: y2 T- h. m6 E
7 \ Y; t8 U* S$ x. S4 [
MODULE_DESCRIPTION("Led platform driver");8 {' [/ ^- X5 e; O. C, b
MODULE_AUTHOR("Tronlong");/ p, \/ t" b8 q
MODULE_LICENSE("GPL");
% y. ?% ]$ } {/ q2 b- P- l
4 c% O1 w5 ?0 f2 a' p |
|