|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, n2 X8 `; D8 O7 j% _9 T# D
#include <linux/init.h>
( }9 z: R" s; U D+ b# O+ L#include <linux/module.h>& g, X; d1 Y X$ @
#include <linux/kernel.h>
0 c. [. I1 e3 z" {$ t3 F+ {% s#include <linux/types.h>
- V# y* R! i4 Y! e#include <linux/gpio.h>
$ f. N' u& i* M#include <linux/leds.h>
$ u; C2 H& i/ a, _#include <linux/platform_device.h>" d; `! q- {6 F, K
& m0 D0 s. y U& \& z
#include <asm/mach-types.h>: b! I9 i- ]+ t3 D9 y! m
#include <asm/mach/arch.h>% m9 C) Q+ A+ t. N: c9 y6 s9 y
#include <mach/da8xx.h>3 Q Z' f7 ~/ A7 ^, ~/ x d
#include <mach/mux.h>% F) h) U9 }: M6 r6 k
7 l8 Q/ _. W: A n& J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* N6 v; B6 N2 C6 V1 _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 n! b& h+ z6 a8 c$ K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& N5 d' C! W! Z: J; V1 }& m8 |1 p& l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 L3 L0 [0 @0 N2 \; e k) j3 i2 F; r
3 }5 F, ]$ ^, I, V/* assign the tl som board LED-GPIOs*/. q( m# k0 e9 q; `7 U/ k
static const short da850_evm_tl_user_led_pins[] = {
0 |6 ]7 v V( b/ A# @3 d' a" ]8 ` /* These pins are definition at <mach/mux.h> file */1 h! C. A5 {; J. m& ]
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 { v9 w Y( b4 x. x) @) Z6 c0 U/ M5 B -1
3 a- r9 R) }+ e5 [7 L* O. _};4 j$ v4 c/ B+ B. D
k4 f3 L% g# |! Z% Z1 A( V' P+ W
static struct gpio_led da850_evm_tl_leds[] = {
0 X, v i; F+ ? M {7 v6 V, e: e* _
.active_low = 0,% F9 J% F+ ]: [4 e4 ]' V
.gpio = DA850_USER_LED0,
. B. [. o# ~/ v7 e; d' U# p0 B0 N .name = "user_led0",9 d% E- h8 b; w( F% c
.default_trigger = "default-on",4 a3 T2 k- u. a( T
},
' f3 |& t7 _/ H7 z1 f2 ` {
, j4 i6 {) b( F/ q3 W .active_low = 0,3 X9 N2 _6 Q1 K
.gpio = DA850_USER_LED1,
; D" H6 a. R+ g+ V( y/ b .name = "user_led1",
- l, j. ?& A& j5 ?5 u .default_trigger = "default-on",7 B" _8 n/ p. n+ g
},) F, J2 ?& q: \ Y
{
6 \. `9 {6 q7 Y6 V. s% O. s .active_low = 0,0 d1 v3 G# Z+ t) K- G- V
.gpio = DA850_USER_LED2,
O! G5 y% s6 c. { .name = "user_led2",
5 K' N* I7 y# o* L) q* Z l0 O .default_trigger = "default-on",+ b" ]# |, h% ~4 c* U
},' @* ]& s: n; }+ G7 n" Q
{9 O$ o: `. J3 p$ [# x
.active_low = 0,/ T0 v8 V4 y6 i8 ^3 p7 J' _2 R: @8 c
.gpio = DA850_USER_LED3,% l$ S! l. h% ?$ Y
.name = "user_led3",# [" l3 @& |& q/ }5 B
.default_trigger = "default-on",
9 e, K1 o* j1 N4 C },
2 c- ~- I. I& ], X( D( d};3 q7 J7 J" l3 { a
/ h4 d; e/ N4 q, T. G, m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 X) W% B/ m- V .leds = da850_evm_tl_leds,$ [; [0 D0 _7 H
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* _7 A2 r+ @9 y7 L
};
/ ]5 [, U/ V7 X \" A0 F
w& c4 E ^" z0 y: Rstatic void led_dev_release(struct device *dev): U8 z% C" t \, d5 D
{! _7 A9 u( ^* e2 U$ T l6 G8 `
};
6 U" p( q8 a) `0 T. I, D4 ^9 }
# F# @# A) i; c; B1 R% T/ |static struct platform_device da850_evm_tl_leds_device = {
! k9 j. z) ]( h .name = "leds-gpio", s/ y/ s% n- Z8 |% x$ N! e7 z" W
.id = 1,
) `2 J9 i/ v* d; P( A .dev = {
0 T! |4 m1 h, C( v; L .platform_data = &da850_evm_tl_leds_pdata,. D( S4 M2 X$ P% e5 B( J* A u* y6 A& t
.release = led_dev_release,. N! y; C! L+ o1 j e" a
}6 @/ w; T2 ?! P1 v) q* Y
};( o4 V$ e r- g* e" s
3 L9 ]+ u% ?5 r0 S) Y( sstatic int __init led_platform_init(void)( R3 Z& N0 r1 f" t
{
( w) W) e/ Z6 g8 h3 d int ret;2 d5 O- v2 a; {4 k
#if 0
; f" f7 V4 ^+ o$ e! z% p$ U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 M8 H1 f( n3 u1 ^ t$ p1 v3 k
if (ret)6 y7 V C) W; R) |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* [& w' A4 y/ T( D
"%d\n", ret);) L- R" T9 j P( ^! p. Z/ Y4 M
#endif
* `5 H1 C8 z6 _- a& [8 U ret = platform_device_register(&da850_evm_tl_leds_device);
4 J5 j3 m' t# P; @" S: h& N if (ret); ?7 r# P. |2 `5 t8 l; r
pr_warning("Could not register som GPIO expander LEDS");
2 E; M) \& x- ?- v' _9 A else" p2 K0 D3 i* @
printk(KERN_INFO "LED register sucessful!\n");
: M- N/ c+ M% Z, _+ K5 L* i# c+ y/ T& k* b
return ret;
7 z& o/ \; C: z! Y}( w" p# b0 O& e0 P, `- _: V6 _
1 t+ b$ E) T# K) v( x% Cstatic void __exit led_platform_exit(void)7 h$ s: N4 R5 w V( U: r& d
{+ Z9 G1 R" N: I
platform_device_unregister(&da850_evm_tl_leds_device);
3 _( e( F. s" |* }5 y- |/ a j
! H1 m( W( V6 X1 M8 d% I$ H printk(KERN_INFO "LED unregister!\n");# |# U. {9 n, t5 s+ h5 z/ B
}, c* g$ b1 [) X* Y$ I+ J$ H$ T
0 l$ @1 X, u0 V1 c! \1 V/ q
module_init(led_platform_init);
% z2 O) O ]9 T) j2 t" Pmodule_exit(led_platform_exit);
' x3 ]- j" H) |9 H, v5 T' |* J8 b+ }( U$ q. p! {" f, u
MODULE_DESCRIPTION("Led platform driver");1 l" H; k0 w( D$ k" a4 B0 ~0 I
MODULE_AUTHOR("Tronlong");; m( v. y2 ]5 v3 J+ X4 Q/ ?8 O
MODULE_LICENSE("GPL");, ?, G9 k6 f8 N6 O9 c- |
" f% x# r% D4 i1 Q. ?; x. x |
|