|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 W) z! v/ f% i' C h6 [$ z, N#include <linux/init.h>
1 y1 X) D4 U6 o. C#include <linux/module.h>2 b3 F8 q' H) p1 S
#include <linux/kernel.h>
. ^4 Z5 _3 L2 ^+ r# _" H. r#include <linux/types.h>
. g" p. C& x1 \" F3 o5 U$ @#include <linux/gpio.h>* `; j$ q& `" V' `; i+ E8 A
#include <linux/leds.h>, D+ i2 z; T1 P. M$ p
#include <linux/platform_device.h>3 L& B: H, |( b+ l8 i
& v& W! m% X4 y
#include <asm/mach-types.h>
/ `. U5 ]0 O- c% W! r3 f#include <asm/mach/arch.h>
; i& B9 T2 u* w0 h: j' X2 L: D- ~#include <mach/da8xx.h>3 w8 `& N* g/ {5 _ V: W5 W
#include <mach/mux.h>
2 F/ {2 w# ~( a2 K( _. x0 h$ z/ f# W) K9 t x7 {! p2 k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) o* `. d! P! J& I& l
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ {' }* D1 p! b2 q( N4 U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 P- Q( y! U9 r- ^6 A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ K s: q' b) H/ v" o4 t; a2 G5 A9 w V# `$ D5 U# B# h
/* assign the tl som board LED-GPIOs*/* c' I6 z1 Q+ d% A B: A- [
static const short da850_evm_tl_user_led_pins[] = {
. v$ G! `5 S9 V; S+ h9 U /* These pins are definition at <mach/mux.h> file */( `# E' V% W( Y w1 }& _( L# h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! m" @+ _& h7 O2 t9 }" e" v" }
-1( s/ M0 S6 ?4 y! C) W5 P, }; P% A
};/ V/ C$ `/ y- ~" f) e6 v
0 c% x+ Q. l* F
static struct gpio_led da850_evm_tl_leds[] = {
/ h( p) m- F* w9 v1 d4 {; J {
2 T2 P T* H- z+ j; j .active_low = 0,
& p. u! @. y- P" \- W, j0 W .gpio = DA850_USER_LED0,
4 [3 v* k3 i9 c8 M* E$ I' O .name = "user_led0",
, l7 z% x$ z1 X' r7 u2 U K7 k .default_trigger = "default-on",8 L, v7 {; y+ X8 T; g" v; F% y
},
' @& N% t% m! S- ~, ]1 W- w: K' w {
* ~% F) m+ q9 d& ]7 W) C( L( f( m .active_low = 0,
8 G0 |+ g o8 f* U" o ]) `2 Z9 D .gpio = DA850_USER_LED1,
( O7 t, s: ]7 e M$ s) \ .name = "user_led1",7 j9 @6 U- p) E
.default_trigger = "default-on",
8 n7 e' v2 B& N1 s },* y3 t8 i' F# C' r4 a/ \- x
{
' ~1 e4 j3 y) | .active_low = 0,: ^) P4 b* H) K- V
.gpio = DA850_USER_LED2,% g: z- |/ A6 E6 ?
.name = "user_led2",
/ z8 P G9 F+ h( ^" }. {, y* G .default_trigger = "default-on",3 {" j4 `& }9 F/ Y( c3 d* Z
},
* R2 c& n [% q9 V! \4 v! W5 h' m {; J2 N6 S7 i8 t
.active_low = 0,
" m1 B j7 J0 i- Y5 M .gpio = DA850_USER_LED3,0 s3 o S; I. R$ `+ O" \
.name = "user_led3",
- i2 w% P/ G2 o4 a" o/ |3 }' w .default_trigger = "default-on",2 L8 ~1 ]6 u' c9 j+ j
},' H5 j8 q- z# W/ q; ^* |
};
" M% O. K" p$ I8 [% P& [: } Y
% N d/ O7 }" V9 B" Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 I2 V5 Q s* x+ Y# f# I
.leds = da850_evm_tl_leds,
! d, t, n+ o& Y4 ]- y K. a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- ?/ S; g1 Y' W; E$ A
};, i! s2 d P6 b& G; E* i
. t0 _) i" x# k3 U9 [0 _static void led_dev_release(struct device *dev)) ?0 `% P7 ~& ?6 h. l
{
% O8 @4 Q$ m9 y* ~};
7 M6 ?) M9 k$ W( v
0 N+ `- s8 u7 a; `static struct platform_device da850_evm_tl_leds_device = {8 l1 G* f, f4 g0 [, B; y/ M
.name = "leds-gpio",
* c' b- l5 ` `6 j& [ .id = 1,
- _$ i' G/ x' p/ r8 D5 D .dev = {1 k& N" D2 [5 Y
.platform_data = &da850_evm_tl_leds_pdata,
5 t& |; Y8 ~1 ` .release = led_dev_release,
b. N# S$ e9 y' U. s }
4 \1 D( ?* J5 v, o9 q/ J5 Z};, |" e& e9 ^( c
3 r3 P ]$ P) \9 K4 |
static int __init led_platform_init(void)
( K% w' W o0 l' A/ B0 D{
; U1 P8 K& X1 w/ O int ret;
" @! P5 C. Z$ b' y" y" l#if 0
( T" N A& I, |% `! { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- g+ X8 s8 ^; ~0 A8 L3 V) ^6 B+ N if (ret)
) I8 v4 [3 V* @1 I% r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; j3 }$ b$ h4 n "%d\n", ret);3 |, X: o; M: Y- \2 @
#endif: T; h; M! _5 n v1 E6 b0 I: x
ret = platform_device_register(&da850_evm_tl_leds_device);; ~% h( w- S* W/ P, c$ n
if (ret)
* }# A0 i$ s- L7 u$ K' x1 G pr_warning("Could not register som GPIO expander LEDS");+ k$ J6 ]8 \6 y# i L
else, P$ ?. U/ u7 z5 X& x: ~7 i x
printk(KERN_INFO "LED register sucessful!\n");
+ [- a7 Q P1 a4 s* f8 i7 G* ]4 y; c
$ Z+ u- @' r) v return ret;! n% O# ^ _7 G* D1 v7 V# ~
}
: M8 `; u' Z% O$ W5 @
' e0 S" R% X' Ustatic void __exit led_platform_exit(void)
! w$ g- e7 F; }9 x{
, A6 N H% ]! q) e( K platform_device_unregister(&da850_evm_tl_leds_device);
+ Y* t7 D8 ~8 G' S
3 a5 ~* W* b: {# H, M printk(KERN_INFO "LED unregister!\n");
6 d# ]! w. Z k6 Z; H G% a [ F}
7 G' |) J. g, ^# j) i- h( V- T3 J4 v( E5 J2 M
module_init(led_platform_init);
1 Y' q* G* W7 l2 r) U& [& N' @module_exit(led_platform_exit);8 n# S/ T8 F3 [
! W: i- Y. j5 |! ?+ a' i
MODULE_DESCRIPTION("Led platform driver");! H2 p3 ~+ Y1 x. ~! A
MODULE_AUTHOR("Tronlong");, ^# Q" @& m- x1 t
MODULE_LICENSE("GPL");% ?; u/ e, r( J( r5 a* _8 h
/ D6 j2 x( m4 e, m! _ I% T
|
|