|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! ]7 S- N* D2 A5 N3 O#include <linux/init.h>* _6 O& a$ f' M- [
#include <linux/module.h>% d/ `& o7 w3 r: u! o
#include <linux/kernel.h>
9 e. Z% u* ^6 ~" }0 n#include <linux/types.h>
; C4 I( n8 E ]( y( B+ t4 \#include <linux/gpio.h>; |8 [ M; ]1 f- P6 J3 Q
#include <linux/leds.h>
5 } x4 x- E% m#include <linux/platform_device.h>" M1 L$ a1 ]) X: @6 m
} \ U6 U8 B# x
#include <asm/mach-types.h>
" _: x" U$ N' s! E#include <asm/mach/arch.h>
9 O1 U3 J% w( m! O4 s8 l#include <mach/da8xx.h>
6 U6 Y0 p2 ~+ l" Z, I# W( u: n#include <mach/mux.h>7 X: ~$ o% X. L- S5 C2 C, T5 |
- E& f3 Y$ d" M. K6 k9 a8 B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 A" G2 c; V/ h' G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ x, s0 H1 O& h/ u#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# m7 ?: x- P9 @5 }4 o3 \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ }; w/ q$ U* V+ | ]; \' T6 G6 K+ g3 [; E
/* assign the tl som board LED-GPIOs*/, W" g% D8 N% B# m; D
static const short da850_evm_tl_user_led_pins[] = {
# e0 h: `) g3 z/ ? /* These pins are definition at <mach/mux.h> file */# c& w6 C7 \7 u) d! s
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ a3 o4 y& I+ s; Z' ]
-1
C2 b6 Q4 E! N3 U, i6 n};+ F9 [/ `) b* }4 y
7 Z" Q5 q' C4 H3 O, i* I
static struct gpio_led da850_evm_tl_leds[] = {
; t; G& }+ L1 N8 Z; A0 k {: ^* ~0 \$ i! e4 ]; ?
.active_low = 0,, j# M) \( R) Z5 {; G3 F; o$ b$ ~
.gpio = DA850_USER_LED0,9 U9 R; d. `& |: C
.name = "user_led0",& H, O/ A d% F/ W3 }( f4 W" w1 C
.default_trigger = "default-on",6 ?$ {" q5 w, |* m( w, C/ @
},8 d* @! s( R8 f3 I6 W9 C
{5 P2 P) f1 Y }' E1 ~
.active_low = 0,
X7 @; x( ~6 i( x3 y% l .gpio = DA850_USER_LED1,
: o6 X6 S) u0 ^3 U; B+ Q# C3 Z .name = "user_led1",
0 x6 ~1 w6 i: `( d1 f3 l .default_trigger = "default-on",
5 O/ O5 {' f. Z& G },
8 k5 R& V9 C: b& [( z9 W% n& F1 N {' \1 K M0 b2 b& ?8 L4 [
.active_low = 0,
7 I4 \8 ~) x$ U X* ] .gpio = DA850_USER_LED2,
6 d) y4 [' {! B* p# h& F' ]) Q" u2 Q .name = "user_led2",$ L: {" H0 Y i2 S- L8 O6 }
.default_trigger = "default-on",1 i9 L. b( ~. Z q
}, e5 K# o5 F' H; O- i# K$ b
{9 k' r/ s0 f/ P2 L8 B
.active_low = 0,
5 p8 [( Q8 Y' H- K) Q) J .gpio = DA850_USER_LED3,5 t7 b& x, M; L. z3 Z e0 ^* i
.name = "user_led3",# _( H s! P4 ?* U1 r* @' N
.default_trigger = "default-on",
' `1 ~* V; @- F3 E& u: \. m },
2 r+ y: Y* l; f! x; N, w9 B# g0 Z Y; _};5 F6 x, R4 J( E; C. B8 E( P+ d( H
; K- J1 P/ @/ J0 z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 q8 W7 K* N; \ .leds = da850_evm_tl_leds,; N( Y, z& h# L- _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 n( u+ C* ?9 T9 k! A
};/ K. X/ A3 d+ _6 L
) i# l8 e5 d6 n( q+ m
static void led_dev_release(struct device *dev)
7 u8 C8 v9 x0 Q6 o. K$ V0 t0 `1 n{& v# v1 l3 `# X1 l
};
% T j6 b2 Z4 S5 Y- n$ j, s+ p7 |% Z. \4 S; ^4 q; m9 v5 |( _3 I1 A) U0 W
static struct platform_device da850_evm_tl_leds_device = {( [5 ~: A( @! s
.name = "leds-gpio",
4 V4 I, r' z- f5 g+ d: j .id = 1,
1 Q$ ~0 [* F; a) \1 J9 T4 ] .dev = {
, w3 m- W! @' m# A- q1 k .platform_data = &da850_evm_tl_leds_pdata,$ G( K8 C4 @6 f) w
.release = led_dev_release,# H) W+ q/ E9 ]5 t. G; p3 W O# @
}
$ T: ]% T% h5 s9 Z+ n};* N5 U' x* c* D6 R" Z5 S# b
5 s" s3 n& @8 B
static int __init led_platform_init(void)9 u1 y+ w4 D) X. D% t7 ?
{, E3 P+ D S6 @8 z; e
int ret;$ o3 _) L+ f& q- h( Y
#if 06 r! w' [7 O0 Q" e- N& A9 u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( S/ h7 T6 N4 A8 [% a
if (ret)! O4 G7 R+ V. O3 U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 }: b" D% O. `
"%d\n", ret);! \- ~7 @' s7 I; V
#endif
2 ?5 q2 H/ g4 K5 |- Y* c& M* h ret = platform_device_register(&da850_evm_tl_leds_device);7 ~! X' {9 O/ _1 f! R
if (ret)% J: _# I' h/ X( p/ P4 B! Y+ @
pr_warning("Could not register som GPIO expander LEDS");
/ x: N: s3 ?: I else
* }8 @0 B5 J% J/ C/ I6 q printk(KERN_INFO "LED register sucessful!\n");1 X @. p0 `% n5 Z
" j6 y+ T) t1 `
return ret;! c# g& e* {1 A
}
& O. h* z" f. s7 i2 O
6 H& l# L6 k3 p6 A2 M4 R& ]: [static void __exit led_platform_exit(void)
, s: U! g# T5 p1 e" T; l0 c' t( P# l. y{
1 j" ]5 r: ]% D5 O, R platform_device_unregister(&da850_evm_tl_leds_device);
% K0 z* `) s8 \
: A/ Y* v! ^* w; _/ A printk(KERN_INFO "LED unregister!\n");4 h K& {3 d O# n# c
}
9 ]* r$ w# s5 c% F$ k E1 ]$ L
! \6 z* G; ^" kmodule_init(led_platform_init);/ F7 n0 M0 j$ U+ h
module_exit(led_platform_exit);
$ _; d* d+ R( L! [4 @6 K- g1 K# ^! i9 g0 v% e
MODULE_DESCRIPTION("Led platform driver");
( p5 M) q% \7 M( H8 o x- WMODULE_AUTHOR("Tronlong");% y' I0 P* E4 ^+ n$ B% l/ r, s; y
MODULE_LICENSE("GPL");
% U; D2 O0 m2 x8 J, I2 H/ _
& P* N! r' s& o x1 ~! h |
|