|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 Y( v c! U0 B4 F( s- q4 f
#include <linux/init.h>! Q, w6 s1 y" c
#include <linux/module.h>+ L, T6 b& r e& a
#include <linux/kernel.h>
& S; V$ ~+ E/ i# j! b0 J. ^#include <linux/types.h>' S/ h2 \' n- s' o; _
#include <linux/gpio.h>, ~: r: R* B: b! ^; N" ` a
#include <linux/leds.h>
% }4 F2 H8 d% ]8 p# S; e3 ?$ J& q' i#include <linux/platform_device.h>
/ E* ^( g) j; O8 X% m# F) ]- {1 c! O! S
#include <asm/mach-types.h>. C" V0 S2 G: y5 X: ~
#include <asm/mach/arch.h>% Q9 g" z7 w+ ~( v. K9 e. P
#include <mach/da8xx.h>
8 P W: `0 l& V# Q#include <mach/mux.h># v0 Q& q2 f/ b% [7 {. [
5 V. i4 R. }- o& I, @6 \! W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 X; Q, ^# v) c0 H# x6 y% D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" v( N V; `3 h3 N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ I6 P8 I3 }3 X1 V1 O9 U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): n( Q' J" p& G7 U9 b
1 K# X: ?! ~: X9 ?/* assign the tl som board LED-GPIOs*/3 d7 ]! I1 S1 x$ G9 m# L
static const short da850_evm_tl_user_led_pins[] = {: }% r1 R1 X5 {
/* These pins are definition at <mach/mux.h> file */9 @# }9 G# r' x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 v" J. o! a. p8 E: q! S -19 Z1 }' w$ y& x
};
4 R1 w4 x, Y) r' g7 k5 ^( j
2 [+ g1 W5 Q! W( astatic struct gpio_led da850_evm_tl_leds[] = {
2 c3 z* k4 @4 q, d, r+ m8 ? P {; c" Y1 K/ ^/ B) r, B, ?
.active_low = 0,( N. \5 x' [9 Z6 L; D; ^; ]2 g
.gpio = DA850_USER_LED0,
9 X# [9 k* Y8 P+ O$ K/ w .name = "user_led0",
q! J( V# h; Y+ e. I, }+ D .default_trigger = "default-on",
5 G+ A) c2 J8 K! l5 m0 {1 z },
/ ~2 q2 Z) x( d1 S( n5 N {
|* B( n( F: R: d2 t .active_low = 0,2 T4 t7 U8 F$ R; b7 A& q
.gpio = DA850_USER_LED1,! l" m2 U- K0 q$ x- c/ M
.name = "user_led1",2 B( s; r+ j4 j% T) J" Y4 P* V
.default_trigger = "default-on",; {7 s' U+ \" w/ ~' b8 j
},
8 W2 N+ _0 m4 V% a3 P {# J F/ ~4 b3 r+ A2 Z
.active_low = 0,
# H d% x9 r, N, {& R, X% j) M# I! C9 W .gpio = DA850_USER_LED2,
4 G F/ c- u& T# _) p .name = "user_led2",
, h* c0 k* R: m' m' h! F5 U2 R .default_trigger = "default-on",1 B: H& S- q/ L |) ^+ A! p
},) y" D, {# G6 L( `3 t# g. E
{
9 {+ v/ T) p4 P/ y2 ]9 ]% L6 t .active_low = 0,+ v$ ?* }: p4 s; E; j% c7 R0 _
.gpio = DA850_USER_LED3,2 ?4 d( D: z8 e' P( B8 Z; V
.name = "user_led3",7 r) g* l' ^5 h$ ~1 y
.default_trigger = "default-on",
1 t8 e9 ]1 c6 i0 @; R) N/ E1 F },0 C& O5 U4 _; g8 S- ^3 W2 A" g
};( o& v* Y, n0 J; C8 P- z9 X2 {
! c( U* y; ]" Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; b" ~9 ^) ^4 P9 T .leds = da850_evm_tl_leds,: j6 _( n8 ~7 F N5 k) y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 D. ]% N8 M% ]' w$ ?2 O; Q" ?
};
2 E" g! Q- z5 H2 v9 r8 T$ a1 c
4 c* K# _; h: B# `8 Estatic void led_dev_release(struct device *dev)
% I! e* {9 `0 {: E1 S) ~{2 p5 U: H+ Q d5 s
};
6 x! c2 Z7 d/ _! z- _) f
3 S) j3 j) V0 z: `4 V: M7 C' jstatic struct platform_device da850_evm_tl_leds_device = {3 C5 U; s6 `; G& `( G* n
.name = "leds-gpio",, o9 M2 e/ A3 D: _7 b- f
.id = 1,' N5 y' J; L4 w2 h
.dev = {
t, u, w! u: Q5 H) R .platform_data = &da850_evm_tl_leds_pdata," w& o! v* p3 N z+ S2 f3 R5 f) v
.release = led_dev_release,; `& |% x6 h; E9 l
}8 u% B8 C, J0 d0 Z4 I
};
9 I+ K0 _9 M& F% T0 ?
' l, k i9 R/ a2 [5 |, S% z h1 L tstatic int __init led_platform_init(void)
* h- k6 k: u( u, x- b* v0 s6 L{
9 }3 U( e* X( l# h/ T0 n G int ret;
2 r9 W4 n$ N$ r; B4 u0 k Z- h( f#if 0
5 b+ K( {( k% ^3 e1 p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& d( u; ]* l4 h0 h
if (ret)
" K6 ]7 J4 K q0 }) Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 [, e* [2 k! z+ t "%d\n", ret);" o& t# h ^' A5 ?
#endif) C. f8 u2 |' V8 _. d
ret = platform_device_register(&da850_evm_tl_leds_device);
4 C" P- W# B/ D3 n: N. P" s7 k if (ret)) m) c M) s- N
pr_warning("Could not register som GPIO expander LEDS");! I+ h8 y0 A. w/ s0 d2 q
else* c5 n/ e! Y7 Z l
printk(KERN_INFO "LED register sucessful!\n");
" E4 k5 `7 o9 ?( G* Q4 s- o8 V- Q
) h/ v& g0 L% l- q5 [7 N8 o return ret;
1 H7 X6 H5 h' Q; c- f! l}
9 ?' e* D) n9 u( B1 Y( }( x
3 X$ Y2 w. _$ p# L' Wstatic void __exit led_platform_exit(void)3 f; E" E; [, |! H4 Q% D
{# ?: k2 ?& b; G! ]; G
platform_device_unregister(&da850_evm_tl_leds_device);0 o K9 @) h$ d. ?
7 v8 E0 H. U& w# Q printk(KERN_INFO "LED unregister!\n");
2 l: v2 b4 R! e4 D3 Z% A}
; @) k) m$ v) G4 o) f0 E
1 D' V, m3 k1 smodule_init(led_platform_init);
/ M# m6 ?2 C: ]. g; l! hmodule_exit(led_platform_exit);0 ]* E$ [" I w6 Y- @
8 T% V" M6 R$ C2 E% ?. ^, ]$ O7 xMODULE_DESCRIPTION("Led platform driver");
1 g8 v' j; N2 PMODULE_AUTHOR("Tronlong");+ h# q. \% _' F# d! D' x( H9 R
MODULE_LICENSE("GPL");! ` {3 G7 U' i7 {; @ q" S+ |
9 a$ R" g& c* V& M; k4 N |
|