|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: e( b5 R$ L3 p! {#include <linux/init.h>- f# [. s- d* c' H8 Z ?' L |
#include <linux/module.h>
" w6 J" `; ~2 u7 T. g) z+ z. M#include <linux/kernel.h># t) {2 g9 g' q9 ]
#include <linux/types.h>
7 |" L( Y- }/ T0 W s#include <linux/gpio.h>& F0 Z; k4 w# }
#include <linux/leds.h>
$ c* t" y7 U# N#include <linux/platform_device.h>
B% w- i p8 q8 w/ t- M8 F5 X+ I$ o1 w% I l
#include <asm/mach-types.h>
4 q! T6 x# y# o0 o; s# H# N& j1 o#include <asm/mach/arch.h>
0 {# ]5 O4 w4 L5 u#include <mach/da8xx.h>
2 [. S* C4 B9 q8 N; A5 `; w#include <mach/mux.h>; j* B( I: f" L, o3 d9 x
# B3 q9 H3 I! o7 K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). R4 x- N5 g6 W# W
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: g7 d/ Y/ A8 w! h#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& g- q, F- q, ~! [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ O% c- K* _% B6 |1 Y
9 t/ m7 m+ x$ N/* assign the tl som board LED-GPIOs*/
+ r( I: V' C0 @) }static const short da850_evm_tl_user_led_pins[] = {6 k% i$ v( g. T( [
/* These pins are definition at <mach/mux.h> file */4 m% A4 l! l+ ]; T
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) X% h) y# u0 d8 Y. n -1
9 `# I( S0 s8 Q1 M};
& `: K- l" I; N
! Z- g% w6 ?; X( l% K0 V* qstatic struct gpio_led da850_evm_tl_leds[] = {
) n6 X- ^, N; N$ ^( d8 b5 Z4 { {
# `, F2 U0 A+ @4 b+ C4 U- p- c .active_low = 0,
" s( ?4 o* R8 {% Y% q .gpio = DA850_USER_LED0,+ p2 ~$ v' i* g1 Z* e
.name = "user_led0",
K" z! L4 |2 y% @! B .default_trigger = "default-on",
5 _) b# \2 o: z' d+ L2 H1 _ },8 x) I4 a! k+ a/ t# x; k
{
: k* ~+ y) O* s .active_low = 0,- l/ d( U; `$ v8 m! ~
.gpio = DA850_USER_LED1,! k5 e& k( m& h# O* r* q" {
.name = "user_led1",- x1 M; U3 v0 i* I# [0 B0 R% T6 G
.default_trigger = "default-on",/ _, o0 i! E" K+ u5 k0 a9 \
},
& T9 V/ D$ a7 b* F# v5 U {+ ]: `6 X2 q' V# k: q
.active_low = 0,
# i- s. @1 [6 P$ u6 B .gpio = DA850_USER_LED2,
# s" b( x% ?9 y1 l5 a& I0 G .name = "user_led2",
& v4 b) e; O' B' v( q! q5 N- X .default_trigger = "default-on",
% ~7 n7 s! d( X+ v },* G* @0 b3 D5 P1 D6 b5 R
{
( Y9 w+ V" K% u2 j- |: m- H .active_low = 0,
1 G, y& @; H/ x- e* J1 m% i: V1 q .gpio = DA850_USER_LED3,. E5 k# l: j% q0 ^7 \
.name = "user_led3",% M5 t: i9 u. A ~' x$ k
.default_trigger = "default-on",
3 B7 j$ b) K6 q( A w6 @ },4 }0 ?& E0 h# B
};
/ h: Q$ B, D6 e* B, V, F1 @, E1 J( k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, W$ B6 U, p2 N( x1 o) f .leds = da850_evm_tl_leds,
/ F; d E- f+ Y% j: j .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," X# Z1 \: Q% i+ R
};
w, X9 p: ~) h: a* R( o9 p) {6 U0 D7 S3 ^3 S' y- O5 f4 _
static void led_dev_release(struct device *dev)
- x, J/ x! j$ o1 E7 ]4 O$ l. E{0 N/ \5 H- G5 l& j) K
};- ^" w/ C3 R- v( X9 `6 C* @0 ]
) _4 `3 j3 Y( Y B/ H$ i) T
static struct platform_device da850_evm_tl_leds_device = {
0 m2 s+ N2 Y& }2 j .name = "leds-gpio",; [; Y P7 H6 v( f( j ` u! \3 {2 n
.id = 1,2 e& S/ n7 w0 ~. q! ^2 O. s3 O+ K
.dev = {; ]1 i) E! [ a1 K$ q% x" N
.platform_data = &da850_evm_tl_leds_pdata,
3 ?/ `. p' B$ p: V .release = led_dev_release,) {2 ~- s/ c# C8 X) j9 x
}
2 ]: M' F, v, v};: V# j; G' r% U9 H# |0 @ o- J
- U- [. G5 I$ }$ M/ U9 P
static int __init led_platform_init(void)
* q3 q& n4 n+ C$ g4 G5 |% x) I{: M$ @9 k+ l* t7 B8 l4 Z% k' ?7 q
int ret;0 P) N- \$ G0 D" D3 C
#if 0
/ S2 o1 J+ V( ]4 ~1 ?7 S6 b7 a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 U4 T4 T' F. }" H) D, j8 t. @
if (ret) v' ^' h0 G1 D: Z; _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' l2 {4 R6 x& @6 ]$ t "%d\n", ret);" G1 b" y" w5 L& W) d' j* ]
#endif
) c; t. c6 J- V" U ret = platform_device_register(&da850_evm_tl_leds_device);7 N3 `* F) l4 W4 U9 Y) n2 C
if (ret)3 |. x* c1 |+ a9 M1 R9 I
pr_warning("Could not register som GPIO expander LEDS");
6 ~4 e) d* ^$ Z0 N! _# v else3 |7 g% Z2 T( f5 _0 X8 J( E4 @4 u4 @
printk(KERN_INFO "LED register sucessful!\n");
3 ~6 |) g5 e6 d+ S$ I3 M* }
* Z( I8 N; v2 h2 J( T" k/ w& S return ret;6 U! E# _0 @: ~3 O6 R& ?9 n, B
}" D5 Q$ _+ a# p. g/ x3 h9 S: H
' `, J8 O# g6 c
static void __exit led_platform_exit(void)+ w1 v _0 k" M0 ~
{9 e, a4 A& |4 c4 j l
platform_device_unregister(&da850_evm_tl_leds_device);, j @6 P, X' q. {$ L
5 N1 Q, {; H6 n& }) v8 T
printk(KERN_INFO "LED unregister!\n");
* E! S( W/ \/ d F}
" H! ^# Q# v: ]( b) [0 }/ A/ W3 S' a# u' ~1 q9 H5 J
module_init(led_platform_init);
) a3 r* Z6 j" B, ymodule_exit(led_platform_exit);
# B) n3 g" e' x0 `! {: |
* x' c/ @" ?/ c, OMODULE_DESCRIPTION("Led platform driver");- g2 b$ ^0 B7 }9 o) h
MODULE_AUTHOR("Tronlong");# }% q( B( N( v( V0 S
MODULE_LICENSE("GPL");* ^ K& m: [# g4 Z
* G( u# z' R1 K- `" Y; A3 K! f
|
|