|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 ~- |6 ^& x. o/ o& p% w0 L#include <linux/init.h>
Y$ I2 M6 x& a( O8 Y$ x n( m$ z#include <linux/module.h>
1 k/ P5 R3 @4 m& q$ H$ f& {( L1 W#include <linux/kernel.h>: R2 G9 I0 h- P- r/ P/ K F
#include <linux/types.h>
9 z; Y V7 }8 j8 W#include <linux/gpio.h>
" T) x! ^- t0 h#include <linux/leds.h>
8 b& C3 \3 R1 i#include <linux/platform_device.h>7 s% {+ A9 D7 @! F; q3 n
m4 ]: N7 `3 Q4 p! W
#include <asm/mach-types.h>
$ C1 G3 y6 ], x2 T. G4 q0 x. r, G#include <asm/mach/arch.h>
+ ]% i4 _( J" U2 J; _$ Y4 @#include <mach/da8xx.h>
% G4 y* a3 g: l# ?4 E' R8 E#include <mach/mux.h>
" \2 x2 o0 Z' m% G9 c; @6 ]+ F) G' \3 h/ m3 ?2 l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ g0 ~) ?% n& S. s2 A) f6 s! e, [ P3 Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
z7 [- z6 H6 f' B! h#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! o" A. L# P! `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ ?* X' r' V3 o O: J; \* d# o# B5 Z8 r
/* assign the tl som board LED-GPIOs*/
1 Z1 H# y* e' l2 n: F) ]static const short da850_evm_tl_user_led_pins[] = {: K7 [8 l0 V' _; r7 ]' e7 Q
/* These pins are definition at <mach/mux.h> file */
( j. ?. `4 k0 I8 t9 o6 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 X" Q9 t! `/ N Y. P -1
& R* Z8 H- n2 j. {; k Q};0 r: |* `5 E8 i3 G# Z: t
3 }; |2 @! e( V( \
static struct gpio_led da850_evm_tl_leds[] = {, l# y; l0 j) f2 ]! C0 K% K; e
{
0 [! V1 o/ S: E( S; E& w .active_low = 0,
; ?. B& p" I' b .gpio = DA850_USER_LED0,
7 b$ _' i5 i v* a: e9 X5 @ .name = "user_led0",
/ g' q" X( S( {9 T7 e4 K- G0 ^# } .default_trigger = "default-on",
, N1 o( E, R8 a, u) e },
) B- X( l# b. F1 I {
1 x+ A8 u+ r6 |& @0 J .active_low = 0,2 S2 j( u C: w- w
.gpio = DA850_USER_LED1,2 f0 c; u! r8 x
.name = "user_led1",* J4 B5 k2 A" a+ S" L. P' M! ^/ Q' E
.default_trigger = "default-on",
2 \/ `' H8 Q% u9 M U, ? d },
% K* D3 @& G! N$ ]" U' E# W {+ `4 M& F+ G/ V; ^/ t7 q
.active_low = 0,
. L5 f' ]- n' o4 ^) J# H. ] .gpio = DA850_USER_LED2,% p, L' [+ j& v5 V: k. o. b
.name = "user_led2",( @3 r0 E9 C, r# g3 R" b$ A& M
.default_trigger = "default-on",3 }. E4 ^# @$ p1 J
},
! ?" J6 r0 \/ s9 g1 @+ D {
. N2 }7 t$ T, r/ U; u7 H .active_low = 0,
- n0 p8 k. D; T8 Z; W .gpio = DA850_USER_LED3,4 B# e$ @$ ^' l( j0 q
.name = "user_led3",5 o7 Y: W' P2 ~, j
.default_trigger = "default-on",
5 U% @& J1 c _ A# i4 ]- R },$ y2 ]; X W* o/ ^
};
4 e6 }7 z* r; J& `; ]) G
8 M& f" q0 v! n# c* O. \3 nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 w, x1 n% \0 `
.leds = da850_evm_tl_leds,8 J) {0 C6 W8 p
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ \- r I4 Y9 _' w% K) o; C};& N! W2 [5 U# ?
2 X! r* ~3 h$ {1 g
static void led_dev_release(struct device *dev)
6 J& t# J% U. I. f1 y{) i9 Y3 Z& j) t: _1 g+ Q
};5 y6 O8 \9 P# K2 F6 `; t$ F
# \/ \ U1 x) r) a z+ j4 ~7 x" M7 Estatic struct platform_device da850_evm_tl_leds_device = {
0 Y' c' V% g, q. H .name = "leds-gpio",# b. D9 R. E- \6 V# x1 {
.id = 1,' ?4 D% w& w I% i
.dev = {: l0 O/ i) k+ c. ]: c
.platform_data = &da850_evm_tl_leds_pdata,
7 F+ h$ y; b+ C7 p2 j9 d* B .release = led_dev_release,
) x! N- D! |% \+ ]" i }4 |0 z" F' \+ {9 q) N( ^5 [
};( I( e/ L1 ^4 r
6 p% u: h2 o& h& k3 h# Kstatic int __init led_platform_init(void) r, R7 o# _0 R9 t
{: [# r3 R2 R$ X r- l
int ret;
' Y4 [ A; q" m6 e#if 03 f& I" p0 o& C, S1 [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 |; c0 N( s5 h% y! y6 j0 ^3 p
if (ret)5 ?; B* O( s m# {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# Q# s0 x3 A- {: _3 I& R "%d\n", ret);/ `* o% J/ T$ U5 s6 A4 h3 K, U" }
#endif
2 }) F0 ?5 a4 K+ `, E9 C/ \! c ret = platform_device_register(&da850_evm_tl_leds_device);
% o/ _7 O7 N* C* @( X. F! _+ ` if (ret)1 g9 M7 l9 A/ Z; f
pr_warning("Could not register som GPIO expander LEDS");' q2 I. l# M' v/ z# ~
else: k8 e% B* z1 l5 ^* q
printk(KERN_INFO "LED register sucessful!\n");: q) H! o4 e5 E5 I# b
! i& Q2 {+ D; h+ r return ret; M. ]) U8 c5 F+ G, k; K8 V
}
6 E- k8 W" D& @- Y! W# L2 U: b( L3 J
static void __exit led_platform_exit(void)
6 o8 k( x/ ^4 V2 S{( |2 o* Z! _+ f) I [; |
platform_device_unregister(&da850_evm_tl_leds_device);( E4 T9 h7 r' Q. e) ]% O% G2 r
D* I3 C: u2 g' n4 {
printk(KERN_INFO "LED unregister!\n");, q. V7 N9 X" K$ A" X. P
}
( C- g% }/ Z. t; N' Q
' l9 u. b Q. `3 Rmodule_init(led_platform_init);
$ N' s3 ]- `" Z2 J# gmodule_exit(led_platform_exit);! X$ i& U! e% b% y
3 _: V& J9 A; t( G% R4 e
MODULE_DESCRIPTION("Led platform driver");' k7 l) n& Y5 M7 C1 w
MODULE_AUTHOR("Tronlong");
: C) n7 L/ y" u h2 G7 b8 ?MODULE_LICENSE("GPL");
: _1 j6 }. W8 g2 x( L9 e& L) ~" q. a( c' H
|
|