|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 h8 W' O* L; v6 b#include <linux/init.h>6 m4 z( r+ ]8 K' T. S- I' g
#include <linux/module.h>6 I- ^, _% L& i5 i8 I: N3 p0 I
#include <linux/kernel.h>
( E/ |0 D; \! n' g( F7 T7 u#include <linux/types.h>
1 M" n, k/ z% k# s7 i9 j#include <linux/gpio.h>
7 M1 z9 ^. o% H8 \#include <linux/leds.h>
# P* [3 q+ \% H#include <linux/platform_device.h>
# Y! h$ N& ^; h. p8 x# m* u: [2 q% Q3 P( r7 U1 O
#include <asm/mach-types.h>! |, N j: ~6 U7 J' v" n3 n
#include <asm/mach/arch.h>' Y9 l: R: J# f6 c3 h. ]
#include <mach/da8xx.h>
L2 u5 K2 W' j+ y2 c/ \#include <mach/mux.h>- V L2 w* l3 Z( _7 V) M
3 h U% `' P5 v( i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! j0 \6 Z4 W# y3 c: c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ I1 B* Z& O) m' F$ V#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( \/ m2 p' M% O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ z+ Z- E( e% E% v! F W( ]+ f
. s; t' a `6 ^0 A) p& V* e5 s9 t
/* assign the tl som board LED-GPIOs*/
, |; O* F2 H' i. |, |8 K Gstatic const short da850_evm_tl_user_led_pins[] = {
2 }3 \& [ M8 _ /* These pins are definition at <mach/mux.h> file */0 ^, G* h( m- \) J, f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ `4 z4 d$ T2 r4 h -1
9 [: A9 ?2 {6 Y7 s6 F, [, d};
# \( u8 x: ]/ F( a% I
$ [8 m$ X2 T* Q% n% h6 istatic struct gpio_led da850_evm_tl_leds[] = {( a' h" C; Z Q; h$ Z
{
# E* Q$ [9 A% ~ .active_low = 0,( e8 D- m( x7 R
.gpio = DA850_USER_LED0,3 V- A# P; f% F2 O
.name = "user_led0",
$ ], l4 ]( d3 y: ~- M4 j .default_trigger = "default-on",+ d v8 K8 |8 ]% F
},& W% ]% u& J- O: J
{
4 W5 h% r( T: s- Z3 V/ j1 v& D' R .active_low = 0,( a# b3 {( c* E8 Q2 I- }) j- ]
.gpio = DA850_USER_LED1,9 A4 {( Q3 W# V, ~4 q0 c ?5 E/ D
.name = "user_led1",
9 l- ^. i$ e0 v! O. P c .default_trigger = "default-on",7 } h9 C& X/ v. z" ?% ?: H
},. \; P$ _. n8 a2 d0 z. Z& R$ e5 m+ x
{
+ G) t9 @: Y0 G9 W; T6 p .active_low = 0,' F, ]) n: b: `* x
.gpio = DA850_USER_LED2,6 ^, F w4 J& c" t9 ~
.name = "user_led2",7 z; H! I$ }7 r4 ~1 h
.default_trigger = "default-on",
% E8 P& P' H$ A4 e+ e. s! D# l },$ u! w1 M) H* z- [1 N
{
( O/ i. _; \. ^ [; a) X; u .active_low = 0,
: ]) t0 o8 T! Z .gpio = DA850_USER_LED3,
# x J/ L% c' o B3 w2 b .name = "user_led3",) [ `9 L$ h {' B5 Q: g2 l# x t' o
.default_trigger = "default-on",; W$ }% d2 i( c. {3 u+ @
},, j* H% S) C' `5 q$ ~2 S
};
# A: O0 Q! g3 B& |+ o" ?& L) c6 I
h' O* h& z' f$ A. Y+ Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. H& J. l( l0 Y: F6 ^$ |/ e .leds = da850_evm_tl_leds,' g( Q& i# {" Z0 \: l- s0 c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& `( j4 y$ N# I3 C};
$ U3 M- G* l) a- s! `6 N
6 M2 b. v1 `# }static void led_dev_release(struct device *dev)* C( @* _1 Q, ~! _2 @
{$ B) p* O1 \0 j) o$ W }
};0 r% F i- q8 |) F
0 \7 y1 ]9 z; L+ U# _static struct platform_device da850_evm_tl_leds_device = {6 r" p) L2 u5 g
.name = "leds-gpio",9 T) C t8 l5 t8 A c7 c' n
.id = 1,7 D+ V) v R1 }; y
.dev = {1 S( P" ?2 `" q; L
.platform_data = &da850_evm_tl_leds_pdata,' I: F$ k! e. t7 D+ e+ h
.release = led_dev_release,. w8 u$ ?8 J6 N
}
' }) _1 S7 s' s; ?9 _};; i6 K) a: W% P2 ], ~5 \
! u" A- k+ f, Z j2 k/ [1 y+ ostatic int __init led_platform_init(void)- d, C- u, c7 z+ C( G
{9 t% _% o. | p; L1 i2 b
int ret;% {+ k$ Y' p6 o$ l3 x3 u6 x, `
#if 0
' R( S; a/ X0 f& n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 q7 }' _$ p8 K- x
if (ret)' I( h& G6 \- c4 F; P% J; ?, r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ g& v! c' [- `: s( H
"%d\n", ret);
9 m# z" d, I7 y7 W: ` J#endif
0 ~$ y" q, o" R' S4 @( x7 @2 F ret = platform_device_register(&da850_evm_tl_leds_device);
+ k/ t! x H/ d: Y2 Z if (ret)
& Z1 k7 e" v7 j+ `9 X& b pr_warning("Could not register som GPIO expander LEDS");
+ c% n$ \- |7 ]+ O% U& S) ]5 g else: Q4 E( f7 T+ |* x: ^5 ^9 {; n
printk(KERN_INFO "LED register sucessful!\n");
- w; `4 v# u" ?% a* W: B1 K8 B7 O5 ?6 U9 z; \' ]
return ret;
3 n. r/ f9 ?6 T9 f% i- t; i}
, ^% A* f9 M, M/ m6 A' w! R6 R$ y# D7 G' l0 M& H5 a+ c' j
static void __exit led_platform_exit(void)
Q+ U* E* c: V: S{
7 V& N5 h1 O4 h: W8 R& i1 K platform_device_unregister(&da850_evm_tl_leds_device);4 @2 f. [( l. k# _ u: ^& X
$ y' ?( ?, [) V" g
printk(KERN_INFO "LED unregister!\n");
) _- y# {: j) _1 R}" B: b/ {, W/ ^2 Y: p% n, e
' J& Q6 j1 o0 V) D; [
module_init(led_platform_init);# J4 r' z& n( u0 q
module_exit(led_platform_exit);
2 l n, m/ m( v8 I
/ P: w2 L: d$ ?2 _) pMODULE_DESCRIPTION("Led platform driver");
& v0 |# \ o7 U! Q+ q) JMODULE_AUTHOR("Tronlong");
5 P7 F1 C* ^% V' @ M7 XMODULE_LICENSE("GPL");
0 ~9 N* V3 c' a0 A8 S" Q+ h0 `
+ I/ R9 Q2 j' R, ^ |
|