|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 {, a: t2 l" E/ d p#include <linux/init.h>5 ^; t! D+ F' I o$ ?
#include <linux/module.h>
9 v0 B) n/ w4 q1 C8 W, U#include <linux/kernel.h>
7 e; P w# ^, ` X$ \" W, k#include <linux/types.h>
J+ ~& T, [/ E) p#include <linux/gpio.h>
# B0 G- Y: g2 ^3 b% ]" Z) Z#include <linux/leds.h>! \+ s2 O1 V# I3 D1 U' d
#include <linux/platform_device.h>
) l0 a, s4 R" E$ V; s* x' n
% j) r3 u# H! K- P, n- f* C& n) ^#include <asm/mach-types.h>6 N" w# l, v9 y6 d
#include <asm/mach/arch.h>
' z$ c6 Q/ g f: Q6 [! O#include <mach/da8xx.h>
2 B! ]2 V% R/ X4 x. B7 o- Z#include <mach/mux.h>2 Z, l4 V5 I& ?& a: S$ D$ `# Z
" i- _8 ^/ z# y+ Y$ C; @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), ~6 y7 U. l) n$ _9 j; f& c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 R$ f I N% j+ o8 Z: j% h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! i7 B, |+ U9 O0 {/ w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# t* ?7 W# q& g
& G! B, k2 @$ g9 l! P2 h$ E* [
/* assign the tl som board LED-GPIOs*/9 X7 E) @* ^, j5 a5 L! i. f) F
static const short da850_evm_tl_user_led_pins[] = {9 z) \4 g/ z+ Y# R
/* These pins are definition at <mach/mux.h> file *// D) k* O0 ~6 N! C$ ]: F t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. u+ m, W4 B8 r8 U5 ~# t" X -14 k1 T# ~- z% k) Z; c
};
+ w+ a3 Q+ d* o7 T3 s4 V# c5 p
! M; B9 b" M' x$ Qstatic struct gpio_led da850_evm_tl_leds[] = {
* R% ~: s @' p* k; W* n {
0 O% u/ h3 _" n( F .active_low = 0,
( g0 g( J2 e% s8 f, X! Z) Z .gpio = DA850_USER_LED0,
! i! R% ?: o% P8 t2 U( _1 X .name = "user_led0",
( ?9 i7 w9 u. ^ .default_trigger = "default-on",* Q: g2 m5 y- F( C% W# n5 @3 K+ @
},
0 ?; M$ ]/ [; c1 I, d8 Y8 {" m8 o% ^ {) K5 x( t1 }0 h3 v& b$ n3 `
.active_low = 0,2 W# `4 t2 I e' z+ g+ d1 G" b
.gpio = DA850_USER_LED1,$ Z* a* I# W h( m% H) k
.name = "user_led1",
4 Y3 X" t% A8 r .default_trigger = "default-on",! J6 f8 ?3 I+ N
},2 j8 n8 b. Q- X
{, T# k8 {, G- r' y( T6 V
.active_low = 0,3 |# B U: e8 H
.gpio = DA850_USER_LED2,
6 D1 L6 R3 \. d. I! b .name = "user_led2",
2 }3 `: c! c$ o( S .default_trigger = "default-on",
: Q5 Y/ g0 E, u3 P, {* B },' w" x2 U8 S# k2 A
{* p9 s+ }6 c, h3 B7 T2 t. K
.active_low = 0,2 \- H7 N% V1 S6 f
.gpio = DA850_USER_LED3,
3 B+ T" D* c* a9 U .name = "user_led3"," N, @; ?; T, B, Q, J g8 R
.default_trigger = "default-on",
: [ H! ]5 Q/ y; ~. ?# J4 K- A# U },1 r4 s, p/ c' d% r
};
. F0 D6 ~- Y9 w, n {% R( ]
m+ R! P) |' |# wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { ~* x0 Q7 C1 a4 @/ T, f. b! X9 H
.leds = da850_evm_tl_leds,; W2 o! k5 W! A. s U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 I& `, q+ e. I! Y1 u
};5 d- Z0 e% i! ]# i1 {: @, k7 n
2 i5 T. Q7 Q! k1 q0 e' t: q( kstatic void led_dev_release(struct device *dev)( O) s2 W4 `4 a9 \( k/ o
{' a- C# N0 S( G5 B/ b. f& x- s; K
};
8 J# U5 b" R# T" V- {% [% t9 _! k$ P. ]
static struct platform_device da850_evm_tl_leds_device = {
5 o. D/ t# g, h5 g+ `0 O .name = "leds-gpio",
+ a/ T3 i1 j* ]4 L) z .id = 1,- ~6 @6 `1 K/ `1 y, G6 D* ?& B7 S
.dev = { K# }8 c. [5 l' \) h1 o( r2 c
.platform_data = &da850_evm_tl_leds_pdata,
3 ?1 C& V; j" b" u \! T7 P .release = led_dev_release,
, D( v# E' x. ^7 c, i' i }
+ D1 X: q6 |1 w1 g};
4 O7 {# Z2 {4 z! z9 r, r; @! k% J3 c( B, C
static int __init led_platform_init(void)0 m( K0 J$ d. Q1 ^0 R* Y
{
; C0 y2 Z7 n/ d8 q- C W int ret;& r# K; |2 c# f H
#if 0 H7 v2 q8 J- V; _, h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; |3 }, U1 l, W' U: ^9 Q+ Z+ N" Y, X3 \
if (ret)
' e, i8 P. x% l0 k0 k, g. A, O2 ~7 j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# ~3 X. }) E3 ]- ]/ j "%d\n", ret);
% Q, V# g7 F$ R) s#endif" E9 S: L* ?2 i4 C9 ^
ret = platform_device_register(&da850_evm_tl_leds_device);
( R/ }" j# Y* C if (ret)7 ]! {9 f$ m% P: M% `
pr_warning("Could not register som GPIO expander LEDS");
8 z. C. I. _/ G1 n) z& z else
% D& K2 @; R! p9 ?2 {+ L printk(KERN_INFO "LED register sucessful!\n"); q; a w1 ]. b, X
- g0 j9 m" _! J( R4 h3 u3 X return ret;
8 j7 I: i* @: r/ V: O/ T1 q9 u4 I}+ r" a; Y' w. r3 m$ v
! o3 C9 R0 O) t. _3 u9 l) cstatic void __exit led_platform_exit(void)) @8 I) {9 c2 B2 u% q
{
@: F1 p V/ q+ D# L platform_device_unregister(&da850_evm_tl_leds_device);
7 j u7 X; g% a/ E) z% H! S: _( o& t! D7 Z3 L
printk(KERN_INFO "LED unregister!\n");: r5 m; q- B4 { X& }6 X
}
1 P/ D' {2 r; U* T$ Y% ?' B, f* b4 T' X g# @% k
module_init(led_platform_init);' z" ]* i7 M- C6 r! T0 `
module_exit(led_platform_exit);- a; @# a5 B I
) d- ~, k5 p4 B; |9 v5 J
MODULE_DESCRIPTION("Led platform driver");: n! V7 d$ h/ R+ a3 ^
MODULE_AUTHOR("Tronlong");
- ~2 A. i8 u: L+ H/ wMODULE_LICENSE("GPL");
+ ?+ P ~* ]/ G, H" L' H( F* {, D8 C. R8 a5 ~
|
|