|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* S. ]' o7 o5 B* @: j#include <linux/init.h>
/ z/ L! k6 } o& p#include <linux/module.h>( R x0 U) I: ] P( x& W; K
#include <linux/kernel.h>- \+ y/ Y. Z; G" w6 H
#include <linux/types.h>
/ M6 w0 a+ h1 D# X$ h+ q4 ^#include <linux/gpio.h>
/ u! n' R& e! M+ ~( a#include <linux/leds.h>
+ Z- y) N$ Q0 Q2 F" f#include <linux/platform_device.h>
% f2 a4 U" k& q% L, z9 f5 ~
) K3 A- h: P6 H m4 n" l: b1 ~0 u#include <asm/mach-types.h>" q+ w9 s9 ?$ d2 p
#include <asm/mach/arch.h>
* m3 Q$ g5 U1 h+ ~#include <mach/da8xx.h>
+ M0 l0 M1 J5 _0 q! e5 Q- e$ O#include <mach/mux.h>
9 v- D$ p) t( Z' }/ y2 D
% j( o4 m; s6 N9 H) Y+ `' e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
O, K/ U+ j2 @( R8 y, M- R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 z% \5 T t5 V! K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ H/ r- [" d6 R9 s' r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 g% b, ]4 S6 l5 D
+ O, S: P1 B4 s' P# [9 Y
/* assign the tl som board LED-GPIOs*/% T+ \) Z# a, S, X" M, P1 j
static const short da850_evm_tl_user_led_pins[] = {9 ^3 _% F' a4 `: r8 _7 [
/* These pins are definition at <mach/mux.h> file */3 w- h! }6 F) {- c8 ]! e0 f( G h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 j/ G- L, M7 \5 x. s
-13 J' S+ L. p2 W
};% x L+ A) ^8 i% E; T
: R/ O4 \4 T- ^9 ?static struct gpio_led da850_evm_tl_leds[] = {; p A( Q. x" X# u. t. I3 z
{
$ Q& s8 U) `7 K5 G .active_low = 0,
% h" e- t' J7 _& J$ l! I& i .gpio = DA850_USER_LED0,
0 U' }& E$ p; d' G .name = "user_led0", R0 T! F8 C2 N1 \' H( @+ p
.default_trigger = "default-on",. l, S" n0 Q; n
},
# t9 C- l5 k" C$ d; t: | {
9 A3 C. m z1 q/ V! G* H1 m .active_low = 0,4 A2 U: r. G+ M+ Q" `2 b3 X) J \
.gpio = DA850_USER_LED1,
: {9 b/ W, o# H( L# m .name = "user_led1",1 `# z3 e/ _8 d3 x- O& N! X
.default_trigger = "default-on",
" l5 |6 t$ t. E% F- \ },
/ r" r! R- d$ e- N {
/ a1 Y* s( h2 r" } .active_low = 0,
) f5 m4 V$ r" \! G0 T .gpio = DA850_USER_LED2,' n4 f- r: B, j. z" z* g# b
.name = "user_led2",( K8 ~( v" u, c' M$ m5 \2 \5 V1 `
.default_trigger = "default-on",. C) a+ p) l9 \9 Q
},6 b. I$ X/ x8 h# o
{
. W) H1 s& ~5 d5 z% S0 X b- t .active_low = 0,$ t3 m) ]) J, L% J: V" h5 z: d0 f+ k
.gpio = DA850_USER_LED3,
! N6 @( g1 } _6 Q/ F" |1 a3 C .name = "user_led3",
( ]- G+ m& q6 R8 q4 D6 e) G2 p .default_trigger = "default-on",% a! s2 t' y. K: @9 k8 c, s
},4 x. r' {6 E- B/ H$ @# J6 l
};/ ?( F- N4 O/ i" I: a. I7 N$ m
& w! B+ d, T1 m. g- Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 w' ~9 [, K" L: C* n
.leds = da850_evm_tl_leds,% W& d0 w" O/ T$ U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 V9 r5 A8 @: V' e: n
};
+ b) r: R6 l7 {$ V0 X. @) f% l# q8 _
static void led_dev_release(struct device *dev)* n( [0 F* _* V
{
: K, U- Y: m8 O- x2 V. A};6 N- S7 @: }; n, h$ q
" }6 r( c9 e' W% l) M- ?static struct platform_device da850_evm_tl_leds_device = { i' R: r& {% S% h: W) k9 j ^
.name = "leds-gpio",
: j* N& P4 o. v% {. k% ~% e) a .id = 1,
2 k! q7 W6 a) E .dev = {3 i% ~: H8 g+ ~! V( e) C+ ]7 ~
.platform_data = &da850_evm_tl_leds_pdata,
4 X/ ^% a% O/ } .release = led_dev_release,. T3 E) e1 c7 A! l3 }
}& }7 b9 v& [: D2 D1 W
};
; x$ R3 u/ Y% ^& ?2 l! c# l* y# W# B4 j5 b9 K) @9 b( _2 Z" H
static int __init led_platform_init(void)
& D: R2 E; A. ?" _( T* V{
6 F5 A5 o G5 ~; a, v" F( \! f; u7 _ int ret;
$ r ~4 l, r. H. B#if 0
% p$ h) G0 I" K( V* @- r5 R$ T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 K7 j% G1 [: |2 a2 c9 h if (ret)+ T1 m4 X8 g+ I, |! Z4 \0 }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ I- d4 d# D0 Z$ } @# @* C1 `3 c+ K
"%d\n", ret);
0 B) Z1 U, y! T+ X" Y4 R3 L- V#endif
. c/ ]" L. _5 Y$ ?. {* |% W ret = platform_device_register(&da850_evm_tl_leds_device);
7 {8 _3 t3 N8 W: ~ if (ret)
+ E0 z0 o" l! P5 R0 I pr_warning("Could not register som GPIO expander LEDS");
8 h' }0 }: b# |0 j, m( L& ~ else
% w* t& h' v1 z* Z printk(KERN_INFO "LED register sucessful!\n");
( N7 x, E) U* A9 u3 V! i
! K' V: G& Y0 u$ y5 j3 k) L; r return ret;
# g" s& p2 ?; p}
e- L X4 g" |& a% T3 l/ j; z% i" z; ?# C
static void __exit led_platform_exit(void)
% t" g, `3 [7 w) T6 w% C{
$ B/ O8 I% \8 |; Z! S platform_device_unregister(&da850_evm_tl_leds_device);6 `& w- x0 o& ?3 h
' _$ q9 ^; E, Y3 O2 K2 w, a# N printk(KERN_INFO "LED unregister!\n");
/ \" v' ~2 c0 @& C/ B) o}3 b& L/ Q+ E0 @& _5 Y' P: g
! E; J i! L7 j: p% P
module_init(led_platform_init);5 _& n2 I4 F; O! Y
module_exit(led_platform_exit);- { g+ ~) K% y3 |
9 v/ g6 |# E: T; K0 ~
MODULE_DESCRIPTION("Led platform driver");
; {2 B, d% t3 k5 P" R9 k3 A2 p7 sMODULE_AUTHOR("Tronlong");
8 x) m3 d. K7 r. }MODULE_LICENSE("GPL");+ [! Y1 z4 G, U5 i4 t$ z0 [$ v5 F: r1 p
% R! p3 X3 y2 ?8 g
|
|