|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# T) g) k6 R9 V, x7 g
#include <linux/init.h>; ~; s& }& l. y: U# e; y2 M
#include <linux/module.h>
% J. c& B A, a: l' ]" l e- m: I#include <linux/kernel.h> |4 f4 B( V1 P* k' ^$ v
#include <linux/types.h>2 a; ]% I. T ^5 L% h4 I2 z6 i* A
#include <linux/gpio.h>6 n0 w2 o( Y8 b3 ?$ s f) \9 V: i, m
#include <linux/leds.h>
$ O; J. }1 J9 t0 d% ~ Z( l8 u#include <linux/platform_device.h>& u2 L* g" p1 q3 i
# B0 {7 A" Z" d#include <asm/mach-types.h>
6 r7 R9 v; f! }' @2 K$ O5 m7 N#include <asm/mach/arch.h>' N8 j$ Z1 | n& a- h+ m) \# V# e
#include <mach/da8xx.h>0 m1 C0 b& e; @
#include <mach/mux.h>$ R$ H, Z7 A5 M" K* o4 K
M" r3 h5 V- M: y7 H
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 \8 T0 j$ B2 {8 Z0 U4 G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ ]# h/ O+ O9 Z& K, Q. e9 r2 T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) a* H, B0 {) A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 s( Y# H% e) y) ?! x/ K X' @( Y8 C# ~
/* assign the tl som board LED-GPIOs*/9 |/ ]6 R {2 p! k' a& C
static const short da850_evm_tl_user_led_pins[] = {
' B/ r; c+ X) u$ @2 o /* These pins are definition at <mach/mux.h> file *// m5 {4 }% V# L& Z/ q D* Z( R8 {+ Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; m6 r( n3 G8 D* f7 ^. |! F( k) ?" n, P -15 S- | T8 m- z& C. y# p3 g
};. F3 a3 O4 c5 t, h. v- V |
4 B9 `! q- t' s# `) C
static struct gpio_led da850_evm_tl_leds[] = {
: a) t5 a$ v) p0 ^! ` {$ r' n7 I- G5 b
.active_low = 0, a1 e8 ]% e1 O% J6 e- H( @
.gpio = DA850_USER_LED0,5 X* P, B. F4 r1 p3 m
.name = "user_led0",8 S3 ?& {8 K5 B( { Y6 b
.default_trigger = "default-on",: F& j8 k0 p; \
},7 A2 I# Z+ S$ z# F
{
! n( a$ _! O" L, i6 X8 ~ .active_low = 0,+ i$ r. n2 W: v1 W) ^
.gpio = DA850_USER_LED1,
: ]" ~& i/ [8 u2 f. U/ x .name = "user_led1",
! \: f; \. f [ Z& w8 g .default_trigger = "default-on",
8 c1 `0 W Z# K1 \ },
3 V+ l y! M8 I {9 @; g9 A6 A( J: p% i* p; C5 Z
.active_low = 0,
/ O# y" {. Y8 F0 j" S .gpio = DA850_USER_LED2,
; q" ~ D$ {% I. Z# L% w+ S. h# c9 P. \ .name = "user_led2",
5 R/ `7 u- c/ a0 k0 k .default_trigger = "default-on",9 `$ p" ^6 L8 R# d
},! G3 Q6 m" }, F
{) P! t6 {' f; u! s- n
.active_low = 0,
1 j7 \: R9 E# y" u. e .gpio = DA850_USER_LED3,% z+ _' i) B) O; Y# |6 j: i
.name = "user_led3",
/ i7 H1 k( `' W# X9 Q K) a .default_trigger = "default-on",& v6 a1 _! e2 z$ l# P" Z
},; a( u7 C3 L5 v$ z, a; B
};& q4 e- H* {* n' B6 x
1 [7 B4 ~. d- H6 Q/ J5 ~# |$ e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. V+ _0 H. X. w! h, I: v .leds = da850_evm_tl_leds,
8 o; G6 S. O6 [- c4 x, {+ B( C2 ^8 | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- F! S$ ?& J5 m1 U( S5 ^+ |};
& m' q- y% F' g
( O" k9 [8 F5 Zstatic void led_dev_release(struct device *dev)
# S. a \4 i9 N1 w/ y{
. S6 ?9 _8 l/ m* I D, T};
9 |# M. }& g. f: ~+ B& t* f' K. C2 l8 E# D* X/ u% R
static struct platform_device da850_evm_tl_leds_device = {
0 {, E; O- C" E* u/ ~4 A .name = "leds-gpio",# ]4 {$ ^4 S+ s7 w
.id = 1,
/ {, T9 t# R% R! N7 y4 H .dev = { _/ @# l2 N8 M4 b& A
.platform_data = &da850_evm_tl_leds_pdata,
$ g5 |3 a: V$ o+ i8 B .release = led_dev_release,9 z& I+ O9 e/ s
}2 Y+ u w% S9 }1 @* }. ]$ C' T
};
8 [# |$ o$ Q# C" S6 } z
" y5 o% I7 o) y* G! \2 lstatic int __init led_platform_init(void)
) q/ L2 T' V4 y5 j' x# O{# `' Z- s3 Y/ U5 f) u
int ret;/ H; s) t1 c. A% ~
#if 0
, ^, v: S' X7 c9 J; B' J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, Z/ C9 e0 y& Z
if (ret)
" w$ o' [+ }' K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% E: @; k7 V" K0 d( k* J5 W "%d\n", ret);+ ~- z# t1 [: o: s
#endif$ i# H' q; A* k0 T2 o5 x* g% l
ret = platform_device_register(&da850_evm_tl_leds_device);# r6 O8 o5 f9 f
if (ret)0 p6 v2 z! {, u' \
pr_warning("Could not register som GPIO expander LEDS");, x: h) B7 r: z* N6 G
else
4 f$ ~+ z+ f, e2 M) K printk(KERN_INFO "LED register sucessful!\n");
* h* `' `& V8 S6 \
: S3 p" I0 ] F return ret;" C2 R3 j7 S9 v" K
}
" C: [+ U$ }7 D8 f0 d# Q5 I, _: g9 S; l# }9 Z8 h
static void __exit led_platform_exit(void)/ B+ p5 }6 _; n. @( ]
{0 f) |9 y4 b$ M0 q! K
platform_device_unregister(&da850_evm_tl_leds_device);; B' [. u) y& }( n/ z4 p6 [% \
7 m3 a& V1 O: _' @2 F& d8 Y( A
printk(KERN_INFO "LED unregister!\n");
A) E' m" q2 A- E) m4 c. k, C}
2 ?& ?# ^+ e6 M' L5 K+ [* J- {/ H3 y" [2 u! G" P5 q
module_init(led_platform_init);0 y9 k+ { {( B+ n: i) W2 F
module_exit(led_platform_exit);
2 T, Z) e1 f+ `. \, A9 Z1 W1 v# q' p0 n, i: w! X
MODULE_DESCRIPTION("Led platform driver");0 l$ i; J& A3 i/ |4 h
MODULE_AUTHOR("Tronlong");8 \7 X# J1 _3 I9 \! R
MODULE_LICENSE("GPL");& ^0 g1 B0 i9 A0 W; U7 F6 D- z f
+ W: H8 B/ Y4 Q4 q
|
|