|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% v+ `- V8 ~* ]$ B, s
#include <linux/init.h>( S+ d' e+ a2 K( F
#include <linux/module.h>
. F1 }1 q$ e7 H+ ~4 |$ q- S: F#include <linux/kernel.h>% M' O1 j7 o) P# o; X# Z
#include <linux/types.h>
# m. s; Y0 Q* q) u3 T3 N$ p% D#include <linux/gpio.h>( W8 z; v5 y; ^. w. t
#include <linux/leds.h>% _& `$ I/ R3 i# w- I' J
#include <linux/platform_device.h> N4 g6 R% B6 {9 e$ D5 X9 F6 M
- [% l' Y# R1 N# S' u/ Z a2 P9 p
#include <asm/mach-types.h>( g( B# ?' E/ O: P; S
#include <asm/mach/arch.h>
, m6 S& R( T0 F9 }, v+ T#include <mach/da8xx.h>3 a* D; A+ J0 h5 x
#include <mach/mux.h>% t6 r/ ^( I* N8 e) s
5 @. G6 Y) |# g9 U, [9 G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ f3 y; c! m' S0 q( H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 z# l2 r& h& C: x; X#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% _$ v0 i. K3 ~# d: M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ P4 V; v M) u! J. _9 c4 U5 u
) A- N2 M4 F9 T
/* assign the tl som board LED-GPIOs*/" ?9 G$ v. b j
static const short da850_evm_tl_user_led_pins[] = {+ ]/ J% u* T2 v7 N' G7 v2 ]: \
/* These pins are definition at <mach/mux.h> file */
3 ^: e! x9 k- X0 g" p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 Y9 o) u! B( T -1
0 D# P( y9 Q( @! Z};6 W6 E# T/ Y+ d# ]+ N2 ~0 |6 v
) n& W# x+ z, U- s, m% b& N3 qstatic struct gpio_led da850_evm_tl_leds[] = {
' y6 e* g( K5 V' V {
5 C# I* f6 ^$ h B$ ?4 ] .active_low = 0,0 b4 i. p9 H/ v9 u( ^
.gpio = DA850_USER_LED0,
% f* L% \8 h2 t7 u4 {$ q' K( w .name = "user_led0",4 y4 Z: ~0 f$ H0 O3 l! ?
.default_trigger = "default-on",
- T& I7 w) d9 Z },
- @/ y. r: }- f7 G: o6 x( D. e" u4 |3 c {
# h& h8 }6 I2 w' P) \. F: C .active_low = 0,
' y# j) A. c/ t" X2 y5 Z .gpio = DA850_USER_LED1,* a' m7 n; J; L4 y
.name = "user_led1",( [# I" ^+ a- C# O
.default_trigger = "default-on",
# l0 ]3 E0 l4 W* Y7 D },9 t' W- F O/ t% Q8 l% K0 k
{: q& x/ a% S( R5 N, n
.active_low = 0," W# Q! l2 R# K4 _/ w
.gpio = DA850_USER_LED2, [) n5 D3 N- l' u% {
.name = "user_led2",1 I7 ], q; Z0 M4 ^
.default_trigger = "default-on",
# @' e9 {: ?- R7 ?1 ?% P },/ B! H/ ~. J0 r/ q0 ]: B
{' [; K' j# p8 W0 E; g; o
.active_low = 0,
6 P: M% P7 C! [% f4 l- M .gpio = DA850_USER_LED3,: d% S( H$ k/ L8 v4 W ~% ~
.name = "user_led3",* s0 m7 i4 Q, P# L4 ]
.default_trigger = "default-on",
) V/ B+ o+ s1 u$ k4 B* q }, W0 G" D( o$ G" b$ h9 r4 E
};
1 ~ [. g1 R* h9 w _( Q' x
6 x) T: Q; I' \+ | Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! R+ i( ^8 v: S5 J" A/ _' K+ P- i7 p, ] .leds = da850_evm_tl_leds,
* W. O0 ?& k8 i .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," \9 p9 {2 x. ^4 N7 ]5 G0 e8 E2 a
};
# K8 b# s8 p( m% c) v, F* U4 A+ c
" B8 Q& b; |, Estatic void led_dev_release(struct device *dev)$ d2 [# ~( g5 |# X, X/ Y0 x, ^* N- W
{. V0 C% @. j; Q8 O: {
};7 j8 I% Z o9 a2 c6 n
) o* g# d @2 u& d' z* Kstatic struct platform_device da850_evm_tl_leds_device = {% a: _9 }/ D" o3 }6 ?3 ]' i
.name = "leds-gpio",/ Q, j! R R( A
.id = 1,
+ @: ~7 a' Z0 H' m: Z8 S; V& ~ .dev = {
8 [- O( Z! @4 Q$ Y. H .platform_data = &da850_evm_tl_leds_pdata,; J! [: a: Y2 U j
.release = led_dev_release,7 }/ S# w" ~/ F
}
1 o( V ?9 d; l0 k};7 ^1 l* ~% ?% N* n# g( F. p: h R
& _" b6 h0 L' {: j1 `. b- }static int __init led_platform_init(void)
5 s. d6 a& v3 p" y0 {{
( O; k6 c* _; l8 M int ret;) u/ D0 I% x( v
#if 0
# s% F0 o! O5 E+ w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 R' K) s0 {0 R6 Z0 S6 i
if (ret)
3 h6 \ l/ a2 [2 C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- C4 N2 x; Q; C# f/ _ "%d\n", ret);2 u, [* d! }7 L6 o) z I
#endif J4 m# a) U+ x; P7 H
ret = platform_device_register(&da850_evm_tl_leds_device);8 y$ J K8 h1 l6 h# C5 ]
if (ret)/ r! `9 _6 N0 J+ D
pr_warning("Could not register som GPIO expander LEDS");8 m. D' P% a& d
else
: j7 d1 ^0 x `$ v* F printk(KERN_INFO "LED register sucessful!\n");/ Z+ P ~/ |: s$ b, U
9 `. b- u0 ?9 W2 x, p return ret;
9 x, f" R g9 D8 @1 X R6 U}
' Z+ {8 J2 e1 V o+ }
; R1 l8 P& b& @7 j. |# ystatic void __exit led_platform_exit(void)
: U- j( B; O3 @4 _4 a) Z K8 V{
7 N6 m5 L1 X% Q platform_device_unregister(&da850_evm_tl_leds_device);
3 T1 ~. R; h, T
: N9 w( L1 v9 \+ l printk(KERN_INFO "LED unregister!\n");
- M9 p$ y. ^& C6 A. Z: [% a7 ~}
) V7 E5 A: K# K \; t& p n. `1 Y% T: q+ d) A" N) S; @
module_init(led_platform_init);
8 e3 h) ^9 a G. Z* Zmodule_exit(led_platform_exit);
: X9 `, p6 E4 U/ _! Y1 C5 l6 r$ l' K+ |# m/ T$ L+ I$ u& i3 u# X
MODULE_DESCRIPTION("Led platform driver");
3 {. N: F. T6 Y% b! RMODULE_AUTHOR("Tronlong");9 L/ g% b; ~* @* L
MODULE_LICENSE("GPL");" i& I8 X3 |$ u2 J/ Y, e
! N _' a# y: o: c8 M
|
|