|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) ?* D3 R4 O# Y; W2 s#include <linux/init.h>
% |. n/ I6 Y+ T1 B$ b#include <linux/module.h>
1 y' n9 P! S5 p; E, ?$ A2 m#include <linux/kernel.h>3 X2 V% [, H5 {' O, N
#include <linux/types.h>4 V' Z+ _7 N# U" c% J+ O3 O& K2 q P
#include <linux/gpio.h>
' u( ?7 f) ~( {# D* G6 M#include <linux/leds.h>5 d5 s! i* C/ s: B
#include <linux/platform_device.h>
$ j8 X* B* ~: V3 `+ g5 Q3 ]" C6 Z+ G7 s
#include <asm/mach-types.h>
7 c4 M7 z" A, _" j& }6 _# a' G' v#include <asm/mach/arch.h>4 _) [6 j- x0 G R
#include <mach/da8xx.h>
, p* ?7 m5 B# `' b2 V P( r) k* s#include <mach/mux.h>' `6 |9 b3 E1 b3 `. H
5 m7 Q% H2 f! i: a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 z1 Q3 K# z h7 X7 O- u3 d3 d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 Y$ u D5 |* @) D# e+ ~: S# g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" c5 C2 W/ Z! Q* n `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 {2 ]) j! A1 L7 |0 C; o% Q7 v. d" B" B/ z8 ~# J5 k! V" o
/* assign the tl som board LED-GPIOs*/
$ ^# N* V* B; x. {0 lstatic const short da850_evm_tl_user_led_pins[] = {" c( \$ L, W6 [ V
/* These pins are definition at <mach/mux.h> file */' u3 I. s) f. f$ J4 c7 Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ Q' v# ^1 a3 ^+ W+ \
-1
5 [; G% u" | h% J, I};
# D7 S8 @0 w6 A! i" Z! P4 a; m% r
static struct gpio_led da850_evm_tl_leds[] = {
* l T) \8 d6 @6 @0 c, m( f8 | {) s$ ^1 o% x" \# B
.active_low = 0,
/ \, j) Q1 {, X/ M. U .gpio = DA850_USER_LED0,* G3 M2 `7 |! \: E+ k, m) z( s
.name = "user_led0",) b( W$ G: G. H3 v1 s0 G
.default_trigger = "default-on",5 |2 V4 J* N6 k$ i
},' G4 u% @2 p6 y J0 P
{
3 D ~$ P. s' K7 h8 n2 g2 _' _$ | .active_low = 0,
% C0 L" \* {. R; \. U3 s L. Y% e .gpio = DA850_USER_LED1,) a" Q0 M$ H% O9 Z0 A
.name = "user_led1",9 v# l2 g$ X" D# w
.default_trigger = "default-on",
4 Y0 f! Y8 W r0 n; R },/ H( j" Q9 }2 b& B6 |
{$ x( l. h8 u1 g3 M7 I9 v7 C9 ~3 y
.active_low = 0,
1 D* J& Z) G7 y2 E4 P3 ` .gpio = DA850_USER_LED2,
. S! p5 H( [1 i+ q% |, D .name = "user_led2",
' m$ H' c% F3 |$ e9 W .default_trigger = "default-on",
* p" h9 }. g e8 D @' _- k },
$ F, ]# C' J8 u1 f# J0 u {2 s$ r' q8 C6 _9 }
.active_low = 0,7 M( \$ k. C2 K* M' i; B' s4 u! P% A: H
.gpio = DA850_USER_LED3,7 K' S, C3 T) Z) }# v
.name = "user_led3",
3 b& J- F6 x7 e .default_trigger = "default-on",
2 p5 [5 l; l% M+ g },
( D: k/ ]) f5 m5 V};
9 J$ {3 a j3 m. s" `3 [/ K2 \6 u. ^5 A, k( m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& ^& ?, v; [) y: m3 v9 k. U I
.leds = da850_evm_tl_leds,( ^& \. w: n- w( N
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 z' j% [& A; h+ W+ t# v
};
0 r5 b' q& G) A, o! ~0 ]1 F/ O0 }) j. {
static void led_dev_release(struct device *dev)9 v0 O5 y, g. o/ ]- E2 u7 i; w, y& d
{0 i; l% @! O7 x) D/ O1 l
};
) I3 W1 f% _" e) W& m, w, P. x
! q, r: s8 I: g. `0 T3 \7 }! Estatic struct platform_device da850_evm_tl_leds_device = {
/ h; D" [) P, @; D) ? .name = "leds-gpio",
* m6 o. I- y* Y3 t .id = 1,
7 l& T4 M& P' @3 A3 ^ .dev = {1 g/ t: i$ r8 m4 W7 n
.platform_data = &da850_evm_tl_leds_pdata," E; E. O& A7 i, K
.release = led_dev_release,
8 J0 F5 j' |# M( { }
4 p0 m7 n4 ?1 b5 w* V};
3 l% H N ~9 `- m4 d- r! h/ r5 j( ?$ U, @' @7 j1 @ a
static int __init led_platform_init(void)
% d/ m9 g. P, K1 z- m' @: ~{! L7 w* ?0 d! z( ^
int ret;* M, }) l% D' G+ G
#if 0
k+ i0 H3 E/ d4 k9 F0 b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, ?: p2 D1 o' j9 {! j if (ret)
; ?" }2 V" Q$ x4 _- F pr_warning("da850_evm_tl_leds_init : User LED mux failed :". Z- u4 V* W6 {' O% U5 J6 `
"%d\n", ret);
* j- ~0 o4 H9 K#endif
! V4 J2 [" t8 b/ d; A1 j% ?9 ]: e ret = platform_device_register(&da850_evm_tl_leds_device);) Z2 w, N4 ]6 }: \8 ?3 [% e/ O! h" Q% i
if (ret)! r l" R7 |) L- a( f, c& l7 I
pr_warning("Could not register som GPIO expander LEDS");
0 \, i! F; D# p5 ]* u else
3 N. y+ z' P# v. p/ I printk(KERN_INFO "LED register sucessful!\n");. S5 u" {' D4 a
* f8 `2 l/ y1 T P return ret;
4 w+ D4 i$ N% i5 T( \# ?9 E}
# B! Q2 A' R3 e7 x' g7 G0 o R1 R$ J5 \5 @" x$ s' c$ {
static void __exit led_platform_exit(void). l6 K/ \4 l9 s/ T# t
{
% |1 B! P$ a1 T$ j/ m5 v platform_device_unregister(&da850_evm_tl_leds_device);7 f b- g! d0 R* J# n! `) d
% G4 g' k! M3 h, S printk(KERN_INFO "LED unregister!\n");9 R s$ }( X% i4 v# f
}
, x% B9 }( [' k0 V( Z0 w. @/ J! J( y- Z- `& a Y
module_init(led_platform_init);/ ~" s1 [# g) G4 A0 _; R
module_exit(led_platform_exit);
2 G0 x6 k |4 T6 \7 M
L" q3 w( a( Y; ?+ M% ]$ WMODULE_DESCRIPTION("Led platform driver");
6 r- @5 i& U: I; [2 t& `MODULE_AUTHOR("Tronlong");( g/ Q- W7 L8 _) V: a
MODULE_LICENSE("GPL");
/ }3 v" M) A6 D% j* P) r5 C& s/ i
|
|