|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 s7 D- G6 q4 Y
#include <linux/init.h># r: J( a; J$ i8 i7 m8 O
#include <linux/module.h>
: w ^; S+ U: q- t3 w0 s3 T$ h#include <linux/kernel.h>
; u/ _" K$ R. @. X* X#include <linux/types.h>
, M1 X& h* ?$ m/ C. i% U" @7 o$ H- B#include <linux/gpio.h>
5 K4 x+ F# n# X8 @0 M+ U* ~#include <linux/leds.h>
2 t5 q7 v: p$ {3 _& S* T#include <linux/platform_device.h>
. U$ a& \8 z/ B/ t; r; S0 T% E
6 ?7 s" s+ J9 a: X2 B#include <asm/mach-types.h>
0 d7 _6 t' y5 F1 \' k, R4 ~! o#include <asm/mach/arch.h>% ]/ L E7 H$ {( I; a
#include <mach/da8xx.h>7 O, e6 K2 P2 h* b( K
#include <mach/mux.h>
. B; T; L( P0 z7 Q; \5 ]
5 P! ~4 m# [4 |) F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 {7 Z6 D+ g% T: F3 l2 _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
L* A, e n) a0 N1 c( g7 j2 d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 k+ ~* P n. `/ W$ r9 S1 i: G8 ^/ u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' B/ b! S3 ^2 I: _/ y
+ n; [ I q5 h/ S4 m% r/* assign the tl som board LED-GPIOs*// D# N$ X: `1 V. R1 I
static const short da850_evm_tl_user_led_pins[] = {) u1 o) L7 R: n8 A* I1 N
/* These pins are definition at <mach/mux.h> file */( L; S0 c7 o/ y2 a9 {' ^0 C. F! n! s
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& F) J a8 @# @* B. o8 y& @6 I
-1
' f( m6 K) p! K. q7 K) h' @};
& b+ P5 ]0 z! \, e3 J+ S8 M6 I) E' @/ b: R; W& E& ]/ m' }
static struct gpio_led da850_evm_tl_leds[] = {+ k; @7 L7 b% W# I! ?- d" [0 w; B# { P
{
' \8 Y5 { F ]* i .active_low = 0,2 Y/ T1 R6 e5 ]5 {7 P m% L
.gpio = DA850_USER_LED0,; t3 N$ E+ Q/ P. w2 s4 B
.name = "user_led0",
: }: y! u, C- A$ E8 l7 {6 W% b: {. j$ V .default_trigger = "default-on",
% B+ t6 x% Z8 p5 F/ a+ r },
/ V0 t/ v1 m$ {, O5 P {+ N& L0 Y u( m/ _, @* C9 Y
.active_low = 0,. W0 E1 h+ f D. g
.gpio = DA850_USER_LED1,
3 p, C+ R8 Z9 g6 X7 Q* _2 Q .name = "user_led1",; v' f) T9 m5 C, `: Z- ~ T$ f
.default_trigger = "default-on",7 q1 n# P" Q* ~( V
},
" v, s0 M# K& }( P! L& W {9 t) ?+ |3 e5 y/ e
.active_low = 0,) O7 d; |* r, H) S5 l
.gpio = DA850_USER_LED2,' e& _, e3 _9 s5 A) t2 z; Q( @% {; `& M
.name = "user_led2",
% {" K6 m: B. j* ` .default_trigger = "default-on",
' D) |7 @# e6 D' W9 N, a },
" y8 U' d q f0 w4 w/ i {
' b9 R& y* I6 G0 w1 @4 ^ .active_low = 0,
8 R3 @- q" u( V; B" V .gpio = DA850_USER_LED3,7 E& X, U8 L7 B! ]
.name = "user_led3"," N0 {% }& N% t# _) M$ Q2 q
.default_trigger = "default-on",
9 L% ?5 t1 k$ W" s },
9 z9 `3 g+ _; H- e1 T- V. S1 ~};' M! y; {5 H+ K; P/ k' h `
1 f/ _7 \# g, F+ G/ x1 s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 |) u4 ?& W4 S7 k
.leds = da850_evm_tl_leds,- ?/ n' X1 h, U- ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' `; T6 }4 _1 f8 J- h. l};
0 v2 I' S6 c4 Z7 f
# k% ?0 e: I; bstatic void led_dev_release(struct device *dev)0 l, F" _ l7 b6 U
{
* F0 V1 O2 k5 y7 N$ C};
, ]0 h2 A% g y% R0 |, L$ z; J2 g: a7 P7 E$ @7 G0 |
static struct platform_device da850_evm_tl_leds_device = {
' e' K6 A1 A1 {, y( r% q .name = "leds-gpio",
+ c2 i& q% ^5 r .id = 1,4 z: D# k4 k! J2 B7 U
.dev = {) {# H9 F5 g2 S! P
.platform_data = &da850_evm_tl_leds_pdata,) E5 {3 P8 }5 y' \; q. y/ `: {
.release = led_dev_release,
. F. j+ F9 e7 p2 O/ H8 u0 Q/ e }% w9 a. h8 ~( m7 z p# v
};0 K) I2 C, O! H8 V W: k
( Z. f. j6 c, j
static int __init led_platform_init(void)
, m$ l' a! c9 b{, c9 A7 i! s$ G! W/ t: A
int ret;0 \" E7 m Y- W
#if 0
Y& D' }. r! L! z M* D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 U/ S, ?( n% S( w if (ret)
, ]9 y' g7 `$ G, S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% J! r! }$ I) x "%d\n", ret);" B) f7 Z! H E m: m
#endif: e5 k1 R( s" W0 c) V% c0 Z
ret = platform_device_register(&da850_evm_tl_leds_device);( G5 F1 o% u' }' T3 r
if (ret)
0 }7 c$ k2 ?; C d pr_warning("Could not register som GPIO expander LEDS");0 R! f3 s% ^; J
else; M1 D3 ?! y2 t+ `8 B/ t
printk(KERN_INFO "LED register sucessful!\n");" N) K/ w" q o3 L
$ g7 P8 A/ n- x% d' G* |2 \4 k7 U
return ret;! z! v' o* i# {( O. ^# C
}
3 @$ h& B# S" [$ ^/ m8 ~- H1 L3 X* k$ m. [9 C
static void __exit led_platform_exit(void), ~. C# I) i5 `
{
& |& R& I9 E! v8 T0 @ platform_device_unregister(&da850_evm_tl_leds_device);; v, S2 f+ {; m) I" x1 i6 s' a5 @
$ W; R0 }5 h" Q# q* M printk(KERN_INFO "LED unregister!\n");5 v' \$ m5 }% w( y; d3 c8 q3 I
}- a( m, F. G7 W! F0 R6 d* Y
8 Z4 ?4 W% M. I/ ?2 L, h
module_init(led_platform_init);
: S6 x( N: n, Wmodule_exit(led_platform_exit);
7 f: R& k+ N$ W, \
0 B. t, \# `* p4 v& VMODULE_DESCRIPTION("Led platform driver");. n0 h' A1 ~ R4 C# z2 }
MODULE_AUTHOR("Tronlong");
: V/ _. w- t4 LMODULE_LICENSE("GPL");
1 x* y$ }* ?8 \( I# W
4 ^3 b$ d% L0 S7 _+ F& `: b |
|