|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 P! U! k6 y. a5 R0 v" ^
#include <linux/init.h>
$ b: L* H: D" Y, }( k' x+ f#include <linux/module.h>) J* z% X& q1 |: N: {- K, ^" ]
#include <linux/kernel.h>. z8 x$ ^$ t5 @1 ]& ]
#include <linux/types.h>& a" I6 m% k+ Y B. O9 c% n
#include <linux/gpio.h>
3 M' L! i. S( b u#include <linux/leds.h>
+ D' }4 I5 a3 T: J#include <linux/platform_device.h>- E1 ~( [( z z2 c2 y' v: M# }
) S- ]8 u ~1 X3 r& G4 U
#include <asm/mach-types.h>& J& S( z" h. \; {0 Y. z( ]. M
#include <asm/mach/arch.h>
- w* d$ I9 t' s2 v#include <mach/da8xx.h>* Y: c1 X3 s* W' s7 S
#include <mach/mux.h>
3 |* j% d( q6 M$ _0 H% b' ?* `$ Q( ~5 r8 E7 S7 n. n/ f; y' D7 B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 t0 _, V9 g+ P4 U' k6 T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 K1 m% [$ ] [8 M6 Y) R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* E0 c/ z: ?3 i( Q% f& u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: C- p% ^- V4 R9 { _
+ w* l$ E" R4 o6 `" r- {/* assign the tl som board LED-GPIOs*/, n; a2 [, {/ i
static const short da850_evm_tl_user_led_pins[] = {, N9 P1 l& f3 O {8 _* \- _# ^/ n
/* These pins are definition at <mach/mux.h> file */; a U* q- _; j4 O) E: W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 q" Q) ?7 n/ _) I! Q -1
% H0 j) ]* W6 z2 @' G) J};( {& U" J% o/ w# w z0 n
' L0 h# e2 N7 z6 h+ ]$ sstatic struct gpio_led da850_evm_tl_leds[] = {: B6 b ^# Y; r. @ {
{' n0 W% J, }0 r7 U
.active_low = 0,, A/ H! } O: a
.gpio = DA850_USER_LED0,
' F. `* Y; l( K .name = "user_led0",/ l: S6 t$ ]7 T
.default_trigger = "default-on",
2 j4 h% J" r$ K/ B& \# d- n( F) A" i },
! `% e6 |( X7 M. b$ s+ r& k {
) A4 W8 e' e" ?- r8 Z5 t .active_low = 0,
/ a! i0 c- M$ P$ y! p .gpio = DA850_USER_LED1,
]+ q+ k; f6 D0 z. r .name = "user_led1",
: ~' W% P, p! R& p1 ~/ m: Q .default_trigger = "default-on",' A8 G7 M! D: |& w
},: d6 S4 b. x3 _1 T) W/ P: u" U( J, d
{' N' ~3 J7 j8 k+ z) D# l
.active_low = 0,
6 }& l/ ^" w; H" p3 s .gpio = DA850_USER_LED2,8 g1 ]% Z* A. Y7 M7 ]3 \1 i
.name = "user_led2",
/ ]. g# x8 K: }6 Z. M( g .default_trigger = "default-on",. L" z* I9 |5 _
},, ]5 O- u0 j7 q$ s4 `5 D
{
- T. ]2 g6 ~$ O .active_low = 0,
) W1 N$ L, U- u .gpio = DA850_USER_LED3,
2 G5 _# L- k; f$ b* _ .name = "user_led3",
; j ?$ O' y& m4 v' W: w0 q" D: X .default_trigger = "default-on",. J0 P2 n+ q$ `1 z8 ~& r0 n
},4 g2 Q0 c' z# J9 J U0 I
};8 e, K' E$ ~' f5 o# H+ R3 S
& ]7 Z2 l" |, g- g5 v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 n' c/ R' }, J, ^5 V, K3 T8 F
.leds = da850_evm_tl_leds,
1 z3 t4 ?7 S8 V L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- \% T6 M1 N! C: k) R- S};
* c! R! }1 L6 L' X1 C
7 l3 A! U! E9 F% Ystatic void led_dev_release(struct device *dev)
/ Y- e$ P/ m4 S y0 I, ~{
5 y$ D3 N. ]) o D5 U; j z}; H% h+ D- k8 x
: n2 ?6 \. p% d- K5 c. y
static struct platform_device da850_evm_tl_leds_device = {& K4 L- ^0 Y) w7 G
.name = "leds-gpio",1 h7 t5 Y& X: W) C* W1 }' E$ v3 u
.id = 1,! j- A2 A9 s6 I7 f
.dev = {# r0 R4 r+ k9 k. Y3 }. q
.platform_data = &da850_evm_tl_leds_pdata,
2 ]7 }7 @# t L# R .release = led_dev_release,
2 F- Q0 X }9 v( `/ o }3 g/ z, u8 j% u+ N6 _ E6 }
};$ F/ |6 M2 _. x1 J" b1 \
; ^2 b' a( g: d5 X+ Q+ U- @
static int __init led_platform_init(void)
) a/ @6 Q. c8 ~2 s+ o1 `# K; `{
6 p. ~! T" p. L1 G* w7 I int ret;
7 ~' c; P8 c, L0 q#if 0
$ j) {* G; o: K( d! y5 D/ H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) }1 c1 V2 I& p8 _5 |) y if (ret)
6 {. U9 E3 ?( ?' s e" ]! v# r) X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# M1 A, x/ X' V/ D3 O) b7 {+ L
"%d\n", ret);" w3 s" W$ W8 X0 `: Z: J0 Z9 G, s# D. i
#endif! m: S, H6 e0 w- ]: F* S T
ret = platform_device_register(&da850_evm_tl_leds_device);* y" x, _8 p2 ?
if (ret)+ i% s. e" C9 v3 b m
pr_warning("Could not register som GPIO expander LEDS");9 T: d3 e: N$ b. a
else
3 l! o! Q; i: g. S printk(KERN_INFO "LED register sucessful!\n");4 i8 K3 R0 G6 |' h8 v
4 T( r; R+ E" H
return ret;
( Z- N, m y/ ]4 g! _3 ?- s, ~& t2 Z}
2 ~5 [6 X+ S2 K9 t) F
+ _( x- k" _9 q0 \) Jstatic void __exit led_platform_exit(void)
2 J; H& K' O4 f. d, J{
}1 r- U2 t% } platform_device_unregister(&da850_evm_tl_leds_device);& R& Y% \" a7 q+ R- ^7 p' o
) J. w$ l- |; n. ]# | printk(KERN_INFO "LED unregister!\n");
/ L3 F7 l) I; s. Q' Y/ g: G}6 M B# e$ _$ |) A: H' `+ m
1 B5 G/ U' d$ [7 G1 X0 Nmodule_init(led_platform_init);- E) S m4 z, f" h R9 Q
module_exit(led_platform_exit);2 z, S% y" ]' W! y# ]
0 [% ^8 j5 E4 i! x5 ^- u8 CMODULE_DESCRIPTION("Led platform driver");
# x5 w% r$ `$ Q, Z8 S/ IMODULE_AUTHOR("Tronlong");* I" C7 ]+ Q% s: }8 q
MODULE_LICENSE("GPL");, Z9 a6 q, |; h! l# m5 p5 V8 A3 I) i3 X
9 R6 D" J9 R8 {0 w& \% C
|
|