|
求大神给下面的程序做注解,请稍详细些,谢谢。
) m* t; o, X$ ~' `% ~#include <linux/init.h>
, }9 L2 L5 m C! b* G#include <linux/module.h>
2 f! M. W5 V( J/ X#include <linux/kernel.h>
( o% Q# M1 L% Z+ E& G8 g" c#include <linux/types.h>% } v9 P S; }* `
#include <linux/gpio.h>- L/ M: y1 `! Y/ K9 { }/ a7 E
#include <linux/leds.h>
3 d. ], F, j% o* I( K# e0 w#include <linux/platform_device.h>4 V& F' B) m; ~5 |' }/ B. P4 i% j) [5 c
$ ]( S7 N$ u0 m8 a- z8 ^#include <asm/mach-types.h>7 V; f0 ~4 M4 @' N# q) n
#include <asm/mach/arch.h>
1 d2 u0 q; l: O' o#include <mach/da8xx.h>0 {% r) x) Y+ p$ A
#include <mach/mux.h>0 O4 S* w, a8 f3 G
; v/ N: @1 T' N! [$ ^3 n( @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 h6 P' e% W# M) `) f2 b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 |& q5 I4 Q8 \9 y) e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. D6 o/ ?6 g' K$ K) s( F2 f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' x6 J, ^6 Z+ N! I1 ^$ E
+ ~2 t! v# { n) R( l- `/* assign the tl som board LED-GPIOs*/8 S) q. R c% t6 d% r) p6 g" |, O
static const short da850_evm_tl_user_led_pins[] = {; y- L. b7 x3 q- z% f# P3 k" K5 k
/* These pins are definition at <mach/mux.h> file */. y' D& `8 z3 ?; D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ `1 U6 h; L ^/ e5 x2 `) c" q -1
% ~) M% z$ ?" R; d( j};
8 O$ ]# L) R/ O& y- L/ ?5 y
% t2 v# l, ~0 t5 ?2 ]static struct gpio_led da850_evm_tl_leds[] = { k% ^; l: [/ L9 s, @
{+ _/ w$ S9 L2 L+ c) L, Q
.active_low = 0,1 q L6 G0 f/ d/ w# q! d- k
.gpio = DA850_USER_LED0,
7 b2 y7 b1 @+ O/ `0 _/ _ .name = "user_led0",
; f9 \0 V1 K4 j0 _) P .default_trigger = "default-on",. L# H# \/ b: w, @& j3 Q: l) k. _, Y
},
: C9 p( ?+ H+ N( z$ w& y- N4 h+ R7 H& } { j2 g$ Y9 e) |0 O3 L
.active_low = 0,4 f+ w- O* a; E( @+ B
.gpio = DA850_USER_LED1,5 X1 L5 Q6 C2 {) O
.name = "user_led1",
& v9 Q) L7 Z$ l! c4 L .default_trigger = "default-on",( j6 B1 e. H9 Q5 ?
},- P9 Y( ]# i, q0 s
{
+ g7 d# U) Y7 x% B% d/ I: B% b5 w# _ .active_low = 0,
( _: [7 l( V1 } .gpio = DA850_USER_LED2,
' Z5 M: H; D! l. D1 L( _- ]& C# C .name = "user_led2",
7 x2 l; H; f( J9 U p .default_trigger = "default-on",
& M0 [! z2 e# l% A },# v! L+ g. e0 T; F) f/ B" q
{
- R$ l$ j/ s( i* F .active_low = 0,( B( C4 i: i: B
.gpio = DA850_USER_LED3,& H' p. l8 F J9 b; M
.name = "user_led3",8 v9 M+ v' z1 d/ ?# f4 ?2 j, E% g
.default_trigger = "default-on",2 j3 p/ ^8 d1 k1 n5 h! [
},) _$ K c+ O/ }8 Z4 B
};2 M8 U6 ]2 R% b; o
7 {1 N( T9 u3 r% J: L) {3 H% {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' {3 w. H/ I4 a! ~ .leds = da850_evm_tl_leds,3 I* e& R+ F, u; E( C" m$ h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 L8 q. G8 C- P1 ~};
' L# c2 Z, t& a1 U$ s$ I
( o2 b% `. d2 tstatic void led_dev_release(struct device *dev)5 { y$ a9 C8 E$ K" m# M! C8 S
{
Q* ]. v* X7 V h$ n6 T& k};
% w8 F( C4 a/ i+ j% F% q) W6 r6 K: \, m
static struct platform_device da850_evm_tl_leds_device = {% N" T; \9 V7 j. F, w [, ^+ @
.name = "leds-gpio",2 K% _# ~' |: |0 e6 T- j5 ~" {
.id = 1,4 [% w1 I1 q3 Z6 I
.dev = {7 ? n4 g& ^/ b- |2 C
.platform_data = &da850_evm_tl_leds_pdata,
+ m# [' z9 A+ V; J4 j6 N# A" K .release = led_dev_release,9 J& y! P$ S3 ?) i3 B4 B
}
3 X; c- _3 ^; J8 o8 K/ Y5 r};7 L! y$ G# C% U9 `- h/ Y% U5 w* a
! K" f% r. c, x, p. x9 m! i' F# B6 K! pstatic int __init led_platform_init(void)
8 v r9 n1 @4 P/ @4 Y5 G5 A* N{+ I, f6 O: Y- Z+ r9 H0 |
int ret;0 P% v( s. L6 D+ }0 e
#if 05 d0 K- e0 k0 H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
T! T6 m% @% q' ] if (ret)
8 e5 H3 i6 ]4 V8 d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! d( x% R5 ?' M2 ]2 M "%d\n", ret);
. }9 [* B' n0 r& F3 \#endif
1 z7 @% \ L' |0 x# a ret = platform_device_register(&da850_evm_tl_leds_device);# Y' Q+ u: M( G
if (ret)7 m/ j( ~/ T/ z2 i
pr_warning("Could not register som GPIO expander LEDS");1 P2 q {2 g7 _/ M" `, r
else
( o/ M+ U% F5 B1 x printk(KERN_INFO "LED register sucessful!\n");+ M0 v# D. I7 r, Q8 x
6 S. {' g) T& n' c6 M, S7 y) H
return ret;
; D% b1 A3 N- D/ B8 t}
' ^1 {4 s0 @2 Y2 Q4 l4 T" j9 \; h v9 {% V- h: x, I
static void __exit led_platform_exit(void)
; O9 j w* b1 s7 p& t$ T# R, ~{0 k- B$ K9 k! f1 j, d
platform_device_unregister(&da850_evm_tl_leds_device);
7 b2 P* q# {! C' d+ P1 S! T! W: k
4 u+ d; H2 n+ ]+ R; _ printk(KERN_INFO "LED unregister!\n");" L. D x; q7 t" v1 p9 G4 i
}
4 A2 Q, q9 v+ Q0 f, t( G2 d3 i' |. E3 [% B
module_init(led_platform_init);9 b/ Z1 w* c( Q5 c. Z2 K
module_exit(led_platform_exit);1 G0 ]) l5 s5 Z$ c$ m
& H9 F/ F" X, ` H3 i% S3 e+ UMODULE_DESCRIPTION("Led platform driver");3 U; e% i; k) O$ |3 P. S+ ]
MODULE_AUTHOR("Tronlong");
+ L6 r, }6 L; v- `MODULE_LICENSE("GPL");
( j; |. W( ?5 l7 {0 @0 B5 e o5 i) F# _% X
|
|