|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 Z+ Q, c3 D" [; k4 h! A#include <linux/init.h>
1 m4 Q( L: b. j1 b. x: _5 B- |' w# U) u3 U0 d#include <linux/module.h>
' @/ R/ Z) R" D9 |* P) x5 l) G#include <linux/kernel.h>
( [" l) G3 J6 O, n$ M#include <linux/types.h>
! m: A% F- I/ X5 @: \7 {#include <linux/gpio.h>
, `) ?, K5 T. E" Q#include <linux/leds.h>
( p8 a+ B: v+ v" Y5 e& s$ D l#include <linux/platform_device.h>9 n* U2 C+ i, o: H
/ l( P& i0 m$ S) B#include <asm/mach-types.h>
6 K: s. o$ f" N6 M( r#include <asm/mach/arch.h>
j' m U# [0 {$ ~0 B. u" G#include <mach/da8xx.h>+ o% I3 i$ L5 V
#include <mach/mux.h>0 @* Q" n- J2 a0 f' |4 F
7 y0 g; |: l; D2 A1 `! ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& [; G! c6 o$ r3 @4 L7 `+ k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 ?, B2 {: _* Y1 t7 b2 t9 y: ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- W. R) W" [# M$ U7 u" _ M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ x: j( ^* v: C) Z
8 z9 j' c' j% K8 C# F2 D& `8 r5 A/* assign the tl som board LED-GPIOs*/! O( c- E' _2 C$ |' R& @
static const short da850_evm_tl_user_led_pins[] = {5 ]2 i: v: M' D0 |
/* These pins are definition at <mach/mux.h> file */
- X/ p, a/ _) B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 K4 m: p2 |' p1 V* J5 |, @! Z
-1
0 W( x' b, t; @! w6 ]7 Q};) ], o5 b! A* I7 U z
8 @+ C7 k2 q8 T/ [0 |2 f1 Lstatic struct gpio_led da850_evm_tl_leds[] = {5 ]; _+ D# O& P" }6 E, B5 w
{' X7 r4 }, z$ i/ U. N, y
.active_low = 0,$ S1 h* Q) [0 `5 O
.gpio = DA850_USER_LED0,
$ X& h5 @; @/ r, q6 ^* p6 f! m/ V .name = "user_led0",
4 R# g* F+ T8 V3 \( u6 O |: X$ C% n .default_trigger = "default-on",
+ a+ W& j* u! N( p; X0 W },
2 {2 u' |7 Q$ S4 { { t1 f" X3 }- K" X: j; _& a
.active_low = 0,
* c0 } {" H; U- f .gpio = DA850_USER_LED1,
$ |8 d! }# C4 Q1 m( P4 q" u .name = "user_led1",7 o- {$ a. x% R# T- r/ T
.default_trigger = "default-on",5 o0 n5 z, Y% h7 U1 I# }- D) \
},$ N6 G* i0 V" f( f
{4 k' U7 Y8 L( h( o
.active_low = 0,
4 l' M) v9 Z# ^; j .gpio = DA850_USER_LED2,
' t( s" y" v, J8 \9 u .name = "user_led2",* h1 r# o7 M4 Y: S9 E* U- ^# h
.default_trigger = "default-on",
, o* _: }( m! x. {( S( l },
1 k$ }) ?& I$ { h9 k1 O6 W {
- P* A* t- i' M# c7 U0 G5 S .active_low = 0,
: q7 T/ b$ r+ n" W8 J3 }- X .gpio = DA850_USER_LED3,
! @2 {& H, w* J' c! H' G .name = "user_led3",; j5 j& v0 Q1 M! Q
.default_trigger = "default-on",
9 Z! ]7 L! ` F },
. Z) H2 m2 U5 j6 k! x# I};
: D: @8 m. V6 D" L7 E) S$ p
A2 k6 c$ @& j5 N( Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ Y0 c8 j7 C. E8 b* ^; _0 k .leds = da850_evm_tl_leds,8 v4 Z- W) J! z% v$ @7 p }
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
P8 D4 J; x9 m5 F9 u}; r9 h+ H: p6 R7 ~
! L" B/ ~5 y0 Q2 O. ?4 \7 E1 z0 b
static void led_dev_release(struct device *dev)' _ i. z! r* `+ a, { T$ K0 G; d
{
* n9 g# _' S3 \- a# b/ P/ J/ b};# d+ \8 d. L* [% H3 |5 F& C+ ?
9 u4 ^) C, _9 qstatic struct platform_device da850_evm_tl_leds_device = {3 k# D- D# \2 U
.name = "leds-gpio",$ m- |9 }7 d" ]; V4 p! ^2 T6 O. M
.id = 1,
; w6 a4 }/ j( b6 | .dev = {( m! Y8 j V! K3 E/ N: Z9 E
.platform_data = &da850_evm_tl_leds_pdata,
$ Y; j3 h0 \1 k" q" K! t .release = led_dev_release,
8 i: d1 l" y* ^; l' ` }+ p& c* Z3 k1 [6 f+ b
};! p$ D2 @# O. }2 c' D! K
3 h8 m7 ` @6 s6 e8 bstatic int __init led_platform_init(void)( J* }% B7 v5 Z8 u: @
{: m1 ^* U, s% W0 x! r, f! i
int ret;
9 ^3 f0 R. T7 F9 u7 o5 E$ e#if 02 n& q3 d, S3 ~- l1 F0 M9 {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& C8 t- r6 V3 g8 \3 J
if (ret); |" g" E: b# } ]& s3 b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% r; {5 F9 @* G) d( e& M
"%d\n", ret);
' T4 ]2 s+ ~( \8 W/ i9 K" p! _#endif. R, s" l( h P+ A
ret = platform_device_register(&da850_evm_tl_leds_device);5 A! {$ Z' Y H: ?) m
if (ret)
" h+ U& {9 Q" K8 d$ b5 L) u& E3 m" ~ pr_warning("Could not register som GPIO expander LEDS");& j/ T& t0 J# Z
else5 c. f. A: D3 M" X
printk(KERN_INFO "LED register sucessful!\n");5 f4 V9 ~- d" \; u* @3 f1 r
$ ] Y1 p9 m% @: b# d/ J+ h9 H3 U
return ret;: O G6 H' {) e! T" [
}. o# f; A. p* Y. h( f3 {, F
4 q! K+ R; e8 \9 J M. D
static void __exit led_platform_exit(void)$ ?8 O2 v. w9 p( I( n' I
{ Q- W$ p I7 l: b! d7 D+ h% _
platform_device_unregister(&da850_evm_tl_leds_device);. ^8 F) G8 ~. R. F1 Z
# z- J5 u" F& V7 I, j7 L1 l
printk(KERN_INFO "LED unregister!\n");$ T0 {! x4 ~" Z- w7 W1 L4 e: L2 u3 O% Q
}
4 t4 @% S6 v$ j6 m$ e# D& B% s5 [5 G" W$ l2 b& J
module_init(led_platform_init);8 p# o& ?; e5 }6 `; {4 v( T* H
module_exit(led_platform_exit);
# o7 ` o' z6 I* W. ~* V; Z; m
# Z! U. }. Q! \2 n) B) @2 C KMODULE_DESCRIPTION("Led platform driver");. e) W; [! ]* K* w' R# y! e
MODULE_AUTHOR("Tronlong");8 O+ S/ X" \8 o) _
MODULE_LICENSE("GPL");1 W* L& x3 E/ N T
$ s8 J/ v. B& D0 ^6 }+ I |
|