|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* P1 O6 `5 t% C$ `: ~% ]#include <linux/init.h>
6 M$ Q; n, D/ D' u V#include <linux/module.h>
7 G* Z# Y" a* y$ k#include <linux/kernel.h>
5 P9 g$ R2 _' t#include <linux/types.h>% x! j& U8 P7 r# E
#include <linux/gpio.h>
i' N# t# |% f: f, s#include <linux/leds.h>
( v& N/ \) v* y. k* T#include <linux/platform_device.h>
# H9 s# L/ f& h1 {6 p3 J1 n8 M1 v. @* f; H2 l
#include <asm/mach-types.h>
) E, g) y0 O# @6 g [#include <asm/mach/arch.h>
7 r- q( g0 R! z0 l#include <mach/da8xx.h>
/ F- N" l: m0 l9 U) p0 `( k: j#include <mach/mux.h>6 ]: y4 P0 T7 ]# }2 `/ ^# S% y
! b: g8 d0 V7 |7 \: T9 D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* k/ f% Y! h, a4 o% ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; n$ {( V. l, `5 h: B- b2 b- P N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 l8 Q r, V" O3 r* W& o2 Z: _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 q- C4 t8 `1 M }; l, s
0 b# C) }/ p" p! `/* assign the tl som board LED-GPIOs*/
" X9 g! G# m q8 Zstatic const short da850_evm_tl_user_led_pins[] = {
8 m% X. q! |+ r" D /* These pins are definition at <mach/mux.h> file */! W L& @: y, [) ^' N8 q% `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, F9 Y% F6 T8 K -1- K v4 A" C+ Y% j9 [
};
/ h: R3 W2 u# P3 z# {+ c. i) z& `
static struct gpio_led da850_evm_tl_leds[] = {
( f6 k4 L- [7 Q _! [! I& }! j4 | {8 ^' @: U( u& C( Z! J
.active_low = 0,
2 \& T" c S) d .gpio = DA850_USER_LED0,2 q4 f* Z3 \# q# ]% _6 b# T, l" J
.name = "user_led0",8 w4 m! `0 Z( R4 |) T
.default_trigger = "default-on",7 _9 J! `2 r- F O: t4 h
},2 s0 U- G7 E- R4 j( v/ K5 H9 E
{4 Q, |+ {% B+ G7 X
.active_low = 0,
/ ?# q9 H3 z* q3 S+ J/ M7 G .gpio = DA850_USER_LED1,1 B1 m. O0 m1 u
.name = "user_led1",' ?2 L5 I5 A9 P3 j3 Q
.default_trigger = "default-on",, C7 G% D3 G' h* K- O4 T) P
},
3 Y, ]4 h& E5 l2 w* o* r7 J! b9 m* E {
! _, x. ^2 f1 W .active_low = 0,6 i3 ~! I9 s; l# n7 i
.gpio = DA850_USER_LED2,
4 L4 v' x( b) U/ }% M# e$ r .name = "user_led2",2 I3 l$ q6 Y7 y7 `5 r
.default_trigger = "default-on",
1 T$ ]+ R. q% ~1 w/ O9 n },& @+ ~ o4 q& {5 a6 N! f0 e
{8 B5 s3 O$ m. v3 T# [$ h* }
.active_low = 0,
5 R2 T6 Q8 ?5 `) `2 k, j8 ?9 i .gpio = DA850_USER_LED3,
6 F; |; Q8 j' L .name = "user_led3", b$ v- E/ F' B: C
.default_trigger = "default-on",
2 @+ j, ^ Y0 B$ u },5 C. }/ M9 K u3 H
};; q% }1 u8 r* M1 c; h
' X) r4 {2 ?0 Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 L7 c4 p. N# K6 p
.leds = da850_evm_tl_leds,
3 Z6 P$ v4 i3 l$ p0 _* p/ v1 t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- e/ O- ?, X! }% @9 b) D/ I6 y
};
7 V' p' L3 M1 n9 P
5 y% M0 @, L7 Rstatic void led_dev_release(struct device *dev)
: Y$ D- m; E( w# S{2 f" `& H5 E2 e
}; l$ I. P9 m% E
4 Q9 x) D, f O+ S
static struct platform_device da850_evm_tl_leds_device = {
3 e$ y* {" b Q- q8 _. o/ Q, C .name = "leds-gpio",
7 z H7 f& e4 a4 m .id = 1,- O; N- Z9 x% Y' G I
.dev = {
+ C# u, S# c6 d/ @) J6 g1 H6 J ? .platform_data = &da850_evm_tl_leds_pdata,9 F0 w$ V: k0 P( a
.release = led_dev_release," s3 Q! y7 R% S$ C A5 O
}4 }- L) R; ^1 I D0 I* ?- G8 l, b
};" s7 }% ^+ c% ]/ k' ?
/ ] l/ |6 p7 ]2 A
static int __init led_platform_init(void), k% X" _1 q) a1 P* O/ F( s
{+ D! x. f/ u, O& z7 x+ E% s
int ret;/ k5 I7 Q* m% N0 s
#if 0, _6 q7 N ~8 b- Y& W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 E1 c* G/ D) ]& r if (ret)
9 r1 b6 C7 a4 K' A6 u& k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 d' H$ r, C6 h. E% Y& a
"%d\n", ret);6 T9 u# s3 N8 o; u- X! `
#endif0 H5 x0 G, }8 J
ret = platform_device_register(&da850_evm_tl_leds_device);
7 E5 b7 g) {9 p+ {' U if (ret), _) I0 @9 `: q
pr_warning("Could not register som GPIO expander LEDS");
3 z: I7 |5 n# A: R8 Z) f) M else5 W( n! W4 q$ A/ V# f0 R
printk(KERN_INFO "LED register sucessful!\n");
$ l7 ^2 v* {1 Y* D1 L; {+ a
# z0 C' L& b: N7 z return ret;1 J% C$ z/ A0 P; \" |
}
- ~, `) O, i' e6 ^/ L$ v
( l! i7 b o7 _! K; cstatic void __exit led_platform_exit(void)0 i# h% W, {- @& z4 M: Q
{
& [: ^7 T; `. _! r platform_device_unregister(&da850_evm_tl_leds_device);" A$ _& `* {* S4 \" y
6 V6 H5 @2 I- Z; s- q& M" v- U! n
printk(KERN_INFO "LED unregister!\n");' n3 o! V9 I& N, g$ ^
}
' C! ?+ t& z. _
# b0 F# C: \2 S/ p4 vmodule_init(led_platform_init);! j- g* @, J# J: o: O
module_exit(led_platform_exit);
% v+ V2 n6 V% O7 n$ W' g# o% F) S$ ]! V4 |1 T' \3 q
MODULE_DESCRIPTION("Led platform driver");% { \- C/ T8 Q! {6 J, H* W9 c7 _* ^
MODULE_AUTHOR("Tronlong");
+ t. t+ w% ]: j# uMODULE_LICENSE("GPL");
8 n, _: c8 {' U; i( x2 G! L9 W+ A2 W5 t0 @) r( b: X+ c& |
|
|