|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 T$ p6 M$ {. X7 h6 A
#include <linux/init.h>
4 h( K) M( }5 G: |8 D6 |& J#include <linux/module.h>
7 _8 _* g( c, p% L#include <linux/kernel.h># ^; u' S6 I7 p" D) [: J a
#include <linux/types.h>9 I @( v7 R! A9 D }) U5 D! N/ ~
#include <linux/gpio.h>( S4 ^, [4 ~, Y J" X5 Z
#include <linux/leds.h>
1 z F* M% o; M! \#include <linux/platform_device.h>
0 C4 b- r" I2 ~ f$ }7 |3 C/ }, B7 w+ g+ R# e7 c
#include <asm/mach-types.h>8 r) X) G0 }) e4 u/ V5 V
#include <asm/mach/arch.h>
2 i8 O8 \8 D7 A3 ~4 w& V' C& I#include <mach/da8xx.h>- E/ W- n0 E$ U
#include <mach/mux.h>9 E% @' B Z e% X0 l
; K- @3 H9 C7 `9 D& p1 s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ H2 d$ r6 L4 z$ [1 h( O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: p4 R! u4 D- a2 `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 R/ o# h1 |. } ]2 E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ f6 M( N9 v2 H3 C0 ^( O
: X+ o+ S0 z' L, s% A: S
/* assign the tl som board LED-GPIOs*/# G& E) ^! K3 L# Q
static const short da850_evm_tl_user_led_pins[] = {
$ w' c7 k% C2 |1 E( l) B /* These pins are definition at <mach/mux.h> file */
Q; M+ c8 O' l# \6 H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. i1 ?: O2 I7 A3 x+ }- l
-1* m4 Z9 r& K, X# ^$ O& z) s
};4 s) a! J/ I* v8 B
8 x/ m) z E! L
static struct gpio_led da850_evm_tl_leds[] = {9 G' ^$ w; a# x ~* u9 {
{
& Y7 V. O+ G+ ? .active_low = 0,0 ^" y% v; P1 N2 f% q
.gpio = DA850_USER_LED0,
+ @) ]/ ~' H- g4 L* o7 |" M* \ .name = "user_led0",$ u, ?1 p2 X1 e m( e- U% }
.default_trigger = "default-on", Y/ \2 h7 P5 W2 F5 p
},/ y4 ^' H2 A2 X' F: S
{: w0 f: O7 X# [4 U p% v( `5 w8 S
.active_low = 0,$ ^1 \7 d6 l! \+ l
.gpio = DA850_USER_LED1,* V( w" N* @0 S8 s! B
.name = "user_led1",3 q* ]+ g7 W- [+ W8 } d
.default_trigger = "default-on",* c) X7 ]% o+ j
},' v* A" g. g; b& _2 Q R0 @
{
4 M7 ?" |5 q0 F9 o6 ]- o$ Z .active_low = 0,& d, X; y) J3 j$ w1 k5 Q1 y
.gpio = DA850_USER_LED2,3 I2 M9 g* h) V% d, T# e
.name = "user_led2",: @3 ~$ _5 Z8 b$ {, }6 y
.default_trigger = "default-on",0 c- n" K2 E/ f
},
# ?. ]2 {- c0 S( ?* `* Q; B {
I/ b! X" r- Q; w+ H .active_low = 0,
' m2 I/ |, l, J. h .gpio = DA850_USER_LED3,
# p7 n2 v. N! u+ r( X! f .name = "user_led3",+ {! H' R# s5 P& p# S
.default_trigger = "default-on",5 S7 ?6 g4 J" d9 a m
},% V2 h: g$ i7 V; Z E+ l
};
+ p' z- Y# g$ z7 T" k4 `
0 ?3 I0 @9 |1 D% {7 {- ~0 M/ hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 c% \# P( H7 b: D" G
.leds = da850_evm_tl_leds,
8 D( V! d w+ `2 N3 k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# W' l" U: t& Q: M};# S* X% c5 K; ? X) Z
N ^/ T# w% P& t" t2 J" U0 ~
static void led_dev_release(struct device *dev)2 \' l- x' o* t( D7 w' z. Y
{0 L& g3 E0 p: m( ` I4 L# v
};: ^% f/ P: Q3 ?) n' r& H
2 y) { K! \6 o r% p
static struct platform_device da850_evm_tl_leds_device = {
$ Z& {: w- e; Z# c% r .name = "leds-gpio",6 k- I+ z9 D( u; c! z
.id = 1,
" ]* ?+ d3 F. a2 J, y' s. K .dev = {
t: E- m9 A' J" k .platform_data = &da850_evm_tl_leds_pdata,
* M0 Z1 n4 }1 h' M. z I .release = led_dev_release,
. U9 U1 d, f5 V- w8 B- m0 k( W$ y+ X }' l) u& m, u2 a$ }
};, o p' U% k) w. z+ @% x2 @
& P( J) B+ V8 N' E. x1 |# mstatic int __init led_platform_init(void)
9 f1 S; y8 R0 V! G$ Q$ n3 T$ x{5 q2 \6 d: N; n6 `4 s% ~ S, v
int ret;3 c! F* I% \: O7 p
#if 0, Q; h3 w2 U& B* o6 i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" H7 D+ ?4 R& W0 T% |' S
if (ret)7 t- N7 b5 p! x. g! K0 H5 a1 z; K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ M Z7 }" \8 I1 V+ @5 O$ ?1 E) U "%d\n", ret);$ T) \0 h! a; @ w
#endif
! B5 F6 X( x; H5 ` l5 P+ p ret = platform_device_register(&da850_evm_tl_leds_device);* k( y+ c* t! t$ d. h
if (ret)
' i$ K5 x% R- ?0 f( \' V pr_warning("Could not register som GPIO expander LEDS");/ g* U- m" R) b$ _
else' C; p6 T/ B% N2 O
printk(KERN_INFO "LED register sucessful!\n");3 S8 C9 f0 c2 N% Q
' U# G" |7 P" o( p$ @ return ret;4 z7 B$ A2 W9 y1 W8 I; \# j# J
}3 g! A7 _& B: C+ D
0 W C! u* d4 z$ e
static void __exit led_platform_exit(void)
* G# I: D) j: d7 J% j2 z{3 _2 Z& @; g7 B3 w2 y! f* b: j8 N
platform_device_unregister(&da850_evm_tl_leds_device);
; T6 ~' A' h1 M6 t% d [+ b: B( ~1 v- \3 g: ~
printk(KERN_INFO "LED unregister!\n");
: V6 F3 u* N6 [3 s! K7 }}
) Z: p& \% f: A. |- F" k2 F; o7 q+ J+ }/ c2 ]
module_init(led_platform_init);: h: _, F) h8 e+ Q3 t# a
module_exit(led_platform_exit);
6 e- `& d j" m- k. H! Y
9 o+ T; j" m2 l7 U& m( g0 nMODULE_DESCRIPTION("Led platform driver");
0 j$ k* S8 f* R0 xMODULE_AUTHOR("Tronlong");- G& |# H8 ?/ w+ i
MODULE_LICENSE("GPL");6 K2 w( }1 l# q0 F& i+ m! _
2 `- S. U# a) u& s" V! ^, q
|
|