|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ A/ z, H8 V, l. y: }% J
#include <linux/init.h>
" } U9 J8 j' q1 m5 V ~#include <linux/module.h>& g& w4 O6 b& {8 d; a% R
#include <linux/kernel.h>
$ J1 A$ n: O, @6 o#include <linux/types.h># }% i! w0 S) t' d
#include <linux/gpio.h>
: d c- @: S9 I5 G#include <linux/leds.h>
$ U; s1 ?6 p& o#include <linux/platform_device.h>& D b/ `! k$ t) w. {$ S8 b% z
0 F1 Z- [' n6 W [
#include <asm/mach-types.h>- k* h; p$ [+ m! t* A- s4 R
#include <asm/mach/arch.h>
- E( y! @$ [) B3 L- x#include <mach/da8xx.h>
7 v$ d! G, K, p' u7 k; m#include <mach/mux.h>
2 o% @9 ^ W- {% Y+ G, ?, F) R) p0 i# P. i) }: o: }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( _2 h4 K8 b4 u. T+ U6 i
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
o7 r- ~1 @3 p9 ]9 r2 q7 q- X#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 G2 o& o2 j" [# Q% p& S0 s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 Q; X0 B' {7 B; f
; A3 u6 x" H) j! S/ c
/* assign the tl som board LED-GPIOs*/5 S% S- c+ [' Q9 z8 Q5 i1 p
static const short da850_evm_tl_user_led_pins[] = {* o+ [& G) r: q2 n5 s! q
/* These pins are definition at <mach/mux.h> file */. t! s) a6 G: B& }" z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, G4 t8 j% ^( X5 O& V6 r -1
( T) F- W. a: S! ~! U2 _};
, J* `; d* D# C
! z; x+ Q8 I* f4 z/ fstatic struct gpio_led da850_evm_tl_leds[] = {& x+ d0 }+ O, [9 @& y5 ~9 D8 N/ _+ y# i
{# n3 T" y Y' W& o2 E j$ p& y
.active_low = 0,
5 z2 x" G- Q% V) N+ t7 @ .gpio = DA850_USER_LED0,
, A6 f6 {5 F+ d6 O: c$ x7 y* T+ e .name = "user_led0",
9 d# ~5 ]2 h! V2 g& U .default_trigger = "default-on",
6 {0 X6 m, k" m8 q- P },$ z+ d8 z* {( @) k l; V- T( |
{
B7 A$ W% i& \9 J: R .active_low = 0,
) {' ~. b8 E. @7 [ .gpio = DA850_USER_LED1,/ G2 k+ A( h# W: w1 x2 v' U
.name = "user_led1",% `, M" l+ _/ a: W
.default_trigger = "default-on",
6 E1 w; r% B" \) D: s2 w( I/ W I% n },
[' D$ o+ t6 A' o y. Z9 ^- t {
* W3 M; T w% X6 o6 j% V( G& a .active_low = 0,1 b( n1 A i- M
.gpio = DA850_USER_LED2,7 Q! W* P# u( j" w# A* W# H
.name = "user_led2",
8 n$ @" S7 Q* d .default_trigger = "default-on",
+ H- \- j; [$ I+ Q$ f2 A) k P },
- |, D' e, V. Q7 g {
# C4 c' D6 v* R& d' d .active_low = 0,$ I% M8 {& Z. s* [+ X
.gpio = DA850_USER_LED3,
1 e1 ]! [" Z6 H. q4 E .name = "user_led3",8 [7 i; e' m3 `
.default_trigger = "default-on",% g4 K: Z( W: y) r+ o2 k$ J4 P
},
! e$ g& `1 {% x, J# _3 V( a Z4 E2 S};* Z n, i# m- S/ e$ Z
' E: m& K( P% g( g/ w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) g( h; ]: a- @ @9 s ` .leds = da850_evm_tl_leds,9 S6 X4 ?2 u7 `, E- m9 o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% c1 u$ F$ c+ h" _7 f) Z
};6 Z7 C L& W" k' ]+ {) h( K$ r
. p6 _; k/ t% y6 J
static void led_dev_release(struct device *dev)# s( Z. k0 Y4 u1 e6 ?! K: ~+ E! O
{( I( y- i0 W' o9 J; ?
};
' W( ^: p" G, R# S/ d/ r
" w' }! ]' i- z- A, h" mstatic struct platform_device da850_evm_tl_leds_device = {
' U/ V8 J% O& z$ c2 i% ] .name = "leds-gpio",
6 `/ L4 N7 |0 t .id = 1,% Q( R) E ~; E8 X
.dev = {" o# p i3 a% S3 c/ J
.platform_data = &da850_evm_tl_leds_pdata,2 y8 X/ i c5 [ g3 Y9 h8 x# H
.release = led_dev_release,
3 i" Q6 ^( A( k9 Z& P }, G, s7 l' B# b* J9 a
};$ J* b! q6 u$ _9 Q
- ~) V8 l+ C. N1 x3 b
static int __init led_platform_init(void)
$ i! _$ g+ s r V T7 l7 R{
8 x6 k! d$ f1 a+ V7 w int ret;3 v8 Q& d0 w$ H9 j
#if 0
0 Z4 T! O$ d! e8 ?" d ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 O! |7 Y9 B0 ^3 l0 a& s
if (ret)
" b2 E1 h# z6 @8 S4 `. { pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, i( i5 a {# N "%d\n", ret);
- T1 {+ C" Z0 i- U: h- n# R) i: ^: r#endif
1 }5 j0 G) t ?! } ret = platform_device_register(&da850_evm_tl_leds_device);7 d# `# z% K6 w2 }
if (ret)+ m' `! h8 ?* Z L% p! F
pr_warning("Could not register som GPIO expander LEDS");
8 G2 n& A j' x4 @ R else
Z! | r6 R+ ?3 T printk(KERN_INFO "LED register sucessful!\n");4 m0 L4 \6 }0 q- n5 K i: q
! ]4 n: u3 Z. C S/ m; z return ret;
' r) J" |: t; B' W0 [( ^" x2 w}
) n: G% i% Q: C( z$ A) B- H
! a0 A9 L8 C% }% V% C7 M8 istatic void __exit led_platform_exit(void); ]- b1 W/ i0 E1 f1 k% a
{
5 v5 H `6 J5 M; F2 s# z7 q platform_device_unregister(&da850_evm_tl_leds_device);: v. o5 Y! J$ c3 u. l# G
) n4 g }6 Y- ]0 h, { printk(KERN_INFO "LED unregister!\n");% u$ {) L. v# w& |6 y, k
}
5 E5 m& I; w. y5 c4 i2 p2 N
) d4 z5 w. c' c q/ Jmodule_init(led_platform_init);
2 f2 C$ K3 u9 U) _1 Tmodule_exit(led_platform_exit);* {2 D8 z2 M+ Y7 m
: U2 ?# ~/ A" {* W( O. t0 k5 A
MODULE_DESCRIPTION("Led platform driver");
) ~* D6 W2 _5 B# S% @% q; CMODULE_AUTHOR("Tronlong");
. a0 s/ _' G2 e( W/ JMODULE_LICENSE("GPL");
- c' y3 e. {, p$ U. U# ^' L2 x0 _& @5 {( R" L, t
|
|