|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 X( | ?' x& d, O7 K#include <linux/init.h>5 f- L, g, L: @* D3 x' @) T
#include <linux/module.h>1 L" m: c% ?" T$ F+ `0 s! b4 L
#include <linux/kernel.h>
+ M1 l# e# I0 k$ Q/ b( J#include <linux/types.h>
2 o" @" Y4 }" p# O9 O5 Y5 C#include <linux/gpio.h>) Z8 L: v {7 S2 @9 s$ h2 ^5 b
#include <linux/leds.h>
$ O& ]7 o/ a$ R8 z8 _/ f#include <linux/platform_device.h>
: ?: {! P! O: ^ T
& j0 u7 L) t- N6 p5 J7 W( F#include <asm/mach-types.h>
& b' z! k; }: Y. k#include <asm/mach/arch.h>
0 F+ _: s& N9 O) |#include <mach/da8xx.h>- Z a7 e% h- d
#include <mach/mux.h>
( E; v4 f. ]" a2 T, y) z3 E9 Z. E5 C1 U
! c: d' c7 ]6 p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( C2 r8 d1 h% T @6 d: w' G0 a, _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. S; D% r! s/ u* ] D9 w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& r; P; ]5 h6 H1 T/ ^" l+ p) f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ Z& x( t, q. T8 a
4 \7 u% }2 a2 g& A$ f8 C/ o3 b/ ~) a0 A
/* assign the tl som board LED-GPIOs*/8 v6 [- z$ L. `+ ^
static const short da850_evm_tl_user_led_pins[] = {* U. X+ u* d) C: W5 u) C
/* These pins are definition at <mach/mux.h> file */' H2 g6 i% v+ v% m `; @# @. j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 K# ~. |6 K1 j6 {2 [' V) g
-17 u2 v* j4 P8 F! z+ i
};
Y2 f0 W5 t4 i& L4 X ^+ @8 L( h: k: U5 ]4 C& d6 y
static struct gpio_led da850_evm_tl_leds[] = {& B R3 s: M; O6 R1 h
{
0 l2 h4 c1 Y! T, }0 G .active_low = 0,# G3 ]0 y; _# i
.gpio = DA850_USER_LED0,
2 F3 v6 J! \" E .name = "user_led0",
5 `% K5 V+ z+ p0 L2 C .default_trigger = "default-on",3 U) ~5 W, G/ B
},
1 \$ c0 \* y) _6 c, ~7 M/ G1 e {
6 _. ^2 y( m5 p- u% {! E) E .active_low = 0,2 [( H7 S m* x f
.gpio = DA850_USER_LED1,
2 @7 F% V' j" B .name = "user_led1",
2 I: i. Z r9 y; `) X3 u .default_trigger = "default-on",/ D3 f/ Z6 R0 m& s6 ?
},
7 J G& n" v5 K( o R {+ f9 ~6 K: C3 @
.active_low = 0,
K7 o& O# Q! P3 S5 R* p4 P4 l .gpio = DA850_USER_LED2,% l3 G+ z) I7 |6 O
.name = "user_led2",+ I- R/ u: Q' a
.default_trigger = "default-on",$ H$ L: S& L x0 a _9 z7 H
},- I4 p6 U/ }0 m
{; C% a. T2 V; h6 c/ e, A- Q. b
.active_low = 0,. n1 Z+ L5 v$ {( d' Z8 m% z% ?
.gpio = DA850_USER_LED3,
+ d" J8 F5 ~- L. w .name = "user_led3",
0 j' E3 y- n* o ~* n" | X3 [ .default_trigger = "default-on",
, e/ C6 m: s+ Y, q" G }," u$ k7 R7 S: x0 l( V. O% k, `
};
1 I, s0 s/ d4 `3 }; ?' r6 s: G0 U0 L% E& _5 k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 O5 v* I' h6 `" V2 b .leds = da850_evm_tl_leds,' E% |$ j4 F7 j) _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 S7 j& |( x6 Y};
% Z& i* o9 _8 v1 l7 }
% d! V- f) k' a$ E1 Bstatic void led_dev_release(struct device *dev). y% x5 E4 W. b" D( e6 Z
{
, j D0 X+ D: v$ |! ^5 G' @# [, j};
) Z8 n2 ^* u3 N1 N, p: S) i1 n; {) g- _$ I
static struct platform_device da850_evm_tl_leds_device = {
& I3 U. ]6 U/ h7 t0 Y .name = "leds-gpio",
7 b, {) c) ~) _' ]9 q9 T& P .id = 1,2 J7 l4 s/ g$ j& N, m7 J
.dev = {/ N% F( l/ ?' I2 E( @
.platform_data = &da850_evm_tl_leds_pdata,
1 J/ F' |& Z; R. \4 f .release = led_dev_release,7 E! ?# P9 s2 e9 T9 p! ~
}- L3 C! {& _$ {1 H
};5 N+ @* {0 f. F: O5 f9 S
0 u6 B" u6 N2 J8 V5 Xstatic int __init led_platform_init(void)$ M9 w3 f+ G8 b
{
; {1 k2 z# a7 F/ Q int ret;: A6 R. n* o+ j' x
#if 0& ~( F* ~" P% n5 g. ` A# a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( ~* B5 c, W' w' s if (ret)
6 q( H: _8 a+ ^1 @ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ v; s Q% d H
"%d\n", ret);
4 R3 z" P- v5 J. E#endif
0 c- Q& ?% v; N ret = platform_device_register(&da850_evm_tl_leds_device); K- i. f+ Q/ b" L$ N
if (ret), C3 p1 }8 u& T* _
pr_warning("Could not register som GPIO expander LEDS");
; v; q/ V# o5 m else, t _; s0 l+ J! t* ~
printk(KERN_INFO "LED register sucessful!\n");; T( |. A8 X7 K- @6 @) P
7 K$ w( x' c2 Z( w, L return ret;6 w- }& P: h) Q4 ?6 t; N! g6 T
}
! h+ T. R; {$ T. U6 h: l
. u% e7 V; R/ n3 S6 r( v0 D0 m7 Gstatic void __exit led_platform_exit(void); R0 ^- |7 U+ @( k* H/ P3 Z
{4 U$ D$ @$ @2 e7 Z" F' e! L
platform_device_unregister(&da850_evm_tl_leds_device);
# K- O: M) q5 @( V9 Q1 d& I' P8 I- A; T$ M8 i. h6 d8 i
printk(KERN_INFO "LED unregister!\n");7 X n. S( l4 e$ i
}$ c! m. ?/ b2 [- \% T, z8 b4 N
( C3 {; m2 A4 d; J
module_init(led_platform_init);
9 Q# [% _9 Y7 A. Q. mmodule_exit(led_platform_exit);
- K3 T( g2 `) Q. [# [8 K. u& r" C4 r+ e
MODULE_DESCRIPTION("Led platform driver");
. ~# c, e1 W8 V7 y$ q: f7 Z" MMODULE_AUTHOR("Tronlong");
. P* ]; T9 r; A7 y" t0 F) e* ~/ lMODULE_LICENSE("GPL");7 E$ l0 z0 i0 m0 `: ^' Q" m( o
) P. j, b _8 ?
|
|