|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" D/ A1 L* w$ e# @# V#include <linux/init.h>
2 p0 s! a: a/ ]9 ^( a8 h#include <linux/module.h>1 I% {3 `+ Z$ d2 d- Z: G1 D
#include <linux/kernel.h>) Y3 V# K: c p% X5 o7 N L
#include <linux/types.h>
% B8 A! S. [3 T$ E0 Y#include <linux/gpio.h>8 X, s0 X$ n# Z0 x
#include <linux/leds.h>
3 v. b c$ A7 J+ L- E#include <linux/platform_device.h>+ y2 E, i, l( R; M' M
* q; k" K3 {+ r% i2 T#include <asm/mach-types.h>
; B1 w: k: H" X# w! W3 y7 t#include <asm/mach/arch.h>
4 E! H" U! C1 e5 Z/ K#include <mach/da8xx.h>3 b* \ a/ b! B' N# B, R
#include <mach/mux.h>3 j# {$ l+ K3 u9 n% D0 ^
$ V$ z8 s) S- V3 N& r B+ U7 m
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); I- E' o, |7 Q" o- X4 K1 f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 X: I/ [) m8 ^2 d' D7 ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ F2 H8 R6 p) Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 T1 i- b) }+ U# h& j I
: ]/ {: f* {( X6 Z
/* assign the tl som board LED-GPIOs*/% G6 V8 u& l. p$ H. n- t
static const short da850_evm_tl_user_led_pins[] = {, z R& G! S: \6 m4 |% B
/* These pins are definition at <mach/mux.h> file */* v2 V; h, d5 g5 f; Q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 \% \* p( |1 S3 T& K7 ]
-1+ ]; z$ v# c8 d/ W0 |. r
};" D) }" |( W/ v: ]4 |
k2 w0 T) M' S6 ^
static struct gpio_led da850_evm_tl_leds[] = {
% s! {. p! v: M2 p( O2 v" ~ {
: R, ^. N1 f& q .active_low = 0,6 ~. L8 e, `+ X# p& ], p
.gpio = DA850_USER_LED0,
! o' g! A* k- j: w: X4 [& g2 N% j .name = "user_led0",$ D$ B/ q% I7 `
.default_trigger = "default-on",
6 z+ M5 d) ]; B1 s7 C% { },
2 c" W! I' {# q$ J4 V4 L1 Z/ E {
% L9 v" B, r2 @3 A) V .active_low = 0,
9 ^! X7 q3 x% o& g$ O. i6 k .gpio = DA850_USER_LED1,* b" y# ~( m' y7 ]" f' d
.name = "user_led1",
8 K/ _7 a+ o+ Q# f3 b .default_trigger = "default-on",
* c6 u l D4 L: i },; I) u* @' A2 `1 M3 ?% G
{: J7 L4 B) {: G% J
.active_low = 0,
' Q+ N0 e' H D .gpio = DA850_USER_LED2,; v' Y0 K/ C; k1 @# g
.name = "user_led2",3 o3 p) C. G f6 x; T5 z
.default_trigger = "default-on",' ]" F: T$ f% |' Q
},4 Y& k# Y+ [. t! }
{1 k r- d L/ m* l
.active_low = 0,
2 c( `- F9 V! Q5 b .gpio = DA850_USER_LED3,' Z4 Y' O, ?9 ]+ a; S' \2 E
.name = "user_led3",
3 _; O' a5 ?4 n% R4 I5 Y .default_trigger = "default-on",
7 X" H1 n/ E( R5 D5 Q! P },
4 b: V1 ]# B$ D; s9 R};
" ^ m& I+ [" |* s9 @* f- ?3 v
0 \+ b. Q5 X8 N8 U) N, U# F) \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 ]& v- G: q! \3 v% W2 Y% m+ T .leds = da850_evm_tl_leds,& L9 q/ j2 d, W: `& G0 }7 b8 ^7 B7 n; U. z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 g5 [: P9 M: N L, e1 H+ e};* v/ e1 M. ?, @7 X I
! n/ D% R- A/ Z4 `* ~ \static void led_dev_release(struct device *dev): }$ Y# Y. m! a- ^% A% ?& Q
{1 d+ F# f5 O% }- c& d
};7 _, Q3 s i6 P9 P& Q, A
- @- u l% R3 n, ~2 I4 _5 p9 H
static struct platform_device da850_evm_tl_leds_device = {
6 p0 T! C4 c3 b( J .name = "leds-gpio",5 N+ @5 n& A. I. e7 X
.id = 1,4 \0 r6 S0 ?; O8 c# x
.dev = {! c; `) d- J6 k [' p* X( q
.platform_data = &da850_evm_tl_leds_pdata,
/ E* X7 W+ n5 w$ c, ~ .release = led_dev_release,
" q8 b0 R3 u4 u1 x& u }
: Y1 P' _4 y4 `( O};
" \! D9 j* n! ], r
7 w* b4 }+ A) _" {static int __init led_platform_init(void)
+ }6 N% Z( w8 x& Q3 `! J" l{8 E0 [: w/ `5 C0 {5 W
int ret;
$ D: x2 B( x" J& A* c#if 0, m x* {6 e* c4 q. q: Q. E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 w: |, W: D+ E5 u
if (ret)
* _' ^' h: l9 e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" r6 E+ J# n- ?
"%d\n", ret);
) ]8 h% i: a6 Q4 H6 H5 z#endif1 U- P2 a) Z. v# z1 O- p8 K- h
ret = platform_device_register(&da850_evm_tl_leds_device);" m7 P/ E! ^* j7 q8 j
if (ret)
9 N0 R5 y3 y8 q$ v. m4 S pr_warning("Could not register som GPIO expander LEDS");
% b. V8 \: }; ~; B& b else
5 f5 F6 W8 l8 n6 x( k: ? printk(KERN_INFO "LED register sucessful!\n");
5 n# G) \6 t1 |: \+ L' g8 c' A6 g# e. J& W- `$ M$ Z. s- @
return ret;
$ @( ^& L/ t7 }2 P6 ~}
( {( F H) d) \/ I- k+ Y: `# n5 Z$ `3 [) t7 B7 A
static void __exit led_platform_exit(void)
* \0 A- j5 b3 f) n% C! u9 F{+ u0 b" _( r0 X
platform_device_unregister(&da850_evm_tl_leds_device);
8 [3 n" a2 s' k5 P0 N
: z7 c) F. T# h# N* T2 c) d& C& o printk(KERN_INFO "LED unregister!\n");
+ v! l( B$ P' c}( b2 m3 A" ~1 p/ E( |7 ~' ]; Z
" |: I8 p9 a3 b- j: r/ o
module_init(led_platform_init);) I$ L' {5 a' Z! i. M
module_exit(led_platform_exit);# {1 H4 E3 _5 |
$ b# E: W0 ?+ @# P
MODULE_DESCRIPTION("Led platform driver");- W7 x5 r. ^% k; ?6 c. e: @% G
MODULE_AUTHOR("Tronlong"); W; w) R( N. M& ~% P! }# b* V6 K, z
MODULE_LICENSE("GPL");
; u$ Y0 P9 g, ~4 W/ e' E) m) ^
y: |6 C y: z |
|