|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) y2 M4 L" u3 E3 f9 H#include <linux/init.h>1 j I% a Y- Q9 u/ Y
#include <linux/module.h>
2 t# {+ Y' Y/ [1 x7 x#include <linux/kernel.h>
+ P$ U( a. d. y: F+ h#include <linux/types.h> K9 t; Z: F5 B7 S( \$ T
#include <linux/gpio.h>
Q& t# w- }; c" M+ {9 @#include <linux/leds.h>
. K. l g6 s- ?5 I, Q5 b) Z; z" n#include <linux/platform_device.h>' k+ m! H; Z9 f# { z9 t
+ ]& T- [/ } J$ v8 z$ ~4 T% I5 D( o/ [) w6 |#include <asm/mach-types.h>
# B: ?1 f* H5 l# [#include <asm/mach/arch.h>
9 O) u# V# K$ H# W#include <mach/da8xx.h>4 }( r+ t' y4 [+ i% t
#include <mach/mux.h>
6 k: z- x' \. F+ J- d2 A
" i- ]: u' ^% u. z8 p. Q( l4 F }5 ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 y: A' o. g/ r5 Y6 O9 S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! Q; }. v; P" P1 Z% C3 p3 u! C' V9 w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 H" m' o% ~" R0 Q1 p+ y* Z! G3 ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 ~; ^7 S! y# d: p" l$ \$ O# M! T$ r% w( Z" Y
/* assign the tl som board LED-GPIOs*/
1 ^) w) K+ h/ ^, t" s9 \static const short da850_evm_tl_user_led_pins[] = {8 {( B2 X# q3 Z0 ]
/* These pins are definition at <mach/mux.h> file */( V8 ~9 V7 O& ]/ v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ y; H; w0 p$ U ?# \
-1
( [$ O8 }- d$ S, ~& \6 P};& V. `; _9 l9 S. T/ Z
0 a0 a) ~ C9 J6 w, a. _ xstatic struct gpio_led da850_evm_tl_leds[] = {. J. g [* g. [+ L4 J( G
{2 U% E; u- j1 C+ R( t3 q2 r
.active_low = 0,$ F" e) W0 }7 i7 O6 F
.gpio = DA850_USER_LED0,. c! x5 n$ Q( k, b9 V4 y
.name = "user_led0",
7 b5 K+ U0 O" O .default_trigger = "default-on",
. U0 J* P$ o, z% p- h3 V, E },
- B7 x s2 b3 ~$ q" m& P5 c {0 t' m9 H1 `- Q% V! ?
.active_low = 0,
N2 V; e/ F6 A" Y7 ]1 L .gpio = DA850_USER_LED1,2 u/ D8 A0 ~' D7 A5 s
.name = "user_led1",
3 |) n; i5 `! `9 f, b$ i .default_trigger = "default-on", O1 w# ~/ ?% o% N
},
' B3 ^: J+ n( t {
+ W# @$ J5 t6 r. T9 Q .active_low = 0,
5 [2 d& H% F& a! E+ z1 r* {* A7 g .gpio = DA850_USER_LED2,+ L" P- J6 f5 `" B4 q, W9 v, n
.name = "user_led2",
2 e7 O/ o" D4 G# Z7 A' o. d .default_trigger = "default-on",( d7 p0 w0 F, w
},
( [" }( j- u! g1 i0 ` {
& p1 G6 {7 x; @7 e, i5 t: ~+ i .active_low = 0,0 R# p E- J K( Z% `) _( u
.gpio = DA850_USER_LED3,& q+ k" b# k' Z9 G: G6 x
.name = "user_led3",% G; Z4 c7 ~/ i3 M2 W- N' c. @1 l
.default_trigger = "default-on",
' R0 a- v( L/ c7 o },+ f6 f2 x* K0 p7 a
};0 ^) t, n" X3 x- w @
0 Y4 N. X% Z. F" q6 estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% D% r6 [# [+ g4 J/ v$ r .leds = da850_evm_tl_leds,
2 x' f0 c6 v; F- e t6 y% \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; C7 n6 T' ?! U% p, y};
/ y1 W# @% V9 P$ K" C: f- k n6 @3 n% D) u2 z! A
static void led_dev_release(struct device *dev)/ S' z& |* M+ P) y: f
{+ l8 P) o: y" E
};
' q7 S" I1 {$ c! z
0 w3 _& Q- U8 W2 K6 y3 a8 Hstatic struct platform_device da850_evm_tl_leds_device = {
% q* \# Z' r6 C+ Z$ A1 \9 } .name = "leds-gpio",/ S8 }4 Y0 r# M; ]$ R: k8 P
.id = 1,4 z3 v. g3 |8 r9 G
.dev = {
/ ]# \" h3 y. h; v, C .platform_data = &da850_evm_tl_leds_pdata,
% U3 o+ V2 o2 C" J( K7 P) x- p .release = led_dev_release,
- ]. ?" i6 e8 I1 }( n9 q }: [3 J9 j( r4 l! C
};
7 H- D& x6 z" x- p' E) ~" T) @! U+ O- a& G
static int __init led_platform_init(void)
9 f% `3 p4 Z& R8 J2 ?7 x% Q{! @2 h; q+ r" g
int ret;/ o. l8 i$ i* g s* x) V$ o& \; x
#if 0
4 f- W" v8 W/ _9 L* M+ B5 ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' P* j/ N5 D* B* x* D3 ?' @
if (ret)4 c7 F9 {. E& L- ?5 u. v8 k9 ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") I+ c& H- P8 E
"%d\n", ret);
' k5 y' A" c/ c' k# f8 k# K3 }#endif
% s& {% X0 S/ n. k' Q* V ret = platform_device_register(&da850_evm_tl_leds_device);
/ P: F& z. t# K0 t: {2 f A( } if (ret) G) b% @$ H! s
pr_warning("Could not register som GPIO expander LEDS");
- E' v5 S- U5 N else
9 w" `% b! }2 t5 d" y printk(KERN_INFO "LED register sucessful!\n");
5 C$ Z) C7 A* g3 H9 u' k) |( |4 @7 C) [4 T
return ret;
& Q5 J7 v0 {+ _ L" V1 v}
5 z4 W0 m; ^8 w) D, O6 b3 {! x0 [
static void __exit led_platform_exit(void)8 S n0 H. p! H# ?
{, I+ p9 f a; @. F2 S N
platform_device_unregister(&da850_evm_tl_leds_device);, X m/ I* |3 i1 o) q# g# u
9 g) V7 s" w7 v
printk(KERN_INFO "LED unregister!\n");, w+ p8 r) R. L$ F
}
( i+ N5 X3 o: \+ G6 u* R. X% \7 r1 P% ]4 M. I7 E+ r
module_init(led_platform_init);1 `7 |. W: G$ e8 V, Q& y% o
module_exit(led_platform_exit);
" v; m- k5 f3 M1 Q" V& p" k6 {1 P2 l4 L$ I
MODULE_DESCRIPTION("Led platform driver");1 a2 W* ~2 M4 J- ~9 M7 [5 ^7 n
MODULE_AUTHOR("Tronlong");& O+ n- @$ J/ b2 S0 |4 a3 y0 O
MODULE_LICENSE("GPL");% A7 ]. V9 Z" n; C- ~; v
6 D' l1 t8 v' j# l. y8 v& E0 G
|
|