|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 u- p5 H8 c- A
#include <linux/init.h>5 E- ]: t$ u/ ^% u. c) B. i7 I5 g
#include <linux/module.h>3 R, k9 s7 l6 u; M" l- T
#include <linux/kernel.h>* ]( h e. r5 }- r
#include <linux/types.h>, ~( v4 S# g' }' H' q
#include <linux/gpio.h>
7 \: u& L$ J2 e% Q#include <linux/leds.h>
7 w; ~! ?* p, w! U0 O#include <linux/platform_device.h>1 P- E( F, N( F1 J
6 F6 H/ ?0 p- G+ x
#include <asm/mach-types.h>
, P' M. C& S4 t0 f2 h! V#include <asm/mach/arch.h>: ^7 |1 V7 ?/ Z/ z+ X8 J, X' u5 _
#include <mach/da8xx.h>& l( c: N* m2 w
#include <mach/mux.h>
+ E: L6 g) g# f) A8 O: w2 L# j6 I: W- [1 K0 n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# O: y6 T& ]: s& x$ w#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' W0 M2 p. c2 r4 N" X- Q* Q0 \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* t4 G0 e$ s3 `+ F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! k$ z4 L% @! a; \3 }
1 q; @& W. ` b/ n4 O0 R/* assign the tl som board LED-GPIOs*/
& m4 L6 z+ ?& H) w+ v z. O' c2 G8 Wstatic const short da850_evm_tl_user_led_pins[] = {
* p% S& l E. ]' q3 n, l /* These pins are definition at <mach/mux.h> file */, h4 A1 X: D0 s E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% n" n2 L% \# ~% f4 k -1. j4 ?- h# T' q6 G* D' ^6 U
};) _* }: O, ?! p; }5 a2 X& Q6 y# x
! l/ K4 x" A3 Hstatic struct gpio_led da850_evm_tl_leds[] = {
3 R5 `1 X$ a* l+ e2 o- F {
8 L. D9 B; ?9 j .active_low = 0,, [6 d/ w7 w. ]' b2 P9 Z
.gpio = DA850_USER_LED0,
; H3 X+ C" j+ l/ {# _ .name = "user_led0", [7 o+ g5 @9 |; P# A D8 U
.default_trigger = "default-on",
; J( m+ x4 |1 l, m },
; L# u9 V' M! E6 d) h2 d {
2 n9 O5 t5 n$ ]3 X3 c9 f; u$ L .active_low = 0,
% z% i- E* q$ l& B, | .gpio = DA850_USER_LED1,
! Y) r" P! E2 l) v .name = "user_led1",
) A" ^! I9 `7 k, y0 w9 D/ c7 ? .default_trigger = "default-on",- }' _& ?# z9 H$ Y0 C
},
6 }' v4 b" S8 o/ m) P) Z3 Z0 } {
( ?! e& c- U f% w5 ` .active_low = 0,
- N& [& R; u6 Q) N, s6 k5 i .gpio = DA850_USER_LED2,+ @: N, b1 A: c2 @# l: o
.name = "user_led2",/ `% ], P/ z2 f* V3 m3 y
.default_trigger = "default-on",1 k( m8 x' M; K
},7 N# V8 e" @& o
{1 \5 {. p r6 u( Q& K/ O# T
.active_low = 0,
# y! @* H# o; p .gpio = DA850_USER_LED3,) N3 s) j3 h( a7 X6 r
.name = "user_led3",
4 j) G/ |) _3 b% ]* m/ \$ j .default_trigger = "default-on",3 } `& E9 e2 w# W& _
},/ u: Q& ]) n: q5 v4 O, Q
};
" @( Z& Q: B. }, Q3 b: u; Y
( q1 I4 l0 z7 H9 n- }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ Q2 W6 `# N; c" @+ ] .leds = da850_evm_tl_leds,
V9 Q5 l8 g; @8 t0 a, b" f4 A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) ~: N! Z# O+ i8 r8 K: F
};
+ y: u0 w( ~1 E. h) N: y! ?$ n6 `- W8 `6 l9 N
static void led_dev_release(struct device *dev)
3 h( W( T2 t. _$ M' _9 _{ D/ @! i; _7 c$ d1 o2 e \
};5 N1 f) @/ {* {# D1 ], ]
& w6 } b# f3 Y9 u8 `% V+ Estatic struct platform_device da850_evm_tl_leds_device = {
7 X; {0 K5 F% t! A8 A' s .name = "leds-gpio",( X, a) m" |/ ~; Y! R
.id = 1,
& }0 O. t4 h) D- M .dev = {
# O6 U6 s4 [2 @% q .platform_data = &da850_evm_tl_leds_pdata,
* p; _ R8 l3 ~& L8 L4 F t% U .release = led_dev_release,3 ]" M9 D2 i( @
}3 n2 [1 E, i( }& P
};
5 I4 |" b4 z6 ?+ q4 ]7 @ N) [, o/ S0 w7 G
static int __init led_platform_init(void)3 E/ b z% F2 `9 e( d' ~$ o
{
) g8 s- o, f( o! d int ret;! J& P; K0 T7 K1 O3 x3 r @' F9 S
#if 0
Y$ A: o# n6 u1 o9 q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% [5 L2 i# s, @/ N8 |: F if (ret)
, e6 o8 `9 j' h- W. W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* F. M6 |) L- I
"%d\n", ret);
9 a9 V5 q) U$ ~% ~#endif4 ~: a; o6 R1 J$ v
ret = platform_device_register(&da850_evm_tl_leds_device);
) ]/ o( k; I1 Q$ y: s if (ret). s" x0 U b% l) |$ Z
pr_warning("Could not register som GPIO expander LEDS");9 x, H4 e3 l5 D, o$ N
else+ C' e1 {: ~ r0 j' f3 B9 }
printk(KERN_INFO "LED register sucessful!\n");
; D: ?( L' u4 o I. Q& J) A
3 @$ C- K5 {5 A return ret;
8 c8 ~$ }" b, K}& k$ _2 |& g* ^6 H
2 s" i. S% r% ^7 P. D. H7 o& `
static void __exit led_platform_exit(void)
& R8 C6 |' ^- d, N' T; P3 E{' c/ f2 A# F/ M% I% |9 O
platform_device_unregister(&da850_evm_tl_leds_device);
5 a4 L( I+ w }5 x8 r% g3 ~2 M$ N! L4 e1 `
printk(KERN_INFO "LED unregister!\n");
% f; Z' T( U) Z! L0 E$ L}) B- }7 Q6 F: [ G
/ I0 ~' J3 K9 _) k( a* O2 tmodule_init(led_platform_init);8 H( t2 }7 R( e" d# [
module_exit(led_platform_exit);
4 c% m4 }$ f8 u! P% w# ^: o; X9 w. [
MODULE_DESCRIPTION("Led platform driver");
( a$ {! U7 Z6 z u* ]2 T5 LMODULE_AUTHOR("Tronlong");0 O; Y+ w+ u( \
MODULE_LICENSE("GPL");# y) w% C* w: L3 q: X& G7 g5 ?
4 [1 u j; m. Y, k( h, H3 x
|
|