|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ C/ m: h8 y: u: v" |#include <linux/init.h>
( _ k! J+ c; V& o$ h4 N8 y#include <linux/module.h>) `' } G- U/ G P
#include <linux/kernel.h>' R, W7 p. C; E' O) L C
#include <linux/types.h>
' g0 Q9 V& ]. r#include <linux/gpio.h>7 y6 b. s: C$ A) j. i5 G+ g5 x& M
#include <linux/leds.h>
9 b5 j1 ]0 y: G5 c8 h9 ~* j- w9 x' ^#include <linux/platform_device.h>
9 I/ R0 [! m! C! g% H4 g6 i3 E& v. G) R- V+ \5 A! e/ C
#include <asm/mach-types.h>
& t5 b5 H8 p0 C1 ^* B2 k#include <asm/mach/arch.h>( T5 t) K* h2 y" y- N
#include <mach/da8xx.h>
2 s% {0 ^% q3 U+ H% `#include <mach/mux.h>( a$ l0 s! o. ]" `
/ `' v/ o7 U* q- L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: |7 x, p$ [9 O6 b: B7 j0 t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 F1 r( R2 W# u7 Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): S2 y3 Y, p# b/ J; [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) h. s3 u% M# [
0 i3 W' L, H$ N. y2 u3 Y
/* assign the tl som board LED-GPIOs*/
5 E- ?4 T: L4 e X- t6 Rstatic const short da850_evm_tl_user_led_pins[] = { |0 W* }% v" i* Q @. m
/* These pins are definition at <mach/mux.h> file */2 l3 O; V3 t$ ~% ^8 I# o( q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 t% J+ s: k, a. G% R+ k
-1
# l" N& K7 s! A# P4 j3 Q4 w};
! O3 i* E8 v3 ~: H) z. K7 B) c2 M. Z0 D( U* q& Z/ q
static struct gpio_led da850_evm_tl_leds[] = {
- x) v0 ^2 O0 h7 S& N+ r" c6 J3 M {
2 I4 ?4 I( t, _* D5 x8 V .active_low = 0,
( i7 N7 {. {$ ?3 D3 P- H .gpio = DA850_USER_LED0,1 ^1 J5 S, t6 H/ {2 g+ Z- z3 x
.name = "user_led0",
$ D% g4 g$ t: m .default_trigger = "default-on",
9 T$ A% k8 D& D6 r) m },1 b4 p4 L$ E+ ?& Y' F* y( ~* @
{& C4 h ^9 j" C7 c% W4 F! ]
.active_low = 0,3 F# R! i7 @) g6 u! T
.gpio = DA850_USER_LED1,4 D4 y' N# M# o4 p$ I2 t; Y2 ^, c
.name = "user_led1",
: z0 }- `# S0 _1 j' @3 ]9 C6 d .default_trigger = "default-on",
+ W* h4 @/ j- K3 Z, s },
( [6 b. B, ~* k& r3 W5 e( o {& J7 ] {
; R3 y( S6 ~, c! m( {4 V/ K& w5 S .active_low = 0,# ]& ^8 c4 t! Z
.gpio = DA850_USER_LED2,
: K2 ?$ }" W' [; m. j7 L( o .name = "user_led2",1 L9 d" ?* p- ^! z& T. V( h% u
.default_trigger = "default-on",+ S7 [0 a* A) h4 V) y% X
},
- G- P; [+ R- N. k: @9 g4 {' M {
. F ~$ W- o5 Z+ u& k .active_low = 0,! s, p$ H& G: F
.gpio = DA850_USER_LED3,
' Y* [1 e3 a% A5 u3 m i# K .name = "user_led3",+ v0 I2 u3 x4 S! o
.default_trigger = "default-on",6 o% a6 b2 M5 Z
},
& n! R/ \- } `) k/ Y" W};* P8 T6 d5 h/ A$ `0 \
; I) @% F! }3 E5 [3 z- H$ z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( x; |, u: u, J( f1 C7 t
.leds = da850_evm_tl_leds,5 ]& t* y% o- H- }
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ g$ v! F) U y. L& |
};/ Z+ W, c% W0 ?# I( j% {: j, r; R0 z* c
6 ^5 R% n; f* U4 n6 n6 j5 rstatic void led_dev_release(struct device *dev)1 ^! S8 S1 W. F c; R' ^3 F- m
{
* v( }& {" B$ r: `7 Y5 d6 W) c# _* S};
( ~5 ?8 J" u3 C$ U7 ~ H: W/ Y1 M$ T9 d, E
static struct platform_device da850_evm_tl_leds_device = {
; x1 q& c; M! |* `% L .name = "leds-gpio",3 p8 _; g0 A2 z7 h- a( B+ C3 O4 _$ ^' q) V
.id = 1,
2 f8 B2 k0 \* V* P9 K; s .dev = {, \& u0 W5 ~% @
.platform_data = &da850_evm_tl_leds_pdata,
4 q8 i( Z, u H2 l2 ~, Y .release = led_dev_release,
# D+ Y* M0 M# e2 z4 \ }* `+ h; w8 I6 x+ n$ H2 k
};4 p8 {8 K z8 \7 B9 l
) C# [* P7 Y5 ]2 P+ z5 S; }
static int __init led_platform_init(void)
$ Q" f# ^# J7 a4 t{
' `- @( h, D/ S* {& o int ret;
& Y5 b6 r4 S. ] R; f+ `; Z#if 0
: i" W% Q- K) K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 X! E5 X, o* G7 f' W( J
if (ret)
' ?; m' r+ O+ g+ k0 f* { pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- q( r6 E2 S! ?7 t/ m6 [! ` "%d\n", ret);
; @& p% |0 d1 S#endif
3 P& i' J6 [6 G0 v2 L ret = platform_device_register(&da850_evm_tl_leds_device);6 Y) e6 }; O5 m
if (ret)
! P P! @+ p( p9 a6 } pr_warning("Could not register som GPIO expander LEDS");
+ X9 @6 w: C1 u1 x& v) X: l' a# U else) l$ {; r$ E3 Z# H
printk(KERN_INFO "LED register sucessful!\n");
$ Z# ? R, l) e& |2 v5 O! L1 K* j% y9 ` r: E
return ret;% S) y5 _% w; t/ k+ |! f
}# [" n8 Q6 u& L5 x5 O3 Z1 I
( q7 ?7 f& z. X# }/ d, S% u
static void __exit led_platform_exit(void)
, R; `1 g& L4 u* ?{
- Q1 t; a3 o# B; I) K platform_device_unregister(&da850_evm_tl_leds_device);
- w3 E9 |9 A( O& [: x
1 \& F0 I7 X5 a9 l/ u: x d printk(KERN_INFO "LED unregister!\n");! R: z) M. ?+ Z/ u4 W
}6 |0 V* i3 y; h* n [
; p, e& g4 E3 nmodule_init(led_platform_init);" |5 [) ?. A ]8 o! u+ x" O& K
module_exit(led_platform_exit);* Z4 C* |% I! Q
$ F) \! z+ b n$ d/ P0 U
MODULE_DESCRIPTION("Led platform driver");
t; j0 W+ S. ]% E4 I$ x8 m' {& WMODULE_AUTHOR("Tronlong");
* }$ n; E- J0 TMODULE_LICENSE("GPL");
2 N m, I+ n' L, G! P! s3 U7 z5 W7 P8 b5 F2 u! X( S C, N
|
|