|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 h2 U% |; D2 |! ^! l1 {#include <linux/init.h>
! p6 B$ c+ L/ R& k2 T4 f#include <linux/module.h>
$ W& A9 L) w& N1 {& _7 k#include <linux/kernel.h>
3 H) U/ A/ ]0 W u' u! q#include <linux/types.h> p4 c8 t! A1 K5 ]
#include <linux/gpio.h>( D1 w9 s: {. w. a5 k; M& H
#include <linux/leds.h>$ \& l) H2 ~5 J) l0 i
#include <linux/platform_device.h>
5 b1 F9 k1 Y- M9 n: D, U, p2 T1 x7 n/ K4 ~3 m
#include <asm/mach-types.h>
$ a( o2 q3 a) a#include <asm/mach/arch.h>
3 J1 g5 v, O# g& G#include <mach/da8xx.h>- q0 W9 e0 b* q- m4 r1 K& a
#include <mach/mux.h>( N9 n- r: V- U# k9 _/ w* E
e3 p+ [& g0 `$ k3 x) T k0 y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 G0 ^! e+ R7 ~) y6 f8 B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' G- ]7 L6 j- \7 m: K: r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: L$ w0 ~4 H& |8 G( F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ X" l" K- q1 _+ g- |, n4 [
1 U; G- D# F- l7 ~/ W0 {/* assign the tl som board LED-GPIOs*/4 i* _3 S4 K3 l' Q/ M& i
static const short da850_evm_tl_user_led_pins[] = {
; ]. F- F7 g- _6 |; s/ ~$ Q /* These pins are definition at <mach/mux.h> file */- G2 n+ E. w+ [3 t2 o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 S" o' l x* Y4 U- P! {* y' Q5 t
-1
. E. ^0 N ^" S0 r& K; M};
: g" n* d. V4 D
' ]! v( }/ v# g+ n+ h- lstatic struct gpio_led da850_evm_tl_leds[] = {4 ~. x- \: P$ w/ l8 a
{
3 }- r/ L/ r1 u- h8 i) ]% a: } .active_low = 0,
4 S7 J1 G, W) M' i. J7 \7 J! r .gpio = DA850_USER_LED0,
4 W) q& g/ v! j! o- a! j0 _6 } .name = "user_led0",
_8 P6 ?8 t2 u" e+ U1 ` .default_trigger = "default-on",
) p! R% h% ~$ G3 y5 L. | },7 I0 T; T7 b. j' K/ C
{2 @3 |' c+ ~0 C: `/ L% ^1 t+ D/ Z# n
.active_low = 0,
- U; v9 ~6 z2 Q$ g; J .gpio = DA850_USER_LED1,5 D5 u# n0 |5 C+ U1 b, Q
.name = "user_led1",
. f0 B/ w4 h; }; W) E8 n .default_trigger = "default-on",
a" X! B5 A7 r },3 V1 B, ~/ t7 ~. X6 ~/ M) M
{, r- W( A0 B! |* @5 }. \' K
.active_low = 0,
9 Q; z0 \! x; x0 G" m .gpio = DA850_USER_LED2,
% T4 ]/ O: R2 S7 Q) T .name = "user_led2",$ I* x: ^4 r: A2 P4 V
.default_trigger = "default-on",
8 l' l8 ^% j) p4 N },
# V+ I* A- c& `# m: N {
* {0 y9 {. s+ J8 B: o( Z0 W& S7 \ .active_low = 0,
3 Y' i0 [* d. k .gpio = DA850_USER_LED3,
$ k4 E2 @ z; ?8 T/ y .name = "user_led3",. Z# b6 m* E' I0 A- u! Y9 a# Z! o: [
.default_trigger = "default-on",
& b' ]" o+ C% [ },# c/ G- M# t; [3 L) j* W
};! P, P) e. i' M# P
* W5 A4 O3 s5 M1 ^" @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: _6 Z5 G; {6 R$ O* |. {
.leds = da850_evm_tl_leds,
% O) t+ g" X" B! P% k, F9 j5 M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 D I3 C h- @* m3 B$ [};
1 ?( }( h/ D _) ?* }( n* \
& K8 U( M! n0 Y* o( u+ @static void led_dev_release(struct device *dev)
9 B/ R( D: O: T& i/ `* t, _+ O4 x{3 x. n% ]# r+ F, K
};& m1 X1 t- Z( ~2 v
\# y3 q( `* N% \! r' V1 A( ]static struct platform_device da850_evm_tl_leds_device = {
p U' t4 h! `8 u4 S+ ] .name = "leds-gpio",
" b- ], ~! d' _7 R4 b1 Y .id = 1,
0 ]$ p* Q2 e( R+ ]) H .dev = {3 R, V5 L" ^7 ]% ?. M6 _* q8 r$ L
.platform_data = &da850_evm_tl_leds_pdata,: [ U( i: K- w A' I: M
.release = led_dev_release,
% S) w$ l' Q: t }
- H5 w# p- T0 J) D9 g! G};' S2 P9 W4 n; K# {# t( { g" u
6 b7 d9 x |2 B1 i% mstatic int __init led_platform_init(void)
' G( l" A* |) Q/ l/ [{; }8 E$ O$ Z% P. B8 x4 K5 U
int ret;3 U; e6 o& g, @9 W+ G5 P
#if 0
% p. t& X+ z$ r1 Y- {. @ [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 d) K- J+ ]5 T9 d
if (ret)6 i# d9 V. N6 W$ E) A6 A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 R8 b( K8 W& ]* H# | "%d\n", ret);
3 U* a# e$ Q, L5 z7 d: G3 q# |/ l( s#endif' Q) t! e& R1 ?. B
ret = platform_device_register(&da850_evm_tl_leds_device);
1 h. c6 i: q3 _ if (ret); \4 E+ Z0 o1 B+ P$ b) J4 _
pr_warning("Could not register som GPIO expander LEDS");
' D2 ?4 X5 d2 R. ? else: H @5 L5 s# u- @( G9 z. Y
printk(KERN_INFO "LED register sucessful!\n");
$ C% Z) Z. x& e0 E
- @) d0 x _# }( G return ret;+ G; e/ I6 }1 o6 q1 I9 Q
}/ d. I- s; T2 ^6 {8 N
8 T' o4 F% t# h4 E' i# Z& h
static void __exit led_platform_exit(void)5 v& F% X- Z: P+ v5 _% w
{
/ o( P3 r8 y1 q, }5 |/ ^4 t platform_device_unregister(&da850_evm_tl_leds_device);( t: M' \9 T. N0 n. l
7 p- E5 O" |, X' R) _- |
printk(KERN_INFO "LED unregister!\n");: b a$ k, }: R
}
2 u2 ?5 G# k/ E7 }, ]7 [. Y B/ G* O; p7 t# ~
module_init(led_platform_init);
" T7 v- O. }2 L( Y3 i' ]module_exit(led_platform_exit);' n, E) p7 h' W8 H5 }7 Q# }
% v! Q; y( S9 k' N" B# A
MODULE_DESCRIPTION("Led platform driver");
3 z p4 W4 p5 S# c1 zMODULE_AUTHOR("Tronlong");
$ K' p3 {1 p n5 x8 MMODULE_LICENSE("GPL");
- J% K0 M8 Q _& j4 b9 L, W
3 Z5 C% T3 B5 V |
|