|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) h* G4 y7 k* N! @4 A' m6 B#include <linux/init.h>) R2 f' |8 E! ]" h: p1 r( Y
#include <linux/module.h>
! m5 n, J) G$ ], n#include <linux/kernel.h>* Q- N& ^8 i: f* k b- C* ?
#include <linux/types.h>
: v7 B) R1 ?" V) H#include <linux/gpio.h> X- E% t" X2 u, {* o& |! j. v( [7 ^/ l
#include <linux/leds.h>
2 w/ i7 W, @3 y N#include <linux/platform_device.h>' c+ J/ h2 c( r
& Z8 r4 o: p4 K0 I$ A
#include <asm/mach-types.h>
6 J& j4 R& s/ z1 e#include <asm/mach/arch.h>$ F% f: G3 C- z% e+ v( P$ l
#include <mach/da8xx.h>
$ V+ | v! L: ^3 I" M/ h# T% w#include <mach/mux.h>
, M: i; \4 T; m6 k! D' X
0 _1 x5 K7 V' s: [% O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 c/ w: `9 v( U3 E( T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' |& R3 o+ t/ w p- }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 T. j- X. v. U g
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. ?( d6 b1 ^: c, l0 v/ @: p* M( [
# b' i3 N a. `2 I: e/* assign the tl som board LED-GPIOs*/; y# G6 l! }& J7 S
static const short da850_evm_tl_user_led_pins[] = {
O* Y D# O8 _. s7 ~3 [ /* These pins are definition at <mach/mux.h> file */
' M k4 Q d# c3 \$ J* ~+ J0 O: M/ r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& w/ V2 D& f6 J# h& W -1
5 \" x% u: _0 w4 g};
+ X$ `, K: Q2 T0 z: a! u8 @: V6 J3 ?' p9 y% Y/ }2 s. P* |
static struct gpio_led da850_evm_tl_leds[] = {8 s2 a: S4 _4 D* Q/ c
{; J* l3 Y% U# U8 g }% `% J+ z$ M
.active_low = 0,! m8 S$ d4 Z; S3 P% B$ U
.gpio = DA850_USER_LED0,$ Y. ~; }% y- [3 a% D
.name = "user_led0",
9 }0 _) S3 Q$ `5 U: g8 o .default_trigger = "default-on",
( ]! n+ l( J. @2 F+ f" X j' P },
% d" E8 ]" H' ~1 B: O {
3 L% a: U/ i, b* S/ q .active_low = 0,
' E2 ~; R" A4 X4 u6 ^ ] z .gpio = DA850_USER_LED1,% T& g4 E3 p$ P0 X+ W' L3 C
.name = "user_led1",7 b; c; ~! u3 n
.default_trigger = "default-on",
3 t) s1 f* D ?& A( t4 @2 c3 i },
; c* `9 h; h0 O8 u1 @$ Z { e8 o \ C7 f" ]& ?9 u. @& [7 z
.active_low = 0,
: ~, d3 G2 B: K" g1 ^2 p" ` .gpio = DA850_USER_LED2,
7 y4 y* C9 m/ [0 g( [& M8 Q .name = "user_led2",
# T& `$ n7 M2 D# w0 e) | .default_trigger = "default-on",7 |9 y" G$ P4 n) B' }9 a% `
},5 M# v( H& v1 c& X( k( p* S7 X
{: ?8 \1 W3 q8 _7 F- [4 t0 r
.active_low = 0,
; G) y3 H+ r' t5 y7 Q1 K .gpio = DA850_USER_LED3,1 D$ x0 \- W. S5 H. ~
.name = "user_led3",
: V u* x2 X, c, A! G% H" ? .default_trigger = "default-on",
3 U$ N& U: ~) s0 } },
/ k+ }( Y+ W6 U' C};. P' ]: [2 z0 t0 v
& F; V& c4 R6 ^. Y8 Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 P' f( Z$ W7 y4 ?1 U
.leds = da850_evm_tl_leds, j, f! G2 s+ P4 i+ y- r0 Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ K, ]: k3 N+ h8 O. T; Y7 J- [};+ ?1 ]: j7 k% m* Y# B9 l n7 ?
# W0 i. V2 ~" t- `8 Z7 ]9 hstatic void led_dev_release(struct device *dev)
2 v" ^0 C) W8 ~# x$ G* t+ ]+ _{) z( Y. `8 o; Q ? S/ X
};
& Z3 f/ G5 V4 j- J/ p1 U2 c# f1 Z# y8 L8 b, G
static struct platform_device da850_evm_tl_leds_device = {; i' l* d& i7 d9 V2 E7 y" N# \
.name = "leds-gpio",) K; v1 X3 ]# U, `8 K
.id = 1,* W! o# z* |. Y$ q- H
.dev = {
; ~8 M. w' ?, ?! T4 u; L .platform_data = &da850_evm_tl_leds_pdata,9 ~8 P) P N% |# I: p9 u! I
.release = led_dev_release,
# ^% Z, Q8 \2 o: G6 J6 f; u6 S }6 \7 b: [! ~$ K! x& l
};
( M' m4 r, _0 e6 ?3 W! ~7 n; h* ^
static int __init led_platform_init(void)# E; b* E& ]- o, Z8 U+ w
{
4 X4 q& K. J3 z7 M! s1 L8 n int ret;
2 D5 v. O* \5 M4 `: c* \- T#if 0
! V3 m, u* D5 F8 w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 d- s- k7 L, C( i& `1 r) J" X- y if (ret)
) K% d5 T0 e E8 \- C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# V/ h9 i0 p9 k3 S0 O& v/ v
"%d\n", ret);
6 D7 B9 t, W; x8 ~6 Q/ G: n+ s#endif
0 L7 C2 J. I. Q4 S6 W) ] ret = platform_device_register(&da850_evm_tl_leds_device);/ M% B5 S2 A2 u, _7 Q0 ? q4 ^
if (ret)
- q# p) F l+ }7 _ pr_warning("Could not register som GPIO expander LEDS");
' o" u; A8 O! a1 }+ T7 { w else# r% g! d1 m" o
printk(KERN_INFO "LED register sucessful!\n");
$ n. g1 e" E0 i
L5 E1 g4 r, r. @$ x @ return ret;, @ C, g# }! I
}
- J; D. N4 F( x+ h
$ }+ L8 B& Z) r cstatic void __exit led_platform_exit(void)
4 l$ T/ _. h+ p2 n: P. q8 B1 j{
+ z; m- E, a* k# X# {1 p' n$ i7 M platform_device_unregister(&da850_evm_tl_leds_device);
* I3 |0 n6 B- E6 f2 U# O# h0 j' G0 d( f
printk(KERN_INFO "LED unregister!\n");; h# M. ]0 e) x0 s8 e4 {4 I
}
5 X/ i% _- a- `+ r @ o" T$ p6 p( T4 e% O2 I, D2 t
module_init(led_platform_init); E; }' {% l3 \+ F' K4 Q$ \
module_exit(led_platform_exit); h$ k) v I3 v- F v5 o( m
4 g4 t7 }, q% E3 g( }7 f* L% n
MODULE_DESCRIPTION("Led platform driver");- y2 Q) L) S' P
MODULE_AUTHOR("Tronlong");
2 a6 V/ G- ~8 zMODULE_LICENSE("GPL");- L* i/ O; p/ g n+ \
: X' Z' {3 O! ~, V2 G+ x/ B |
|