|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: d& m; K0 I, `6 l9 Z$ \8 N
#include <linux/init.h>2 \: m# \ j+ C w
#include <linux/module.h>
; x, b2 J$ I4 a, q6 A, x#include <linux/kernel.h>
2 M4 m6 I0 v3 s) P#include <linux/types.h>
# M+ ^, u% y9 e' f#include <linux/gpio.h>
+ W/ T( r4 m; A) G#include <linux/leds.h>
" D! P0 q1 z9 C6 v. z/ ?#include <linux/platform_device.h>
& f4 S1 l0 `3 ?4 M) d+ Z
2 Z& h! I& k! O1 j8 @#include <asm/mach-types.h>
: M# C- W; u& [4 Q+ F1 H$ X( k! }#include <asm/mach/arch.h>
0 _0 r T" s$ J1 @0 |3 O- i#include <mach/da8xx.h>
6 W5 t6 n0 R0 q+ F#include <mach/mux.h>
) L0 d0 Q. E# T: H6 A) Z
! F& l! c, H4 E: ^: w1 D#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 F9 K2 q: [3 I$ R `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 e9 ~6 V7 P) Q5 @( R% G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
M8 b4 A, P$ f. d#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). G1 @0 V. G3 n' `/ \1 {
+ ]8 `: T0 w7 w# N* x3 W2 H/* assign the tl som board LED-GPIOs*/8 q- `$ L. S( H. U/ L( m
static const short da850_evm_tl_user_led_pins[] = {( O2 _- B+ _4 u5 x
/* These pins are definition at <mach/mux.h> file */% v' E2 y/ B! D. x$ i6 U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- W; V% r e" j3 `* W" K9 e -1
0 \: C* p" u/ N) [};
, m- p' N7 n" }. V: A
( O; H) R; V! q0 |5 kstatic struct gpio_led da850_evm_tl_leds[] = {
: R! G B& v2 g8 [* O+ h {
1 R; w2 x$ _/ ~- J8 e" r. ` .active_low = 0,, y* R2 x g. W# A. S' k7 j' m8 d
.gpio = DA850_USER_LED0,
. }. W7 A6 U, K' @4 z2 G. f7 I .name = "user_led0",5 B; n/ }0 a" ?/ m2 z% l
.default_trigger = "default-on",
6 l7 H2 ?$ z9 G- [ },- a$ w: [7 Y6 W* J5 S
{# _1 l, |! [+ W& B6 s6 `
.active_low = 0,/ n9 e, ~5 [' l$ \
.gpio = DA850_USER_LED1,
2 ^8 _. P; F1 j& Y .name = "user_led1",
, G R2 Q( j8 @! C" a' { .default_trigger = "default-on",$ S6 {4 i! | t; x0 X9 x' A- I: o
},& E5 n8 m2 u, q* [& R2 n/ H, d
{
+ z# D1 P( y" v9 H+ F- k .active_low = 0,; L! x% s. o8 G1 z( Y$ v
.gpio = DA850_USER_LED2,
/ E8 Z' X7 Q# p& b0 u .name = "user_led2",
4 Y8 @% J8 G F" e$ o* k; S .default_trigger = "default-on",
% I7 F% W7 F9 V* R' } },8 u3 \7 i& g; V% e2 F9 p
{
" P) ?3 \3 v9 j, w .active_low = 0,
0 s$ k& ^ F9 B9 i! j% j2 r1 F .gpio = DA850_USER_LED3,
$ S5 X: g/ g* ]4 p2 n .name = "user_led3",
9 P' p8 `9 n$ j/ p .default_trigger = "default-on",
. E& D3 a+ `% m! x% O },/ s0 w' P; }4 d
};' [9 }! a( [7 p# E/ s
# R# J8 k: P6 Y5 W, v: I5 Z* I) Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" D+ x8 k, k! J; ]2 C .leds = da850_evm_tl_leds,
* [" r. y2 s' n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- J: D; x; q2 w3 {, ]7 D
};
, G+ ^& Y6 |! ]! f
& `- V) P8 K n! I: estatic void led_dev_release(struct device *dev)
1 [# \& c' H J4 {6 ]5 r{
% Z5 B2 h3 `+ b5 J3 m% Y9 u};3 f, {) @/ |: ^" E1 }
) E2 L4 Q' s; J! L x
static struct platform_device da850_evm_tl_leds_device = {6 \0 E) k" X- x
.name = "leds-gpio",
! y' Y, E8 p( G. }1 K .id = 1,/ w$ s; j6 m7 Q0 L
.dev = {; S" W, Q$ r+ e4 r% }
.platform_data = &da850_evm_tl_leds_pdata,
7 Y1 i2 J c+ {/ p. z+ n8 B$ [ .release = led_dev_release,
3 s1 z' o# Y W, C3 T }3 e5 v( l* ^9 Q2 {3 V; d
};
" ]- F, C5 r+ O4 |
' }) N1 Y7 @1 m" O& k7 y5 Fstatic int __init led_platform_init(void): r9 T5 C4 A' @& F$ X( E
{
' d" H' k6 D; ?, o6 f6 [8 M0 B int ret;" g! R: L$ c* u9 p C2 u) C
#if 0& I6 Q% K) x( Z# t4 _* U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& n# P. _- ^; }( n" z0 h if (ret)
' `" s, I$ s: l8 f6 g: e4 z& [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# V, y$ G4 F a8 q7 |# i, U
"%d\n", ret);+ `3 a" R S& t# d. }
#endif- G5 v& {. e% a4 T
ret = platform_device_register(&da850_evm_tl_leds_device);( J! s# `0 @$ X
if (ret); }' z. j4 ~, J9 U- ^2 n3 P) w1 Y7 q/ W
pr_warning("Could not register som GPIO expander LEDS");$ v( Q% I: [9 Q, B
else* B+ c% E6 C8 Q0 z
printk(KERN_INFO "LED register sucessful!\n");0 ?; ?% q" l% m; c
5 W4 o; {- P' b# D+ }/ _8 |- ?( w- P
return ret;
# T4 q0 p2 j$ d( v: }# A) E/ h}4 r! Z5 ~8 l- B) n* d* e' F
# T% } [% s5 y4 v n
static void __exit led_platform_exit(void)
; _* i, H" u# x) A{! @" j4 e! s" w9 N% ]
platform_device_unregister(&da850_evm_tl_leds_device);
2 r+ C# B; C4 Y5 Z) E/ q; y
1 R* _+ _2 ?$ i1 {# X) y0 Q& I printk(KERN_INFO "LED unregister!\n");6 W' j, e6 F2 }3 ^3 P
}
% ` o9 }- @& X1 H
; K4 p/ I" t: d: ~0 wmodule_init(led_platform_init);/ H) ]3 [! d# K
module_exit(led_platform_exit);: o, t7 T( M) d6 @: |! P
! X. i; S* M" e3 \% s- V# i% g( iMODULE_DESCRIPTION("Led platform driver");
8 P) n3 Y1 P' ^4 }/ HMODULE_AUTHOR("Tronlong");, E+ d7 m5 x+ x. C" w& y/ G) H% T) ~
MODULE_LICENSE("GPL");2 H/ p$ N+ }$ \# y6 L# _# O& L
/ R$ k! Y) |& ^" p" [# l- e |
|