|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" G7 h3 [; S" c8 k# A#include <linux/init.h>
3 B F3 W o0 M% s#include <linux/module.h>
# H$ T, X3 N* S1 \* ]. l9 S4 H#include <linux/kernel.h>
4 g: [% j9 @. L( i#include <linux/types.h>
# U7 m1 O4 h2 c5 R# F1 {#include <linux/gpio.h>
% e* K6 b* Q& _' ]8 |: J#include <linux/leds.h>
2 p' R$ G. @' W; L1 T2 |#include <linux/platform_device.h>
. f7 S0 c N( K l. k+ _, R
8 @% d) h0 g0 K; x8 @1 c4 _#include <asm/mach-types.h>
4 m4 {+ G7 `: h: t' B+ ~! d#include <asm/mach/arch.h>
4 `0 z( ^% M v( Q" y8 O1 B* O. C#include <mach/da8xx.h>
; \! F/ r) t6 Z" A/ L#include <mach/mux.h>
1 y! O- i9 d& _4 R' `5 v
/ g I- r0 I! C9 o5 z' w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 k# {* z2 m% X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): D2 ~0 t) f# S( ^! m# L! Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 t# w& G/ o3 d0 b; d4 E, |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 l* r9 S( W( {( ~" M$ b
& `, A A# z9 S
/* assign the tl som board LED-GPIOs*/0 _) @# D8 N2 l
static const short da850_evm_tl_user_led_pins[] = {
) J$ ?/ U' D8 U: L! m) O) P /* These pins are definition at <mach/mux.h> file */- u8 y/ m* O4 H9 f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* O P5 R) r: k7 k- d8 x [ -1* k, W! s, T( P) S( k% m) z- v
};: {; _2 H. Q( G) o
& o6 T- B) k; F& pstatic struct gpio_led da850_evm_tl_leds[] = {- z' p8 u$ m3 H- ]
{
2 H5 o+ W7 i6 J9 d .active_low = 0,
3 v2 B6 G* Z$ w! ^! i- s5 J' j9 J .gpio = DA850_USER_LED0,
+ m( U# I8 e9 }- ^+ D .name = "user_led0",
! V3 a. V2 G% |% `6 P .default_trigger = "default-on",
2 R7 C/ `) M! t2 r% y7 n9 W },% X) r! v& Y! |
{
$ V7 h- l% Y, W, U3 h1 f E- Q% H .active_low = 0,, U; b1 G9 K9 E" `4 s- V! C7 q. w, z. ^
.gpio = DA850_USER_LED1, w) ]4 a9 f4 ]9 |6 c. {, G
.name = "user_led1", y6 q+ N9 l9 i) e9 k( i: A$ O5 q0 G' y
.default_trigger = "default-on",
; q1 i0 l8 N( T6 z6 Q% v r# N },
0 k; k" F/ G$ R {
9 O' Y, [; }, F% S; ?' R- c6 y .active_low = 0,) _- F1 O8 h E4 Q
.gpio = DA850_USER_LED2,
/ j6 q' \; q7 n+ E .name = "user_led2",
+ s, e* L# l0 J' E .default_trigger = "default-on",
( S, P( z W% S" P2 R3 d8 I },+ ?0 B6 t7 p5 K$ E; M. n V0 o
{
+ J+ V3 N1 H5 s( H1 S4 S- Q! l .active_low = 0,* P) u2 _* V6 I: |* z
.gpio = DA850_USER_LED3,
" @+ q& ~7 |/ z8 ]! p b .name = "user_led3",
7 f) O/ n: {$ `$ b. e .default_trigger = "default-on",2 l; ^; ]& |: a0 D# p
},2 I ?- B/ p" H1 Z- h
};8 V3 o( _0 G9 X
" g" O, P2 i9 D) F$ c) H! Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; U3 d- A" G; Z7 R
.leds = da850_evm_tl_leds,& ]2 j1 T- u/ O3 |( C3 g2 y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! B' p- y& {8 _. i};
5 _7 D. ?7 `! B4 C Q ~" B4 w4 _$ e# k* }
static void led_dev_release(struct device *dev)+ r/ `/ k4 S# q! e# P
{1 v1 b2 ]/ W9 W" W
};0 v4 n% B) n$ ]' \5 v9 J
6 e6 ^" ]$ @" z0 k& E- E
static struct platform_device da850_evm_tl_leds_device = {
' D- u4 P( I. _/ F& g .name = "leds-gpio",
6 i2 Z7 g- G6 E p2 Q/ E) o5 V .id = 1,
& }, l8 K* w" N2 \9 z .dev = {
2 |- \% i8 R& Z- j$ |' ] .platform_data = &da850_evm_tl_leds_pdata,
: Z) P! _% Z& I. f/ y7 u .release = led_dev_release,* m+ L3 l5 K5 Z
}: L2 k" E2 j9 W& O C, N& C; H
};
: m* i+ p1 C6 X C0 A5 f3 ~8 S0 k$ b- B1 C
static int __init led_platform_init(void)6 J. R# E5 n8 }2 q( z
{
" ^! O$ _& f0 [! O$ L' ? int ret;
, l6 B2 m: L7 _& C& F% e2 S#if 0
& P' x: C2 j& n& J: ], n/ ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ A9 @7 ^/ O/ _+ _
if (ret)
& g( @( I$ N `* c! Z& C$ `+ v% [5 E pr_warning("da850_evm_tl_leds_init : User LED mux failed :") h9 U: k1 X# K$ b
"%d\n", ret);( x! P$ t0 d2 Y: n1 o
#endif1 f7 G9 l- k$ Z0 ], b) U
ret = platform_device_register(&da850_evm_tl_leds_device);5 l6 `) l" ?# I( w" `" T j) j
if (ret)
5 M$ @0 r9 k* ^! ~6 q5 \ pr_warning("Could not register som GPIO expander LEDS");. Y$ f* ^) V; |# }
else" N2 A! P+ z: x7 X% N
printk(KERN_INFO "LED register sucessful!\n");
* Z- H/ k6 D1 w! S: H0 H
) i# \' n/ K5 ]2 \9 r2 t& ?% [ return ret;
) G/ v& [! i2 B* [- ^- U: d) W}
4 l f( {: C0 ?4 o. h, q$ @# d. C0 s) D
static void __exit led_platform_exit(void)
/ O0 }" |" t" V" W( ~{7 |4 O: i1 h l) o
platform_device_unregister(&da850_evm_tl_leds_device);
! m+ H: ]: X3 G: q+ x4 I+ ^
! b- K9 V) q( U0 G! T printk(KERN_INFO "LED unregister!\n");
5 m$ C F* h2 A/ O2 n, q7 ?}
$ Q3 x) S- M4 e
, T/ c4 ]- L7 B% [module_init(led_platform_init);* V, D! V1 i4 J( n
module_exit(led_platform_exit);
. B- a5 e. x9 I! @( U/ S
. R/ h: v% _$ O' {. I, D7 hMODULE_DESCRIPTION("Led platform driver");4 U$ {; r# J8 K+ a
MODULE_AUTHOR("Tronlong");5 n R/ e' f% }
MODULE_LICENSE("GPL");
6 ?( \' F0 r) s
& ]( o, j* S3 G( h8 D l |
|