|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 N4 }4 x" M% y4 E9 }# D
#include <linux/init.h>- [6 ~: C" J/ O2 [: ^2 s- p
#include <linux/module.h>2 k0 Q& u# k$ ?$ r, [
#include <linux/kernel.h># I0 t5 O& ?2 L, n' u) P
#include <linux/types.h>
5 R# y& M! B8 J% M) k. C#include <linux/gpio.h>* ~! x, S7 b+ r2 w5 t& D9 J6 w
#include <linux/leds.h>
+ q- M$ u! j& `. F#include <linux/platform_device.h>( m9 s, }) D' x* W( {5 G
G# g9 h( k( A#include <asm/mach-types.h>* o9 H' t# N7 W0 O, m
#include <asm/mach/arch.h>
6 J3 F1 n0 F$ g9 s0 ^#include <mach/da8xx.h>8 i' G; W% U K8 n
#include <mach/mux.h>) }; c9 a% ?3 \0 v) B r
* v3 Q. K) Y) J5 Z6 m( Q7 l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, ~3 c2 Z. g" Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( u1 n2 Z- Y7 D( ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 k1 t% ~7 \! z! F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' y. }1 ~6 |4 t" J
% Q2 p% Z3 r4 a: m3 J( i: [4 g$ t/ s* @/* assign the tl som board LED-GPIOs*/0 F' W# W1 s T+ w) S
static const short da850_evm_tl_user_led_pins[] = {6 K N l1 b! j4 Q- I' X. r
/* These pins are definition at <mach/mux.h> file */
" }5 W* _% l- Q: Y# x6 Q O DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ J! I3 ]" g) N" w
-1( J: Y: c3 \- I9 D" ^% f: H
};
. r- N& W6 G. V9 c' c5 j3 c! U5 h+ o9 A/ @- W. ^: N
static struct gpio_led da850_evm_tl_leds[] = {2 }, k) A: z: ^
{ Q3 F& f0 S# I7 g
.active_low = 0,/ M1 U% W/ E p$ ^6 S
.gpio = DA850_USER_LED0,7 \; j2 `: u! R: m* s& y
.name = "user_led0",* K: \3 u6 m2 [* _8 ?
.default_trigger = "default-on",
6 C5 y8 @" N- b( E },! k j, k; ?) ]" ~3 j+ n: ]
{
! K p$ J7 K3 A4 i+ j a* Z .active_low = 0," O0 N6 B. ?7 N a
.gpio = DA850_USER_LED1,. P% u# N4 @" q
.name = "user_led1",5 B9 F3 k& X: P$ S6 r' w8 ^0 {; f
.default_trigger = "default-on",
! g( n, H. u3 S. _) T9 u- Q+ D8 e },( H' ?, `! O* P- T) _% j( U* N" A
{9 k$ ?) ~! [+ h- _. v# v
.active_low = 0," A& \7 y; q1 \1 Q2 ]2 \+ ^
.gpio = DA850_USER_LED2,( T) y. Q0 t% V" I# e
.name = "user_led2",
/ l& q; t. w. V& E: F/ w% b .default_trigger = "default-on",/ x( w6 X3 F: G) N
},
# E: D7 t6 a" D; b {
2 N4 u' R9 _7 |- ~4 v. m' H .active_low = 0,
; L: A7 M. `, f, b .gpio = DA850_USER_LED3,
; p& N1 O5 X, \ a( n) u& n .name = "user_led3",, R1 F; G+ ^7 n: E# F
.default_trigger = "default-on",
5 C& ^; n. t0 I( Q% | ^$ i },& y5 ?& X5 Z. G3 L& D1 g/ P! ~9 G
};
% _0 d( Y: ^) ^# L- k: u% Z: _$ n8 H& c# {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: J, V- L% A( \7 J$ `3 p9 x
.leds = da850_evm_tl_leds,8 y& j* I6 `1 Z7 \! s( }
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ H% N, H" [- T6 n
};6 i: w3 e, w6 L5 ~+ f! T
; E2 e9 y0 `- a- }% hstatic void led_dev_release(struct device *dev)
2 s) r/ m% I# V' p$ z p" G" Y6 H{
; ]) x, z- k+ W& x8 J7 y. N$ I};4 a$ k: ?4 g8 A9 [- ]( n' s' J
- J3 A+ \4 k! X7 G' E2 O4 g5 Q
static struct platform_device da850_evm_tl_leds_device = {; {9 j0 |1 R" j! a) P$ c
.name = "leds-gpio",
' |- Y4 L" s* x q! s5 u+ [6 U .id = 1,9 d5 J, K' J. {; S! r
.dev = {
+ B/ F% ~$ l" D1 D; h5 L8 b5 T .platform_data = &da850_evm_tl_leds_pdata,5 S5 r4 t) f e$ p. a) ]
.release = led_dev_release,- Q! s# h5 _! Q
}8 x* ^. e; M$ }3 f' K
};& U4 M! y7 X3 q' W) d8 p2 g4 I. r
3 W% {( E. F, astatic int __init led_platform_init(void)5 B7 j, p, C. P$ J; |+ q
{1 n" K3 a, c0 f u+ K
int ret;
+ X/ p% |% T; |+ v' E#if 0% h5 \( a+ K; L& O: V4 B
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 ]+ I2 }+ a! S9 D if (ret)
0 |1 H j0 \. I7 h t pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) A& N. H7 p8 j+ ?2 |8 M; Q9 R "%d\n", ret);# H, Y5 [5 U4 ?/ t4 A
#endif
2 I. b* ]) |6 Z ret = platform_device_register(&da850_evm_tl_leds_device);* t4 i w' r D, t
if (ret)
4 Q) {7 I+ @9 }; p, m pr_warning("Could not register som GPIO expander LEDS");) j. \/ f. \$ Q, X: q% f8 d
else9 ?3 q- p! T, ]4 w8 L6 W4 g
printk(KERN_INFO "LED register sucessful!\n");
' u" r7 ~; B" F5 Q: s% [& m
+ N; O9 n8 M3 H( U5 t8 b return ret;
: c3 D( x, |- O$ m4 I- a4 P}
2 p' T# w5 n, [" f
+ e! m1 X* s* h* ], pstatic void __exit led_platform_exit(void)7 D6 F5 T" U3 I& s4 u
{% h( D m- D# T7 L$ n. M
platform_device_unregister(&da850_evm_tl_leds_device);
) F, l2 M7 |: }% k B( S5 W* S: s( q) N' ^5 r6 a
printk(KERN_INFO "LED unregister!\n");
1 F8 W& k( G7 y" I) y, l1 D+ U) O}2 H+ c* l( I! C0 w" M) Y
5 L7 z! G: m# X* m
module_init(led_platform_init);
6 p2 N3 V A1 I$ ~module_exit(led_platform_exit);( a: d6 C* }( n) h
. \- t- Y* g: y3 aMODULE_DESCRIPTION("Led platform driver");
8 g9 A! R3 n4 J% s4 K$ w* B! ^7 GMODULE_AUTHOR("Tronlong");; J3 B0 T4 r) i) F6 n( f
MODULE_LICENSE("GPL");4 v3 Y" f0 o- v( }' v
+ l. `4 C" ?" O8 X! t+ k) ]# b |
|