|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ L( r, \5 Y, l& u#include <linux/init.h>
4 s4 `6 J% n4 C* Z- G V# ~' ?#include <linux/module.h>" P8 m0 z3 U. F) \
#include <linux/kernel.h>
( B* @+ r! D: v, O1 g* c& a/ s#include <linux/types.h>
* U d4 S3 z9 E9 D6 A. N, F5 t#include <linux/gpio.h>, S. p' x1 g7 a
#include <linux/leds.h>) y3 l& M% Z; H7 @- W8 N
#include <linux/platform_device.h>% [" P$ P7 l* k6 ^: `1 \
1 ]1 J N- M! O$ r% j; x. _
#include <asm/mach-types.h>
# x% ?& k& X* x#include <asm/mach/arch.h>8 B9 I. [+ x6 [8 K! e* _2 [: }( l+ v
#include <mach/da8xx.h>
- l9 I$ s' `* Y) z. C( A#include <mach/mux.h>
' F; g" T: M' z0 R
5 Q9 L- w0 E1 {7 h% R7 z1 J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 B$ e3 I$ Q" ^- ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) H5 E4 E% J6 t$ Y: d+ m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& r2 L3 G' N' s F9 o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), A' i( y( c7 i9 ?# ?1 _
$ N6 q0 s& l2 S4 @0 [! b& F( s/* assign the tl som board LED-GPIOs*/) G: O. h4 O5 b9 N7 ^& ]
static const short da850_evm_tl_user_led_pins[] = {
9 Y/ S* f. O9 L4 Z /* These pins are definition at <mach/mux.h> file */
7 s" W d, S* `$ e# n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& I' t6 Z: q G9 B$ V- Z2 z -1
- G7 |) O! Y9 Q};
$ @3 q7 O; L9 Z% O$ i
7 Q- s( E1 }5 Z: Q. g9 n) Bstatic struct gpio_led da850_evm_tl_leds[] = {
6 O1 _6 q9 S& E3 x1 l" E. W {
Z% M7 \8 {+ B8 F7 f6 Y4 C1 o .active_low = 0,
9 y# T: \8 j1 @) r# R3 G) k .gpio = DA850_USER_LED0,
9 z" O/ f$ F* S8 H( G4 u) i .name = "user_led0",3 Q4 Y3 G/ H% g" P+ i
.default_trigger = "default-on",
5 P6 a- P& v+ N( T9 m! _0 C# ] },
6 m' T6 N3 y% o" O$ H) H {- s3 F3 g. ~- K( ~$ V$ m# V' P7 v
.active_low = 0,
8 E4 W& Z5 \' }( b2 i5 n .gpio = DA850_USER_LED1, \' g: R0 m$ C
.name = "user_led1",
7 o: T; D& o' ^& }1 K! U1 r .default_trigger = "default-on",
. Q3 v5 w" L" i* F. B6 \+ g },) A: f- M3 m7 R2 i" X! o
{/ m' x5 T! \- p0 \ h
.active_low = 0,* y3 _ ]7 j9 {- t
.gpio = DA850_USER_LED2,6 a- n" F/ [ o
.name = "user_led2",! a- h- D' F# O1 m! u$ K9 i$ n
.default_trigger = "default-on",( ~2 V$ e/ }/ N! P, ]
},1 f1 ^# [+ q8 ~ [8 r! {
{' k0 V6 t/ R+ h i
.active_low = 0,5 v4 V; `. |( h( F
.gpio = DA850_USER_LED3,
0 N; M- m1 _4 ]: f% j' Q .name = "user_led3",
! }3 Q; [& L, q) t .default_trigger = "default-on",# d2 N& n$ Q0 M7 ?
},
) ]7 m- T' n- c5 n( {" |};9 b7 \, r, _, B& j2 I
' E x8 _' k3 ~# Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' \/ I9 v k. Z* Z5 e. q .leds = da850_evm_tl_leds,1 z2 Y6 Z) }, F/ l3 x3 p5 f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ _1 m l: s0 {1 V. O};! a0 K9 W7 Z1 T7 Q% n3 R) f7 H; T
; |1 E% P: Z/ l6 z* ^
static void led_dev_release(struct device *dev)
, \5 V5 P$ }4 y2 e{1 r6 z$ Z- U% O/ R0 X) l, v% [
};' C6 _6 k" M9 A- c- ^
1 K- W6 F/ p' C5 z: @5 b! [# J/ Y4 ~
static struct platform_device da850_evm_tl_leds_device = {" Y- j2 ^4 {/ y& s
.name = "leds-gpio",/ r) R2 ]" n. |6 a4 h' W
.id = 1,
" b% y( r: U# L; p9 G% f .dev = {
+ ~+ H$ H/ g7 t5 J6 f# J .platform_data = &da850_evm_tl_leds_pdata,- _& J2 C' i1 D# @
.release = led_dev_release,
6 q, }. R+ K! }- o/ r9 ` }
0 \! S3 p3 T: J# k1 B' A- M};0 k: V/ w5 |- h4 ?, m5 g0 N5 _
' s3 @$ N0 h0 fstatic int __init led_platform_init(void)2 O- n6 s/ E: W; _ K6 a4 _
{+ Q/ P0 X5 Z& d9 E: g* n2 w1 Q5 c
int ret;
& \: c; S4 i/ R: o. H2 ~' I8 E#if 0
3 r; B% {. T$ w3 a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ x0 h4 s; s) d! S if (ret)
9 g- V5 l3 l# e+ ?/ Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; H; u3 U2 e/ g7 U8 v
"%d\n", ret);
/ M& i, D6 W! I3 `" w6 G#endif
: x0 H" Q* b. ]. n' ~ ret = platform_device_register(&da850_evm_tl_leds_device);( R1 C7 P8 s4 Y
if (ret)
! W8 J8 ]( |9 t7 |- I# R pr_warning("Could not register som GPIO expander LEDS");4 L' [9 @0 t5 Q; |
else: t" N& C, X- ~5 \/ A
printk(KERN_INFO "LED register sucessful!\n");
. o( g( f# X& @% d; [$ P' {" E
( s- g, n1 Q! i. H6 B b5 Y6 r: o4 ] return ret;& _, \0 y' ^5 R: m# u6 |
}
Z8 D) q( T9 _! K$ l6 j
2 t( b/ d) U5 U u- A; ^static void __exit led_platform_exit(void)& P* |8 b$ C# \& N: ]( `8 ~
{. }, \$ d* J5 [' ]8 e8 {$ P
platform_device_unregister(&da850_evm_tl_leds_device);
) {) r3 V) B3 q8 s' N6 P: U$ M: r) y; k7 B+ l# p0 }0 k
printk(KERN_INFO "LED unregister!\n");, M6 M: @& T U- X- w6 X# g
}
! a1 k/ y6 ]$ h) z$ r- {; G# g; i% [6 L
% o, [* x! Q# M9 _; r+ J/ Lmodule_init(led_platform_init);4 X" x7 J/ C: f. Q% X4 [! A
module_exit(led_platform_exit);) m, Y* c6 E" z2 C" U3 g, D2 ]
1 r; |$ N) s& ]. |
MODULE_DESCRIPTION("Led platform driver");
. M1 g4 d& J0 z7 e- B( uMODULE_AUTHOR("Tronlong");4 L7 T( h i2 Z
MODULE_LICENSE("GPL"); O- {! }8 O3 s4 Q+ |. T: z
4 q1 D+ D1 J) A1 J: u3 j" D |
|