|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 e$ G* p. ]7 }3 Q/ v! p% Y0 ?5 ]
#include <linux/init.h>
c4 x E- Z- x% O: e' u k: D#include <linux/module.h>
) u5 I K- @0 {3 K" s( c* `#include <linux/kernel.h>
7 y. W# c' D0 D G0 W#include <linux/types.h>
2 V: r2 v9 _9 H, M5 U; l#include <linux/gpio.h>
! t" s* X0 D! W: n, P& h; E#include <linux/leds.h>2 u; L$ F B$ m4 y7 f0 w
#include <linux/platform_device.h>
2 l5 _+ Y( M" L$ z4 U$ E
0 H: n. f) F. j/ `+ i4 o#include <asm/mach-types.h>
$ w, |1 |( o9 t6 [# l#include <asm/mach/arch.h>; ^7 ]' |" L# g, I: N6 Y
#include <mach/da8xx.h>
4 G( m _% h5 G1 R- F: p% D#include <mach/mux.h>' b$ P$ b8 \! c% c+ v
5 y. Q( R- P9 P- B( D3 `0 Y3 Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 E4 G. {6 c0 I) Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ W- E+ i V( A3 ^! i6 k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); M6 J# a* ^! J$ y7 R1 {: J A; m& P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). y% o* O! d3 m8 R) y9 e$ d. y. N
$ K' g) Z" d" Y' c
/* assign the tl som board LED-GPIOs*/
9 @7 B- U' G$ T# ~static const short da850_evm_tl_user_led_pins[] = {
' b% k' T( _2 Y6 a7 R /* These pins are definition at <mach/mux.h> file */" `% y+ F3 O% X3 b; A3 L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 L1 E9 w a b5 v' j# Y8 Y -15 _* P5 J- V6 ?7 A6 q C6 ~8 j- d
};+ g0 {3 E2 V; _; Z! N3 a* }
( _& R, q4 i* C: |! X- kstatic struct gpio_led da850_evm_tl_leds[] = {
; q+ i6 p- ?8 s2 H" M' U8 d {: K J8 d* n# q+ W. o
.active_low = 0,
+ ~7 C7 S3 X [7 i0 u7 _8 I6 { .gpio = DA850_USER_LED0,
1 l9 s* `1 \0 W .name = "user_led0",
7 w" @, m! \8 t .default_trigger = "default-on",( N7 L; h9 `, H
},
& ~4 {) n' K- Y/ ~+ b0 t0 V {% R: W( j2 x6 r2 G
.active_low = 0,* D( G" @# `* V: a5 d$ |2 _: L5 m+ ?
.gpio = DA850_USER_LED1,
/ ^& i+ b5 h. X/ c .name = "user_led1",
( F- H/ B% I9 v6 @) S/ [ .default_trigger = "default-on",1 d# c% }5 g, ^4 t
},; ?) I8 ]; d4 {0 {
{
# a4 \ P; V! f2 e4 I; B .active_low = 0,
, A& ~7 ~4 u- `. v& E; H0 N I6 E: | .gpio = DA850_USER_LED2,
0 S" q1 O# G8 L% t* D) i .name = "user_led2",
& S+ I' G$ }+ C$ u .default_trigger = "default-on",
2 G$ c% a7 K5 V& d3 |' P' ~ },, ~; S, D7 b0 s, s2 r
{
( u# e6 D& @) p9 ?! q* K7 N. Q .active_low = 0,8 I& g( {) r& @( [; J; z5 W
.gpio = DA850_USER_LED3,$ @" ~% a2 A! e, w$ x1 H. w
.name = "user_led3",% _7 }% @& u" q" R; D0 m$ {7 l
.default_trigger = "default-on",
! p, K! K; ?: a9 ~4 m5 }7 c },
& r+ y& z% M$ Y};
4 S+ U; N; V z- H; P% O9 D k7 ^4 `, W7 v, M% m2 f9 d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ u* Z/ }3 l% J7 [6 ^$ A5 x9 w2 j .leds = da850_evm_tl_leds,; }0 G& m1 K5 N, h0 z6 E4 \% x( x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 c/ T7 K' b9 u/ X7 r, V4 B
};
8 h2 d- Q; C* V
$ e- T& ^8 f8 p& G, v. gstatic void led_dev_release(struct device *dev)0 L$ \0 @4 y' `* C2 w2 Z7 r% P
{! K A4 f; D/ x; P4 x3 ]
};
j" E7 q1 @$ l
# V/ A) D& ]! `- r0 Q, A% F# Bstatic struct platform_device da850_evm_tl_leds_device = {5 ~2 k9 ]5 E6 ?+ P: K
.name = "leds-gpio",8 V/ _& c9 \& C$ h9 d& P; c
.id = 1,/ J } {, B0 N b
.dev = {
7 g6 w- y$ H: t; B! E .platform_data = &da850_evm_tl_leds_pdata,% I/ D$ S$ D# v1 ] X7 E# i
.release = led_dev_release,
; {1 m7 A" x3 w$ a/ j }2 H) M" s. M4 l g* ?+ `" [* x3 @& H
};/ S" G, \) }3 Z1 R* Y0 D4 [8 L, ~: P& }
$ `) F. e, Q \static int __init led_platform_init(void)
G, j3 K9 e8 p b2 ?# t/ d{
( o1 ^: ]3 w" j: F# R% ?& ^( U int ret;' Y3 @! v1 F; p& i' i; X* o% j
#if 0
- x9 ?% O! u0 P4 u$ u$ R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ O# F2 l5 h0 F6 H7 a* q
if (ret)
% C4 q9 @* @' ~; j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 o+ p- C" k; _) @' S- {. z% S1 F2 E
"%d\n", ret);2 }$ t# {# w, n0 T
#endif( E' z. e' P) u! Y
ret = platform_device_register(&da850_evm_tl_leds_device);5 l( _1 e* X1 \
if (ret)
$ N$ t# G9 w0 F. ?! V! C pr_warning("Could not register som GPIO expander LEDS");3 m0 i/ F4 e9 {; H7 @, \$ a h
else( V- A7 Q' s1 h& c
printk(KERN_INFO "LED register sucessful!\n");; ]4 a3 x4 E9 h5 V
: |/ U- {9 L a* x
return ret;
' e. U3 }' U7 l Q) {3 H3 X6 ?% ~* p: v: P}
. q2 B/ V- c- |) E7 p
( M6 z$ S6 \7 U$ @- fstatic void __exit led_platform_exit(void)% q' F, z- F& ^1 B1 q) Z
{1 n% e$ f8 ~9 ^1 v( Y# J. g7 B9 G9 |! S
platform_device_unregister(&da850_evm_tl_leds_device);& S. e9 J+ A8 Y' z- z* {
, i3 V B) {5 D. R
printk(KERN_INFO "LED unregister!\n");: F, z' F T( `
}+ y" |8 L. C% J
0 M+ D. P) r5 q# Vmodule_init(led_platform_init);
: ?2 P6 E6 v* J& N( tmodule_exit(led_platform_exit);
5 t. G) q( N8 ~7 X: Y7 [
& I' t* N b. }2 D! m) tMODULE_DESCRIPTION("Led platform driver");
) R6 M" _- Y# u2 Z. I, SMODULE_AUTHOR("Tronlong");2 T! Q3 M7 y# j, y. b
MODULE_LICENSE("GPL");
( _8 M3 l0 l7 @/ c- M$ q
. U& }0 Y" ?% D3 P |
|