|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 }3 p1 i) V$ W3 m/ _% e
#include <linux/init.h>6 ~! G" A& q& \' U
#include <linux/module.h>+ q: w2 V' f, ? y) U- H% A
#include <linux/kernel.h>& s" C2 e. | @2 P" f1 `
#include <linux/types.h>
4 N& [- X) n! }% z$ h) O#include <linux/gpio.h>
6 _& i; O8 J/ r% L/ k#include <linux/leds.h>0 X z7 d3 G7 b7 o; B
#include <linux/platform_device.h>
3 B7 n: y' z' R, {2 w+ H: `: V+ t* C& U- d( H
#include <asm/mach-types.h>
2 S$ S) ?" R1 n! p3 P#include <asm/mach/arch.h>
% t4 z; z! k1 \3 z" N#include <mach/da8xx.h>
; _3 P( z5 s% X d4 ?* v#include <mach/mux.h>
! u- \, X: R# C, C3 C8 F/ F9 c- W3 i ~# ?& T/ a. Z+ Q! a$ C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ k2 u$ z' i4 W. j; Z% J8 A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 p5 e0 i) q m' x( |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& ^( _. \* L/ R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: v, r( I; ^6 ~# u! W( j+ B& C; f
% \7 ^4 l/ N C% M6 A. k/* assign the tl som board LED-GPIOs*/. a( r: \$ g4 v5 n/ j
static const short da850_evm_tl_user_led_pins[] = {5 E5 `/ _7 x. K7 r' j( t6 T0 f
/* These pins are definition at <mach/mux.h> file */6 L- V9 M v* ]1 w* g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ m9 b! W" P/ z
-1
/ \+ y, c# Y( x' E6 s8 R, g `0 P5 u};
+ A" n, |# c. Y6 r( A6 ?" _; k* r
static struct gpio_led da850_evm_tl_leds[] = {
, @8 |8 I2 j* r {
% b8 i7 L; v C& P0 A: `$ a8 X! J .active_low = 0,# ?- R3 b R, P& V# k! @, b
.gpio = DA850_USER_LED0,7 R* U9 ]: V* F. ^ Y
.name = "user_led0",
/ a2 s; D, s2 e .default_trigger = "default-on",7 ]* L% `; H4 B! R
},% A% B4 S d' z' a. L
{5 \! O3 i3 }, a
.active_low = 0,7 w' T, _4 b' `6 @
.gpio = DA850_USER_LED1,/ j0 t2 K0 s- d7 O
.name = "user_led1",
8 }1 `3 H5 h8 M; w% ` .default_trigger = "default-on",
3 _7 T4 W* X2 o9 j9 H; U },
C( N+ Q4 q0 R {
" q/ z6 g7 K9 B; T6 ^: B .active_low = 0,0 B- \7 Y, p3 [: g
.gpio = DA850_USER_LED2,! Q& I1 r4 b9 q8 L6 V4 M- y) @
.name = "user_led2",
0 d9 y/ a0 Z! M( L* D3 J .default_trigger = "default-on",. i! [1 u, ~9 A
},( E9 J, n% N+ N, ]2 t
{
& |& `8 E+ p6 E- L9 | .active_low = 0,: ~- e% U/ v, H' q ]
.gpio = DA850_USER_LED3,
, S+ B# b4 T' O .name = "user_led3",; |, e, q& n+ \( x4 b1 g- {
.default_trigger = "default-on",
! D$ f$ w# ^4 I3 o6 w },% I" |$ k \' F8 T
};, b: P' q9 S+ c0 O* a% K: C
2 A. ^4 n( u( D1 _6 Y3 q4 ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# e5 ]7 Q% X8 o5 t" l .leds = da850_evm_tl_leds,$ U+ f, B; \+ O3 o; f v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& W) S" V' z H% h( b: M a) @};6 p+ W/ l' A6 ^2 Z; l
9 s, }3 _4 \' F+ W9 g# z9 jstatic void led_dev_release(struct device *dev)
4 O5 R6 ~; t; \7 k3 O: \7 F( [{4 I; ?% T4 }7 E
};- s* E. N1 s0 S) {: v" I2 Y
. e; r+ x. ?1 t' @4 c% O
static struct platform_device da850_evm_tl_leds_device = {/ L! H3 I5 f6 v; V: J5 b# {
.name = "leds-gpio",
! U2 Y3 R3 S8 H3 ~1 A7 d2 D' V .id = 1,
, R# r8 T+ J2 K8 D .dev = {) }$ s4 o6 p. ^
.platform_data = &da850_evm_tl_leds_pdata,0 D* Y! P2 }$ A& A. v
.release = led_dev_release,
& j9 K/ |8 z1 p$ K9 q }; l2 z% B; L6 C2 L: v- q
};
7 n" S2 O5 B) J) W9 N. H, a; _
static int __init led_platform_init(void)
/ r/ l% U8 E: S: P, Z/ @) s$ d{, {3 }% i4 c; R. L
int ret;0 u0 g, M" J5 C
#if 0
9 I& \1 s. ^- q2 d$ C8 ^0 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 G1 n6 C) n! x0 O if (ret)7 E8 ?1 z- h3 A9 L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, S8 [# e# f) G; y/ F "%d\n", ret);( ]2 T+ `) q$ \( S9 d) d9 }
#endif; }" P, R7 L G( U. g
ret = platform_device_register(&da850_evm_tl_leds_device);
7 {; U$ A" @# q1 Z. J3 } if (ret)# B. L# d# r0 \2 K
pr_warning("Could not register som GPIO expander LEDS");
+ I4 m; W9 c' T- C5 I else
2 n+ H" K1 e8 C4 @* D( x printk(KERN_INFO "LED register sucessful!\n");
9 f8 ]/ ]1 E6 W3 O8 O
9 L, l# Q; ] C/ k return ret; t* ]2 s! N9 E
}
4 h$ O' Y: r+ f+ Q3 g0 s3 {1 C- e& U' {
static void __exit led_platform_exit(void)9 ?$ l! c: _. H& W" s
{, U2 Y2 p7 I, m# C
platform_device_unregister(&da850_evm_tl_leds_device);! s2 b& j. D' @# m5 s% v N
6 q& q, w1 a$ a+ G
printk(KERN_INFO "LED unregister!\n");
# _3 |' G3 J- X3 a5 x4 [. w}
0 d( v- h) `, M9 N$ X5 Y. W% F
# [6 @6 L# Z: |module_init(led_platform_init);
% {# Y- ?, v1 V( \# C& O7 m! z. tmodule_exit(led_platform_exit);
' B3 t u: _) Q; v6 P; g) ?$ B% h+ a2 I3 a( I
MODULE_DESCRIPTION("Led platform driver");
- I3 {& }( U0 @: I$ u/ ~2 uMODULE_AUTHOR("Tronlong");5 Y- D* U' H/ ]$ @. ~, a. T8 ~$ w2 Q
MODULE_LICENSE("GPL");
" T+ ~& a. O; X" L$ H' i
7 A+ l) w4 o& x- y5 v |
|