|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: i0 U- c1 v" G- \" c# E: Z1 j
#include <linux/init.h>
0 c% B& t' w3 |9 ?#include <linux/module.h>
2 [. }' f5 {" u0 [#include <linux/kernel.h>
F2 v' k R2 D8 V# f* f#include <linux/types.h>( a2 b. A9 P$ v+ E+ G7 a' J
#include <linux/gpio.h>: v C/ ^" U1 Y3 N2 }' T
#include <linux/leds.h>% ]+ V6 P/ o& P* W# R' x7 x) K
#include <linux/platform_device.h>
% C! m/ E, ^; t5 _* j5 y1 P# h7 B$ ^
#include <asm/mach-types.h># g5 v5 B: Y4 U' d
#include <asm/mach/arch.h>) D# A1 R6 m" e( w) g# `
#include <mach/da8xx.h>9 S4 ?/ o& h0 D' V3 `4 w* a6 U
#include <mach/mux.h>6 N" G" i$ i8 K' [
2 h, M: p5 g8 w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- Z0 o/ H5 ~! O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 u; P0 C" F4 Y% P2 R& [. m6 [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- w, |+ k# G! S- W& [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' X' s# y) X, @ |, c
) \! v) ~, g* t. F4 w. V1 u/* assign the tl som board LED-GPIOs*/
7 c! S; D5 Y: b! ~: Fstatic const short da850_evm_tl_user_led_pins[] = {
1 ^5 Z' i Z8 b+ S /* These pins are definition at <mach/mux.h> file */; S T: H9 I& @( L& l
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, l! [2 W) F$ S -1
2 ^# [3 { t0 }: G9 d};" t$ Q, z; }/ w# S8 C" L
/ X) x4 d0 X Istatic struct gpio_led da850_evm_tl_leds[] = {
9 a( V$ w9 v) U# f {
8 l# Y3 [3 S. J8 a# T2 h .active_low = 0,6 r5 m1 T! P' M, J/ W$ o2 D% H4 ~% E
.gpio = DA850_USER_LED0,
$ z; C2 @# S3 |) j! B5 }. J" B .name = "user_led0",- \8 w, l" M2 n# h% p% n1 t( t
.default_trigger = "default-on",3 J7 k" H0 c1 p. G9 _
},
. d# x! S9 e/ \& T I: y: U {+ t8 z( r/ S9 ]) a
.active_low = 0,
4 \9 J$ S8 N7 r .gpio = DA850_USER_LED1,
4 q; p$ g) T1 j" S .name = "user_led1",
7 V1 J. o1 T5 z# o: n .default_trigger = "default-on",6 r3 G r0 J; @9 d
},5 }: o$ z8 W d( Y' j
{0 Z5 b9 v! i! J1 u, F# b. l! y
.active_low = 0,
& A0 z% E+ G% R5 Y& ~5 B! U; U' M .gpio = DA850_USER_LED2,
/ U/ t( z I# V. ? .name = "user_led2",0 v4 J( I7 }) C
.default_trigger = "default-on",
9 M t. ]: \& N7 o* M },
4 g- d- n$ n$ S {( _2 x, K7 V; i& s+ q; \0 k
.active_low = 0,. w6 g# |; @: {* `; _% D& e8 M% U
.gpio = DA850_USER_LED3,
) K0 q, k% H. I% i- B .name = "user_led3",
" _. t) g" W/ n3 k .default_trigger = "default-on",: d9 X. c/ v7 j) w- y' y) r& c
},
3 A: W- q5 ?# g0 {& R! ~' o2 X};
: G2 m4 n u! L- N5 }
7 n% g4 \ K* y& E1 S" o2 d2 Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, ]3 M: ^: N( O4 l, n, p
.leds = da850_evm_tl_leds,
$ y: R' O7 d& \/ c8 F% ^+ m! h t9 g .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- {: k9 x' x- c+ _' M};, j/ ~, U+ v$ ?% q# ~
% X& C. L+ |2 Y' r/ {' i3 @' E
static void led_dev_release(struct device *dev), V( C2 A0 E) ^1 R4 ]1 e ^4 ?: r
{
) ?5 o. w* q8 q/ n$ D) {& j- m};
# U% z6 o" ?/ d6 c( Y4 s& T$ W" l$ o& k2 C9 _2 h# `
static struct platform_device da850_evm_tl_leds_device = {7 Y2 B- P4 K9 M& F' U3 t9 V
.name = "leds-gpio",) X4 {: T' y& T2 ~8 _1 Q
.id = 1,+ H1 V1 s, L2 s$ w" n
.dev = {
\( C( m; I, p' a* H .platform_data = &da850_evm_tl_leds_pdata,
D4 q1 \" Z5 d# T9 K/ f .release = led_dev_release,0 C- P1 }1 r4 l* ~9 y# k
}: Z- M0 z9 w' g8 c, \
};
1 ]* m1 F+ C! Z6 r' g
/ }# a; f1 O6 H* {; w9 R' S* n- t& wstatic int __init led_platform_init(void)
! A0 `) m/ o, U j$ p/ N{' k; `5 U+ r5 L6 i
int ret;
3 k9 N) ?- M8 c+ k3 }#if 0
8 }: l/ y( x m, q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 k, W& J" _. N! b: t8 q; q if (ret)
: k: M2 K1 N$ v- B/ Q$ ]: W* O$ k( }) C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 g: t3 G0 {$ _$ i/ d8 I& T "%d\n", ret);* }8 U* N3 q9 `& C, ^: ~2 b0 ]
#endif& d ?! r& @3 a( m, z
ret = platform_device_register(&da850_evm_tl_leds_device);
/ ] \5 \, p# d+ o2 |8 B' U if (ret)4 G% ?, A, i- D1 @& \* b
pr_warning("Could not register som GPIO expander LEDS");. I) N% h3 \ ?, K
else
' u: a3 f6 F6 K; \* i7 A& t4 K; }" I printk(KERN_INFO "LED register sucessful!\n");! e3 [6 r& t8 D. C( o+ r. ]
W8 v, t6 C& l2 S: Z- i return ret;# |, V6 G' W1 I9 [7 ?
}" `, |! T/ H7 D6 y1 w O4 Z
Q8 m, e, @, f; ]static void __exit led_platform_exit(void)# W0 l% k0 X3 b+ i2 k& W0 w; N
{+ d0 E0 S* W% I
platform_device_unregister(&da850_evm_tl_leds_device);
! O% t' [/ |3 _9 c) a6 l. k L, N' J% N: i( A& ^/ l: }6 v; R# V
printk(KERN_INFO "LED unregister!\n");1 ^! b' v7 }) s# ?6 O
}/ K" W3 p5 i p+ y8 i) y
/ k* l/ \; |* f9 h
module_init(led_platform_init);
# w0 \7 O7 u4 x- Vmodule_exit(led_platform_exit);
$ H) n6 `# n# V& X; [+ x9 ]4 m! x+ l- @" @' r
MODULE_DESCRIPTION("Led platform driver");* q) W% W& ?6 C3 B" Q: u
MODULE_AUTHOR("Tronlong");
, F" b. z: G& x9 aMODULE_LICENSE("GPL");
. @" c8 j$ p5 {8 d$ c3 s
% P0 w W+ S0 V( }" ` |
|