|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 i3 _& f1 g' T& C4 j: W x5 K: J& L4 z
#include <linux/init.h>
6 s3 c# E7 F* J$ w7 k' j% k; T. x#include <linux/module.h>* O' _* [1 Z9 p4 s( {
#include <linux/kernel.h> U1 K% w8 p+ U" h
#include <linux/types.h>
6 ~8 D1 h' Q/ f: p2 ^1 R9 o) T#include <linux/gpio.h>2 ?7 h8 G) a o$ Z+ q6 m
#include <linux/leds.h>) O" u0 f; `/ b! y5 B
#include <linux/platform_device.h>* `! J& H6 l: Q e5 v
! x, b7 p, D! x# s* \
#include <asm/mach-types.h>
7 ~( U* Z7 P) `2 F* I; E#include <asm/mach/arch.h>7 A4 t- n! O9 [8 R
#include <mach/da8xx.h>
U# E& o8 Y) U. `4 K- Q; c* G#include <mach/mux.h>
! Q) x8 H0 p1 h# I
* u6 M: L+ \# X& T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! D8 j1 W* ?3 w' j/ W4 K$ `0 f5 b$ o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% K3 K/ W8 t$ m9 s6 E' \$ Z8 q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 H9 h y8 @3 {6 P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). j( g9 b+ c7 @ {$ Y
( b+ R' n6 Q }3 K: H" W. F
/* assign the tl som board LED-GPIOs*/5 r8 x$ {0 {7 g d! x' B" t
static const short da850_evm_tl_user_led_pins[] = {
* z$ g$ O( l! o' O /* These pins are definition at <mach/mux.h> file */
2 O& I/ h8 f- } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 k L* c9 I+ `2 U2 y -1, n \5 g5 s6 c, q
};$ Q8 t6 Y( e' ~0 [ O1 q% \
9 U/ F, }) z O$ f% D" F$ vstatic struct gpio_led da850_evm_tl_leds[] = {4 R- r& U+ G4 T/ [6 w8 r* Z
{
# I& d) q" j5 g. v7 b" f4 m .active_low = 0,( F3 O; k, p# ]
.gpio = DA850_USER_LED0,
O( I1 O8 W1 x2 |& `9 C .name = "user_led0",+ m/ W, ]: ^% f4 y
.default_trigger = "default-on",4 w& g/ K3 [, Q, R& `) e9 c
},
' q* `0 {( Z" R q" }! q) e {+ M. h3 Q, M, o# |
.active_low = 0,5 p" x# d; b, B/ q; s
.gpio = DA850_USER_LED1,
1 |2 D# R7 X% @7 P3 V$ G .name = "user_led1",2 R' O( L, J3 y+ u( a# q- V
.default_trigger = "default-on",
( N u, H! [4 \1 G9 V! `! u },
& T6 o# q& `: e6 V6 Z t! t {. ^9 ~6 w: m# L0 M% H
.active_low = 0,
: E- o* \* n- G6 ~ .gpio = DA850_USER_LED2,
! E* T2 n3 _) n( R9 W+ |1 k .name = "user_led2",
& k3 Y" J) G5 [# o: I) B: r5 m .default_trigger = "default-on",, ?( ~% I% P; j4 g1 J8 j! x6 V
},
# c: Y, I; O+ }' @, m' \7 j2 ^7 m {
3 L9 `; N( L! L$ u, |$ r- x- g2 b .active_low = 0,$ G2 _0 ?; q$ `! U- n) Q6 M
.gpio = DA850_USER_LED3,
1 e' E: S9 y$ l9 T/ A! B; F9 W .name = "user_led3",, E& K1 ^5 f, i+ H. x
.default_trigger = "default-on",
4 P* {# ]8 l0 W/ K7 |' I },
/ P e( ?6 |! G! e};+ X. {: g. o3 ~$ w$ O
! |5 q& k( A7 L x0 K7 |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' W5 Q. a9 N4 o/ D8 S { .leds = da850_evm_tl_leds,' t8 r# P) q, \8 p t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; s7 t8 n5 a# o+ m
};+ w) a+ L$ X X4 t9 w
: ], }1 z, H; Y" k
static void led_dev_release(struct device *dev)
1 e1 N; a/ h+ V, {" D/ ^{
6 @. V9 E! {0 g" N};' X+ V0 H2 P4 ?$ ` Z$ ~+ ]
+ e' A1 {4 v8 j) @- x4 n
static struct platform_device da850_evm_tl_leds_device = {6 P: j8 I: D9 [& \3 b. {# o
.name = "leds-gpio",
/ t4 X$ \4 F7 ? .id = 1,: |& r2 L* v! @7 k f$ [
.dev = {3 m# S1 j) [- I6 [5 w
.platform_data = &da850_evm_tl_leds_pdata,; ~& g S6 X9 X; ?( Z7 u i3 \% g
.release = led_dev_release,- s4 f/ C' l h' A
}
9 A) E: S1 k4 w5 K* q; U) N* a# }};
7 I7 v A' I/ ^/ g0 B. d
; e+ d/ N' I) i/ C, `static int __init led_platform_init(void)7 y3 v* Z- x% ~0 k
{ z) y. U# T4 x
int ret;
p# \- ]6 ~2 i9 m% F#if 0% ? c/ L7 s$ L: z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 z7 ?5 w s/ ^% ?6 ^, B8 b+ r* u if (ret)
! t9 p8 c6 H4 D5 W* B6 m% p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 u" D( ^& K `5 m" v% n
"%d\n", ret);6 `0 d+ Z: T. R" S! F9 }
#endif
3 i& A x9 G6 Q I9 O ret = platform_device_register(&da850_evm_tl_leds_device);
1 C( @. b8 A8 W, S5 C if (ret)- U# z; ?$ _, @: O. M0 B
pr_warning("Could not register som GPIO expander LEDS");
8 U0 w% I U& f C$ K, \ else& ~; P- \2 H9 \0 E
printk(KERN_INFO "LED register sucessful!\n");
5 e( F( y: C. h; _! [* q7 `! J+ @2 i: z
$ I( }" i4 U* a. V7 e: Z return ret;: @, H* o! R& q; `, t1 K
}
# P5 y# b6 w7 i& ^% t7 n2 q
$ v' V5 S4 g! c1 s( h) f& {static void __exit led_platform_exit(void)8 |$ N5 L3 H* Q1 v0 [, O
{
. v/ G' e0 q+ o$ H$ r6 p3 G platform_device_unregister(&da850_evm_tl_leds_device);
, b* D i5 \ q7 ^- r4 f8 Q S2 h. j6 H% E' A
printk(KERN_INFO "LED unregister!\n");0 v7 x# h$ I" v3 X& _1 O) b
}. e" ^+ R' w. M0 N, ^
: Q3 c6 w `5 S6 m( h3 j
module_init(led_platform_init);7 Q0 h7 X. r/ C) @6 A1 L7 H3 G
module_exit(led_platform_exit);7 M. Q/ ?9 M$ \! `6 L2 Y+ O- _8 x
: _# Q7 {- p9 R* b6 R) o* LMODULE_DESCRIPTION("Led platform driver");7 p2 n2 ?2 n0 w( z1 B0 s3 n+ h+ z+ J
MODULE_AUTHOR("Tronlong");) Y. ~4 @% c8 A4 [; I' t' \
MODULE_LICENSE("GPL");7 j$ e8 @' H8 x" t- T. H
5 g, G* v1 i2 D* C2 a( I c$ k5 m |
|