|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& U. e# f7 z- w7 H6 u6 c( u
#include <linux/init.h>
! l5 e8 @8 Z/ {6 K$ j6 w#include <linux/module.h>9 S6 h7 l; W8 t
#include <linux/kernel.h>
& A# U7 b! d4 V% a( W#include <linux/types.h>
: |8 N! i6 ?/ u% F4 c#include <linux/gpio.h>
' f4 b9 X' x( ]$ _#include <linux/leds.h>5 V5 s* j0 ^2 G- M
#include <linux/platform_device.h> C. Q, p" Q- x- E0 E$ q4 d
4 a9 N2 X! A& t, ]#include <asm/mach-types.h>$ G% L/ m2 B* i3 D6 F8 v3 v# z
#include <asm/mach/arch.h>
8 `# a* M% L+ s9 x#include <mach/da8xx.h>
. l/ T8 a* [+ E9 z7 u#include <mach/mux.h>4 a% _) P1 g5 v: |- S8 J
- y! {- f; ~6 ^/ T! }6 X; Y' s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! Z& E7 Z2 l" L5 X. ]$ h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, F& J3 O7 q% k+ t; ?& h# o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ U" k. q. |; o5 O1 G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ x; }5 `( a9 e! i" b& E, J |/ n. {3 f' ~8 W* _8 r7 x
/* assign the tl som board LED-GPIOs*/
}: v5 E, J3 Y, Q$ Sstatic const short da850_evm_tl_user_led_pins[] = {
$ c O- T" m) ]) S: s /* These pins are definition at <mach/mux.h> file */
w& D! }8 T+ w% n# R$ B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, }4 P$ ?( n3 r1 H0 Q( U& @
-1
* Z" z8 c+ C& o8 X/ Q};
! p4 ^/ o6 ?( ]. o& x6 k( A9 w* j0 z
8 e/ E' d* ^0 pstatic struct gpio_led da850_evm_tl_leds[] = {
" m! ~, U' B6 B8 }& J: s, { {9 W6 W/ U) ?$ K- _, R! Y( V
.active_low = 0,
9 D& n: M+ |3 G7 E- U8 ?* @& V .gpio = DA850_USER_LED0,
3 ?& q" Q9 ?- r% ^) q( B .name = "user_led0",) b! d* ~: U/ ?6 W; w S$ O4 O
.default_trigger = "default-on",
6 ?" U0 k3 K; Z5 H7 g },
7 K V/ M% Y, n) b0 ]$ b% l& T {. K4 |) r6 I% F8 O; {
.active_low = 0,
$ R" E2 j5 K5 b0 { .gpio = DA850_USER_LED1,2 O# c, ~ J8 U0 z9 B, O# o! B
.name = "user_led1",6 ?( V; P4 Z1 N/ ~; o2 U& j
.default_trigger = "default-on",5 A: `% v+ r4 H, x
},' l* c! Y, _# H7 B) P M# a9 e
{
3 G, S+ f1 n6 a" `* v8 a7 [ .active_low = 0," Q' j/ [3 w; G# e) e
.gpio = DA850_USER_LED2,1 C. k1 y8 p V) |
.name = "user_led2",- b ]0 o6 b* H8 w' L2 c
.default_trigger = "default-on",' t9 k' G" ~- ?: d$ G
}," U9 G! Z. V; m1 P/ F
{8 k* F! \* \* ]4 I6 Y! }/ k# k9 y8 R9 d& P
.active_low = 0,/ y2 g3 Z0 Z$ t# d2 U
.gpio = DA850_USER_LED3,# ~! B4 H w/ B4 G+ o- E0 X7 ]
.name = "user_led3",
# B$ ^& D9 V6 A& l6 A- T/ {8 I .default_trigger = "default-on",9 V# G% F% U: c7 S
},
1 p! G k$ m- c$ h# D! I. \};
& w ?5 }# d& g- u( ?$ q8 q" I5 H6 n9 t( q3 ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# z2 f# p/ l/ H- r. U- s .leds = da850_evm_tl_leds,2 [3 U4 e, Q3 R; I2 e2 S! Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 c) V- g6 X0 C' R};" s+ T; m' I, G. v; c
% ]6 b9 T1 B7 c" lstatic void led_dev_release(struct device *dev)4 E. o' S# j2 L0 n+ u/ m
{ [2 v3 `& `$ }9 s( B& G; }
};
8 V$ i( l2 n5 R4 a1 @( X. Z& n8 D& e: Q. S- k) h7 m/ c2 E
static struct platform_device da850_evm_tl_leds_device = {/ n7 ^3 p0 \2 `+ z- P4 d
.name = "leds-gpio",
% d' l: A* f2 v. l' E1 E .id = 1,, s& \4 K: v0 G" ~- f
.dev = {
/ ~1 f. Z! N! a* v9 a .platform_data = &da850_evm_tl_leds_pdata, o. `) `. ^9 j1 y- ?7 Q& o$ u! ?+ @
.release = led_dev_release,' O+ C6 {! s1 n! v, `0 S+ O
}: o) M3 B$ G6 Z8 O- n; V
};
# i3 g+ U; p* L, O3 t) u6 m9 |, t( U; e2 r( `
static int __init led_platform_init(void)
8 m9 _2 C8 ?- f" i& c0 m. q{3 q$ m1 C0 S* {
int ret;1 S6 Q) _/ N; B; r! ], K) ] m& Z1 j7 q
#if 01 P2 J# i {& F( o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" j. e( R3 T" Q* r4 G: Q' ] Q
if (ret)8 S, r# @5 r- x3 J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 e1 p3 a3 P3 u "%d\n", ret);; H+ i1 W# j, \* M
#endif
' ~" D1 Y; q7 m/ d ret = platform_device_register(&da850_evm_tl_leds_device);
5 s& j3 U7 L- Q" e4 z if (ret)1 n8 K# o5 o/ d0 J! ^
pr_warning("Could not register som GPIO expander LEDS");3 k9 t! T$ S, | f
else
1 U" q- K0 B' `2 g printk(KERN_INFO "LED register sucessful!\n");2 a% |6 V- Z6 K: ^- }
5 S& c+ O0 g: c) E
return ret;
0 y0 M4 l# f0 e: Z* H- g+ A}
6 A0 h' Z' o; q; w" d3 t2 x' E1 I5 M# W/ i6 |
static void __exit led_platform_exit(void)
B. n5 x* @& ^6 g+ H+ k{
% u* s! v7 Y# m( k4 C/ p# x7 h- M platform_device_unregister(&da850_evm_tl_leds_device);
& g2 r* E2 O* ~; w" N' W$ K. `' o) {- t+ V; e# h
printk(KERN_INFO "LED unregister!\n");
9 z, g b! J: P& d* m}' |" ~' M8 s4 P6 l Z& K/ i
% d, i$ \ z; h. X, g! l8 cmodule_init(led_platform_init);
% X `5 ]9 m" i5 Pmodule_exit(led_platform_exit);1 }' }$ C! U- I6 O- k3 k
4 v, l5 l4 F7 @" C, T
MODULE_DESCRIPTION("Led platform driver");
3 N! L. A- X' A t1 N8 [MODULE_AUTHOR("Tronlong");% W' x+ m5 U: s3 P3 h; \: ~
MODULE_LICENSE("GPL");
& `& B- C- C" L) @' P! ~4 G0 w1 r4 y5 _5 t
|
|