|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ }5 U. h4 B+ |; U1 j% E) W#include <linux/init.h>2 O/ o0 b4 ?: b3 Q! S; d# _' p' r
#include <linux/module.h>
3 o2 y# r) n- @: z6 S5 p#include <linux/kernel.h>* ~, N1 @% a* y# B6 E. o
#include <linux/types.h>7 X8 B/ Z4 n8 P- {9 i: p$ {( I$ X
#include <linux/gpio.h>, Z/ `- x$ h7 @' e) u: U
#include <linux/leds.h>+ F# R' E, t# {$ p) {" u! M& v
#include <linux/platform_device.h>
9 C4 A% I' F8 W1 Q7 B% j+ l, i
8 ]0 j7 }- d- i5 n/ a#include <asm/mach-types.h>
) c- u8 u# F* a s v/ e! V4 G#include <asm/mach/arch.h>
_7 I/ }3 }- n# w% X5 U4 C#include <mach/da8xx.h>
! n: U0 Z$ I$ h2 u0 a#include <mach/mux.h>
, E: ?4 @, v0 h+ Y6 U! C0 ]1 {4 [2 f3 k& V% g7 k- }. r! d& y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
}( H5 t( }9 D6 {/ H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( q# F0 R' I: d# I* b6 ?! q/ j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), a+ I7 `) @' s1 q: r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 d' U7 E* i1 }& _; k% \
/ W, c# u' i1 @9 w2 A/* assign the tl som board LED-GPIOs*/5 I F3 _2 I! n5 ]( J
static const short da850_evm_tl_user_led_pins[] = {
2 F0 [# E7 d L( O5 c0 @! B /* These pins are definition at <mach/mux.h> file */
, o4 x5 m+ o: M- w7 s4 B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! V/ b0 ]+ o' i+ w" c4 L4 t
-1" M6 ?- } a) d6 s F* P X, x8 x
};
& @5 N/ v! u! H; x* J' f; n6 ]1 i; S8 F# i
static struct gpio_led da850_evm_tl_leds[] = {( @: F1 u1 L- V
{
. W" M, X$ R9 X' r .active_low = 0,' ^6 _5 @& ?( a# v8 [( ^
.gpio = DA850_USER_LED0,! o( d8 m i1 ~2 v
.name = "user_led0",. X( R" I( W. g. g) ^
.default_trigger = "default-on",
$ q' V5 W# M# e1 c },
& V" Q9 u6 {- x: T {
7 m6 f! C' p3 i .active_low = 0,# }0 a* v2 o, g; A7 S; I' L5 f
.gpio = DA850_USER_LED1,
- e. q' U3 J, D4 y .name = "user_led1"," i- j0 Z' t1 p
.default_trigger = "default-on", V0 e+ X. W, \; U; t. Y/ b* a8 r9 J
},
2 @) |; H, S) l0 q {
S3 z; }) Y$ J7 K- I& s' a0 y: h1 U .active_low = 0,
" J( R# B3 ]0 A( f S .gpio = DA850_USER_LED2,
h0 }3 V, F0 [* [# |/ q .name = "user_led2",
0 L2 q3 \5 U, ]9 Y, \( j& h5 K .default_trigger = "default-on",' g6 p% E+ @5 p! {
},
; Z5 T# _2 L' ~* ]& E {
% h/ e$ d) E0 e: ]+ y' H2 S3 |; _$ I. r& k .active_low = 0,8 j* ~2 r0 {2 d0 I9 o6 E
.gpio = DA850_USER_LED3,
! W5 f& N! w3 [4 C .name = "user_led3",
' w6 u6 u' d2 x" y/ w- ^8 M/ K .default_trigger = "default-on",% y* F# [: Z! M! v3 ?4 K e
},; i# A' I/ ]( |7 T" V9 Z
};. r* D, T \5 n0 l6 e! Y
& y! V! C5 C8 \! n- a, r {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# A" Y9 z# p$ V% X; `6 R, g2 l .leds = da850_evm_tl_leds,
# {& {7 G% O, _) c .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 G0 r' Z' z7 q};
1 \3 C: w2 J, R! \7 m4 P5 j+ Z h7 s) k
static void led_dev_release(struct device *dev)
, u$ B. T$ q( {- O/ J; m+ p{+ U! c* b( y* ^) C, E& u
};3 l# P$ I4 V# C3 t/ H! R
) \5 }6 T' ]( n7 C7 A
static struct platform_device da850_evm_tl_leds_device = {% U! }0 ^9 M6 Y; Y; Y/ T8 n# F( ?8 w
.name = "leds-gpio",, ^8 c/ V$ X0 N" U8 ]% z
.id = 1,
2 q. [ s2 D# e3 E .dev = {7 J" k; ]5 F6 F6 v" S' u' x9 h
.platform_data = &da850_evm_tl_leds_pdata,
6 H, J) H L% z, {2 ]" M .release = led_dev_release,2 D' i% |& P2 h, o, t
}/ G, Q, Z) L$ I2 ?$ V/ H- ]
};9 y* E# j$ A% b2 I
/ s# u4 Z, I* g, |5 z1 H# j& m0 A% Q
static int __init led_platform_init(void)* `' r3 l' c" m" S. X& ^/ H
{
9 a/ M( m9 u3 G) E. z+ I: ?0 Q int ret;0 d# g2 t/ l: _( T$ s4 c4 H7 |3 s
#if 07 e- R, _) R' Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& L" B3 Q) ~2 D7 p7 `5 O5 R1 W if (ret)$ z9 l' z5 w; [3 v4 M; y) W; K: X7 y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& l4 f t$ n- R7 o8 T! u" u* X
"%d\n", ret);
$ j# ~; M$ c; Z#endif0 X: W1 I( j0 Q: y( V& z/ t& P3 K
ret = platform_device_register(&da850_evm_tl_leds_device);
* B9 B3 k# r. a7 x if (ret)
! p( J- B6 }! Y0 S/ M pr_warning("Could not register som GPIO expander LEDS");( H+ h& w* V# G+ I4 K) f) \6 O
else: B: q$ O9 |) f9 ]0 T( O
printk(KERN_INFO "LED register sucessful!\n");
6 |+ L3 o' L {) r; Z6 k5 D9 r4 }
return ret;
! y- _5 p! y5 @2 }% x2 X4 s' R; u}! v. r* z# T7 n7 m
% C9 r! s, A0 t
static void __exit led_platform_exit(void)
& }9 M8 x" Q" t2 X{
, u, E9 k2 k9 T+ y6 ?8 R: t platform_device_unregister(&da850_evm_tl_leds_device);9 s- b, s. v2 W+ ~1 a& V
1 @0 H- o" R3 k% w) r) o m printk(KERN_INFO "LED unregister!\n");6 i2 P- z# g9 Z9 ~# A) p8 Y
}
# M5 h. n {0 v
* {/ W5 ]3 e% mmodule_init(led_platform_init);
- i; Z$ X* m/ r! W/ d; Kmodule_exit(led_platform_exit);
7 ^8 D) ^. {! _3 w; e+ ]3 [5 i
$ E5 t# H3 i2 }+ jMODULE_DESCRIPTION("Led platform driver");
+ b3 A4 F) i4 b$ j9 j0 k; `7 }! _. IMODULE_AUTHOR("Tronlong");4 u6 F- d4 c' m- r# G
MODULE_LICENSE("GPL");9 x: y7 F. m" B" _' u, N" b
$ a. }# y! R, w5 v |
|