|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. [+ W5 ~7 o4 w. i) B1 |2 Y
#include <linux/init.h>
/ A4 f+ i' Q- p3 z( t+ z# b' s#include <linux/module.h>" }& R' P0 y( F) a
#include <linux/kernel.h>
: s& m1 X7 y0 ^# K8 v( w#include <linux/types.h>' {/ i) [* _7 o2 h, d
#include <linux/gpio.h>5 m2 t1 ^, X0 q
#include <linux/leds.h>
. B1 [# X& G3 F#include <linux/platform_device.h>
9 v% U) T# }7 r, L0 Z2 k. V8 f& Y3 m0 P% U F5 W
#include <asm/mach-types.h>
3 H3 G6 I( \; U#include <asm/mach/arch.h>" w& J) D3 }, I
#include <mach/da8xx.h>
! c8 T) q: a# j4 ]#include <mach/mux.h>2 u+ S( E- m4 l6 p
6 u. Z, J- d6 d) p( R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* J: u0 X* A5 o) n7 {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 W/ S, v$ f0 o+ i7 |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 v! f' M, G5 m; K" }& j% H# m0 |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* q7 G& D2 O R/ }# R q$ l* H
}9 z, I5 ~& l( u
/* assign the tl som board LED-GPIOs*/: n6 d/ U0 b& ^$ I: J' G
static const short da850_evm_tl_user_led_pins[] = { P8 Q! Q" I0 y; F# d
/* These pins are definition at <mach/mux.h> file */% c; o+ p/ z( b. c% _# M' s: {/ Z! D* x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 e- M8 z) n3 q% R; n, [ -1
; Y6 l Y/ e3 a" O) o1 y$ R5 l};2 D5 H; p; ?& [
+ \' }4 M3 }2 @static struct gpio_led da850_evm_tl_leds[] = {
. U+ \ k8 X1 ~) q {4 Y' W% ?6 u/ B4 i- T
.active_low = 0,
8 V% D6 p9 m( K0 Y \ .gpio = DA850_USER_LED0,
# p5 S: t3 \; ?8 e8 f .name = "user_led0",
' F! L( e4 i4 X2 u; E' A6 [9 ` .default_trigger = "default-on",' ^5 \! x. d8 E8 \
},$ ]! M! |9 G4 T2 Y6 W1 F
{2 I( \; R! S) U, p$ x2 x- p
.active_low = 0,
9 z/ O5 ?1 p: k .gpio = DA850_USER_LED1,
3 y: t& A! G5 C8 C, A .name = "user_led1",4 @# B4 v( v* U0 [$ @% P) @
.default_trigger = "default-on",! u# B2 e$ u7 D) I( l
},1 H' ?. m9 g0 n3 j5 i7 p6 ^/ w+ a
{
* ^5 Q4 T" d9 `+ n0 Y .active_low = 0,8 R9 g$ j$ W3 f% h5 `; r
.gpio = DA850_USER_LED2,
; G) N# G- d7 e) J2 J .name = "user_led2",' {* a* d* w8 B% d" c
.default_trigger = "default-on",- I( _7 m. B& r" Y1 n$ P0 E% F! q5 {
},
& |- `- Z; Q r4 i) e% ~$ p {* j$ W! j, P: r, o9 |6 n" a
.active_low = 0,/ A, \& U8 R6 K/ q4 W
.gpio = DA850_USER_LED3,9 z @# j; F& ~2 K6 p
.name = "user_led3",
1 ]! }# G% d3 g3 [; V$ T .default_trigger = "default-on",
% q: z9 h7 S0 u M },$ B+ t9 _7 h, e
};
6 E9 O* d6 c e' a' o/ J" E k* l4 a6 k0 c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 n! T5 d4 D# b* ^% m# D8 U i. L .leds = da850_evm_tl_leds, u! V: c0 k5 o. j+ ^ \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 o- z9 Z1 h, L3 B: R};$ ]& }9 @1 n) s @- e' v+ b' I! \
! B" M9 p$ e/ h4 fstatic void led_dev_release(struct device *dev)
% b) x0 R# E7 N+ B4 o0 r( O5 r{
+ b. K5 ?% z; ]9 `( m2 X+ A. Z) e};; M/ V5 p H7 `7 \$ a
1 H0 {2 S$ }/ i. ^& i
static struct platform_device da850_evm_tl_leds_device = {
% Q! q8 N+ m# a( t7 o2 u! J' V/ @ .name = "leds-gpio", W5 _' ]% |3 F: y
.id = 1,3 g6 c7 L$ Y7 d8 m% u; R
.dev = {
4 d1 T! ?, {3 f u/ { .platform_data = &da850_evm_tl_leds_pdata,
- D: t. m ^# W2 z .release = led_dev_release,+ u* C5 P8 o# Y/ A3 J
}
5 b' ]. e! U* Z+ X4 t};! a; Z z4 Z" T" @! E: ]& @* x
" y7 q& K4 \* ?0 G7 w. Y3 hstatic int __init led_platform_init(void)9 h/ A0 m& @/ D J9 m* N1 Z
{1 @9 {; s* D& G( a$ t
int ret;
) t3 U4 W# \1 l7 [& m#if 0( r. f3 `% `. W8 E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! ]: E( I* L' e& h8 p/ T+ P( `3 ^
if (ret)1 [, A. G% A% x1 I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- Z* J1 z4 y. U) d/ |3 Y# m; ] "%d\n", ret);
8 a& q0 X/ ~0 t. e#endif0 e$ K" @2 f$ d5 E/ A" o. P
ret = platform_device_register(&da850_evm_tl_leds_device);8 y; \) p( Z6 N) P0 V: h
if (ret)
) B. Z( {7 ~; p2 E pr_warning("Could not register som GPIO expander LEDS");
( H& `/ |: C* F, o$ e; T else
6 K4 V8 V5 q1 d& {) h$ R' T& r y printk(KERN_INFO "LED register sucessful!\n");
6 i& s% z( k* g! @8 u
, L+ O+ J: u) y @% N return ret;+ r+ J1 p0 o6 k3 R9 r- {1 O2 z6 Y- p1 {: t
}7 j1 K/ M* W- A% ]' M( o) b- i8 h4 \
/ X+ d4 Q/ V9 u2 Y: Rstatic void __exit led_platform_exit(void)9 A# }& p4 X5 a) l1 o
{- X" D! K o7 p. C) ~6 k
platform_device_unregister(&da850_evm_tl_leds_device);
! Y9 E( z( M7 @& l* q8 S! o0 s% ~
printk(KERN_INFO "LED unregister!\n");& V$ Y, z1 h; s
}
2 l. E+ O- C; s u9 w- {; n/ z V2 A! k. w7 r$ Y7 \3 l
module_init(led_platform_init);
. \4 ]$ q5 k3 amodule_exit(led_platform_exit);- }% i r, G, ?& Y8 o- ?
+ }' W7 c7 Z6 m2 s [5 |MODULE_DESCRIPTION("Led platform driver");7 P+ p2 \6 g: ]) `
MODULE_AUTHOR("Tronlong");3 w& K" u/ K) G
MODULE_LICENSE("GPL"); o6 {8 D7 F6 A( A" o) W8 n8 S
8 Q3 e9 G; T+ Q# Y4 ?7 s r
|
|