|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 I. {- p% C5 l! H
#include <linux/init.h>: _% A, q/ x) y: L$ i6 X2 T
#include <linux/module.h>
; z( f i. ^ Y7 o#include <linux/kernel.h>, O, I- q/ ^$ t ]: z1 P7 }
#include <linux/types.h>1 \1 n- w( ~. F; K
#include <linux/gpio.h>
* {# ~' i U: Z8 g: D#include <linux/leds.h>
. l& o. a4 W h1 o. ]" ?+ _. _#include <linux/platform_device.h>
, U% X5 q. ]* i
1 K" x: O$ R! p7 I#include <asm/mach-types.h>
2 }% Q8 G% Y4 N#include <asm/mach/arch.h>
2 p" E' O. ~$ @9 _& P _5 }1 b1 Y#include <mach/da8xx.h>7 l8 f( D/ \5 R" |; L5 C7 _, |8 v- R
#include <mach/mux.h>2 ^4 b/ @0 N- X" h: W" J
; H2 w3 Y2 R$ g- n6 n) A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 L9 }+ N) t; f, O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 b0 B l& `8 m& F' g3 Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# L- E# N9 P/ W* L! R9 }5 z( _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! n) @# f8 s: L3 S4 s
2 v$ I J! B4 ~: \ Y$ f
/* assign the tl som board LED-GPIOs*/
8 T0 j2 X4 ^8 T( Cstatic const short da850_evm_tl_user_led_pins[] = {# E X* Q: w. m& X4 ~$ D
/* These pins are definition at <mach/mux.h> file */
9 o( y3 P: Y, ]) Q% h! g7 m DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. {5 T0 w9 K8 ]2 F" a
-18 m, U( p3 q2 L f, Y. P/ E' I
};: r" r0 V$ ]+ g# E
; S9 k5 M' d2 q& T: P
static struct gpio_led da850_evm_tl_leds[] = {
2 @0 }" @. d+ q+ ?) M {0 r9 b6 f% m( ?. f1 b. W5 C. H( D: C6 B
.active_low = 0,/ c# E! E3 O8 t1 p, a& J% a
.gpio = DA850_USER_LED0,
1 U2 Z: c5 f1 h/ k. ~ J% ]$ W4 s .name = "user_led0",
7 R* f3 @- ]: e1 G- u+ g) F .default_trigger = "default-on",
: M. p" j% h: O( I },% o. w/ p, x# p2 S q
{' }" n: q( K4 e5 g# v( V7 `
.active_low = 0,
8 }# G k- U; L' ^7 d4 v .gpio = DA850_USER_LED1,. G3 B5 I s# u: M
.name = "user_led1",
5 f" T' M1 S3 b2 s1 V) m, q .default_trigger = "default-on",5 O5 I) [) ~3 Q+ J) g7 `: a; Y
},! F4 ~" o4 H' b& p: E3 E8 t
{
; A* Z3 r) w4 D. ?: Q .active_low = 0,
' C9 L/ N5 j" ~% P; O3 P .gpio = DA850_USER_LED2,
) ^/ S1 V8 [( B: E6 B .name = "user_led2",
( J; h& b+ u. @8 v ` .default_trigger = "default-on",3 @9 }7 k, u$ q7 y+ T: c9 @4 w5 u
},* u! K9 g" ?6 J/ `% v
{, v5 Q/ K. U# X& f
.active_low = 0,
- z; N. Z1 r' z/ A3 ]: b5 }& K .gpio = DA850_USER_LED3,1 ]( ^. o7 b8 `! L' _, o |
.name = "user_led3",
- y/ O% }. E: U6 M+ t .default_trigger = "default-on",
, m& `3 Q0 A& ~ },8 l, n/ h) v5 d5 v
};9 Z. F$ e1 l4 y" M# `4 j6 Q7 b2 [7 ^
0 k, r6 n5 g; m! {7 m$ f: _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ @( P9 Q' T8 u' Z
.leds = da850_evm_tl_leds,! L$ B! ~; }/ o. r9 w
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* C( L4 ~1 v. x" v4 F0 F3 K# E' t};9 n' Z/ k9 x2 N/ K
5 i* O- a( D2 u4 Bstatic void led_dev_release(struct device *dev)' U2 F3 Z) i* B1 _ {0 P# o
{
+ |1 |+ }6 d* R2 L0 F};. v/ p" Z" O! d) c& _
, |7 a3 l1 N6 f% o& Dstatic struct platform_device da850_evm_tl_leds_device = {
# d" S3 [" {4 x8 Y Q& B/ [& I .name = "leds-gpio",8 {% }2 K4 B$ A0 e2 H* m: x
.id = 1,# y! Q, q& {- G7 @5 s) l
.dev = {" C2 T" i( ?: @' H" K8 m$ g6 V O3 a
.platform_data = &da850_evm_tl_leds_pdata,. k" x0 j8 a: ?1 x- d# L/ W5 Y
.release = led_dev_release,
# g; o2 i3 e" E% o8 S/ G }* \, l) ]8 E( ~ f4 s/ Z# w4 n
};7 q7 I" ~$ f, D9 R! O! H
- q6 h4 b6 s2 ^5 A! @$ M8 f+ u
static int __init led_platform_init(void)
$ ], U6 D/ T0 s5 G{
8 {* b# Y6 s8 t9 |2 A int ret;
1 F" A& T6 B/ e! H' M% l* C#if 0
- y7 n7 B. w5 A! G# C; R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' ^2 g, B+ C; ] if (ret)
5 O9 {, E; y5 h# \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ E- d' i8 `! k4 K# G& ^, D
"%d\n", ret);
+ G( N) _ w+ W r8 b#endif
; h: j. E; x6 j/ |! `' _ ret = platform_device_register(&da850_evm_tl_leds_device);
% ~# H+ ?0 Q" ^+ X if (ret)) o7 Z9 O3 P* |7 e& Y- P& Y8 C
pr_warning("Could not register som GPIO expander LEDS");
+ C- L4 S& g% S' d1 j else3 X# p+ J% g; k6 r0 q/ t7 d
printk(KERN_INFO "LED register sucessful!\n");5 [6 B- x3 u( n% j, F! ], K) L( t
|1 M0 U6 @* F# o7 U
return ret;
& J0 q. m' S/ ^% I- `4 I}
2 _0 y- m% s* V" h. g/ s+ D6 A3 o% D
9 u- ^5 A3 L& l* {3 Hstatic void __exit led_platform_exit(void)
3 n. o+ J* |1 E4 U& D R5 F/ c{8 C4 Q. h. Z% z; `+ w
platform_device_unregister(&da850_evm_tl_leds_device);# f9 |2 d0 G2 k4 g( l
5 G( F. w0 S, \9 \7 x
printk(KERN_INFO "LED unregister!\n");
2 d& t6 t6 R0 k3 s}" P, |% e9 d. C6 p8 s3 o
4 ^) @4 S$ w) h0 g! ^
module_init(led_platform_init);0 ]9 x0 _: ]! `
module_exit(led_platform_exit);/ \4 ]. P0 \2 S7 o/ V8 ^
# o$ v! o% E4 fMODULE_DESCRIPTION("Led platform driver"); r8 U' [! R; W
MODULE_AUTHOR("Tronlong");
7 F2 w$ e! S3 F O! ]MODULE_LICENSE("GPL");+ j2 ?& k N: L4 X/ B
2 P. l6 m# h* f |
|