|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 R5 G- y, b, w: `#include <linux/init.h>; z$ I2 E% x' H$ k5 V# ]( b) d2 g
#include <linux/module.h> x0 f( D2 w. s' i
#include <linux/kernel.h>
; S1 A! M0 `1 h; [8 O1 e; b#include <linux/types.h>" p2 c3 T9 Z( x' E$ C8 n3 g- _
#include <linux/gpio.h>- U9 S4 U5 @ W( x' c2 V
#include <linux/leds.h>
' r: R' E7 G% Y' A#include <linux/platform_device.h>/ N4 C! A! c- h+ ]
' z( ~# ^0 D) N: F6 i5 f#include <asm/mach-types.h>
7 Z3 C, p2 ?. W#include <asm/mach/arch.h>
3 ~# v3 R! ^; I( {: @. G9 H# f+ g" T#include <mach/da8xx.h>
' _. n) h: q. \0 w& ?. h#include <mach/mux.h>6 _+ x2 t) Z( r( i( P# y) P
# ~! B% f% V! o" `8 U. `6 _; e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
g5 X9 Y3 Y, E/ a+ K% g7 d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; R8 S$ {1 `3 w+ c; G' @5 m4 x$ p! w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). c2 t& Y& m0 A( e: E* ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 |( L" C# ^8 M2 Y ]
$ [" q; a% @" X x& f/* assign the tl som board LED-GPIOs*/% Y' V0 v8 s+ {2 A
static const short da850_evm_tl_user_led_pins[] = {2 L& \: _+ X. }9 J- L
/* These pins are definition at <mach/mux.h> file */
: c& L( L7 p9 p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. K* E$ z, G! Y3 I$ J
-1% ?- m; N8 J6 |0 |! {$ {1 j
};
. M5 M, q1 i( C( S& V" r# q, Y; {1 O+ e/ ]
static struct gpio_led da850_evm_tl_leds[] = { h6 e+ v% ]4 r: \7 e# Q3 t1 j! ?
{
- B. Y M( r8 L2 J .active_low = 0,
6 ]) T% Z6 h! X! G .gpio = DA850_USER_LED0,
5 | v$ q! s9 m$ e/ u7 L8 ? .name = "user_led0",( D2 J" R! q" C1 K
.default_trigger = "default-on",2 I6 N, [$ E6 A
},
/ X, S% R4 N! F) Y1 g {
1 K# F: r* B* v, B .active_low = 0,' V) o" `! L7 N$ }2 p! A& F9 f4 A9 I8 h; J
.gpio = DA850_USER_LED1,, H. x: `% w8 X9 z) M6 S% p
.name = "user_led1",
1 O' m" o; j. m9 d) Z5 Q4 H .default_trigger = "default-on",
( R0 c7 @, m& L p4 Q9 z },6 d$ h6 i/ d9 o/ X6 S% G. z$ W
{1 t' o7 L# l% o# ]
.active_low = 0,
. P! `( m; i/ `8 I4 ` .gpio = DA850_USER_LED2,
7 C; r5 t, O Q6 A, K/ X8 C" i1 J .name = "user_led2",* B6 r1 L; G6 x" t L5 L C
.default_trigger = "default-on",
& S; b& t" d* ^0 N7 u },* ]: S' q$ _+ \8 g9 K2 M
{# ?# |( L9 c4 i- H
.active_low = 0,1 h: C9 @0 L. G9 C' U+ i- H5 H# ~5 O
.gpio = DA850_USER_LED3,1 @; R% o$ _; S0 U0 E
.name = "user_led3",
" K- r- ~, z' K! z0 ]8 q# K' A& { .default_trigger = "default-on",& R5 z }+ S4 Z" Q( U& Y
},
7 L2 W u1 \/ ^( W5 U& \};
. l- N' x2 G% E, z& C1 S% _1 W# |& o) J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 A4 i" ~) X$ U& I2 V1 ? .leds = da850_evm_tl_leds,1 ~: i6 ~; L5 z: d- s/ [6 L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ o( C4 H4 n M2 M
};
9 v/ I; |4 Y. B5 _3 C/ c" k4 c. o! l# A: x. j+ u X; J+ R W
static void led_dev_release(struct device *dev)/ ^. s# E' }; ^* A: i
{
8 }9 D( O8 x, K" L) c+ r2 f};. D4 d! ~5 V% b
8 A0 g! L3 g; ~4 Nstatic struct platform_device da850_evm_tl_leds_device = {* M: k. [/ c4 [7 _7 a {5 M4 \
.name = "leds-gpio",
! j% W, Y9 F$ o .id = 1,2 H0 F) L v, p) [% g, P
.dev = {
: G. B1 E( C) X a0 H .platform_data = &da850_evm_tl_leds_pdata,
X9 B- X7 ], a2 ` .release = led_dev_release,2 k0 i$ q4 f# v/ G J. c6 g
}
5 A7 H! q1 G7 F+ V! ?9 p2 l};
1 J1 E( r' ~1 ^' m* y9 R5 @
: P+ F; R/ ?8 L. G# g9 O: ^6 Lstatic int __init led_platform_init(void)
2 I' {) ^: m( p) i% ]8 Q# V{$ y) y, u- X3 j
int ret;
* m' W6 L4 x q3 G( I#if 02 m, d, o: `8 O0 j4 b0 l# \4 a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% ~9 q1 n% h& G) D2 d
if (ret)
' I( Q; h* \0 d5 F* D1 ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 h2 |: ?% g- I- f
"%d\n", ret);
! `5 y4 X4 M" U3 |' M D#endif; D) M/ _0 x7 `+ d4 l; G
ret = platform_device_register(&da850_evm_tl_leds_device);
# i: y. z! U. p5 v7 N* Z if (ret)
% |; q" W9 s$ H. P7 _& ? pr_warning("Could not register som GPIO expander LEDS");
& r: ^" p, z8 y) Y3 _7 K else
! Q7 [- c+ a3 l9 T3 J printk(KERN_INFO "LED register sucessful!\n");! a4 O& L# p0 l/ C, o
( U) z1 D2 {- G' F
return ret;
m, H% A' L4 [9 m2 m}
k3 F( ]. p1 l
& Z6 s7 @( F5 C0 [2 i" Zstatic void __exit led_platform_exit(void)" o* R) S; Q" L; _% R
{0 J( W9 `: _2 t, \5 B: Z* Z$ @
platform_device_unregister(&da850_evm_tl_leds_device);5 M; X* J3 B( o5 b" O- j e
; p4 V: E3 @5 J5 U: I3 S
printk(KERN_INFO "LED unregister!\n");/ G5 p3 b. c( Q4 L; P
}
6 b; X% l3 C! K
8 b$ J8 n" i, T7 O7 C+ y: [module_init(led_platform_init);$ _% m; D( Q; z, x2 T1 j5 H' x# c
module_exit(led_platform_exit);
' s3 z* y8 [) e- ^3 Z% E: w5 i0 ^( D
MODULE_DESCRIPTION("Led platform driver");
. Z+ s6 x, G$ ]+ z! `5 BMODULE_AUTHOR("Tronlong");$ w' ^0 c& f( g9 A; t) g0 t' q5 v& G% r
MODULE_LICENSE("GPL");. C! u4 |7 ~) G" G
2 s# `. W- U- Z3 F8 T( ` l! y7 t |
|