|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- f' Y$ N3 w' W' |# z
#include <linux/init.h>
: x7 e6 u s8 d( Y" v& G# c; \#include <linux/module.h>3 ?, b; w6 |6 v' I) A! M6 f
#include <linux/kernel.h>: _# k" y9 r* A& a( C
#include <linux/types.h>
7 |) j) M" E+ Y; \#include <linux/gpio.h>
* K- Q1 J' e- w# x" G+ H1 K#include <linux/leds.h>3 |7 w% X; ^! W+ o6 a' y
#include <linux/platform_device.h>! x4 l" ^- d; G/ i* \7 @6 z: g
5 {; F/ E4 [* V$ `9 f
#include <asm/mach-types.h>5 q: U" a( p1 h* J& y
#include <asm/mach/arch.h>
: v+ E# M, s: X) ]( ~+ Y#include <mach/da8xx.h>0 S/ D1 T1 { G* F" C& w
#include <mach/mux.h>
9 \7 a/ h& h7 a) B3 ^6 l$ A2 C3 M: }+ F4 c
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: M/ @) J8 c4 R3 R+ \* T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( b& e+ R0 N4 F" G1 e: H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" f' a, ]' R4 }% x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 y1 p, V) v9 y
[ Z9 i" n' p- F5 _6 _& L/* assign the tl som board LED-GPIOs*/# D4 D+ F5 @! b. L; ?
static const short da850_evm_tl_user_led_pins[] = {+ t) @9 [+ u( f6 j5 [9 X( i
/* These pins are definition at <mach/mux.h> file */$ x: [' j1 n. S- C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. O9 g# E6 A# C' X0 H; Z: d
-1# o4 b% x! \; @
};
% w* D/ \1 ^# a( y w: g; R8 D' Q- ~
: y* _# [6 m8 w/ F# \! B% | O. rstatic struct gpio_led da850_evm_tl_leds[] = {
+ R- N2 J9 k9 R7 ] {
! L, m. I% e. D' P2 s4 \9 d .active_low = 0,; G; F! [, g; ~ }. {6 f! s
.gpio = DA850_USER_LED0,: _( u5 N! p. W& ?. k
.name = "user_led0",
' ?" F" c7 ~- k3 d# g4 D. G .default_trigger = "default-on",* b* F# z$ q' \% \. e+ M; P" E" K
},
; g/ `: P9 C& a$ M' ]7 {" Z V {
; A- D4 @. M( H- i! k .active_low = 0,5 C3 Y$ K. @) _4 J$ v6 s" {
.gpio = DA850_USER_LED1,. }7 M- M) h3 U& T7 p
.name = "user_led1",
! u6 B4 t7 {7 Y( F7 ~4 ~, {1 N .default_trigger = "default-on",
% i; @6 K% F6 B$ H" g0 L3 v },
$ f4 S) C t$ O' r {
+ j: i; \. Z( }+ h2 l a .active_low = 0,
( s+ s6 A; ^. u9 M! v0 n .gpio = DA850_USER_LED2,
& O8 p7 F8 c" U6 L+ j0 Y .name = "user_led2",
1 h: e5 y; {4 J# _, P7 R) L .default_trigger = "default-on",
+ i* t# L7 z: V( ? },% T5 r( W# y2 R% M& O P
{7 a) L) T/ s6 w& A* A
.active_low = 0,. S$ g& Y1 f# \
.gpio = DA850_USER_LED3,/ `' q# c" I% z' x( e7 b. b
.name = "user_led3",% v! V: w m$ K3 f+ j0 z
.default_trigger = "default-on",
% [/ m* b9 z8 C! ] S& U },( i4 l6 s' b# o- b( U. c
};3 G0 t; Z& S3 H2 _: _4 P" B
0 |5 l, H1 a5 L% G% \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: d0 ^7 I* C# y$ ~! |1 ^ .leds = da850_evm_tl_leds,
+ A+ U5 S v7 o% U8 O# A8 b .num_leds = ARRAY_SIZE(da850_evm_tl_leds), O, d. q0 ~3 C
};
& H& _9 y1 I2 o) {2 F% d W5 t* M5 K6 O# ] V$ T* {
static void led_dev_release(struct device *dev)4 h! w$ D" ?1 `' Y, V! W
{
4 [, c0 J5 ?3 N4 ^# \};
' B+ t, M$ R$ |4 y' u* p7 d0 E* S
static struct platform_device da850_evm_tl_leds_device = {: z" B- O) y# w6 w) ?9 |; _- t! h
.name = "leds-gpio",
0 f( W& j, [5 X# Z7 Z8 k .id = 1,5 M* l( m# e6 r7 a( c
.dev = {
3 ^# u$ @% q( i- p {- j .platform_data = &da850_evm_tl_leds_pdata,
+ F( ^$ U/ W/ a2 e+ d: j, \ .release = led_dev_release,
" j( y# `) o: q) ~ }6 V' g. j/ |( ^" @' J1 S( ]( j s/ r
}; y2 E6 F" L. Z/ _5 N
3 j( X: s4 J* Kstatic int __init led_platform_init(void)
5 y% A: x" M6 \' ^" U9 N( H; y! V# |{8 Q% x7 m* X$ H
int ret;
$ N" z6 q4 X4 f* K9 v#if 0
9 P4 `0 z1 F' @/ D6 l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# b4 U9 Z0 m3 ^1 n' \
if (ret)8 o* i# c* R4 {0 z, \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ c! S# Y0 P3 s. O) e "%d\n", ret);
' x3 g6 P7 n) _! ]0 A# ]7 o#endif
1 B$ T) o: s$ Q" o6 G; S ret = platform_device_register(&da850_evm_tl_leds_device);
2 D3 | ~1 j; L/ H/ A if (ret)
7 N' Q0 B/ x6 z- U" I- M+ n; ^# B {: I pr_warning("Could not register som GPIO expander LEDS");
/ \; Y" q* s' Z else, Q, @& c3 m4 h
printk(KERN_INFO "LED register sucessful!\n");
" w$ q! h# d5 w) ?& p$ Y% D) d5 U5 t; M1 n5 ]8 |. t7 [( w
return ret;" v; g5 O" h* q) o
}
$ D7 k ]' S( s* I+ z! R9 A) o _. G) S, M0 b8 X& v
static void __exit led_platform_exit(void)
' I' q9 i1 H$ `* I' S{
' B! e- g* X! E) N% Q% z/ [& x platform_device_unregister(&da850_evm_tl_leds_device);' o% o3 ^' T. a6 V
# n, Z" h8 z( a1 r7 m) y* }1 x printk(KERN_INFO "LED unregister!\n");
9 y$ k1 Z& D: m1 W8 O} A5 o: m! a$ I9 X' N
5 I: c9 g" Y% f9 v8 i6 n/ T
module_init(led_platform_init);
$ O4 Y: j. I8 U3 n1 S# Zmodule_exit(led_platform_exit);
* H3 c8 ]" Q- l6 { }( t; v/ e5 D6 Y" N7 o1 S5 o2 j h
MODULE_DESCRIPTION("Led platform driver");" g1 P% f8 a N/ q
MODULE_AUTHOR("Tronlong");# ?# ]! P( L- w, n6 e, S! G/ N
MODULE_LICENSE("GPL");) G @) j u6 C7 r6 Z
/ }! v v0 H9 c* [6 q' Y |
|