|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( G. i$ T, @9 J& I4 d
#include <linux/init.h>
" ^! f, \8 a1 d. y' _& `5 J( ]( }#include <linux/module.h>+ C0 L, Y3 q$ e: y/ E: \( s
#include <linux/kernel.h>
2 x4 J! \, ]0 Z( w$ z; X) C#include <linux/types.h>" r9 Z4 g6 s+ v9 c
#include <linux/gpio.h>
1 V( y& t( Y4 O$ B4 u9 @ A) c m#include <linux/leds.h>! C+ u0 ^7 |0 ]/ j/ A
#include <linux/platform_device.h>6 i* A' w9 s* l& n u( o
/ Q% o& @/ n" j4 T#include <asm/mach-types.h>
$ j& C1 l% g1 M$ v+ P4 L#include <asm/mach/arch.h>
$ o+ y3 p# b; u; ^% N#include <mach/da8xx.h>
! g% M0 Q) c: z; P' f. c, v" g#include <mach/mux.h>) I" }6 c2 ]: F- t# p9 O. w
$ D2 ~+ M3 L, b6 g0 R3 [3 h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% m* [9 Z" V% x8 i& ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 y! I' o$ @( C% v' X8 r2 u#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 F4 A( \0 g2 z2 V. u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% x! A7 \# y8 Z/ S# G# }8 Z( [) i5 ^4 X
/* assign the tl som board LED-GPIOs*/
/ f& t3 A1 x. z- `: e9 k1 Q" xstatic const short da850_evm_tl_user_led_pins[] = {* V; H3 }- z e3 ^
/* These pins are definition at <mach/mux.h> file */
6 M: C# ~. [; K( g5 m; N( o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& Y3 M; m I: r1 b% q, B4 K% Z -1
~# z K; x! N2 B) u- }};1 ~4 u, \2 D) o; E& H7 M$ i
/ z+ I0 L0 `" h; ?, ]static struct gpio_led da850_evm_tl_leds[] = {5 R& D8 R6 L' M
{
) }/ p# _8 p) z( ~! I0 | .active_low = 0,
0 f' P( H9 C$ U9 A .gpio = DA850_USER_LED0,% r G+ w6 T" ^7 \% [
.name = "user_led0",
6 n3 D8 g" k7 O/ h& B* P3 A) H .default_trigger = "default-on",
' ]# i' x3 U$ e; W7 L. t' X },- d5 D: |/ Q0 a4 ]' F
{
# X# e; q0 B7 \1 x2 f$ \* z# S, m4 l .active_low = 0,* p5 |% F: K/ T, D2 t* r; P
.gpio = DA850_USER_LED1,3 t0 o, C+ v1 `8 L
.name = "user_led1",
! B3 }! B. k' b/ G1 a2 q: G .default_trigger = "default-on",' ?; a: m2 k: k @3 \# X& a
},
( e- }: L6 q' c. F' T. W) b {$ _; O9 U9 [, w. m1 J5 n: @# m
.active_low = 0,9 i' r* I( T. _0 A
.gpio = DA850_USER_LED2,
# _) h, @3 R0 x, ?% d1 O& A# Q .name = "user_led2",2 M( `7 b& [5 k! O6 \6 g
.default_trigger = "default-on",
/ o/ W" r- E8 j2 F: G, S3 o: e },
' N) ?5 Y$ b6 E5 c6 S# Y& }7 n& o {. W/ z7 H- k1 ?8 J
.active_low = 0,: r5 G; o/ ?+ [& R4 l6 P$ f
.gpio = DA850_USER_LED3,
; \7 }% ], ?1 o$ a3 U, T; F# \ .name = "user_led3",
- A) V' g5 w) b" ? ~ .default_trigger = "default-on",
3 u J3 q* Q- ^8 N5 D+ Q },
; @3 Q* ]9 t) i. z! v# x) x};4 t9 v; L! V4 N- n( B& y+ g" ?
& \1 U7 o1 t3 |5 W" |0 _3 M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) j- j( c0 ~+ s$ @9 k" y
.leds = da850_evm_tl_leds,
) Y9 ]7 j" n4 E9 [$ _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 Z; E5 H: E& N0 h; ^
};
+ K8 D: W# S- [) m; W4 V$ P4 ]0 _2 h3 H2 j& R
static void led_dev_release(struct device *dev)
' `. @0 Y! s; o0 [. c{! g' f" N, s5 c: D* K+ @0 {4 }" W
};8 H" x8 C: ?) @" l) O6 S( A
+ ?7 W) U0 }9 g* istatic struct platform_device da850_evm_tl_leds_device = {% t, T- H/ h: t q4 y0 T" X
.name = "leds-gpio",8 R3 l% }6 z7 J
.id = 1,1 @- M2 S2 O0 O
.dev = {
' K$ I4 o H1 p; o# e# K t' H .platform_data = &da850_evm_tl_leds_pdata,2 u4 w6 m! K/ F" }5 O; T5 x
.release = led_dev_release,
8 }0 K+ a! ?! |2 k6 ? }; m5 s: R) F# n
};
; x! n5 U3 q |- E
; t8 o; O6 K3 P+ q$ wstatic int __init led_platform_init(void)" e+ ?8 q" S! ^* d2 q
{" u0 j, W; J: [: ?
int ret;
. ~+ {, c. E! J8 J3 n, @#if 0* \3 M1 A2 k3 _3 \& {6 {; k' O$ y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% ~% K* S' \& }$ g
if (ret)
' }) c0 E3 D7 {, W. w$ K pr_warning("da850_evm_tl_leds_init : User LED mux failed :", a+ E, V; k2 K" U8 w- c
"%d\n", ret);
Z- W; }5 A& I#endif
% X( h2 g( u* D0 s ret = platform_device_register(&da850_evm_tl_leds_device); U( n5 `$ w6 j5 m. U" l! T0 ^/ Q8 p
if (ret)
( j" e5 Z4 I7 Z, }: o+ {1 G pr_warning("Could not register som GPIO expander LEDS");/ S4 n6 ]! E6 s. D6 t- ]) H) O
else3 w/ D; q/ {0 h5 E6 R
printk(KERN_INFO "LED register sucessful!\n");
. I, u' T0 g* h
. G9 L, @/ L: y+ G8 c return ret;
$ _% E8 m+ f0 S- i# X" M}
8 `. V, G' `) p+ Z, _- K* u# ~, d" d- b; i
static void __exit led_platform_exit(void)
( x* A6 _% n" g{$ K% n9 J% K# [2 X
platform_device_unregister(&da850_evm_tl_leds_device);
6 i+ q7 M/ ^; M/ z, e( ~
$ c3 Z( V+ a( j3 D' i printk(KERN_INFO "LED unregister!\n");
2 j; m( i# c: r}
G6 p* v4 Q0 z4 i; K/ h
) `* N/ d1 E* l( e( x6 Z- Xmodule_init(led_platform_init);
- l: A, \( _1 n+ amodule_exit(led_platform_exit);5 L4 F- B, K! E# M7 D
! A" L9 G6 |' B- V
MODULE_DESCRIPTION("Led platform driver");
9 {) O; E( [" R1 m) w0 vMODULE_AUTHOR("Tronlong");
; D0 s$ M1 c4 @- o# w1 kMODULE_LICENSE("GPL");" r9 f5 o& m) Z/ S# Q& k6 F; [3 p
0 @- s/ `* o3 H |
|