|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- [) A# o+ { X8 H3 y( ^" U
#include <linux/init.h>) ~1 c* d, K; c
#include <linux/module.h>
0 J; P+ z, {* f! {4 M) w& v#include <linux/kernel.h>
) `& t7 W/ S3 _9 M7 `#include <linux/types.h>
* d; @' f! n, l! @#include <linux/gpio.h>
a. E- T1 \& ]$ e0 T#include <linux/leds.h>
/ F j( g% K, A. v6 u5 H& g) U#include <linux/platform_device.h>
! V7 T2 z( A d0 ^+ K, K
% \: B. S: O' q% S0 n+ V#include <asm/mach-types.h>
3 p- K. ?* s3 Q9 Y: B& c" |/ o#include <asm/mach/arch.h>
. B2 J2 y; `. B, y1 \4 M- e8 i#include <mach/da8xx.h>
; t& `7 d ]: M$ Y. q8 G- f9 g#include <mach/mux.h>
6 _7 t" _: g8 @) J
$ W" J2 K% s; w) M J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% Y, e& e) o% C& u) T& f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 z0 `9 X! L0 J2 X+ l- Z3 M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( k; m# ^: r/ {) l6 z# U9 ]; b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( k9 y/ d% S% G* z* p: S
7 y- y: g/ C t$ q( q) h: F/* assign the tl som board LED-GPIOs*// N; Z7 h9 L* x8 b. f
static const short da850_evm_tl_user_led_pins[] = {' Z( g, x w- u _; g
/* These pins are definition at <mach/mux.h> file */; A8 ~2 p5 Z& E4 ?- B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" t( B3 o7 Z9 U& u# Z) b -1+ q! _' E) `+ O: E8 L4 m/ l
};
$ Z% R" p: |& J2 k f; \1 i
6 B9 }6 ~/ x2 O1 ?: w2 z& n- sstatic struct gpio_led da850_evm_tl_leds[] = {
1 m3 ]' f7 L0 L1 w. n- X; V& h {" o' V0 q! |0 @- q7 S
.active_low = 0,
; m1 |6 ~0 Y A/ z .gpio = DA850_USER_LED0,4 }: b# D- p; V
.name = "user_led0",
: ?6 D8 @5 {" P* A# B! H( ~- E9 q) s .default_trigger = "default-on",
_: c4 f+ Z! N; b" c4 B( V },, K7 X# \4 I# z' `
{
* E4 _- l' Z+ W: j9 M8 ^% X .active_low = 0,
7 _5 t" j5 Z9 c/ L3 x .gpio = DA850_USER_LED1,) u1 C& M: N4 k: S
.name = "user_led1",2 o7 i6 [; K( e, b
.default_trigger = "default-on",) M: Z3 J% e8 x0 s
},# Z8 \+ N0 U; o; j3 B7 b
{
: A5 ^! G* k1 s3 y5 H9 Z0 o. Y$ A .active_low = 0,: S7 }5 o7 V2 t3 _0 Q Q
.gpio = DA850_USER_LED2, ^3 ]2 M% z% q
.name = "user_led2",
& z3 Q& T+ Z/ ^0 R5 Y1 n! t .default_trigger = "default-on",
! K" k5 @! G% Z M4 A& C0 G1 \) D: ~ },. |. f) V: Z! T" I. T
{
9 r. g8 `: u, D* g# T2 ~% y .active_low = 0,
( l A! Q! g& V/ t' v .gpio = DA850_USER_LED3,
2 p' ~! B, n! [7 a# [ o .name = "user_led3",
, P( ~ @7 j5 O" i .default_trigger = "default-on",
N9 L2 w5 H: z0 a. e! j$ E },7 M& V4 ?: p1 A7 B9 l. c3 j
};
; f1 `8 C. k9 q3 D! W
3 {# I5 N( {4 z- O, rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 z" k: E3 k$ k8 f2 E, G, Q
.leds = da850_evm_tl_leds,: }! O4 n: |2 ?& ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 C! k0 V$ p/ R1 S& ]% z};( x9 v$ P. N" n4 ?; y
; d- d1 P( }, o0 |
static void led_dev_release(struct device *dev)
4 i( q+ i( v% N{ c9 o7 ~% @. {8 ?0 N
};8 Z: U% y. r8 {7 [, ~
% _+ p# P1 Q8 H& i
static struct platform_device da850_evm_tl_leds_device = {4 D/ u7 v" i0 V. }
.name = "leds-gpio",
! t2 w# F: E: [: c: Q9 C% R .id = 1,/ |4 w6 J* y1 l
.dev = {; t9 f( T) x1 r9 ~
.platform_data = &da850_evm_tl_leds_pdata,
1 J i( j% J5 x) M: M9 \3 i .release = led_dev_release,
* e( t+ ~* }2 s) { h }
" t+ s3 j6 C" r+ j, Z+ {; Y3 F};4 l: `3 z [: T" H9 F3 b4 a
! |) [5 K* n' [- w! _: E
static int __init led_platform_init(void)
2 _4 h- P3 t% K, I3 u0 m2 ~# F/ r2 d{
. V# c$ m; W0 }/ _ int ret;' |" @8 K( }7 X
#if 0
/ D% }+ @7 p4 q+ i1 s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 W8 c5 t# X; f T7 d
if (ret)) `2 x$ Q: |% P: l) U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 V6 n7 }# y3 C+ e- |9 H
"%d\n", ret);; T: {" q! t) K( K4 [
#endif; `, W- Y& `5 P7 g3 k% V
ret = platform_device_register(&da850_evm_tl_leds_device);
% |4 ]( P$ D5 m; K$ |) h0 U if (ret)
' S1 v" z; P* N) j pr_warning("Could not register som GPIO expander LEDS");
- p/ q% c) ? V! c+ w) _8 Q+ } else: ~! x* \* z% T Q% N# g
printk(KERN_INFO "LED register sucessful!\n");# v3 Y8 v7 E5 D' r9 n
9 ~/ f6 g0 c, g" X7 m5 p" R return ret; t. n( _0 b. ^) L; b# ?4 j x
}, Z" R7 m) m' m: E* D$ @" S
5 L2 E% W# ^- F) `8 ]static void __exit led_platform_exit(void)
0 _6 z4 `4 J$ E/ L9 X: I{) G C/ P! l$ \
platform_device_unregister(&da850_evm_tl_leds_device);) a. k9 d. G1 m! f8 K% U. l* ~/ X: y
* _* H8 J' D/ D( Z4 @2 S( o& \
printk(KERN_INFO "LED unregister!\n");. @' ?, @) {, T) M; i
}
$ B$ x6 \* n, C) Z! ^4 a. o
7 ~0 v, ]; g N( @/ V( h( Tmodule_init(led_platform_init);0 }3 t! l3 D U; d
module_exit(led_platform_exit);0 S( A- Y9 \: }" n. P `
# ~0 K5 i$ f+ z
MODULE_DESCRIPTION("Led platform driver");
7 g I2 d% w% {# W( ^5 J% N2 bMODULE_AUTHOR("Tronlong");
; H o9 U+ g8 M- jMODULE_LICENSE("GPL");
$ N( T( A) |3 D; u
2 d* l9 T# ^; e: I |
|