|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. ?1 \# L; ~6 r0 g% a4 ?#include <linux/init.h>
7 B; C' W% L# J, d1 c/ y#include <linux/module.h>5 r, m0 u, J: r# ]
#include <linux/kernel.h>& V) X* H' u3 @
#include <linux/types.h>
4 Y; ]$ C8 g6 `1 ^+ l#include <linux/gpio.h>
2 E+ a" N* a$ N/ Y0 m0 Y#include <linux/leds.h>7 Q6 W1 X8 |: J# T7 s
#include <linux/platform_device.h>
2 ]5 @6 q0 j& A8 i: @2 F* r8 s9 ?- m& {& D5 s, Y, Q! h4 O, t1 Q
#include <asm/mach-types.h># B/ I3 R2 K D1 E1 u' y
#include <asm/mach/arch.h>% H1 y- m, R0 ?% s2 ^
#include <mach/da8xx.h>2 I' c- B, C2 J1 K
#include <mach/mux.h>
2 e: G4 u7 e( Y* V. o+ H5 b6 x/ H* x6 w2 b: o0 x" V
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' _' o0 |& l. i0 c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): w' `* A; D+ o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), d! N2 e8 F$ t7 ]- F0 I2 @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 y5 K Q4 @/ |
: K$ G8 y) s9 d. X
/* assign the tl som board LED-GPIOs*/" u, ^9 G1 ~2 d+ k- F
static const short da850_evm_tl_user_led_pins[] = {
' z. v9 h( _, b; j, f% q /* These pins are definition at <mach/mux.h> file */
! Y. u2 j1 i0 v1 p3 ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# H# E& J+ ~- R( w. e
-1
6 A x1 R$ m. X};/ t% K" d# b! p! I
/ e- }8 _4 k# u M" E' w0 mstatic struct gpio_led da850_evm_tl_leds[] = {
$ D. b H+ w8 Q {
0 @; k1 w7 r, ]5 z. C .active_low = 0,' ?1 q5 M( F* k% m: ~% @- f
.gpio = DA850_USER_LED0,* h+ i" \$ J& H c8 L. y
.name = "user_led0",
8 j% \% ]( s& o/ h .default_trigger = "default-on",
- k1 ` j3 h. E' z/ X },
# _/ Y0 f& m9 o% X t' J {
: l8 a( Q2 i1 T .active_low = 0,( f @: w2 x" H+ u2 T
.gpio = DA850_USER_LED1,
; W1 P7 i5 Y+ U8 Z, l. ?7 t .name = "user_led1",0 z: \. J2 |( C3 R
.default_trigger = "default-on",
8 \) k& b; g" C1 w$ F },5 c* G+ p' U0 g6 x
{
0 h3 a; ~% {2 U- | .active_low = 0,) z' j n5 t4 x
.gpio = DA850_USER_LED2,% n* \; j3 T9 B
.name = "user_led2",/ n* t: d: z! z
.default_trigger = "default-on",
- \ d: Y1 R4 V$ W$ w S, p, m },% A9 e. O4 |& c8 U- a1 u$ x$ j' ?
{
- i9 c9 I% U! @1 L .active_low = 0,
" o- m" W( c5 M+ n .gpio = DA850_USER_LED3,& m; B: m0 r6 D; e$ h
.name = "user_led3",
1 z+ A. _) T9 r, N .default_trigger = "default-on",
' |+ _# A" X, Y1 F D0 v+ a },0 p# s4 c6 T2 A, `
};
; R! j8 \* ]( o5 F3 }! R$ F1 f w D7 I8 l" E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 c% S8 W+ g1 L( w- C( R$ j
.leds = da850_evm_tl_leds,
( N5 G# x# `( B9 V3 b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& j0 A3 M, C6 g" A0 h2 u
};
6 u4 h5 Y4 H/ j. Y4 s9 q. ?9 V8 F5 M9 I' x X
static void led_dev_release(struct device *dev)
8 k6 v; Z1 y1 G6 ^9 O' H{+ V9 C. R7 u+ Z# M% l
};! E) `" D) a) m. i
5 ?6 W r- {% t, W0 Nstatic struct platform_device da850_evm_tl_leds_device = {% M" l1 u5 J8 W( [
.name = "leds-gpio",
) S/ K* z/ f$ ~& X( y+ X .id = 1,% F+ D( b/ c: F# e: g( n! U e
.dev = {
! n; r G$ r6 b4 s .platform_data = &da850_evm_tl_leds_pdata,0 n! P2 b( v4 N% T
.release = led_dev_release,, ]) j, r8 f4 j. _
}; X- B2 N$ `5 t+ u
};
9 {* K2 [+ |6 X2 c0 Y/ b) o! v
static int __init led_platform_init(void)
6 D5 b! H9 Q& g, g+ t* o{ X! P# ~2 g+ j2 d0 c) _0 W
int ret;7 [3 K9 U9 D$ g& }, X
#if 0* u$ {4 e, u# b4 m1 L
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 s+ v- B/ f; J, L5 m& y if (ret)/ k7 Q, f9 L/ r% B, w% U5 k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; w& R) i0 P. ]8 [6 q. y
"%d\n", ret);
& r0 _/ H; n- D( A#endif( k; n* g+ t& y$ Z6 V
ret = platform_device_register(&da850_evm_tl_leds_device);
5 m9 ^" x& O* a$ q) H# p if (ret)/ o) a7 v* L' K
pr_warning("Could not register som GPIO expander LEDS");
3 k/ { v9 o. e" q7 p! q9 j Y else
X4 y; H+ r) p: N* t2 ^- u% Q printk(KERN_INFO "LED register sucessful!\n");/ b, Q* b, w. e, }
$ @' P$ W7 |/ Z$ j: ~) r return ret;
5 [7 i. E8 T d k" @6 f}
" i b3 E6 I# F) r6 }
4 U3 s2 f8 A: ^7 C3 zstatic void __exit led_platform_exit(void)3 q4 H1 d3 S) D @' J8 c% w
{/ a( ` O- g- `
platform_device_unregister(&da850_evm_tl_leds_device);# k( d! y) |- s t' c( c+ G
. c. U. U5 s5 C; N+ S7 s printk(KERN_INFO "LED unregister!\n");
7 B3 a8 X) K) V( j}* p/ z- z% H, G% J8 D
2 z# O1 W g% A8 m( @module_init(led_platform_init);5 G" Y1 `$ X6 y. ^' g0 R- V
module_exit(led_platform_exit);. f& Z( a% e! M# V [8 [- B
* S: B( Q* n8 ?0 t0 v
MODULE_DESCRIPTION("Led platform driver");
3 h- K# A' a' Y8 f; y; {& H8 yMODULE_AUTHOR("Tronlong");( g/ a) ~ H- G$ g, k. u
MODULE_LICENSE("GPL");
+ _" I' X! o% D% e2 X2 N% e
1 r9 X0 I6 C9 F! g6 t( ? |
|