|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 e0 g& S- N) p8 t#include <linux/init.h>8 b8 Q6 p( u/ i# w' l
#include <linux/module.h>
' V, ~& A4 H# X% }. ]0 q' Z* y#include <linux/kernel.h>' b% @; T$ E+ N5 q! b( W: v7 W! [
#include <linux/types.h>
$ I- A) K5 R2 ^% h! u1 C! z6 W#include <linux/gpio.h>
+ O0 v( B* {8 Y# o8 Y#include <linux/leds.h>
% O3 z5 F$ B4 j7 ?% V7 }#include <linux/platform_device.h>
- x( h* o: d- O% x2 x; q. x! E8 {+ `
. i& ]4 B0 R+ O#include <asm/mach-types.h>
5 w. |/ [+ j" M#include <asm/mach/arch.h>- v& Q0 x8 m6 c% K7 } C
#include <mach/da8xx.h>4 Q- G) B2 z9 V; j* r
#include <mach/mux.h>, R% R# |0 o- [) t4 n
4 y4 Q7 O$ v, m4 b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% ~2 P3 E1 v+ a' p x4 [! C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 J# B5 b: S" @, c" q, w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ \9 O- O6 e0 a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* h1 m1 ]- h: \$ s
% t# J8 \; t8 ? D! ?' r/* assign the tl som board LED-GPIOs*/
- m3 @* S/ y7 C$ F8 o3 T2 Y4 ~static const short da850_evm_tl_user_led_pins[] = {* [8 Y; ~) p0 V- q1 U
/* These pins are definition at <mach/mux.h> file */' a& e. h( D; a' U! Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ i- O5 [, n- y3 M8 F; i/ H3 ?5 n1 ]
-1
' e, x. q1 i& Y4 g};
0 T% Q* H( f _, [$ p% I0 O' N
, v0 b! n3 C+ ?; U5 E$ Z; f3 \" estatic struct gpio_led da850_evm_tl_leds[] = {# \9 S7 M" \; ~( w& X
{
$ ~& a8 f s/ M7 Z, L .active_low = 0,
! {( y7 e8 |+ Z8 K .gpio = DA850_USER_LED0,
! A; |: h; a0 N! ~% B! @ .name = "user_led0",# f3 F5 o5 q- p l/ V p1 i
.default_trigger = "default-on",
) B6 A) d/ x. M5 L },
8 w7 _+ N$ {; u, S {0 ~% {& q% Q- G
.active_low = 0,: e# \) X- j8 v
.gpio = DA850_USER_LED1,
" e1 _: v/ k% `+ V! k; R .name = "user_led1",% K/ l) H* E8 g1 c
.default_trigger = "default-on",+ K9 p! W) a$ B3 _' h' d: n
}, U: e* d4 c# M( v. u! F. f
{: B5 i5 u* X6 r
.active_low = 0,/ r9 C: a! J4 b: [
.gpio = DA850_USER_LED2,4 O- m3 ]+ |6 A" X. j: O" _
.name = "user_led2",
4 g7 X- V y* T, C. M+ D. Q/ h .default_trigger = "default-on",
, Y; V# @7 Z( H5 q% r3 I% ` },
! Y. Y& r2 C/ n+ o {& b4 G! Y, }1 Y2 p2 r4 f p1 N
.active_low = 0,
* T( t3 ?1 m& x4 q: P" q .gpio = DA850_USER_LED3,
2 }0 S; ^" F" V/ F .name = "user_led3",9 L: ~) x( n- M( x; p* L9 E- x2 h ^
.default_trigger = "default-on",) n9 A( o2 U: o( u
},) P8 j: Y, n" I7 _: G2 B
};
' S; x" o6 @( s! x8 K* A
3 A7 @1 G, G: d' h' Q) _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: H, Z; v. [, i. a6 q6 K
.leds = da850_evm_tl_leds,5 z7 T/ X* \& s+ t; l# R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 H$ k7 ?. Y3 k2 J6 u! x1 ]};- v9 y& U( f# C4 _
+ ^3 @/ U8 c6 m5 m, O* e/ O# c/ Wstatic void led_dev_release(struct device *dev)) ?( J& w8 q1 @1 p$ w" q0 \
{
# s# V4 N; l* I1 X/ n};$ C: ?8 I- N! k8 U b
- K/ o- [0 p- t. ]' `9 vstatic struct platform_device da850_evm_tl_leds_device = {
. K9 l2 z) h& d9 `+ [/ t# u .name = "leds-gpio",+ y2 O7 @) T. ~1 L
.id = 1,
/ [" q( M1 _4 K .dev = {
- V8 l" Q" H. E8 [* @5 } u* E .platform_data = &da850_evm_tl_leds_pdata,
$ Z4 s3 [* v6 T( F) [2 n8 U% k .release = led_dev_release,
1 y0 M* |5 q: s# u1 p5 S }
, ?! I- o% R0 c8 i6 ] T$ H};
. f: a! I- x" M& ?$ p! ~5 @6 u1 E. j
static int __init led_platform_init(void)
7 p& o* q0 c7 D6 q{. y }2 C% x; |& c0 Z' p+ F
int ret;( `, g$ r9 h7 u; w& l
#if 0
5 r6 N# J$ C( |# t. w. Z+ s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# g$ S' z: g3 R8 e
if (ret)
/ d1 m Q$ q9 b; O H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" f5 ^( _! Y# B1 A f+ Q "%d\n", ret);
7 X! F% n% r7 x7 |#endif/ J9 s0 ^8 ^7 ?
ret = platform_device_register(&da850_evm_tl_leds_device);
' o& U# i- x8 u4 U9 v if (ret)
) o+ ~/ F3 r6 L% r# t pr_warning("Could not register som GPIO expander LEDS");
) Y7 G h# n' E( O! g else
+ d/ {- a6 C# \& |8 e/ Q printk(KERN_INFO "LED register sucessful!\n");/ N. R# A6 W4 [
9 W- e/ F6 G: |) G$ ^/ n8 a# R; t# E$ S return ret;7 L! @7 @. p' l/ _7 G1 P" ]5 i
}, J1 L: m+ y/ G4 ?8 X' O0 f6 Q/ `7 s3 x; D
% D% c) K7 q& O* wstatic void __exit led_platform_exit(void)# F$ D5 E: l- V5 Q& U
{/ r9 s4 ?8 R [4 X7 A1 E; h2 e
platform_device_unregister(&da850_evm_tl_leds_device);
& x8 }. ?) B+ C9 [/ V2 u! ?/ S/ m4 w) {/ } a6 {4 T8 N# Y8 J* {8 B" h
printk(KERN_INFO "LED unregister!\n");* Z3 I, M5 }2 l4 {
}
0 d% b$ M" N6 l" V2 p& d/ {. u6 g% `
module_init(led_platform_init);
0 M4 K5 E2 P# e3 ?9 }2 pmodule_exit(led_platform_exit);# d" n/ {% S7 [# m& o$ w
" Q ^) E6 y6 @5 N0 ]MODULE_DESCRIPTION("Led platform driver");
# J- D/ W/ ] {) W7 c6 }0 X S+ r: A. TMODULE_AUTHOR("Tronlong");) ^$ g4 P5 {; n+ T% a+ H- j2 i
MODULE_LICENSE("GPL"); N9 W! {. ~3 [9 v
+ |6 Z+ i" D- q2 o! S
|
|