|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' K* \ ~. y: }#include <linux/init.h>
; T% d/ D3 F9 g: Q#include <linux/module.h>5 g$ W& N7 E% q
#include <linux/kernel.h>
3 d8 p4 G% X! W, _#include <linux/types.h>! _: M0 H% I% k' m7 @, m( `
#include <linux/gpio.h>
1 h S/ E) l( Y. j#include <linux/leds.h>, H; Z) E( V9 H( z: n; T
#include <linux/platform_device.h>
: T/ T4 m& p$ J% K9 o( e# }0 m: m4 `' z, s* k$ ~& J/ h9 F
#include <asm/mach-types.h>
7 E& }+ F d; x8 T- Q8 `5 W#include <asm/mach/arch.h>
* G3 |; U p% c8 y- T3 T0 C0 a ~#include <mach/da8xx.h>0 @6 J5 b+ W+ K; W
#include <mach/mux.h>% o7 @4 E. e- E, C( A+ x
; \) w& U, J( }0 O; X) p3 N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 y' @ i' H+ }" D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ b5 Z5 a u- Y/ C: D' Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ @' j' {2 P$ v' Y+ C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 U8 K5 n$ N2 i7 ?9 b/ `/ E! q) N0 f9 ?8 }, o
/* assign the tl som board LED-GPIOs*/
) S `2 A8 K/ F" U' @9 [ estatic const short da850_evm_tl_user_led_pins[] = {
3 x3 Q4 }) H, [ /* These pins are definition at <mach/mux.h> file */
% X. Z( ~ @& F; V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& [' |. ]$ w/ z7 t -1$ Q7 P3 b2 x) N
};
4 j$ o/ d4 |7 [5 W2 i# f" U9 g. x: y6 k7 \4 A
static struct gpio_led da850_evm_tl_leds[] = {- v/ @% t$ U, J+ U% I: Z
{
+ W$ m5 P5 D/ X) E2 |. H .active_low = 0,
$ I% `) B7 ^: {: U: v .gpio = DA850_USER_LED0,
3 `( S/ b4 e5 n .name = "user_led0",
$ p! z8 M' M$ o4 ~+ a! G .default_trigger = "default-on",
# ~3 `- Q6 [, c6 k# j6 v! i6 @! k* d },
5 i/ D: q# `; J+ O; g+ e! R. \ {; t2 `: _; U1 o" D) ]# ?; C
.active_low = 0,$ b, S, w0 E$ ^
.gpio = DA850_USER_LED1,
) b& x u7 W7 |0 p { .name = "user_led1",
9 H& j/ Q1 R% v; F; t8 J9 D .default_trigger = "default-on",
$ I! b% Q5 [; ^" e/ c' i N },. {( {: r, B8 {: O6 ~& t8 w
{$ M2 ]0 V, J8 _$ t
.active_low = 0,
# b6 Q* k! K1 c$ Z( v' C .gpio = DA850_USER_LED2,8 z4 |% E# g2 w9 G" n0 t
.name = "user_led2",
8 Q1 T3 |( q5 T R0 v( s .default_trigger = "default-on",8 {/ E; x1 N L7 x. g
},$ V5 g. i0 M$ ]
{4 h( h7 v: ~2 S" Y3 k, F
.active_low = 0,
$ Z T( e8 G" \' c; d .gpio = DA850_USER_LED3,
; @4 {4 c2 p8 w' B .name = "user_led3",
9 ?3 F7 M' `% ?% ]6 x .default_trigger = "default-on",2 q! @9 j6 g' S6 p
},
6 ^: z" T& j& Y" A* i5 k8 ~4 ^( x! p};) E# \. B; z) b0 e) V2 q( L
) o: ^% K6 U( c$ f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ F4 n2 s$ T' n3 q .leds = da850_evm_tl_leds,9 p4 {3 h% k7 [0 v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( w) w7 y9 C3 l2 p" v, H) h) g
};. y8 Z( L9 a2 H
7 d5 N5 W. S6 R' Z' sstatic void led_dev_release(struct device *dev)2 |- W& e+ L$ f1 S
{( u: H. X9 y* x f! M' f' B7 n9 S2 K
};& t. C1 H; k/ J7 u; \8 Y# V9 {) ~
& Q; p5 L8 R3 U' B; n, E& mstatic struct platform_device da850_evm_tl_leds_device = {
! @ B: a h) y$ w .name = "leds-gpio",
4 y' [+ R0 S4 T" V0 C$ v# ^2 l .id = 1,
; |$ B& Y8 U% T% \" t7 X, x .dev = {* X+ t4 H7 r. k/ T. z H" @1 X
.platform_data = &da850_evm_tl_leds_pdata,
; ?3 j: G) s, x+ c) S7 N .release = led_dev_release,9 X9 W5 K" F% n
}
" H( s/ {" q+ m0 }! m- _8 j, [};: \" ]8 d% b* w/ T2 \) Y) P
) ~# l1 J) J2 v$ m3 v; Sstatic int __init led_platform_init(void)
3 {4 d6 s3 G+ P' i) ]5 D2 a6 I{$ ?4 v* I3 ~8 n# n
int ret;
8 Y7 S, P$ P6 J/ x0 K4 T#if 0
: j) Z; |. H: U9 s3 `& I+ q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 U- a \6 y8 w$ E$ m6 j. X& D
if (ret)% q8 E; o3 X! L5 ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; I3 {9 A1 h. B! S# g% |0 r "%d\n", ret);
8 L. W; [' U% B8 S& a+ [" Q#endif
9 m. X) b6 c/ b9 l! A ret = platform_device_register(&da850_evm_tl_leds_device);
9 f- s4 {6 `* t- @ if (ret)
[. g% D* P! T5 f pr_warning("Could not register som GPIO expander LEDS");
: E3 ~2 s! C8 g else
% d1 h5 X5 n9 Q+ Z printk(KERN_INFO "LED register sucessful!\n");% p/ t7 V: P8 q+ M
7 |8 \4 c" L$ y9 x% S9 T
return ret;
. y7 p6 K; \' Y' p1 f) ]}
* A6 q* Q8 `( b) N% p( C) \: r4 u$ e! u
static void __exit led_platform_exit(void)
+ j, R! V& C# Y* R8 K4 [) O{
! D) E% }4 K" B3 } platform_device_unregister(&da850_evm_tl_leds_device);3 j# ]2 @0 [" N- M
' i1 M4 Y* r% M3 [: m! k! r printk(KERN_INFO "LED unregister!\n");7 V7 b3 Y$ J. [
}
; {8 `+ V" ^! n2 c7 Z+ G" o, ~6 I7 ]
module_init(led_platform_init);! e6 M) _& K: `. t* v- X* J1 `
module_exit(led_platform_exit);6 H7 c$ N' d" ], C7 X
6 t2 U8 M8 h0 F8 H: ]; Z% m
MODULE_DESCRIPTION("Led platform driver");
/ h( G9 d# w2 I0 O/ P+ M& PMODULE_AUTHOR("Tronlong");6 a+ ]$ H0 u3 u' b1 Z2 X8 j4 z
MODULE_LICENSE("GPL");
# O" T0 R" M$ W: S% a9 t( ^' T2 b1 o
|
|