|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 E- v5 S" C' u4 _: F1 R) u0 Q5 y#include <linux/init.h>: h0 G( r8 d9 D# M, H: L+ h
#include <linux/module.h>! L7 ~# j& S5 T% q
#include <linux/kernel.h>5 Y" U) e& l- e; g( F
#include <linux/types.h>
- {: I8 ^+ C$ z5 f#include <linux/gpio.h>
8 O. @& p4 z! L' u) q! J u#include <linux/leds.h>4 |: @# X3 H( k3 H1 @* `7 p1 ]
#include <linux/platform_device.h>
: U7 @+ x" Z# r' n
! F X* @3 f, H* [#include <asm/mach-types.h>
, c' l. V1 Z3 L# `% K#include <asm/mach/arch.h>
( B- a6 I' J* g, b4 _6 T2 s- w#include <mach/da8xx.h>
# k% f2 t( u, X#include <mach/mux.h>
( X& ]. @9 W$ e$ w% A
4 K- U& d# U* R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 f2 h" s( ?3 u7 W n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) f1 ^9 M! k% V' z' Y8 _& p#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 Q3 V! _% o9 \* Y" |, {( Z) W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- A7 X) x, R$ x, J5 K
3 Z4 x7 C2 N5 M# B# ?
/* assign the tl som board LED-GPIOs*/
3 V# K) M5 Y) P L; |9 Gstatic const short da850_evm_tl_user_led_pins[] = {
) b c" I+ ^+ ]/ _' e! u, ~5 @' r. i /* These pins are definition at <mach/mux.h> file */
p5 l* N; Y# h- l. v# o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 M1 r/ t7 e" B+ M8 Q( w
-14 }; o& Z% H! s2 I
};
% Z$ M6 q3 c" O, w L! x. f0 q* x8 t- n& }0 f3 U0 r/ y3 s
static struct gpio_led da850_evm_tl_leds[] = {
# M6 |7 S& P9 q! R {
, N: I6 e/ n9 r .active_low = 0,! A. }9 s5 l) q) x% Z
.gpio = DA850_USER_LED0,' I' x' o1 j k9 D8 F4 H: M1 ~
.name = "user_led0",
$ D: k8 v$ C8 i6 A. e# C .default_trigger = "default-on",
& P. S; g, W( e2 l& ?' u# M& X) V }, [; ]( e8 q! H. N' A' `
{5 e$ b6 r' s x6 r% k# B
.active_low = 0,5 H' ?0 }1 k/ ~2 \1 l# Y
.gpio = DA850_USER_LED1,# v) Z5 ^1 i3 u2 N
.name = "user_led1",
+ ?$ |. v" U/ \4 [6 g. J7 q .default_trigger = "default-on",+ C8 m3 D4 e2 p7 j6 m( P- q
},1 i: \# n2 j( s6 _5 s0 u% }
{
9 `: C1 ?8 Q& q% M- k! b$ H2 I .active_low = 0,
5 p1 i/ V7 b8 A$ S .gpio = DA850_USER_LED2,' S F$ Y! t$ S
.name = "user_led2",
* h! A& m* w9 }/ d+ W0 ?) J' R; c .default_trigger = "default-on",
9 y% H2 b& e- ~' M' w$ R) _; r! R% L* n },4 M5 { V' `3 ~6 w+ K
{% K& s6 L0 v: y; H6 m# }' e
.active_low = 0,/ H) n- e+ n% I M, G
.gpio = DA850_USER_LED3,
. f: }3 z g7 T9 j .name = "user_led3",
. h0 R' i/ d) s3 T9 T .default_trigger = "default-on",/ y8 ]2 D+ }" W5 ]
},
+ O9 h3 \. R. M# e3 ]* N1 \3 p};
/ X) U4 p3 J, u0 [1 |8 m" b" {; {( o1 C3 E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 A) h. Q9 q* ~( S+ M, K .leds = da850_evm_tl_leds,5 ^1 j1 Q# V* {8 s. G8 \* r) h; t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 P! k8 g( H! b5 U U};
* ]( n0 C" }; f0 |- V' O
. `0 k2 M) V ostatic void led_dev_release(struct device *dev)
& p7 ?* g# [2 M0 f{
' j) G/ ?7 w" `2 Q0 b( u$ u: \};
; t! U8 ~3 j1 @$ b/ \; [3 }
o& U- u. O* N/ M* v; d" Qstatic struct platform_device da850_evm_tl_leds_device = {
6 Z; `( U" [) N .name = "leds-gpio",. v9 [2 y% L# o" p9 A. v
.id = 1,
& X0 h$ o* Y; m4 Z5 o+ w0 m .dev = { C5 X0 _# z! [. S+ [
.platform_data = &da850_evm_tl_leds_pdata,
/ D3 n+ q( u4 _6 P) D& K, ~ .release = led_dev_release,5 y: P$ v( G3 n! U! q- d8 R% P9 K
}; d' {+ E/ E9 D: I
};# }7 C3 T( K, \: F% _& }
8 Y& \% A% K1 R$ x9 C. t# O0 O
static int __init led_platform_init(void)
7 h3 {% S8 H5 F& b' @{ Q0 Y. N% V: @+ ~
int ret;
* | `% ?( F" A#if 0
$ I- X0 i, j- Q: e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 A, o5 R+ z, Z7 l6 N7 _; s& N
if (ret)
+ I$ z/ M0 I: _" r! A: N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; w& B! q* G6 r9 ]5 m
"%d\n", ret);
5 t% l: l8 C: ?$ n& H#endif
; }: H' g8 N3 q0 k ret = platform_device_register(&da850_evm_tl_leds_device);6 K- n) z! {6 }) Q' G
if (ret)+ Y5 ?0 _. B; p+ F" f) V
pr_warning("Could not register som GPIO expander LEDS");
& O% y# M! @' a$ C# R+ E else
7 _; Z4 W+ p$ q+ o& P printk(KERN_INFO "LED register sucessful!\n");
9 d: {7 ]5 }4 o9 p4 u/ P ], W+ B0 J
return ret;' b2 n4 W6 z; N% Q I3 l
}1 ?1 ~* U& `( V; \/ X
8 u( _" ^ c2 b2 s$ j2 s' hstatic void __exit led_platform_exit(void)8 T9 p4 }' U+ {6 n8 d4 X9 }
{
# _6 Y7 r* O( N8 g9 q# D4 z# P" S- O0 \ platform_device_unregister(&da850_evm_tl_leds_device);% q& u; S, v g; b
' f$ n c9 ?* _# N. C, P
printk(KERN_INFO "LED unregister!\n");% L$ E$ ^6 S' X1 {+ H5 B
}
/ V7 N2 [3 \) F* P+ y( N
+ D% s3 Z9 D0 U9 C7 Q$ amodule_init(led_platform_init);
+ [# D( P/ y" t6 \9 ?* j e% G, Mmodule_exit(led_platform_exit);
9 h9 _4 N2 ^0 n# L: x$ }& {# N
0 l" C; |8 N+ c) U7 AMODULE_DESCRIPTION("Led platform driver");
' l/ h. E5 B) ]/ d( x7 ~/ zMODULE_AUTHOR("Tronlong");3 f8 [$ e1 ~ q
MODULE_LICENSE("GPL");- W: e& x6 w. y
9 A' K/ Y* U' \ B
|
|