|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 I- |' F# A$ A: @. [' X
#include <linux/init.h>
8 m, i7 f5 f& E# R* t3 g7 s: b/ T& p#include <linux/module.h>. {% X( K/ P4 W
#include <linux/kernel.h>% K8 ?2 S% F9 e E4 f% w
#include <linux/types.h>
3 J+ y9 N2 N5 B9 s#include <linux/gpio.h>
6 C" }( j7 d# ?9 N8 r#include <linux/leds.h>1 o" M' |; x$ |" o: W
#include <linux/platform_device.h>
' x2 D2 ^) \4 g* E; y: @9 \* V3 M6 V1 G( [* P! h
#include <asm/mach-types.h>' h. m d# Z9 e3 p% ]: g
#include <asm/mach/arch.h>. ]$ X8 R" l3 u4 E, s; r" Z0 ] O3 D
#include <mach/da8xx.h>
3 S3 H9 a0 p9 W: E$ M9 n5 ~#include <mach/mux.h>
& ?; a+ s3 U( d ?7 L+ ]% ?' y# ~5 {7 F
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) X4 z7 t; L* r' ?# P( e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 z* O/ f* b4 Q2 ~+ I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# t$ Q. Q f# E# s% r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 s, C* M) @$ p% {, H/ h8 S( \+ [& d
" V! t- X6 M" r5 V1 ?
/* assign the tl som board LED-GPIOs*/
- h j' w3 Y1 p8 d: v9 o( f( y: lstatic const short da850_evm_tl_user_led_pins[] = {1 I& U; [; J* e6 F! U& I% ^ v4 V0 t S
/* These pins are definition at <mach/mux.h> file */, C3 L* ?. H' I, E6 A% A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 E6 K8 Y- e$ ^" v4 _. { -1
l1 t& ]0 L( \8 z1 _1 K2 _}; u2 F; n k" u' x( Z' v1 m
: F9 f' U" U" d; q6 _
static struct gpio_led da850_evm_tl_leds[] = {* g6 B/ C/ g U% Z
{; R; y3 [ p. Z' }4 g- Z! O6 A) w
.active_low = 0,2 x, |3 ^ d) |2 \% h/ [: s5 g
.gpio = DA850_USER_LED0,* |; r0 |3 [, ~2 R+ O% T7 ~
.name = "user_led0",
$ f: E3 J: x1 X7 Z8 J2 i+ _5 F .default_trigger = "default-on",
8 r! D j* P6 W% H },, z1 r; h# ]) @1 z
{
7 d6 e8 _0 `: v .active_low = 0,1 N4 O8 A' f6 Z y
.gpio = DA850_USER_LED1,
3 i& s. q$ u% ` .name = "user_led1",: ?* G0 ]9 `5 |' a6 m j
.default_trigger = "default-on",
6 K3 L2 [0 ?8 _1 T" f( ` },
: c8 C) U) R0 B9 ?( n {
, O# O! A3 Y+ w) v .active_low = 0,
: q# d$ X$ p% F* B# J, I .gpio = DA850_USER_LED2,
- G. Q0 B: v) C .name = "user_led2",( J5 {9 {- e8 C5 `5 @3 P
.default_trigger = "default-on",1 }8 X, {# o* Y$ M; _
},
: Z, o9 h8 i: r2 l1 m/ y {# t# @# g: ` s5 a3 P
.active_low = 0,
0 R- a. t2 L/ ~4 ?1 p% c4 n" Y9 z* q" O .gpio = DA850_USER_LED3,
: q+ N$ z9 x) l! R. z" b! _ .name = "user_led3",9 |8 h* \+ y7 {5 T. X
.default_trigger = "default-on",
) K: q0 F' A) ^) A3 d },
3 ]4 K0 ^& I" p" @( |- U* y};
9 r/ q& Y" g/ t4 l2 Z- v* r* y; G1 M9 C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 g1 G( n% M. s! i* T3 [7 F. ?0 L
.leds = da850_evm_tl_leds,4 W# e, o: F' [0 T. h. w* d& F# J/ C
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 `: Z1 F2 I6 A};9 X# k' u# S' A' V1 l
% \4 h4 Y: G+ xstatic void led_dev_release(struct device *dev)0 s1 ~5 ~% H. j; P! I
{9 G: ^ d& n; c; N$ v
};2 k% B$ @/ K9 s( d2 X
5 p' i( ?2 b" v$ _static struct platform_device da850_evm_tl_leds_device = {
3 J% C7 `5 R2 m% _1 A9 K .name = "leds-gpio",
- ^# _% c( T7 ? .id = 1,' o. A2 O9 w, J* q4 W; {
.dev = {
! A# T) q3 R" P4 ] .platform_data = &da850_evm_tl_leds_pdata,
5 V) [. j. z. U w" [ .release = led_dev_release,* z% V& t8 Q$ I
}
$ r1 C2 C$ A9 v5 W/ k, }};
1 X* I9 M5 R3 D5 n( }3 A
/ e) G5 X0 T9 y5 D* E9 }# d0 `8 Gstatic int __init led_platform_init(void)
/ Y1 Z: ]/ D+ u1 O0 j ^{
6 c. f1 ~# e; y int ret;: C* l& P! A( x4 z" c
#if 0
7 r# b! g# C0 H' d, x: K$ Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; t# @% }, R# e if (ret)
, B4 h+ X& H. G$ G3 z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 [) U- p/ J& ]8 v
"%d\n", ret);
5 u. a F- c, r U9 H6 ]; i1 o#endif C# l( H/ p' B- s9 E# q
ret = platform_device_register(&da850_evm_tl_leds_device);0 p$ Q4 _8 P% J7 p% I
if (ret)" f) j9 P. i! u+ p( N$ C
pr_warning("Could not register som GPIO expander LEDS");) S S+ ~! O* ]1 g- e2 U
else
, ~. G9 M+ C# _& y. T/ Q ?$ J printk(KERN_INFO "LED register sucessful!\n");' x) Q* k6 _. y; s1 T4 N0 v6 H3 r( I
0 v' x$ q0 i5 K' H return ret;
0 w& r, |/ v! K9 h" N}; z$ {6 ^) Q0 ^! d1 u
9 f/ u' F. n' d: dstatic void __exit led_platform_exit(void). D3 o J; _9 T% J" S1 \
{) ~2 o7 J7 Q9 }/ ]" M- i' [
platform_device_unregister(&da850_evm_tl_leds_device);6 D6 n* d1 [6 g2 {% v, |% {* o
: ^) H. e& I" h) z
printk(KERN_INFO "LED unregister!\n");) t7 X; p( y1 {7 Y ~* W1 a
}
* K5 Q- A! g, C7 Z2 d; H
! D% ~% O4 R, _+ }module_init(led_platform_init);0 E) @- [7 G. D7 \1 T& V
module_exit(led_platform_exit);2 l n- x+ @7 q; N% a) s0 u8 X [: H
7 b7 g2 G) C5 O$ g: a
MODULE_DESCRIPTION("Led platform driver");+ D% J8 s7 J: |4 p1 O* w( l
MODULE_AUTHOR("Tronlong");6 C& v5 i' H$ y9 K2 H4 m; k# l
MODULE_LICENSE("GPL");
( T% l" w5 q* {
3 Z/ C+ q6 x t0 Z* e |
|