|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( H& }/ W- E- o; _#include <linux/init.h>: E T+ [+ v8 U" d& g
#include <linux/module.h>4 P3 E$ N+ R) f& y1 R. r: \
#include <linux/kernel.h>$ s5 r4 m2 e) l- D6 O; P: x% V& k
#include <linux/types.h>. s- |6 `) C; A8 O, D
#include <linux/gpio.h>: R- @/ c$ o7 O
#include <linux/leds.h>
' m/ I5 v" y3 j' M#include <linux/platform_device.h>0 N; E; M, T6 D7 e' ~# A
- u8 n1 D0 d4 `% S7 S
#include <asm/mach-types.h>$ n& k% B" e0 X) w+ G- E
#include <asm/mach/arch.h>
9 o. M2 h# f, a#include <mach/da8xx.h>
5 z6 y# ~+ ~, _* D1 Q#include <mach/mux.h>7 l. B- D3 d% }+ h! f* r
5 [9 C! J7 ~/ K+ M3 g* T$ g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" q. r( x) y- C- ]0 b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; G/ a9 g1 y+ O1 V% d( [$ `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ K4 b: n8 I! B5 r; R. U- c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 n1 D" f, q9 n* P
( E# Y# X9 c$ O/* assign the tl som board LED-GPIOs*/
4 H. _0 W5 {$ ostatic const short da850_evm_tl_user_led_pins[] = {
# U1 b2 ~' E$ X" M; f6 x Y' H: S /* These pins are definition at <mach/mux.h> file */3 {0 m( b7 x! F7 ?+ B! }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) z1 t, G1 Y' z# Z/ K
-1
. l# c$ V# C* ^};6 g- F, ~4 b! t. a5 P6 P
2 Y5 J: p0 E; ~& L8 q9 y1 P; a
static struct gpio_led da850_evm_tl_leds[] = {
- F8 `& @; y8 ~+ r( W {+ o5 B1 }) G# s5 z
.active_low = 0,6 u7 A* a3 d U$ _1 h7 F, h
.gpio = DA850_USER_LED0,
1 a! b# C& b+ t2 W) D7 t .name = "user_led0",
; e/ ~3 m1 |0 I0 P8 q1 f .default_trigger = "default-on",
, E) I' i3 n$ S },
$ f5 k; s, x, Z6 E3 [ N {
9 L/ f( E" F6 b0 E' p$ X! T .active_low = 0,+ b$ z ?( D4 c& h6 p
.gpio = DA850_USER_LED1,
! c+ ?4 G+ a( P1 ]& F .name = "user_led1",
, E) W" ]* z, F, ]. P1 T+ [/ v .default_trigger = "default-on",
. e( J' V- A* j) H+ b2 A# a/ } },
, o5 Q+ F7 R& N* x {
3 \9 O5 Q7 W1 \7 y9 K. ` .active_low = 0,
. a6 A; k% e! d) J( R .gpio = DA850_USER_LED2,
% E! H& ?! L8 W, P .name = "user_led2",8 d& y6 x: R$ r. S4 I* i. m
.default_trigger = "default-on",
7 i9 U5 d6 X, V. ]# i% y1 O5 L },9 B. B. D4 F; d/ Z
{9 A4 M/ b* a: _* t! i
.active_low = 0,
' p! }: \) b9 z9 X i {& C$ O .gpio = DA850_USER_LED3," a* r( A/ p8 a+ G
.name = "user_led3",4 X3 q9 g& G7 e3 M1 m
.default_trigger = "default-on",0 Z4 c2 [3 p# A0 I" f. J
}, _1 W/ N! z2 W+ D2 s: c
};1 N) I1 t% |2 C
( a& s& _6 s: t) M! ]6 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 N2 h, A+ t/ `" A; D% l7 P t" | .leds = da850_evm_tl_leds,3 n L' Z, m: k6 E H9 Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 W# R b2 x! L( T4 Y};
6 o3 K9 u# q; x5 g, {3 S2 I
$ N/ l* C1 k9 f" gstatic void led_dev_release(struct device *dev)
1 p; x5 ~# Y: p3 y: [8 W; S{7 [! }( V2 w b* S# w9 |
};. J. n! i* D$ ?' A7 W9 H4 V3 ^" w' {
8 K) X( `( S8 p( f% \ e$ e) Jstatic struct platform_device da850_evm_tl_leds_device = {
( e9 w% L$ L' u% k# ~: P .name = "leds-gpio", y' S! Q% n7 v4 F. y+ h9 a, A. V
.id = 1,
! T0 ~: Q+ D, l0 b .dev = {
+ O q+ [8 Q* |7 S. ] .platform_data = &da850_evm_tl_leds_pdata,0 i% j8 n2 U8 |6 \* W# w. I% T
.release = led_dev_release,
4 x" [0 E- y! y! r; F8 `( U }7 V9 f* ?: M9 `: \" l& {
};
2 C( f9 G5 O4 i' X& p: x$ a3 P& F' k* A8 N, O
static int __init led_platform_init(void)( T6 T2 L- g# ^: l. T' i
{
, n% o3 W9 z" K- e+ s2 T int ret;0 {- E, g e7 w- j" L. _/ i4 E. v( P
#if 04 R! @ o+ y7 A5 c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: l0 L6 g0 R6 C5 b
if (ret)
: K9 a. e2 i8 D1 {6 T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 s) c! B# ~, {7 k! Q, A "%d\n", ret);
! j: e8 Q) b. L#endif
' E( }$ f6 t7 E7 o2 f% B. f! N8 u ret = platform_device_register(&da850_evm_tl_leds_device);
g' m5 s( T$ `; V2 k W( b H+ G if (ret)3 O g' o/ u$ g2 _
pr_warning("Could not register som GPIO expander LEDS");! s7 E8 ?" Y+ K- l
else5 V" q% L2 u# P1 A6 k6 d
printk(KERN_INFO "LED register sucessful!\n");' P! i% w" h/ f
& g6 L% Z& J' v: p return ret;
- S" G' L7 x0 N8 D$ l}
# i: b1 k7 y0 S' A$ y% L
& }' }4 c4 B8 |# @% x0 {. K7 Wstatic void __exit led_platform_exit(void)4 ~# Z/ x y m$ C
{! f" h+ g2 ]. L( w$ n3 |
platform_device_unregister(&da850_evm_tl_leds_device);1 |: h3 W0 _2 m( X- ]2 @
3 |/ k/ e# R2 e7 Q printk(KERN_INFO "LED unregister!\n");5 H& K- U h$ u5 b; t; A
}- ^4 b- _7 w& F) s; [% Y+ U6 ?2 g0 Y
, C1 k5 d3 x6 W4 Z: Lmodule_init(led_platform_init);; @+ q' n; b& M- i: Y
module_exit(led_platform_exit);/ T+ P. A( H( w& r8 k: ~' e
4 X. {' d3 |# ?* m
MODULE_DESCRIPTION("Led platform driver");
6 v* q% N, f2 p$ \# }. t5 h- p1 N* v& ]MODULE_AUTHOR("Tronlong");
) I! ]9 q/ e# xMODULE_LICENSE("GPL");
2 c7 J* z" h; S, v! a2 A* B( Q
5 X, s1 H# f5 r8 u# d0 R/ I2 E |
|