|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# C3 P+ @$ A6 k+ c% s& ~. ?
#include <linux/init.h>
1 d! n. p. j! d$ v2 A#include <linux/module.h>
# w0 a' _/ u; s i! }#include <linux/kernel.h>
3 {" p' p6 |) ]9 \; v* l E0 v#include <linux/types.h>' U) w' T. P/ U! Y' F! A
#include <linux/gpio.h>
' x% R. \ H. S R4 I#include <linux/leds.h>- H1 `+ Z; P# [: {: H
#include <linux/platform_device.h>
/ Q3 c* W! A7 }% Q5 \1 ~2 q: w, k
#include <asm/mach-types.h>4 M2 ]) r" E' ^7 C& z/ ?
#include <asm/mach/arch.h>% K; Q; x% L5 R9 o
#include <mach/da8xx.h>
5 \8 l H- E: T# n/ N$ \" }#include <mach/mux.h>& X" E+ [3 X. }" ]
$ p, y9 Q. d, Z( D3 v* S; _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); m* N6 l% V7 a | [$ c0 _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), g8 x- ]; e( L9 P2 a4 _& z: V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" G; R |: [7 m% P$ l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, E) \. f/ [9 {8 p, _$ U7 {8 L! ^4 _( r& `# d) _& `+ F# Z
/* assign the tl som board LED-GPIOs*/% ~% @" ?( P$ g v
static const short da850_evm_tl_user_led_pins[] = {& C2 C. q N% n/ E/ ~( c
/* These pins are definition at <mach/mux.h> file */
6 ^! T# k1 B- F1 _: X0 Q/ u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 f7 ~1 T% l \3 v" R ] -1
7 m' h/ L1 {0 R. z# y8 q# f};
! F$ m/ y9 _" P1 P' s0 J3 {$ f
! w8 D8 S7 j2 q- Y+ x6 d- [static struct gpio_led da850_evm_tl_leds[] = {3 m% ~+ }- v j6 K+ t8 f. L/ i6 j
{: N A% h. l& i+ d/ |8 P
.active_low = 0, J/ V: G' x9 @) h, z j
.gpio = DA850_USER_LED0,
! j6 ~0 k# F1 e, b) x" t .name = "user_led0",
% O# ^* v8 F' o2 y4 l( @ .default_trigger = "default-on",
6 b# u. |0 U4 |1 a( \ },
, k4 f: c- n) |" {6 @/ |& U {
% ]5 B" |" }% j& \+ ^4 Z .active_low = 0," I6 c, N" ~& |# J4 K
.gpio = DA850_USER_LED1,$ |; ^, I' ^3 |2 E. ~
.name = "user_led1",
. [* u* X/ }6 ` .default_trigger = "default-on",
/ X& L3 X3 w( i }, a/ M3 B; \0 z3 o, w- h
{
: u9 { E7 H5 Y" d" U .active_low = 0,
- b" N4 i# _& }1 z8 W6 a/ w .gpio = DA850_USER_LED2,
0 W8 i- y$ U+ c! }! R" O* w1 Q" Z8 Q .name = "user_led2", y9 F5 Y+ n4 O$ O. \7 z
.default_trigger = "default-on",
7 J4 @# c; y2 w1 H },
( }/ m- I0 _/ }% T {
. S4 e R) D) m2 r G .active_low = 0,
: X7 H8 j) |4 `5 s# M7 | .gpio = DA850_USER_LED3,
4 e# d# d* }/ w; o .name = "user_led3",3 v4 [1 [0 Y# U- q
.default_trigger = "default-on",$ e' U/ n5 Y% k+ I9 {1 V: q
},
& D0 j' b: t& d% c' k; ~$ B};* K# u7 D2 W `4 d
2 g; D; e# z1 |! S& k, q1 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ g/ @1 S; x; y! o
.leds = da850_evm_tl_leds,
' x; g$ M1 T: ?0 ^" e .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; G* L# P, r% S& F3 Q: ^* L o};
- W0 F) T- O: U/ h/ j M( U* \* u- l; u3 G& n
static void led_dev_release(struct device *dev)' x- P7 z) H" D; V c- l% } n
{3 s4 g* M# |" {
};
' u( P: K; o: v8 h( F4 B6 e+ M2 `5 L' |. a- L
static struct platform_device da850_evm_tl_leds_device = {
& R6 Y/ o3 `5 h& ]7 x .name = "leds-gpio",
" S( b3 y# R7 a% b+ ~ .id = 1,
) Y/ g* A" Z' n4 l1 U7 F! t .dev = {6 _" Z! M6 `, x
.platform_data = &da850_evm_tl_leds_pdata,
1 D* V6 O* [( u% G .release = led_dev_release,( K4 L6 }- J; H4 [$ l
}
) d" B( B6 j3 _' B. Q7 H};) c5 w6 O4 R4 u
" q1 Q! e$ M& r! z' {) ~% b# ustatic int __init led_platform_init(void)% d. i& G" i0 }( k- D0 x
{
: U- e" i' ?1 z C# L3 u int ret;& V* l0 W: f5 [; Y3 P( v
#if 0& j( p6 f+ }* v5 @1 l( _' T
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" M/ j2 ` G! `! B" b4 p% O8 _
if (ret)4 Y+ b0 Y! L; l n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' }0 n3 r0 s/ U4 `. _ "%d\n", ret);' d3 q! s* d) `
#endif
" u8 G j" q1 ]% H S8 a: K ret = platform_device_register(&da850_evm_tl_leds_device);
: m1 j5 |, _# Q: a: i if (ret)
% O, o* \9 Y* T1 Q% ] pr_warning("Could not register som GPIO expander LEDS");
% F% X! n. s0 j( n: u3 ^6 q6 G else
\2 d: @; U7 w' I8 X. n0 C2 v' b printk(KERN_INFO "LED register sucessful!\n");9 V; b6 F X' P' }5 ?5 I
# m2 n7 a/ P: G; k3 H6 I4 l/ J
return ret;& t( I% [6 J2 \8 h( l4 W
}
q4 w% S1 T! @! D* s, X: d9 P1 n
static void __exit led_platform_exit(void)
$ m# ~5 V; m! S0 K7 z, ]{- N; L5 R/ Y$ \6 _5 d2 N6 }
platform_device_unregister(&da850_evm_tl_leds_device);/ j5 w& ]/ t7 f; |# h4 \& v
. [7 Y: n% T4 T3 W+ M0 N* e printk(KERN_INFO "LED unregister!\n");' C+ C( m' ~# R r! Y
}
) Y3 B( Z' i: {: S( j6 s8 z1 ]) R$ k/ s
8 C5 e* {, O+ X3 _' R9 f4 G( b$ J4 Xmodule_init(led_platform_init);0 r5 K1 V+ E7 E3 P# f7 h
module_exit(led_platform_exit);
: F# i! C+ E/ T9 ~# Z0 R, g: H* e
9 n' L* O8 |/ X* I* G2 fMODULE_DESCRIPTION("Led platform driver");3 e6 U5 K2 A0 {7 n0 P5 ~# f
MODULE_AUTHOR("Tronlong");% p8 B# Z# a' ~4 M
MODULE_LICENSE("GPL");
8 p) B3 ^$ N& E' j2 U; H' K
$ v3 ?' c H2 X! H$ M |
|