|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 p. n! k, R( A6 q v" |1 S9 w#include <linux/init.h>
7 K5 {% X& @ U, d0 ]7 q#include <linux/module.h>
4 Q: `$ [+ O6 _" B- `- G3 y, \#include <linux/kernel.h>- Z. O. K0 e+ P2 {2 Y; e$ T
#include <linux/types.h>4 M$ b$ s V; L; B
#include <linux/gpio.h>- f5 y, G" d+ k; L0 [9 i
#include <linux/leds.h>& E6 ]) d% v; H0 @- h
#include <linux/platform_device.h>- Z( _' \/ a( _
# r+ d6 q+ Y) |( S3 b( [, @
#include <asm/mach-types.h>2 q7 j0 M" e& O& n
#include <asm/mach/arch.h>
" t5 u* P' Y. v) Z7 u#include <mach/da8xx.h>
" Y a# l' v0 z; Z#include <mach/mux.h>
2 r6 _% X! n* S+ P& _
% F5 f* s: p. n' _) Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 ]8 M3 K J5 E6 t1 P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 K' d9 `" u0 }7 l J1 d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ k& C3 S! y0 N# l1 j# K
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 H; B$ p: ]; ?
% ^- L4 g& I$ M& V, R/* assign the tl som board LED-GPIOs*/1 a& I. S- B# C0 n! F4 y* e
static const short da850_evm_tl_user_led_pins[] = {# K) K; d4 c* s+ s
/* These pins are definition at <mach/mux.h> file */& g6 n* t* }8 k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," s6 ?" |% R# N& J& F
-1
5 `, p `8 C6 c7 V* m};' s1 ]! n0 ]5 |! ?' v$ W a
3 ?" S+ W3 V: s( S" p! B, b
static struct gpio_led da850_evm_tl_leds[] = {# ^ m" E4 w* ?/ E
{2 V& v2 A8 A: {. i8 y* D
.active_low = 0,
- ]" e* C. u- I2 q6 J" ~ .gpio = DA850_USER_LED0,
( L: W8 m7 W- N( [0 ~. z( [ .name = "user_led0",: n* o) D! h# N
.default_trigger = "default-on"," m3 o# Y7 i; W! S1 H* n& D
}, h7 f$ d; Y. Q1 {" M
{
, `5 I0 [2 g2 o% j( n4 k4 P .active_low = 0,
6 ~& `; ]. \$ O .gpio = DA850_USER_LED1,
0 c9 p8 r o& Y1 T& K .name = "user_led1",
) f4 B1 r9 @ ?8 B" c .default_trigger = "default-on",, B9 q- M/ {# J# u
},8 d' s: J( s/ F7 f5 ]1 Z
{
6 y$ X2 s6 Y ~5 ~. L1 M" v' ^, [ .active_low = 0,5 H) U( ^6 X/ G" Y, `' O
.gpio = DA850_USER_LED2,% |( F% ~0 R! Q2 T6 p. z& b
.name = "user_led2",
: h5 |7 e: @! X0 P' f .default_trigger = "default-on",
* F: a# x* b8 ]( G },
: ?$ z5 m Y }; _0 l( G* C {) b1 E$ `. C. h/ c
.active_low = 0,
8 H# f, r9 N% x .gpio = DA850_USER_LED3,( U" ^/ [ m& `2 @
.name = "user_led3",
3 [( J2 n2 X6 v4 [! q .default_trigger = "default-on",0 h# b7 D* t/ F+ o7 z
},0 i; i1 J7 {7 i
};% A B9 M! T( F4 h, f9 P5 W
6 C" ]0 H d3 V; a, Z, A5 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- q6 t8 v6 l7 S5 F
.leds = da850_evm_tl_leds," E5 c- b' t/ V$ U# m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& D9 R- S+ A# M5 s7 d' s4 `3 J
};
0 {$ o) a4 H. I. I# d; @( s/ \8 m: f: E; S" k
static void led_dev_release(struct device *dev)
. P7 p9 D. O( c% N{
' k. G- M/ c! W/ K) [. J- p4 W% `};3 r( b4 Z$ L d4 ~" R
% y# H* ]3 D. t; J5 F% { bstatic struct platform_device da850_evm_tl_leds_device = {$ [& j" }% r. B0 b" C3 W' M1 |0 @2 @
.name = "leds-gpio",
! r) N' x T9 E4 w) w4 Y/ T: _0 R .id = 1," V" `- [% V* l! M u5 c7 M
.dev = {4 T6 ]# L, C$ H
.platform_data = &da850_evm_tl_leds_pdata,: s9 \8 f( r2 }( |
.release = led_dev_release,1 G6 G5 \7 X% J
}) r6 a ?6 Z: o
};( u, D0 ?) \* `8 H8 W
! x' C. Y* o1 U/ j9 ?2 P( b: g* o
static int __init led_platform_init(void)
/ p; O' l% `/ g( q{* ]' A9 |* S6 m+ X% P8 O
int ret;
! S K' H* U( u0 X$ X#if 0
& U! P ^1 q6 a' t( \% W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 L7 ~' Q- g) \4 A E1 ?8 }
if (ret)# i7 M& t% Z. c* j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* d7 O) p8 Q% i$ \8 ~
"%d\n", ret);
V s2 c0 D) B- O* N#endif
& i' H& l7 M+ p ret = platform_device_register(&da850_evm_tl_leds_device);
# }8 f! S' Q# b, N0 V; ^, U if (ret)
; T9 s) E6 J! N: T# u4 w pr_warning("Could not register som GPIO expander LEDS");
. E5 O" u: f0 _. [# ?2 M/ I else
* R% U0 j8 `3 m& ] printk(KERN_INFO "LED register sucessful!\n");' S$ B3 Y- \8 n
2 |. ^' A1 a2 _; d; c' M" G- ]: U
return ret;
. `7 V' g9 t$ g/ C; {7 v( J# ]}
8 g4 p: I$ o1 w
3 K/ g1 a# w8 f/ y/ nstatic void __exit led_platform_exit(void)6 p# ~, w8 b; S; ~0 G
{/ {3 o% P4 K3 r% b( N% }- j/ L; M
platform_device_unregister(&da850_evm_tl_leds_device);7 }) t6 j0 s3 [" H! A6 M$ L$ B
4 P7 ]2 r7 i- I& ~/ O* b
printk(KERN_INFO "LED unregister!\n");# D3 w0 W. w$ P; [
}
0 h) I6 }" s' Z, \
9 {, W) t" J5 j- Z$ umodule_init(led_platform_init); i) _, E5 @- U0 c. i( x
module_exit(led_platform_exit);
6 K$ T) \5 p2 W& W; Q9 m1 z8 }1 J0 O9 E8 }
MODULE_DESCRIPTION("Led platform driver");
5 B3 @' T) @9 q6 k+ f- n7 v- a5 jMODULE_AUTHOR("Tronlong");5 Y& T' R3 w+ n( T- |& F
MODULE_LICENSE("GPL");
2 _! ]6 s: D$ s/ c5 f
. C, t/ |6 k% S4 g. Q! s: q |
|