|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) O" d* [4 _9 s+ O0 e" T& g#include <linux/init.h>5 W' P; `2 c4 K/ Q. o# a* |
#include <linux/module.h>
8 E5 @# D8 i! `, F3 ]#include <linux/kernel.h>
M K) }9 o9 N1 W#include <linux/types.h>% {. E! v" N$ _7 K8 ~
#include <linux/gpio.h>6 I p: M- C4 m
#include <linux/leds.h>
# V1 t6 e6 R# l! ~#include <linux/platform_device.h>0 T- z; W* w2 D- j' V0 _- z
% W6 ]& Y4 R& ]+ U! |
#include <asm/mach-types.h>
# E q2 H1 i2 `# f/ {0 y#include <asm/mach/arch.h>% x- L! H. e2 j% A
#include <mach/da8xx.h>
$ k& f, Z u) f c#include <mach/mux.h>
' v& c$ H; T( ~, g P4 _* O- F* p3 H
- Y" l' p9 L4 @) N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), z! @" |" Q: I/ F: |7 ?) J' Q# `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 x* O' X5 d& a4 x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ G( `( d# H1 c! e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 @/ d# K$ L7 _+ R9 {" t( q, p6 X2 `6 Q# C; e D
/* assign the tl som board LED-GPIOs*/
" D. s+ T' d- Z1 t/ {static const short da850_evm_tl_user_led_pins[] = {
. v3 o# h0 z4 N9 F /* These pins are definition at <mach/mux.h> file */* l" @3 }& g3 {/ Q: R# [- }$ Y y# R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 A% J6 S& P* ?) P: }5 a
-1. [- e; O% w3 ^" Q" K
};
9 o" d# P/ s. `) y5 r% m4 ]* l ]1 c4 z/ L9 M l+ c
static struct gpio_led da850_evm_tl_leds[] = {
" P0 n4 V$ C8 L: B4 i {
% P0 s9 V- q, u# R7 G+ f' a4 H .active_low = 0,
" p. B, ], G5 s8 ^ _& j7 A .gpio = DA850_USER_LED0,
6 R S. c- F: x% k9 P# g8 h. I& h .name = "user_led0",& y5 E1 ~/ W1 [5 k( X; z
.default_trigger = "default-on",
1 p! w& D/ }9 X8 l- y4 |0 ` },
+ L8 c. @1 U# w+ L9 p# ?9 M& g {
, j0 q2 {. }9 G- T9 f .active_low = 0,6 d: ]4 w+ }8 ]; f+ `1 S# ~: k2 }
.gpio = DA850_USER_LED1,
5 F1 O/ m& M* Q( h. C .name = "user_led1",6 l5 w: P- Z0 I5 y5 V0 b; W" a
.default_trigger = "default-on",
* O3 q" n v- I% N },
* b' V' s7 z+ F% I {, p r8 R/ N" u+ F5 A! ?% g1 @
.active_low = 0,
1 A2 Q, f* g/ c- L% k .gpio = DA850_USER_LED2,- \- P0 n, ^, C
.name = "user_led2",* W9 _. I: {6 Q" ~3 p0 c" g4 j
.default_trigger = "default-on",, T) e" ~0 M* O: y/ V$ {7 {% I5 Z
},
: r: T0 Z2 R6 r, i2 s5 }% F0 H$ P6 n4 n {& q- H. e/ u7 ~0 t& K# H0 K3 ]" D5 b- J: D3 J
.active_low = 0,
8 Z( c' a( }1 E- w( |, c$ X .gpio = DA850_USER_LED3,
3 N, A2 Y/ P, I L* M* w- J .name = "user_led3",% ]% g9 q5 ~1 g7 m# A1 J( n
.default_trigger = "default-on",
5 U+ W$ Q4 \8 f! T6 _2 K1 u },
P- V$ I8 _, n! o) b' u7 W X};
( O/ b$ k9 P3 n( B- Y; k! S3 j( G
( W2 Y0 j5 {% I5 \1 S6 M$ gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& C; i& _+ k* @& V( K .leds = da850_evm_tl_leds,5 X) A( [; _" [5 d0 y, l7 v x3 r @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), C* j `% ^$ q3 n
};
+ V' e- @; x0 [2 |( R4 r8 I) |6 t! }9 {
static void led_dev_release(struct device *dev)
, n4 s8 Q2 Y% Y& u{( o6 s; r- T# ?$ j
};
1 t T. w8 J! P9 Y
5 ]! K+ \: o! s. I- x, p! estatic struct platform_device da850_evm_tl_leds_device = {
8 r8 Q+ O- C: f) ]7 L% J1 Q6 A .name = "leds-gpio",3 c6 g* f+ T, p+ @3 Q
.id = 1,
/ }6 ]5 M, V2 s9 z, z/ S, t .dev = {3 j$ `- D! J& ~
.platform_data = &da850_evm_tl_leds_pdata,+ i' }2 r6 z; n2 }0 J
.release = led_dev_release,
; Q! [ V8 P# X }
( v% ]. ?" S: R4 ?};; a$ u! r1 E; ?8 T8 Y' A
, W: m0 s3 ^( h' W% @static int __init led_platform_init(void)2 g$ j7 N& Z6 R/ k! L. _
{( [+ Q1 W: U: Y3 E
int ret;
. A1 d" ^6 N3 Z9 E+ q2 f' E#if 0# r- H6 x+ h6 K! s/ ~9 E5 n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 }2 Y* F4 B1 G9 n! j* q" P" j ]# g
if (ret)
5 f* T) [+ N4 w' s pr_warning("da850_evm_tl_leds_init : User LED mux failed :") c& }' q4 T. s5 q8 m) |
"%d\n", ret);* n6 \" ~2 u) T/ V, \, C: [
#endif
3 Y/ f/ a9 ~1 C0 }1 H" g/ Y* @ ret = platform_device_register(&da850_evm_tl_leds_device);0 [8 w) h+ L/ ^, E% }
if (ret)$ s) [" w0 C/ [, Y# ?0 X
pr_warning("Could not register som GPIO expander LEDS");
* l9 K! U& u! r$ C else+ G( {' n0 }& e! S+ n* ^( E
printk(KERN_INFO "LED register sucessful!\n");
8 J, f8 p/ T- {4 }+ t+ v3 L* ~& B2 j. E7 J8 S' S4 S6 M/ w6 }
return ret;
; Z' ~/ v8 V g% j! ?# n}
1 E- `5 s+ m" J) G& j6 X! i- X$ w, \5 A- t- J* G
static void __exit led_platform_exit(void)& R% ?4 V7 S% m& w
{0 {/ f2 n- M- C* W
platform_device_unregister(&da850_evm_tl_leds_device);
! ~5 Z! ?, h8 f: l
7 e" j& H- z% z2 W& q/ E/ E3 i printk(KERN_INFO "LED unregister!\n");: d" j w, ]- _/ G+ A' N
}
0 c" \2 S( `3 k4 J$ O& l7 `6 R# d% q y# S& k
module_init(led_platform_init);
& s5 G9 o9 }9 R, m. X3 m) n1 _: [" rmodule_exit(led_platform_exit);% e0 u. F- ]! K( u
8 ?; \* B4 D$ e# C. {! u3 t. @
MODULE_DESCRIPTION("Led platform driver");
, R8 p" @0 _( `0 f1 u0 y' y DMODULE_AUTHOR("Tronlong");3 g; v; H2 C+ Z, y9 `( X% S
MODULE_LICENSE("GPL");
7 ~, m9 j- J( i2 @. t
3 U+ Y4 [6 r+ s* F" z: ~ |
|