|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" Z u; _0 {+ i% n#include <linux/init.h>
' Q0 r7 ~4 d4 A& {#include <linux/module.h>
# Z! F& ?% ~- i% Y- _+ b( O, _#include <linux/kernel.h>6 e# J3 m3 a* g$ R$ H
#include <linux/types.h>
: K; J( t5 N1 h% I( e" t#include <linux/gpio.h>
* L! `2 R+ J3 [; `6 y* I: L: K#include <linux/leds.h>
1 L' l. ?5 h2 f* C4 V#include <linux/platform_device.h>
) _, r7 @( s9 t3 r( @9 U7 C9 B( f) v
#include <asm/mach-types.h>5 ~8 q4 p- N4 q" L; p" l9 o
#include <asm/mach/arch.h>
% |. O/ ~. } [' @7 p. S; x#include <mach/da8xx.h>9 Q1 k, }4 S4 n6 g
#include <mach/mux.h>
- g3 t8 ?9 [& D9 A1 \& y1 z. [% t( L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 S2 {; `2 c& j5 e o- b; d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 B1 `/ ~1 Y- {0 g, l#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 L6 Q6 O' g& O) ] w0 F! ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 b8 Y+ R) g' h/ a- X5 B
4 S2 t9 i& x5 I, V7 E3 u; l
/* assign the tl som board LED-GPIOs*/
# ~& \# y6 k( k, U) Cstatic const short da850_evm_tl_user_led_pins[] = {
9 @6 L5 U/ B+ |' o6 S /* These pins are definition at <mach/mux.h> file */, k% Y; p0 D; \0 K: o9 m8 U* d
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 J& A5 E* a! P
-1
; J- b7 ?) Y; m% h};
* ~; K% |6 Z2 b r5 W+ @3 E) V/ A- z
static struct gpio_led da850_evm_tl_leds[] = {
: J E7 D3 b$ v8 W$ E6 \% P1 ~. G5 L' G {
. c' x+ T& u: H! ? .active_low = 0,
* |, U+ p+ |$ n5 g9 W" e .gpio = DA850_USER_LED0,
+ K8 y/ W/ }1 \6 W1 l% o .name = "user_led0",; E+ G2 `. {: M" A* V6 k8 F
.default_trigger = "default-on",
e( ~0 s" o% e/ B5 B4 M },
9 ]: R% B3 _( F7 N5 v* D% f! c {
- I/ ? d+ z3 g( K- h# d .active_low = 0,4 }9 _3 }* |% H0 [, q7 v
.gpio = DA850_USER_LED1,
' t! I. G4 O S( ~- q8 l .name = "user_led1",
6 _+ i8 E. m2 e7 `) Q- B+ R E .default_trigger = "default-on",
( X0 e& \+ v$ z- C5 N },
# m5 q, I$ z; {; R m {
3 v7 a3 F! m' r$ m .active_low = 0,* @6 p1 L9 u) J9 A
.gpio = DA850_USER_LED2,0 L- d* l) j4 \& U* ]! q/ m
.name = "user_led2",
" ]; q4 P6 a3 c1 j4 d .default_trigger = "default-on",# [: C' q6 I2 c+ }
},
2 b; n& k R$ p U2 N! Q {
1 b: O( O H1 W .active_low = 0,# G2 I2 _+ v6 g' h4 ^/ j9 O
.gpio = DA850_USER_LED3,3 j. P& k; m' G0 L8 r0 J5 _
.name = "user_led3", v$ w: W0 e7 U$ C! @; n
.default_trigger = "default-on",* ^' h8 i* L2 G# \: `; s% l9 G
},; }: r" ^9 V, M4 b2 L9 X6 H C
};+ }8 `) u0 t Z% {8 Y' m
" v6 Z: Z2 S" N+ c2 h0 Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 R/ n& t ]) X3 S .leds = da850_evm_tl_leds,- `: V, q( `9 n' t+ b4 k) J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ C( u1 J! C# K* @8 z; S
};
( O/ A& f; T. b3 m
9 L. f; S% @: K+ ostatic void led_dev_release(struct device *dev)% K' I5 K' q9 q* T0 w
{% V) m3 U. G* |4 W- R( V
};
7 s" V8 f/ a9 M- t& j% n4 Y$ r9 U' ]
static struct platform_device da850_evm_tl_leds_device = {* ]3 ^. ?0 {6 l0 |) j {; I; x
.name = "leds-gpio",, I* @4 s6 i/ v3 U5 F5 y/ V
.id = 1,, q4 D" X2 K! G$ T" ^' k
.dev = {
* t8 H+ r- e9 w* V* t, F$ } .platform_data = &da850_evm_tl_leds_pdata,
9 p2 M& l$ @2 [% T/ H9 N1 u" Z .release = led_dev_release,
* o1 f* S! j' O# y }7 n* e6 z( C$ ]! z
};5 d0 }. ?! ~! E* x) i
2 W, h1 B) W9 G9 l8 ~- Kstatic int __init led_platform_init(void)# _2 [+ J" m, a, c+ Y0 A
{
0 a2 K/ t2 Q% m3 n int ret; r: u# w" g' R
#if 0
6 B( F( H1 ~9 z5 s; H- E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; Y! i' E- T8 K2 ` if (ret)
0 G5 O, G/ ?, p; m& ^% z6 d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! T8 b+ d. h- q% b( P "%d\n", ret);
+ Z8 v% R$ G4 `; w3 h# u% i8 K#endif
9 [: E- g9 _2 F, o( I" x; ^ ret = platform_device_register(&da850_evm_tl_leds_device);
f8 o c5 n1 ^4 k if (ret)
; n1 R$ U/ S, V. ?4 Z# ^# ^1 ~ pr_warning("Could not register som GPIO expander LEDS");
/ K/ C( ~ X) q1 k: {/ D9 t; T else
( l5 \/ \' A# u printk(KERN_INFO "LED register sucessful!\n");
6 k6 m5 e- }+ H# j l: s; L3 ^* s5 k( O0 P0 R
return ret;
; o; g) l/ ]) r3 x6 m/ Y}
( O% m: \- F8 Y% _; l& Q* E3 j9 _" l" l4 G6 n. `4 A
static void __exit led_platform_exit(void)
- `/ m( Y1 W) ^) b$ Z{
1 F! S, B6 d5 O& ^' A4 h. r6 V& q platform_device_unregister(&da850_evm_tl_leds_device);7 y' j& ~; p$ b& e
m( D, L* U3 Y printk(KERN_INFO "LED unregister!\n");
3 Q' a* Q7 ` }% l! z+ U}
" C. \! }# Q' p3 ?& J: @% f2 }- d4 }. _
module_init(led_platform_init);
6 H# k5 S, _( Emodule_exit(led_platform_exit);
. Q3 W6 @, n' K# n, y" j
2 S. Q3 z; s+ P# r) @" a- [/ E5 a, [( xMODULE_DESCRIPTION("Led platform driver");
: m4 [4 o8 B5 k# O! eMODULE_AUTHOR("Tronlong");
+ I& D+ i: C& z G8 F4 n5 LMODULE_LICENSE("GPL");" h1 v3 A7 o3 [% I8 X+ L
; R, {$ W# n5 X
|
|