|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 K/ r8 d1 v. R1 [$ R' f
#include <linux/init.h>! N$ p) r1 S7 \! n9 ~9 E
#include <linux/module.h>! _# e. f+ h4 _4 y* n! b
#include <linux/kernel.h>
; K( u$ J7 f4 @) M#include <linux/types.h>4 a4 p' R- `2 Y# y' @; U
#include <linux/gpio.h>
6 a; A ]0 M- c3 C1 h- Z#include <linux/leds.h>9 L( C3 p# H' |, [' L& b9 {, ^# N% F
#include <linux/platform_device.h>, F6 L, A2 K5 {
0 T1 Q1 g3 ^9 g#include <asm/mach-types.h>
, m8 Z8 w/ R% l, g0 G. F#include <asm/mach/arch.h>( a* B; ?4 r) o; Z1 B
#include <mach/da8xx.h>
4 z2 ^8 \' F6 I" I3 Y# }0 o7 m0 G#include <mach/mux.h>8 I8 W: _+ u7 R/ J2 y: b% a" l5 [
0 a8 S2 G% B! z) u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. ^1 H+ p3 }; Q+ @/ q6 Z) P8 |#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 N$ @/ ]/ J% V$ B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 }1 p4 @! M8 G' b. W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) v' j% q( l% r4 D \$ v/ s9 ]
' D6 \! F$ K/ F/ N/* assign the tl som board LED-GPIOs*/: {! ?& P/ y" L1 H* {
static const short da850_evm_tl_user_led_pins[] = {
' z, V1 e4 @$ j' d0 N /* These pins are definition at <mach/mux.h> file */
1 h) T" H" y8 d1 g& C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# r1 Q( i" J# [# X7 J
-1
; f( m$ Z4 z3 N& h X};
" t( B9 q+ S* {9 s9 j/ f( S' ^: v1 H( X \3 A6 u3 x
static struct gpio_led da850_evm_tl_leds[] = {
( B; v+ N0 q I+ { {
# A$ }6 q ^3 H1 ?, k) W# A .active_low = 0,# S( `$ d# h0 V/ l" g/ l- x7 |
.gpio = DA850_USER_LED0,
6 H* E. Y; O7 ], e' Q' C4 k+ m, y: ` .name = "user_led0",
% q. s2 N/ k& I# J) L- ~ .default_trigger = "default-on",3 k1 q9 s) Q1 _; e+ }4 r
},1 u9 D) l" G- P$ n% D4 a( |; ` u
{
" _5 r$ @' j9 d8 h$ |0 ^% n7 Z! j .active_low = 0,* Y. `! I6 ?' _& }/ s' _: N
.gpio = DA850_USER_LED1,
2 R5 b) ^$ v4 l. ]# w .name = "user_led1",
, V0 M# c3 J: ]" r- A0 `9 W .default_trigger = "default-on",
2 s4 Z2 _ i1 ~ },+ d- W+ q5 G1 P" w- Q! }# W
{+ ?% q1 W$ J7 C
.active_low = 0,7 |: T0 ~! T- P% p
.gpio = DA850_USER_LED2,
% c1 t8 z. ^4 e6 w3 l q @ .name = "user_led2",8 U# d$ Z1 O. s
.default_trigger = "default-on",; t) d7 S% o; V4 B( y
},6 c0 f, B; b/ w
{& @# V& W; u9 i% |* N& {! O
.active_low = 0,
2 L5 U" ?5 ^, D( b$ K .gpio = DA850_USER_LED3,
+ n& b O5 \/ H- n .name = "user_led3",
2 S0 L0 k% P0 o7 Q. `5 T0 o# a9 A .default_trigger = "default-on",
9 P$ \; M% y. k' e: T },
, B& z! d8 T; z3 d! ?0 A4 q# h# Q};5 l4 l5 {, y9 J1 z5 Q
7 P& T8 L |4 e2 ~! g$ o; Q/ Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% r) _0 U D) M& W* b" F4 Z
.leds = da850_evm_tl_leds,
- a1 U% f% G" R# T: I+ |6 t, v .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& U+ \$ J7 H% @
};: C2 @: B, w* L t. E
: T5 A! @ N# f
static void led_dev_release(struct device *dev)7 `" a& }+ [% D7 M+ C
{; M0 _$ b( @. N9 i. ]2 b I; c
};
6 `+ n9 o" g3 V
! X: ^( Y$ p, H' }: c( B7 n2 rstatic struct platform_device da850_evm_tl_leds_device = {' V9 r2 S, A" I; a- m
.name = "leds-gpio",
: x+ G" J& E$ |: Y- Q .id = 1,: Y! l7 r% r) V7 h# k/ H
.dev = {
; s' o! }( b2 _# A3 d4 c .platform_data = &da850_evm_tl_leds_pdata,: V- i: R, F. d8 R5 a6 [. _! @4 {
.release = led_dev_release,! U; O& T2 @7 {2 i' S4 G9 U
}
1 k; [" m( s4 l E" k% s};
% }7 C7 I/ ]6 D# Z; i2 p" t' o
& c+ q& K0 R0 {( s3 i \static int __init led_platform_init(void)
: I& V, {5 i: B9 P- t0 l{' D( j& e8 n% u A
int ret;% `% G) H, [7 X9 y. P; h% @
#if 0( t) u+ D+ F- v0 O% b' N }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 |$ X( ~5 j, G, w7 N
if (ret)8 ]' S0 |9 S9 X9 \/ `; K7 m
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 j" D( n7 C) f- u e& Y5 R* _7 U
"%d\n", ret);
$ z$ p0 ]% [ i4 A, Y- }% I#endif
! E# a/ S$ c8 [; v; ~ ret = platform_device_register(&da850_evm_tl_leds_device);# U4 Y2 V! b1 r9 f$ t o
if (ret); d( U& }% {: u% O M! R, }
pr_warning("Could not register som GPIO expander LEDS");' A3 v% u2 W2 `" {8 W# N
else
) r, [4 V8 x. C7 K. v printk(KERN_INFO "LED register sucessful!\n");" @3 S6 M3 P( M: H- l
9 Y( k- r, O( H x8 o$ }
return ret;
( S# t' r3 [1 M$ D}: a: l! l+ j4 m' I8 c
* k. B- \: w* s7 l! R+ e* f4 n, @static void __exit led_platform_exit(void)
/ L; j7 ^- J! M! Z{# Q! S& O7 h. g7 Z6 |' a+ Y' a
platform_device_unregister(&da850_evm_tl_leds_device);' U$ | r( m/ [1 |
! Z% Z; |. H1 H printk(KERN_INFO "LED unregister!\n");
$ Z0 b4 g$ s9 r7 c" e: r}8 H4 n) V' Q2 ]. W% D
* U7 I8 [$ V& f- j" r- W& I1 x, V
module_init(led_platform_init);. x* w7 T2 y$ T* `& B8 W
module_exit(led_platform_exit);3 _1 r' S$ u% ?( Q9 ]: P5 S3 g* N
$ j) e2 j8 O" m, X
MODULE_DESCRIPTION("Led platform driver");
3 V4 C: o' g& y: D2 mMODULE_AUTHOR("Tronlong");; q5 H4 G' j3 ^3 i! v A- y1 }
MODULE_LICENSE("GPL");2 i+ C6 x. L) r+ f
1 y& K& Q9 F- G$ @
|
|