|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 G$ Q' H3 p6 F d4 U9 f% c
#include <linux/init.h>
+ m5 p8 R) h7 T4 H- B2 U#include <linux/module.h>' m& ?4 [5 M7 e5 f* v! e
#include <linux/kernel.h>% }& A/ o; N) D4 ?1 Y/ U
#include <linux/types.h>
- V0 _! m6 _' T- _' t, ~( C2 M#include <linux/gpio.h>
& x4 O! \, ]0 \! U' U a#include <linux/leds.h>- Y m, M- t% Y1 G
#include <linux/platform_device.h>$ L/ n; B; e% N2 x9 t8 p
* C% G' p3 @; e% O& O; m& _5 w#include <asm/mach-types.h>
2 N. X% L8 s u+ U4 \" f: ?#include <asm/mach/arch.h>
/ I: M" r9 P8 ? ^+ M#include <mach/da8xx.h>2 F- r9 m. g8 s8 I7 r7 y5 J
#include <mach/mux.h>
2 R& }$ |! w3 G, m( k8 K9 Z; f! k, }1 Q4 N' L+ _. P! b: ?" @0 q6 }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 y) p5 z0 D0 o0 g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& e8 }9 d; B7 V; x4 w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) U2 q9 G% _: ]( }& F. n, I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 O V, _! ^. S# V+ t
7 h y; _1 T' @+ l/* assign the tl som board LED-GPIOs*/- _+ q+ z4 ?3 W! U8 M
static const short da850_evm_tl_user_led_pins[] = {$ T+ C- l; ~( _
/* These pins are definition at <mach/mux.h> file */
/ \3 v6 N5 b+ w* u: ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 ?) Z- D* ?- @0 B7 N+ ~, { H5 C
-1( Q4 j1 K( H" x Q
};. I1 ~7 Z% N/ e0 q. U
: B: v! \( Z# ]6 j6 z7 w4 ostatic struct gpio_led da850_evm_tl_leds[] = {
4 O% B# I0 ?: ]$ e( m8 n {4 P3 j6 R# Q9 Y. ]' t
.active_low = 0,, V# Z& v( x3 D$ b- l, }
.gpio = DA850_USER_LED0,) y7 U* C/ A1 E5 ?/ t5 d+ i; }) H
.name = "user_led0",
( O1 a5 G0 r! ]3 l* K: R .default_trigger = "default-on",
/ [" @( m% @7 `3 e' O: Y },
% W/ }& j& O/ E# p3 j0 S {
+ v/ D' ?" \: O, h0 v .active_low = 0,- s* @$ h) |6 X+ m; Y' g* D- G4 h
.gpio = DA850_USER_LED1,
8 _% O; P, }+ ~; E; d' K# z .name = "user_led1",( `* k7 ]% S" f' x; {
.default_trigger = "default-on",4 I' H$ s, s' m7 ^) k
},0 Q& u0 `$ y' s9 k
{% _, L. l/ _: v% r
.active_low = 0,, P9 ` o+ H# E! Z" {& _' y
.gpio = DA850_USER_LED2,5 Y v* c2 O$ {$ U
.name = "user_led2",8 U: b! ^4 L. f( C' h
.default_trigger = "default-on",
( _. A7 T# s$ F& Z/ g: C) w) Q },
5 ~' H" K8 u$ B( K' E {
5 a3 y1 H) }, Y# t! z( ?& w$ G .active_low = 0,( B( ^' {! H- `) @6 ?! l
.gpio = DA850_USER_LED3,
, \9 p0 c1 u/ A: | a0 u .name = "user_led3",( S+ M5 O: q" ^+ X# X/ i7 C* o
.default_trigger = "default-on",+ @! g! m# a& G+ P+ g6 J
},
5 Q6 k) f$ ^" B" J};
( f: S8 ~7 u# U+ N- t0 [" p; r: a1 q. ?" y, R) X' ~6 _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ I& Z2 J0 _5 b% T0 T6 U' T U .leds = da850_evm_tl_leds,
5 I# y/ x" t" k6 L! L0 x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& t; u c' F. {- j7 u};3 U4 o0 v7 o: c |. a, l. V' }
5 C( P7 ]0 \) } u& Z
static void led_dev_release(struct device *dev)
, d1 Y, Y$ \; n5 O* r/ o# b{
5 ?3 C8 d9 Z5 X2 d- h s9 z5 \. |};" R. N- a* A& e" q y9 G9 |: A
C, \$ _; Y ~: Fstatic struct platform_device da850_evm_tl_leds_device = {
8 k% M, j2 k z .name = "leds-gpio",! a% O' {$ O p8 j' |8 {) h; s
.id = 1,
) T+ t5 ]- \; d5 H, u. O, E- V .dev = {
; n9 x9 l) B9 Q* y; E: n .platform_data = &da850_evm_tl_leds_pdata,* p G% K. m! g& m- e8 {8 p
.release = led_dev_release,
) @1 Z" h# T! h( i } C& m$ `5 I ~' w: h9 J; G& D, H2 L
};
5 q) N5 U$ A6 w0 k' v* ?" i8 [) W4 f7 ^5 f3 L, d
static int __init led_platform_init(void)
: H' l$ `6 x0 j# X1 B{$ S- F- ~* K1 J; d2 i: d7 N8 k
int ret; `+ y# |% [# X
#if 0
* }, d- ]; P+ E, g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 ~( Z. A+ R, |* G4 e1 O+ F4 \$ O* V if (ret)
- R2 O9 J6 A" V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 h4 i" ]' O; W7 m
"%d\n", ret);
+ |2 ~4 Q1 j1 |+ B+ V#endif
/ u7 d F$ C5 o ret = platform_device_register(&da850_evm_tl_leds_device);
1 k) R, G e1 L- h9 k if (ret), g2 ]3 ^2 S, S
pr_warning("Could not register som GPIO expander LEDS");" e) d) `7 i) V" o6 D+ j
else& C3 s8 |" E4 ?$ H0 W* N
printk(KERN_INFO "LED register sucessful!\n");; ?" ?5 n; ^# }; [$ h
+ s0 J, E% O" a/ L) s return ret;
! t4 _& c1 [" R; b) W7 n3 t}
; e* b5 a& q6 w" ?/ _- |
* J; g4 x0 t" n5 @1 Dstatic void __exit led_platform_exit(void)$ U& `' q) ?6 w: E
{0 B# b- ^2 P# d2 W
platform_device_unregister(&da850_evm_tl_leds_device);
; c- ]/ y# o. j# I- d
N& d* C9 Z4 j printk(KERN_INFO "LED unregister!\n");
& p+ W" u) N6 O; ^! C z9 B}
" \# U/ C0 M! y' j8 D/ }1 h+ c1 a2 |: Z( P ?* P/ [% f
module_init(led_platform_init);
0 A+ V. L) }7 ^ @6 E' y( s$ Nmodule_exit(led_platform_exit);
4 ~& U: `% o; w4 V# ]
+ v" S% z3 K& ZMODULE_DESCRIPTION("Led platform driver");
: J: F) m! |& v) r) g4 o3 @MODULE_AUTHOR("Tronlong");
3 x3 c7 {+ n; e, L0 ^( oMODULE_LICENSE("GPL");
/ s7 M" i& N4 p# \( u R8 O6 z0 h8 t& p" s: ], u
|
|