|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 }- `4 `' O: d9 m# X2 G#include <linux/init.h>
* v, o7 c, T9 }% o#include <linux/module.h>7 p: M& S T9 W% v# Z, [
#include <linux/kernel.h>0 C* r$ s! y" ^' t+ E
#include <linux/types.h>/ S! T+ g# Z7 A4 z
#include <linux/gpio.h>
6 C0 H% A3 K( z8 d: `1 j#include <linux/leds.h>0 L* Q9 M2 }! x- c/ s* Y
#include <linux/platform_device.h>
4 s' W. E1 }* E) r
Y- u8 y/ W0 ^$ Q) J, \#include <asm/mach-types.h> Q* c& W% u0 o) K* R
#include <asm/mach/arch.h>
$ W) x6 \ ^$ p* W#include <mach/da8xx.h>
, l$ l; }# I# z. u#include <mach/mux.h>) h4 ^; J1 `$ [
7 g) V5 w; t. ^3 o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 V' s$ a/ I( m* l# d& `) M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) v/ v, c* n& ]! T: g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- k, |8 @ P& c$ a3 u$ `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ @, ~" O& R7 z1 U' _" h4 T5 Z
/ v+ e9 A( c) G2 X- N2 c* H0 r
/* assign the tl som board LED-GPIOs*/
' J4 c& a9 s7 ^$ Ystatic const short da850_evm_tl_user_led_pins[] = {- \, a7 q" B# V
/* These pins are definition at <mach/mux.h> file */+ J0 a" O8 {3 M, x- E, P+ p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( r: |( U9 n5 T5 P' M9 H$ F
-1
+ [! U6 \- |5 e+ i, i w};
6 g8 \3 Y' R. a1 }+ R
N* _1 H* d% \; S% [static struct gpio_led da850_evm_tl_leds[] = {# K7 t; p: O5 g3 V: P; a
{9 F3 \, N) \; D! Y
.active_low = 0,
; L7 T" x1 ^7 n4 H% d) K+ A .gpio = DA850_USER_LED0,
9 Z4 a' S7 X& o& F; R# } .name = "user_led0",
' j2 y Q/ O- q" ]2 @. @ .default_trigger = "default-on",+ N- x8 s3 e; x9 y: Z
},1 |5 \6 B3 S/ F5 O2 h8 G
{
( T0 S* _$ G6 L .active_low = 0,
) \2 I3 O" x6 g .gpio = DA850_USER_LED1,
# ^/ ]' R$ d3 N, w% _ D: @, a- O .name = "user_led1",9 g4 P1 P$ A& J: R% H
.default_trigger = "default-on",* f: D, r; F3 ^8 B
},- q# W$ j. v+ c% m( W
{
- Z; d, ~& c/ H# b& F1 v .active_low = 0,' d! p$ Y: Q T+ } u
.gpio = DA850_USER_LED2,0 i( _: ?, c# \
.name = "user_led2",
q0 m* u3 g( Z) J; F .default_trigger = "default-on",
% g5 c# @4 P6 O: Y( f- ~ },
; G. }- S2 N5 A/ L1 ]: s( V {
: Q, K: c2 j8 g& C n6 ~ .active_low = 0,4 r Y; f* `/ w8 s- K/ ~
.gpio = DA850_USER_LED3,! ~' e. g$ q" J; P3 k
.name = "user_led3",
0 q9 v8 U. `+ x5 i .default_trigger = "default-on",2 _# H' R! U! ?1 a# N8 E- Y
},9 G) g' S2 t/ R9 K$ b
};
# C/ v$ ]* o# Q1 @1 s
% Z9 n7 c- C0 ~% _3 t" {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# a! J% q+ Q8 A" P9 {) O: ?" s! N .leds = da850_evm_tl_leds,8 h3 q P/ V1 s" L, K, t* c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 |* T& f" B% o5 H! p7 J
};, p4 m3 N. F8 L* F) c% d, u3 p
2 T, f2 k) p# K
static void led_dev_release(struct device *dev)
" {0 U i, B3 x/ U, G5 V8 I{
' {; H' M, S1 i" e! ^6 t4 }};
0 d! q) Q2 L( a% B( [; L1 r
) I5 U. E) X9 Dstatic struct platform_device da850_evm_tl_leds_device = {% h: t6 C; a% l$ S& ]% b, `- [
.name = "leds-gpio",
" ?) N! N7 g7 U .id = 1,
; K3 K2 Z) N! C* U8 B/ M* h1 m/ M .dev = {
+ l4 k1 v* t$ g$ p, v .platform_data = &da850_evm_tl_leds_pdata,% h! T+ d8 m; V( ~& F& d. i* L2 r e
.release = led_dev_release,/ {8 B* e& G" B( r, F& O
}
4 r, S: u# s! P. E1 n! C};
( z5 z7 u& o; y* y
1 [4 b" o, ?* l' K( Estatic int __init led_platform_init(void)$ F7 B& {: G6 F/ m% Y: T
{3 `. Q3 `4 b4 i% P% B( u! f* t x
int ret;
( Z# J; \- D3 ?#if 04 q9 ^& b) c% ^2 o. Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* z, u* {$ P, T2 s f: U, c if (ret)
/ S" [* [/ J' [& X, ]4 ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' i) L) [: t- P$ M& K# p: C: |7 ^
"%d\n", ret);
" s! j+ X3 n" t6 k#endif
/ {9 ^$ |5 s( O. ^ ret = platform_device_register(&da850_evm_tl_leds_device);
- V2 A1 m8 S4 x9 D( |1 G: T if (ret)& S$ h! C' s, R* W3 ?
pr_warning("Could not register som GPIO expander LEDS");
8 r. I8 \4 d1 d, G. c5 s) R else' L& n: b9 s+ m3 O Z
printk(KERN_INFO "LED register sucessful!\n");' t9 Q( X, y) w4 V( W
2 P, [# _$ {1 O4 f6 m0 M9 V9 x return ret;7 L' R6 Z6 S0 O" o/ t$ x
}
; O* H3 Q+ T) I- h F' U# G& c* w
2 ]6 S2 J8 j1 `) h5 d+ `static void __exit led_platform_exit(void)0 Y+ P' l6 H/ k" L
{
0 Q1 T' l: l. X h. R3 o, u# t platform_device_unregister(&da850_evm_tl_leds_device); D/ n/ G2 P0 @2 O( j5 O2 _. U
" H& r3 `$ q W, l4 m$ o printk(KERN_INFO "LED unregister!\n");0 ?; n$ g% j1 y& E; D
}
% {/ O* k& b* x! q" }7 A- _: E
N/ `+ g" H2 E6 w* O$ i& F0 y: Rmodule_init(led_platform_init);
& X4 N$ {3 N* R8 L! pmodule_exit(led_platform_exit);
/ ]( t. h. k F: n2 s4 o$ H: G, W3 V1 k# ` J: \* s# p3 |
MODULE_DESCRIPTION("Led platform driver");) j# C1 ?2 w4 g: J0 R
MODULE_AUTHOR("Tronlong");. Z2 e5 W2 G1 p; c( @5 s, C
MODULE_LICENSE("GPL");
: i9 |" q3 Z# e0 `" t$ l/ Q
5 |% f8 U4 v; q8 `. S |
|