|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 @- a I* u0 P1 ~1 g
#include <linux/init.h>
( v4 s `) o+ |0 [8 ]+ \+ m#include <linux/module.h>1 L# G# J( C6 K
#include <linux/kernel.h>, F+ E Z9 j7 `; f1 w
#include <linux/types.h>
, V: b$ |. G. a1 H, D c#include <linux/gpio.h>
7 @% t; P/ x9 {- Z+ |( x#include <linux/leds.h>
$ J! U( A& m/ J* P#include <linux/platform_device.h>
$ r6 R! k( v& x1 W# Z# n, |; J: u5 T$ Z( y
#include <asm/mach-types.h>1 y2 g/ s0 o' d$ v) s
#include <asm/mach/arch.h>
) {+ o# t+ w1 w" @9 f9 h#include <mach/da8xx.h>3 }' }/ @4 l$ T, B
#include <mach/mux.h>
& w D i8 X/ Z T z, `, M& k# I `* D' M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- w1 }4 c% A$ k j" r3 j6 g: s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 u. N6 x8 ]) L4 L: \7 g+ ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% @; P3 J8 Q' B+ Y2 H) z' L8 D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 P; V. r4 {" @( Y4 k! r
M8 W" H; w7 N; |& t/* assign the tl som board LED-GPIOs*/8 a6 F c; X( E! r, t# o( B' Z, v
static const short da850_evm_tl_user_led_pins[] = {1 X: Y; j7 l" A. b3 y
/* These pins are definition at <mach/mux.h> file */, k2 L* m, M1 {1 v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 i$ U$ ] q6 Y8 g) L
-15 N0 _" ~4 W5 X) X: T
};- y3 t6 X2 g; g6 O6 ^
/ V8 J/ O( G' Fstatic struct gpio_led da850_evm_tl_leds[] = {
$ @5 k* [ E4 R {6 [: \( p7 O6 k1 A
.active_low = 0,
$ Q. W& C- a/ l- e. U% K9 V .gpio = DA850_USER_LED0,: I6 ~9 ^, z) U; d5 ^. ?% ~
.name = "user_led0"," f7 C% f9 r* @$ A* O% D5 c# w
.default_trigger = "default-on",. o+ n, Q. G0 q7 L3 v7 G9 w
},2 A+ u# G6 `3 e: ]- s" R0 O
{: `. A) ]! I8 Z$ E; v6 W8 t
.active_low = 0,0 u9 V1 J9 Y) z1 D
.gpio = DA850_USER_LED1,
% J9 P/ u3 K+ e" q2 J* ^( P .name = "user_led1",
% W7 [0 @' k! _! C .default_trigger = "default-on",7 Q2 _; x, B+ v& [: u
},2 n2 M/ g% Y! ~
{9 H9 e* s, D8 H/ u |7 {% e
.active_low = 0,; ^4 B% q5 K- x8 L: Y" s$ ]0 B
.gpio = DA850_USER_LED2,& G3 U$ ]) ^- } ~
.name = "user_led2",
2 M H2 u9 q/ Z+ a; a .default_trigger = "default-on",
& m8 }: ?& O! _, W },
u' n1 D/ N. }6 I4 o2 \! A {# v# z1 W3 l+ D6 l7 h* {! g. l
.active_low = 0,0 z2 Y' ?7 O% q0 n" Q' R' s! s& `+ _
.gpio = DA850_USER_LED3,
" `' d: n; | C& a .name = "user_led3",
8 r/ J! V7 l' v N3 U( R .default_trigger = "default-on",+ [( ?8 B* }0 X' Z8 p v
},+ B% R$ `5 b! |1 A! g% y2 ~# ?, b
};
* _2 R+ S8 M1 J' A, G) s7 _4 A1 {) H! ~& X. Z1 K. e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ v3 `; l% V. g .leds = da850_evm_tl_leds,3 X) Z& w$ Q: N5 t8 x5 b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% [* F- G0 |8 L& f) ~6 e0 B4 D
};3 ?! U. {% K" V$ p# Q' A) D' Y% ~
3 _" e, A& ~9 p& Ystatic void led_dev_release(struct device *dev)& ~. l: k, H1 p$ T4 s4 f
{
' E& _, Z& G$ Q% U6 F: p2 T2 h};
: V% i8 y, {( `, e$ C2 |: r5 T8 {- T% |2 B `6 |
static struct platform_device da850_evm_tl_leds_device = {
& o$ b0 F& s% ^5 a/ u .name = "leds-gpio",
4 I8 W8 D5 g* C. m1 H .id = 1,4 k" ]2 l) t: }6 a
.dev = {$ f5 N# k+ \; S5 R% c3 D
.platform_data = &da850_evm_tl_leds_pdata,3 E) M1 z7 H3 C5 a
.release = led_dev_release,
+ h$ h) t# r! X5 C }0 S" A7 @4 _8 ?; K8 \% e
};
1 c( r. D! s8 c
) c; r! V$ F7 r9 K- nstatic int __init led_platform_init(void)7 n6 ~* O% S: e4 z8 s
{, [% R) r- g3 j
int ret;
, ~- P, E2 P' K% c& f( f" F, \5 K#if 0
! @, e) k9 e2 s9 G; y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 G2 S/ O. e9 J" ~5 f/ c* o if (ret)
# g% R- U9 [. i/ K1 S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 @1 p# C' d* R8 ` "%d\n", ret);6 G$ H0 C2 }2 K+ H1 K
#endif! Y- r: C/ @- J
ret = platform_device_register(&da850_evm_tl_leds_device);4 {$ q/ U: @# E! O. p8 c
if (ret)9 ~4 W" x$ a! V$ _% X8 Q
pr_warning("Could not register som GPIO expander LEDS");8 |3 ^) z7 {: M0 H( Y2 m- E
else, Q4 C, f5 v( E3 y: h X
printk(KERN_INFO "LED register sucessful!\n");
0 X" y% @8 W: D4 o/ f
7 P3 k; ?8 [* k7 Q4 s2 V return ret;9 z0 e; V" R+ J5 q
}
; L* u/ ]. U* ]2 @% U& K* D! P; z- O- p _$ g6 B
static void __exit led_platform_exit(void)
' G$ ]5 _1 S4 z# b1 \( U{
5 y. |; i: N) W8 A platform_device_unregister(&da850_evm_tl_leds_device);: h- J# v; i$ K8 X; M
$ V! d+ {) j! v0 k+ | printk(KERN_INFO "LED unregister!\n");
' T9 m: a# B. P9 ^}
. g4 q/ u) i" z% ^3 Y- Z+ I4 v
, H) b" e+ f# X3 k$ x1 Amodule_init(led_platform_init); @) a( N9 R1 g* s
module_exit(led_platform_exit);
& E) o/ _9 h# l# _2 p& P$ M8 D" r+ K, ?: k. {
MODULE_DESCRIPTION("Led platform driver");' U0 z1 P F- Z
MODULE_AUTHOR("Tronlong");# d) B) \/ [+ {0 l. A6 D0 }
MODULE_LICENSE("GPL");
4 L* v6 U8 S: V# j' G. n- H7 X! e; _% N l7 Y
|
|