|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* L1 Y3 `( n& [
#include <linux/init.h>" G8 p% R* b) F3 R
#include <linux/module.h>
; K* y' E5 O0 y8 H8 C* ]2 ]4 o g#include <linux/kernel.h>, {4 s# ~6 Q- _$ ~
#include <linux/types.h>1 x" _; x, t) S2 Z: M
#include <linux/gpio.h>
5 c- d5 [7 x. O0 R# B7 l#include <linux/leds.h>% n& l4 t! E! u+ e9 [! \
#include <linux/platform_device.h>
( V8 ]. W1 g G7 }1 B, M$ G
" F3 M# r* E" }#include <asm/mach-types.h>
' F4 S2 u' m4 h9 R; H#include <asm/mach/arch.h>- R4 P2 ^) t4 H+ x
#include <mach/da8xx.h>
) k& x0 c! i& z3 N#include <mach/mux.h>" \- m8 a; H3 A# q& {
/ z& J0 P) K! c% }' J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' k) N6 G& m) l! j7 @#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) Z: t: W Z" _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 l: h/ d* ~* ~( V$ E2 R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 k" c" L5 R1 a8 C- |) u2 N
5 q7 {. R; \! ~# {! @" t
/* assign the tl som board LED-GPIOs*/, S: m% m" Z" `' y2 f
static const short da850_evm_tl_user_led_pins[] = {- R: o: V8 J& ?, d; H
/* These pins are definition at <mach/mux.h> file */9 k0 J: j+ R; G8 `5 \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 S( h( C) U) K) U$ a* m* C7 {; B -1
! J' B% e3 L3 Y t+ i+ n5 Y- q5 d};" I* Q% u8 P: G Z
: v( k" |4 @$ z5 q2 dstatic struct gpio_led da850_evm_tl_leds[] = {: v- \) }" T) `- s
{
! u8 z" A# K3 ^! m0 o4 C; L4 B .active_low = 0, y3 p6 _" I M
.gpio = DA850_USER_LED0,3 T! u2 l& o* T, B* n& F+ i
.name = "user_led0",
' ]" ~+ _+ J4 [! c .default_trigger = "default-on",8 D. g1 w0 p# }: E
},
6 t6 h0 P$ i3 i {
1 P8 O1 [/ E! N- h0 m- S* f* D .active_low = 0,$ Y) L9 G+ r; F9 N2 ~0 _5 i* n @
.gpio = DA850_USER_LED1,
( z, I& B* z" I .name = "user_led1",
) a4 K, |# A) w3 l: d6 y* w! ~" M .default_trigger = "default-on",
2 n) |! f- w+ n1 M9 g W/ z },) A; v2 C. T" q8 r9 `- g& x! Y
{, G7 C/ P) A, K, ~, o$ Z+ r0 H5 L) ~
.active_low = 0,6 p7 r* E" q; a" |; M! X3 z
.gpio = DA850_USER_LED2,
( k( x$ q) i3 h$ t* E w( ] .name = "user_led2",
" M& a* k& [/ T6 J* {( l .default_trigger = "default-on",
) U. D$ l3 j) ]! y4 j* | },8 y6 Z% j/ M' o5 e& u# w
{* X* m( _# i% y: Q# }
.active_low = 0,
( N% q7 ?9 a0 a# X5 J .gpio = DA850_USER_LED3,! m- B- `, q' f" T* ?
.name = "user_led3",
$ ~2 I& A9 H* ` _ .default_trigger = "default-on",
6 P$ V, T, i8 ~; _1 U3 x },! ^+ ]+ k6 X7 O
};
/ u; a) C4 y c; \4 p2 z7 D4 ]9 v
( I0 j" o4 a: n ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) l( c z* z6 c+ H .leds = da850_evm_tl_leds,) l+ J1 g" w+ K
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. Q" C) U$ ]8 X* `5 X};
& s/ j( @# C2 a( ?+ h3 d* J7 O
1 e1 Z* l; g& u3 zstatic void led_dev_release(struct device *dev)
; `0 ]! \5 {" ~/ M' \0 F{
, V1 t; J2 G) Z% ]};3 U& B* Z0 j& Q6 |
7 a; {! n G9 ~7 Lstatic struct platform_device da850_evm_tl_leds_device = {
" u/ M |, Z3 z .name = "leds-gpio",- R' Q3 ]) |* i. c8 r4 t
.id = 1,
/ w8 e p; k7 f1 Q3 T7 X/ W' a .dev = {
* Q! |* ~9 ^; B) P! X$ |& a .platform_data = &da850_evm_tl_leds_pdata,
" K1 A7 q2 ~; `) p/ `' {4 F .release = led_dev_release,
- x( ~5 f9 d1 z; }. ? }7 L8 N$ X+ w, f" _; K
};3 ?' x/ s4 ~: o- N
9 I9 |4 e1 N* p% r1 i, |static int __init led_platform_init(void), J3 S2 h$ e* D( {
{
. x, K8 I, W* R& l; t! P3 Y int ret;
, Y2 E1 v: w5 Q#if 05 ?6 Z# Q% J9 N9 I$ @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& }2 y; K! o! Y3 H7 z: U if (ret)2 Y' d# P0 c$ W% l L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 R& `( C& X. L Z/ r w
"%d\n", ret);
" t& ^( u' M4 o7 r7 F5 g& i7 }#endif
% \3 J9 ~5 }! t1 X( t; v ret = platform_device_register(&da850_evm_tl_leds_device);
- X$ t2 [4 Z( s. ~! V+ f/ `7 O if (ret)+ I- y" D8 ]) J7 c, y' R1 Q7 I
pr_warning("Could not register som GPIO expander LEDS");
$ `' Y/ E. M0 [. J; L5 w else
: \9 e/ |2 i1 L( G printk(KERN_INFO "LED register sucessful!\n");
4 X" l: R% ?, V8 {8 V; P9 i: G5 L: [# K! G
return ret;% _7 k) c3 W; {4 C$ i- A; \' e. o
}$ l/ O( F6 n6 ]
( I. b3 ]5 d0 ystatic void __exit led_platform_exit(void)
3 Q2 l2 ]; \% j1 f& z, v{1 M7 @+ H+ R l$ o. x' e. D! f
platform_device_unregister(&da850_evm_tl_leds_device);' {1 G" i- D* e$ P, s$ z, D
" b+ I! O) M% N; ~ printk(KERN_INFO "LED unregister!\n");
$ u% t1 M- g3 v}
& M# ?0 y8 W* ]( M0 a9 |9 s/ ^, j i4 h' I. V) b- F
module_init(led_platform_init);* |/ Z- t& c7 O
module_exit(led_platform_exit);3 P/ M3 x) K$ F z+ K
# k5 F. h% I6 F6 Q, jMODULE_DESCRIPTION("Led platform driver");; u6 z% W6 N/ D' E9 f
MODULE_AUTHOR("Tronlong");
( r4 J2 m" r! n* sMODULE_LICENSE("GPL");
, f: \' W; o& e; w7 J3 O6 `/ F8 |" D% c
|
|