|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
t; w5 B* ?1 k) q#include <linux/init.h>
1 k3 g3 q. F4 r4 K#include <linux/module.h># H8 T7 u+ T% x& o
#include <linux/kernel.h>
|6 L% \0 |( D0 r4 ]6 \, K8 X#include <linux/types.h>7 y# {8 P x: N* _" X5 F q
#include <linux/gpio.h>
8 d* A1 x6 }4 k! q#include <linux/leds.h>
& E, b6 H. Y2 T! L#include <linux/platform_device.h>
2 C* Z! ?5 S- L) ]% M5 P1 z- E6 c {4 ~; v$ v& D
#include <asm/mach-types.h>/ R( a# O8 } d
#include <asm/mach/arch.h>/ N9 H2 W( [9 [
#include <mach/da8xx.h>
5 k; J7 _9 H0 }& p; m#include <mach/mux.h>
% K0 B$ T( p# B) l w, ^5 b) }+ T" C) R; ~, B4 `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 f- h4 ?+ G' m3 u$ k: S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ A% s# O9 `" ]. ^& }9 M5 w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ F! s+ R1 g% n1 z7 E4 t, s0 C5 R' a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), c, @1 T- d; s) t' e5 P* _
4 z7 d7 q/ R" m+ C
/* assign the tl som board LED-GPIOs*/
: ?3 T# i+ Z5 @2 `+ w+ K' K# Ystatic const short da850_evm_tl_user_led_pins[] = {! E5 I2 v- T/ A( a: Z8 m9 y
/* These pins are definition at <mach/mux.h> file */3 M1 l/ _5 [) C1 [6 z8 k6 D/ A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) G" b+ ~$ N7 [5 f3 v" c8 }2 g
-1
6 r9 ^% z3 F( H z9 Y};) g( A/ C) }) E; U
y H- q: L4 B- w; a- S& Pstatic struct gpio_led da850_evm_tl_leds[] = {/ v; O& H9 I4 j1 f2 R: ~
{2 N# G, Y5 g* ^- u& z
.active_low = 0,6 i& T- e* F6 Z( p1 v' _1 x0 c: c
.gpio = DA850_USER_LED0,7 `; t) Z& A! [# h# g; H+ A! s
.name = "user_led0",6 L G) \1 E/ O3 E/ i0 ?1 A
.default_trigger = "default-on",* w4 T% X/ c( u" d( k, [9 ?
},/ K: D9 W! u! L3 I
{$ J; Y" u& W1 i4 l. b8 q+ `& z# Y4 L4 G
.active_low = 0,; r! T2 a( y2 ^2 {2 {3 Y; S2 d* J
.gpio = DA850_USER_LED1,+ q4 x4 H# P, p. @
.name = "user_led1",, G3 }5 O8 i5 y, @& H6 J
.default_trigger = "default-on",
4 K4 \) s: o! I3 O8 i },
?9 D* W+ Y* j4 a% I {$ R7 o) n3 Z& v* i$ H
.active_low = 0,; }3 J5 F3 R( u% l }
.gpio = DA850_USER_LED2,
+ ?6 ?1 W# z4 k1 D .name = "user_led2",
: n6 q6 n5 x4 W5 k2 c8 ~ .default_trigger = "default-on",) `6 B# v- x# U- h# W+ s4 j% L
},
, p8 n& Y" T5 F, e/ n! e" s7 t {" O; J7 g4 _& @, w
.active_low = 0,8 k: b* X- q" j; P1 r! [) W
.gpio = DA850_USER_LED3,
. E D: K$ K- V- M3 K( A1 Y5 r .name = "user_led3",4 E% I/ x8 c$ N/ T: a! s
.default_trigger = "default-on",
5 x! U/ i' p$ r* |5 ~$ M( Y },; W0 [9 z8 m+ d' z
};
3 C2 }! Q/ ]# ?
I& B1 W3 }; U7 |0 B3 Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; }' S) D& B& U6 C i .leds = da850_evm_tl_leds,
: `3 q" U9 m7 r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& C# c) S( x/ O0 W) s2 v};% D% t; J9 t! k. e% I. ^3 N
& P6 G* P+ e6 j# a3 G1 _% Gstatic void led_dev_release(struct device *dev)
. i) |3 C: v5 l{5 J, L8 x( X2 d4 g$ f
};
; n0 g) |1 n( p9 g4 H( n
3 |. E/ Z( k. _) nstatic struct platform_device da850_evm_tl_leds_device = {) G( p/ ~: l% ^7 L9 @/ K
.name = "leds-gpio",
& }/ [( ~' W& O& l% y+ p' s) w .id = 1,5 g' H8 \, _2 L
.dev = {
6 J$ H* C0 E& t) m8 ~8 E .platform_data = &da850_evm_tl_leds_pdata,
- G$ V# g& w/ s. ~9 @2 D* e .release = led_dev_release,
g$ | C' ^, k- Q8 b4 K! Y. Q% p2 H }& b# F" X2 i" r: O" h" m
};. X; ]! D- `" m+ Z4 n: u. X
: O; \; y2 x9 j" e7 D: t$ {
static int __init led_platform_init(void), s1 K/ k/ s' I% W$ Q% O
{
% {9 v& ]- Z: `3 R& d int ret;
% c% F( _1 Q# ~+ G* K' j! j#if 0
5 G' D& o9 U9 D- {) A* ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' @' A, ]5 v; G4 i2 M/ Q5 t4 @& K if (ret)9 j6 ?. ^" M' C" _ M8 r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: g( H- T' j* D "%d\n", ret);
+ j) k5 f- Q( q, n5 _, C5 m#endif2 }( c* x- R( @$ y! S" n
ret = platform_device_register(&da850_evm_tl_leds_device);, O) _! q3 Z2 D$ o& w z
if (ret)
8 _! J8 P2 V* m5 a pr_warning("Could not register som GPIO expander LEDS");
D4 ^4 K( [1 s+ y t7 j. _ else# M# `1 Q/ M- D0 X1 y& L* C
printk(KERN_INFO "LED register sucessful!\n");
! C. h3 a$ I; O* O, P: k* L8 `! K4 Q# b* m6 g
return ret;
$ y% h* i u2 S9 S}7 k& n% ?2 H0 L8 M; B
, ^* R" l9 X3 J3 l0 _ N
static void __exit led_platform_exit(void)
# N/ G8 {( g" |$ E h4 l s( N{
% a$ V# {: R3 `9 ^( z& n platform_device_unregister(&da850_evm_tl_leds_device);
( ]( F; p r' B0 c4 v0 V" u
* s2 T# w- g' \# b7 e printk(KERN_INFO "LED unregister!\n");+ t/ B$ h( [# Q) N% m: g5 b
}
; [. E# d7 F* k& [) A
o' T- t0 Z& x* D" h& z3 z) u. d. Zmodule_init(led_platform_init);
" n) M; ?! F3 \* o, ]7 I, Emodule_exit(led_platform_exit);- ~8 L5 J9 H5 K5 Y$ m% J
: Y$ O1 N/ H! X3 Z8 n, c' e4 tMODULE_DESCRIPTION("Led platform driver");0 _ N7 `3 _. g( X1 ?% r
MODULE_AUTHOR("Tronlong");
( S7 b5 F( P5 C) N. m% XMODULE_LICENSE("GPL");
$ s' {1 E0 b( V9 y$ l
, C: [5 m/ o2 a. |6 p8 M ~ |
|