|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' e; e) `: g( t, ]; m% Q/ ]( k
#include <linux/init.h>
. C5 P" [+ h9 X. k- m8 z#include <linux/module.h>
1 X9 c' F% p4 J/ T" \7 ^% M#include <linux/kernel.h>) l; E' {/ ]* _ x# a, J
#include <linux/types.h>( d# Y1 U* b4 ~# C3 P
#include <linux/gpio.h>
$ o* t3 p6 c; M# M* C1 r/ m) J#include <linux/leds.h>
& |: w3 Q" i7 X. b" B& D#include <linux/platform_device.h>
) v% U/ o L' z
$ n( K5 Q1 V; Y$ \+ A#include <asm/mach-types.h>" Q4 [" G# q1 w& i/ k
#include <asm/mach/arch.h>. s! r$ x, R" U2 G! }
#include <mach/da8xx.h>
' H, @ l; m7 f. r#include <mach/mux.h>: C8 C0 Z% ~+ T, \/ s
% f" y; z# _: i0 G H3 L, t( ^8 S L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ f8 M: h- ~ Q, A/ U: Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ v+ R# O6 g9 n! T5 s6 r; h' s
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ \8 D2 E# X/ B, ^) }, f: d/ {. X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; H$ s7 G) X2 Y! W# P* w8 `% }) @; D( U
/* assign the tl som board LED-GPIOs*/
' N! o7 Z$ U& ?6 c. n& `static const short da850_evm_tl_user_led_pins[] = {9 _& G2 h5 B2 D
/* These pins are definition at <mach/mux.h> file */- D& ?& d1 I: h" m$ K* g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- l$ D7 E# E1 B) a. T+ Y1 z" l -11 n8 a: [) B2 N. r1 \
};) g9 f6 _% h5 n6 [( f
2 \. P; b, F1 n5 E/ d
static struct gpio_led da850_evm_tl_leds[] = {
# ^6 q' D$ G. v& z4 F- @% ]: r4 E- O2 s {: S$ f2 K& j7 l7 T. [! E
.active_low = 0,
% h# v, H+ d) j( O) r .gpio = DA850_USER_LED0,
! F5 W# M2 M: [2 }! g .name = "user_led0",
( m& I& c7 c& ?0 N/ S1 f% z/ I8 n .default_trigger = "default-on",/ r6 D9 O* P' R/ q$ a
},/ c0 E9 X# p' c: e; l" d' i
{8 W0 k2 S) \$ |! x
.active_low = 0,
) j9 U. x3 b* y: z .gpio = DA850_USER_LED1,9 n( Y# h6 G0 h' @! A
.name = "user_led1",
j5 ?- J% b9 Q6 @% I7 i .default_trigger = "default-on",
& Z0 J; Z% i2 Z# |0 ~" l },' V+ _# O+ V/ y6 m$ ]( s
{
5 V. u' s7 b( v- F. Q .active_low = 0,
0 _3 L! U* U# W6 v; f# k( n .gpio = DA850_USER_LED2,
: m o( M( @& u* y7 C# Q .name = "user_led2",6 b! R! t! y# s2 w$ u* V. Q, l
.default_trigger = "default-on",4 U) m; _2 H; u$ d7 {
},: V6 |, k& }3 h5 K5 j
{ T6 e3 f5 ? z* p
.active_low = 0,/ t: f# P+ w( P& Q( B1 b O
.gpio = DA850_USER_LED3,$ s5 u/ e% e$ M) a
.name = "user_led3",
& O8 L& D4 ~8 Y, A ]) U .default_trigger = "default-on",+ A7 k& ]7 g. n
},
% `$ {+ G0 k& x. y. h! k+ i5 E};
+ ^# c5 n% u# Z1 N6 L( ?$ z1 }% V! c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ U, T8 h0 |% l5 H% v+ ] .leds = da850_evm_tl_leds,$ x$ c) w! ]+ `$ F8 u. _9 y$ h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 Y8 y d, @) i0 A* i: l3 T$ ~" C};+ V. Z/ b6 u. H' G. q( F% N
8 W" M5 ~# c( W" R4 ustatic void led_dev_release(struct device *dev)
1 J( \0 x4 k8 e1 o7 j{
1 J/ i, g4 n* ]- [9 |9 h};
' P9 j2 q* l# p; w) Q- c9 q0 D
/ d- P5 I; C# Istatic struct platform_device da850_evm_tl_leds_device = {
0 N3 Z! L6 c5 s3 u- h( l% {% x .name = "leds-gpio",
/ b* D; R% }2 \& L5 U .id = 1,
# J1 c8 b! r( l% T& A" M .dev = {
* V: J; k- k$ \4 ~7 X* J( h6 s, S; ` .platform_data = &da850_evm_tl_leds_pdata,$ }+ e/ K" f2 Q" i8 R" l" O" p
.release = led_dev_release,
1 y4 i4 Q1 u' ^, f- N! ^ }
1 D$ x' l* s9 K( I7 u};: s8 k/ l3 K8 n! B4 @
( q6 J' [/ `3 H+ ?. Q3 l$ hstatic int __init led_platform_init(void)* Y6 Z& c: C5 M4 a
{+ s; ?. \. ]7 b
int ret;
3 O2 _, { U7 e( c8 B#if 0 M/ H: E1 s9 I8 N$ }9 q- @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- f& u* O* ]% D7 U$ P j2 Y if (ret)
: C1 J! D& a* D9 I pr_warning("da850_evm_tl_leds_init : User LED mux failed :" o; P+ k+ S# |) |/ y! a' M* G
"%d\n", ret);$ h. B6 h& V' `/ D( p$ b, g( \
#endif
- }9 A5 h8 }4 D. s z ret = platform_device_register(&da850_evm_tl_leds_device);% f& K. N3 G1 y8 y
if (ret)
, R5 U9 o) s3 P pr_warning("Could not register som GPIO expander LEDS");
$ T1 x& r o: N else
3 c6 ^. g5 w, u8 o3 w$ ` printk(KERN_INFO "LED register sucessful!\n");4 a: S. P5 h- j% {# X! H/ k: N I4 L5 k
4 ^" ~; z f+ O6 v
return ret;/ y6 S0 r6 g! r6 v& \7 R) [
}
7 l+ [1 y" M+ _ ]( ^5 ]# _
# Z7 F \( p3 i6 V% istatic void __exit led_platform_exit(void)
' N- k( J' F% ^; W# {$ u{4 q/ Z! R& C9 C# c& T3 e5 _1 y8 n! k) Z
platform_device_unregister(&da850_evm_tl_leds_device);4 ]. F' X. A7 w. O" @. ^
" d* M+ Y& _( L printk(KERN_INFO "LED unregister!\n");
% {$ e& l }( j2 u; _+ Q: [}6 ^& U7 q/ I; c# y# d" k1 Y. V8 J
* @6 D& E; }; P7 l6 }) Hmodule_init(led_platform_init);4 x1 J# s: H1 O# {, {8 a
module_exit(led_platform_exit); T' p6 W. p; ^. H. T8 f
# v; D+ r6 U7 d- U6 p1 \$ V
MODULE_DESCRIPTION("Led platform driver");
0 Y, g7 m- n. T- H$ M1 w& CMODULE_AUTHOR("Tronlong");
6 |3 k8 c$ v& q. EMODULE_LICENSE("GPL");
% Z: T+ a5 e: s6 B4 B
3 V S$ r' I0 T- r9 }" t |
|