|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& k/ }" _5 o$ i#include <linux/init.h>' x# J) b2 `" s$ f, e
#include <linux/module.h>! d$ [" E$ p; j2 F4 i
#include <linux/kernel.h># F" _6 v5 ^ |; e$ Z
#include <linux/types.h>
* d* G6 u1 i; e9 i#include <linux/gpio.h>
+ H9 o; R) M R( y#include <linux/leds.h>
* N5 I* B4 Z6 K) n. {2 Z. F; ~1 A. L#include <linux/platform_device.h>* c8 [% R5 U* R3 m; x, ~
% u0 r; \% X5 q' _0 J. w% {% z& w: v#include <asm/mach-types.h>
A: h; H$ d8 N+ P#include <asm/mach/arch.h>) {6 E2 S! P t. ~' p
#include <mach/da8xx.h># ?5 u# E# p; I$ }
#include <mach/mux.h># O9 \& ]2 s/ x% w& \9 B0 d
, s% H4 R1 r, J6 S1 G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) F+ s# I& {8 [$ a/ F9 \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 I0 o- l5 {9 G7 ^4 J! k+ a( K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) `+ [& A+ T' [; m5 t" {; L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) c0 d0 T) ~8 O& p _( \, u; g
, J9 x/ V3 ~8 G' R! [1 R- o8 @/* assign the tl som board LED-GPIOs*/
G' r* ~5 U W& o( |" Pstatic const short da850_evm_tl_user_led_pins[] = {
" w/ E+ J- i/ v /* These pins are definition at <mach/mux.h> file */7 j' {- L) ?7 |* n" v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 W G5 }5 p$ Y6 e& O -1& K4 E- y) W& c$ ]1 W0 e# b# j
};
N' C; n# Y& ]' L: X% S* A; Y4 f5 v/ }! A
static struct gpio_led da850_evm_tl_leds[] = {5 ^9 c& l) f( Z# F
{; H; t1 G; n* Q; f
.active_low = 0,
; ~. {* ?$ |* k .gpio = DA850_USER_LED0,
3 o4 F" V8 l0 R' x6 l5 X .name = "user_led0",
I5 v1 K! d1 |- u* M .default_trigger = "default-on",
E: l# |2 B! x( x6 Y+ c },
& |! i3 J% T! ^ ` {
# p8 P& y) u2 \6 D6 O% |' l! R/ J& {% V .active_low = 0,
) m7 Q/ {7 T; x+ ` .gpio = DA850_USER_LED1,
( W5 e( q% T& O .name = "user_led1",; X% n1 M+ H% x7 H; v: s' i
.default_trigger = "default-on",& P6 \( L. b/ [+ x
},4 U, E) m7 u Q5 H$ k( J3 L' n
{/ f" ?& A) W: E( g+ ~$ Y
.active_low = 0,- s; l/ l) O4 `8 L4 F e
.gpio = DA850_USER_LED2,6 V( g3 Z) }& K/ Q5 `
.name = "user_led2",
3 l* U* e5 W1 b* K j, p$ ~ .default_trigger = "default-on",2 E8 D! v. p6 f* ^
},
' _7 l. x n, U& h {3 Q& t/ K8 |, e: u$ G% x( B P5 C
.active_low = 0,0 f% s; _% g9 z0 X; ?0 j
.gpio = DA850_USER_LED3,. O1 `6 _4 ]3 l
.name = "user_led3",
5 t0 P% U) D: Y# h# a3 | .default_trigger = "default-on",
+ ^: o( r! V! v2 [$ t/ s0 A9 o },( P' ?3 E* p& s# k+ t
};) r4 R; T- b. B8 e% D" F& w* M
% [/ ~7 x/ w0 A- I* @4 D5 bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# h j* {2 ]; N3 r2 A
.leds = da850_evm_tl_leds,
1 j- C# c2 h: m1 E. g, T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# [# G# C5 j6 S+ ^
};$ h3 n; v9 ^( h; D
- g4 l6 o# _# v: b3 ^( m* v% ^static void led_dev_release(struct device *dev)
# B1 b0 b+ B5 d0 \) d P{
! P% v, @* @3 S" {" y}; @/ Z8 A4 r P
2 } G0 g! y! q5 ~* C$ x5 Z
static struct platform_device da850_evm_tl_leds_device = {: c( W. D) ~" Y* H6 m
.name = "leds-gpio",: G/ E4 y# P2 `: n" a
.id = 1,- _1 } Q6 q5 Q9 G5 \$ d/ [
.dev = {
( q- a/ G+ [8 [& `( |( ?; W .platform_data = &da850_evm_tl_leds_pdata,4 f( e0 z/ T& j5 w6 ^1 `, j y
.release = led_dev_release,
; V$ A* f# Z5 Q }' Z$ L+ o1 d6 f) V( B& G- T
};7 R( Z4 K* V7 S; z [ V
" ?5 o9 q) R* X, M
static int __init led_platform_init(void)
$ V" \3 r3 [, o{2 a# m/ ?" e8 t i, S
int ret;
5 S& }( I1 B- t0 N J N#if 0
3 I" W2 B8 D; f0 @4 \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 p/ K* a7 l2 I" E: [ if (ret)
9 s# h4 |4 S$ P, H8 N- ^$ U1 U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 I6 l2 D# j7 r "%d\n", ret);- S5 w$ v8 q( K/ l' F
#endif' W; A, L$ }$ T6 H+ q3 U% M
ret = platform_device_register(&da850_evm_tl_leds_device);
) |+ J* R& V" D& M if (ret)
, w- p H) M. a0 W: i( H$ C) z pr_warning("Could not register som GPIO expander LEDS");7 |6 z, a l4 G7 z0 J4 `
else) _- P5 \; y& k( i& |' _$ J
printk(KERN_INFO "LED register sucessful!\n");2 e; f4 W& i$ @4 Y" ^& j% u% B
1 ]( W" p) v# @, d3 U! l1 k return ret;
! @- n: o; Y: }! u" j4 R5 M; r}
; d7 k' ^% _/ g+ A% A; E
9 B+ x( T, ?/ @2 r/ i1 ystatic void __exit led_platform_exit(void)
3 q5 G' X9 [& z1 a{
& h- q; u& k5 R3 g platform_device_unregister(&da850_evm_tl_leds_device);/ W- q, W7 h+ G+ e7 p2 x, [* h# H7 K7 P
/ j) o8 _. D: j' Z
printk(KERN_INFO "LED unregister!\n");
8 f7 E1 O. w1 `" @) F) l6 W}
+ D4 A# C1 ^3 D5 [, k- n& q. a, g5 o
module_init(led_platform_init);
1 L7 G1 C$ E/ m8 i* {( ?3 xmodule_exit(led_platform_exit);
: w$ f1 J" {: Z/ w4 C q! G, A
' Y4 v K; x7 rMODULE_DESCRIPTION("Led platform driver");
1 q6 n; G2 {7 ]1 YMODULE_AUTHOR("Tronlong");
3 a* P6 y' i; u5 f3 T1 I SMODULE_LICENSE("GPL");6 O* l- v m! d9 p" J+ T
2 I+ V4 z o" b3 ^6 l+ q9 M c
|
|