|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) N- @! }; ^; K! d, k. N) ]#include <linux/init.h>
- ^, V$ X% y; x" Q# {#include <linux/module.h>" j: Y7 O. ^5 } D: `; y m
#include <linux/kernel.h> n+ c2 |* x/ I. _8 k7 W7 q
#include <linux/types.h>
1 o& @# n( f( m9 |0 x/ a#include <linux/gpio.h>
& L7 J4 C* b" a: X#include <linux/leds.h>
: k8 U+ v% x2 y. x#include <linux/platform_device.h> V3 Y9 R% Q/ |. ?
- z7 U1 R6 P5 d& m
#include <asm/mach-types.h>- @/ b7 }1 z6 Q" m
#include <asm/mach/arch.h>
9 @- M( h' ?0 Y5 w6 M#include <mach/da8xx.h>
9 x! ]6 h$ Q9 b+ w5 [7 w* j#include <mach/mux.h>
/ l$ ^" G; T" j, e
0 v7 Z2 N: | F# `* r6 r2 ` `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 C3 d9 w" @* n2 s: ], s1 Q5 E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ p0 X" I; B+ z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% j# N3 o4 G, }( _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 f5 d) ?. V: \; {$ h
$ e ^7 h# z; A9 ?/ n5 z
/* assign the tl som board LED-GPIOs*/& w% |* V4 J/ a7 |' k7 O
static const short da850_evm_tl_user_led_pins[] = {
& A8 n7 _6 \7 B9 z3 }& _0 Z& E /* These pins are definition at <mach/mux.h> file */
) e7 ?' D: q/ N+ _# B7 T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 L! E% Y% @! s4 L# B
-1
4 }+ \) S( I e C; l$ l};
) t/ a6 X1 u( P2 U. g5 G% T0 k' W% @: P8 X6 n7 f
static struct gpio_led da850_evm_tl_leds[] = {
1 m- i& k' C8 q6 l! O {4 N: C0 G% ^. H4 j
.active_low = 0,/ s. f8 I) k/ {' a/ W' Y
.gpio = DA850_USER_LED0,
3 M# B S' v6 @ .name = "user_led0",
0 l* u$ W0 \" b .default_trigger = "default-on",/ X# Y( B y" A$ Q$ N
},
3 y8 Z4 Y+ ?& y {) P* l! J& R) \9 F2 v3 t
.active_low = 0,
3 C3 a0 m7 V0 j7 U# p. t- F, S .gpio = DA850_USER_LED1,# ?, ~( t) \* U. ~0 T
.name = "user_led1",
; D+ @9 M4 q$ N8 _ F8 F. B1 ]& [ .default_trigger = "default-on",; w/ O& V9 K d/ G7 l$ h4 L' f: b
},
# X# e/ @2 U8 @/ |% E) c8 B {# N% A3 y7 x2 g5 Z {) p/ o
.active_low = 0,
" o7 _" w0 |3 m- u, V- S0 X .gpio = DA850_USER_LED2,
7 {1 I* L( u4 s* b* j4 G% @ .name = "user_led2",
) l b- p" ^( C7 Q+ S, B' ] .default_trigger = "default-on",
2 o6 `' `; L/ E3 b* D5 H0 Y0 F2 O },& [- L/ E" c2 A( N* t- c L
{; v$ }! |$ {2 L
.active_low = 0,
! ?3 E3 B/ S! C& I/ w; E6 c .gpio = DA850_USER_LED3,( f# ~6 m8 N5 T3 a: ?" g
.name = "user_led3",* d- m/ o) X. i$ W8 k( ]1 B% ]& y
.default_trigger = "default-on",! _/ ~ y9 i" ?3 j% Q5 x
},2 w7 b2 l1 q+ x
};( T9 D( W( b9 L5 a! T& H/ z
' `" m* L% V/ C" P$ m3 i# I- A$ Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: m0 X" J9 x$ F( j' z9 s1 H3 x
.leds = da850_evm_tl_leds,/ A7 M% U& v5 q: h- L9 ]$ j) U* \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ j" `4 T1 o g; ^6 P& T7 [9 o
};
1 Z- f$ D4 D/ E0 T* r, ]" g$ A% Z2 {; g5 g9 i
static void led_dev_release(struct device *dev)
# r& r3 R$ e# c7 M- P+ V0 Q+ {; b{
( g& ~4 h! C' c: `4 B& t5 ?};/ P( a) b3 b0 R! F
6 O6 C, c9 C) _0 {static struct platform_device da850_evm_tl_leds_device = {
9 s- Q L+ c# l .name = "leds-gpio",
* x) a2 f7 n! E9 a& t0 J/ g0 } .id = 1,
* a. l/ Z, K/ D .dev = { Z4 _0 H' a' X/ {) I- @4 U$ q
.platform_data = &da850_evm_tl_leds_pdata,
4 |6 o% a. h( s5 m1 f. l .release = led_dev_release,0 h+ W# k0 `2 G% C5 B0 u: A; h3 _' ]
}/ U3 R4 z8 U/ Z" I* Y; }* `4 q
};, L- T7 W! L/ Y8 A
+ c: k' A- {( I4 {
static int __init led_platform_init(void)
9 A% r% s8 {, j. k{2 B6 E+ Z0 j. {2 ?" r6 s
int ret;
3 l) p* `: x" T, j0 j" K, g#if 0
7 }+ m1 x; H! o0 }$ c ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 p" z$ A: v M2 q$ X if (ret): O4 X3 |, b% C- L7 \6 d; Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 i' A& ]% T: T7 L# E5 e
"%d\n", ret);
& z* l* k2 Z6 X- ~1 z) \#endif
6 X ]( K! h8 J: h, c0 Y ret = platform_device_register(&da850_evm_tl_leds_device);+ a$ f9 ~9 k/ M' v
if (ret)5 @/ G; P: ]1 r
pr_warning("Could not register som GPIO expander LEDS");( O5 i' m0 K, G
else
: E9 n3 c Y- [, _8 y# I" A$ B- R printk(KERN_INFO "LED register sucessful!\n");& U# T. R9 K# ^! W B9 e2 G! I
( b4 b9 l: D2 y7 ~ return ret;/ e& j; ]* N+ t) g; W2 j/ n
}$ I* E8 w1 n: E
- d, F* F& H( e, a5 v' N- K( c0 c
static void __exit led_platform_exit(void)9 {% s- R" ?, T- l) V
{ I7 q3 X# t {$ p- l
platform_device_unregister(&da850_evm_tl_leds_device);
" m$ I5 y. _1 p4 X
! [) T# I* w ~2 V printk(KERN_INFO "LED unregister!\n");2 _. ^. l1 o' _% ^, }
}$ a- W" P* V/ h' ~# N/ ]) ^% M
% c/ `/ p9 T3 [/ c5 Hmodule_init(led_platform_init);
. h8 }- q, D0 `/ G( C3 Kmodule_exit(led_platform_exit);0 M3 ~" k( h7 K
/ l1 l: [. m* B4 t" K1 @7 wMODULE_DESCRIPTION("Led platform driver");: k8 ?% n6 [2 r; f! _( P" y
MODULE_AUTHOR("Tronlong");0 Y1 `1 S0 B5 S" } d) v$ Y$ g
MODULE_LICENSE("GPL");% I5 a; x) o' P) k; c
( f8 o; N# u% h* @
|
|