|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 K3 [. s# @; u5 r
#include <linux/init.h>& Y% k; B. ^& T8 F- D0 K: y
#include <linux/module.h>
2 Y+ X3 N% G, a( o( F$ T#include <linux/kernel.h>/ f E( \0 U4 K3 T* l5 J
#include <linux/types.h>* ~+ m! {1 | q! ]- v/ N' i6 _9 b
#include <linux/gpio.h>
) l. p: ?! |9 v' @3 e2 L8 g#include <linux/leds.h>4 ^2 t# T9 z) ], Q* u" t
#include <linux/platform_device.h>6 O! o* U+ p6 i7 e5 W
1 E6 q. V L1 \" r. p; t6 I#include <asm/mach-types.h>
% v# f8 ]3 T1 x+ D- z#include <asm/mach/arch.h>, m+ h/ R1 c! R% h8 Z. V
#include <mach/da8xx.h>
' C+ Z7 R1 p* P9 {+ a, L#include <mach/mux.h>
! p' D( m K- k8 y0 p9 h
* {9 R9 c1 W% I# r/ L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' ?* k* Y4 C7 K8 q1 q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ w' l4 \% C: X; j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# @6 T6 x7 A6 p _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 ^1 R- |. M( A' s
( V0 g' ]0 o& Z1 K: t/* assign the tl som board LED-GPIOs*/& [1 [1 R5 D! f2 g0 J9 C9 t! g9 S
static const short da850_evm_tl_user_led_pins[] = {
( @. H, G9 v. ^ /* These pins are definition at <mach/mux.h> file */
1 y4 M2 u2 ?& U8 \1 m DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 q7 k2 L" M& `
-1% H2 w. P4 P N, m. I: y, @; x- S
};! L9 [, n d K0 {
! q8 x8 A8 E a Z
static struct gpio_led da850_evm_tl_leds[] = {, u4 [( `/ G/ e8 o+ I& f
{ N1 T+ [" m! c- ?2 ~# X
.active_low = 0,
; y' S; T, e2 I' n. P5 m! ?9 I .gpio = DA850_USER_LED0,6 j. k4 Q) X/ g0 C5 e3 b" q6 e1 I6 M
.name = "user_led0",5 k2 z, I' q) D. g6 `# g7 c
.default_trigger = "default-on",
. h# e$ U: R1 D+ n },% x/ V8 T$ S2 H6 S& W
{
8 z: R5 x: H6 i4 M9 v% f( E5 w% f .active_low = 0,
! s1 G0 C( v. r# t G! I .gpio = DA850_USER_LED1,8 r! N% M; c1 l7 ^9 |" y
.name = "user_led1",
* L6 ~7 X/ f S0 }! @ .default_trigger = "default-on",
. V2 j% x4 @7 s V },
2 z! `( H7 @* e/ ^$ X9 t {
& f- n" J# S4 F* [: ^1 s/ Q$ i# H .active_low = 0,
) B0 U" h+ Y: C2 D4 S: h .gpio = DA850_USER_LED2,$ Q' u O6 Y" D9 c7 X
.name = "user_led2",
. H( g) n7 u6 c5 x8 p' y0 p .default_trigger = "default-on",$ D4 u" D7 d( l2 k/ u$ |
},1 t6 W/ ]4 r$ }% E2 r
{! m2 B! {- e6 O7 \" w, b8 z
.active_low = 0,
. J; P8 m6 S! H% J0 O7 P0 ` .gpio = DA850_USER_LED3,; [4 x* `9 z2 L: G) u" W
.name = "user_led3",/ B; }, B( N4 }0 g7 t9 }* y
.default_trigger = "default-on",3 c& K8 y4 f) Y* j
},8 e( _' V6 q7 |. M7 ]
};
- J0 a2 p5 x ~1 C7 j; T j. \6 s( F; g, q1 A0 A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 K# G& N& I+ A( \ .leds = da850_evm_tl_leds,
0 {$ S; w. S+ P. H3 e1 | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' ^! ]2 r3 v5 D* k
};
& [9 S2 D7 E3 M- u; X, l3 V& [* [% Z/ @) ~- X( y# @- e* q' x! J
static void led_dev_release(struct device *dev)
. q# q k) H* m" ~5 K{
( g4 A, g' N9 b% _};
4 d5 w/ X8 |' }+ _- {% ?
5 o! n4 Q) V$ O0 B2 `static struct platform_device da850_evm_tl_leds_device = {! {( p( P0 v* W9 B2 p& f
.name = "leds-gpio",, X. P- P+ Q& J8 ?
.id = 1," ~/ G" N+ z# F
.dev = {9 a7 T9 h% M8 j, E3 Q: K! [7 ^
.platform_data = &da850_evm_tl_leds_pdata,
7 P" Z& P) a5 f# o2 g* U/ l .release = led_dev_release,
. Z: f) f& [8 |- [( D }
5 S# s" _/ `9 F6 `) D, f* A};2 H; p. Q& C( [5 _9 a, G: l
" ]. T4 V5 r* }# Z8 {. i8 B
static int __init led_platform_init(void)# b; M) R: x. I0 U- K, S5 k$ S
{
. b- Y/ I8 s+ ^* z* }! |$ r* p int ret;# w' n) h# Z9 l2 m$ j& F
#if 0
! d) [4 c. x7 U% q9 v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 O6 K. x$ O$ a0 x& H# u; s
if (ret)
$ H( S- ^7 z) t A, @# m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 Z. T7 W5 _0 g# t "%d\n", ret);1 e* P* \$ d& W% w8 M7 M
#endif( W. L R# U2 n$ M, L
ret = platform_device_register(&da850_evm_tl_leds_device);3 }; H9 L2 K) R1 P
if (ret)
7 q. L: a) |! w pr_warning("Could not register som GPIO expander LEDS");6 ] w+ S1 ?: P9 ]' a# o, d* h3 x
else
) B6 V5 B- ^* P printk(KERN_INFO "LED register sucessful!\n");% n2 S2 M$ l1 d, B6 z
~1 N7 q2 R5 K7 Q, w
return ret;
0 Q6 x+ Y' j+ z8 N9 ^5 Q}' D6 [8 D# {" @& k u. i
C5 V0 \0 t2 Z; ~static void __exit led_platform_exit(void)! \& n! W" |+ o/ Z9 j
{7 R2 D* j5 ?: }0 y% V- d' X
platform_device_unregister(&da850_evm_tl_leds_device);
8 W) u& `$ j d6 P: H( e8 v" _, n' Q% f1 }, ^5 ^
printk(KERN_INFO "LED unregister!\n");! _% F3 H+ f5 J
}, C7 h: e7 h: @4 T
, ?4 R2 S P# ~, I# w6 Imodule_init(led_platform_init);
7 }$ y0 {& x% k5 k+ Ymodule_exit(led_platform_exit);. y# c* r7 [( f6 k1 M( d
. O: J/ u" z5 \ _5 hMODULE_DESCRIPTION("Led platform driver");
. z6 _7 U+ h$ ZMODULE_AUTHOR("Tronlong");
2 j2 c1 X/ D. ^) EMODULE_LICENSE("GPL");
/ o0 N. s, J2 U4 w4 T! w
4 O8 J/ I, l% S( s9 \" ^% H2 y. Q |
|