|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& g4 e. y9 U/ A0 o" F4 R" C
#include <linux/init.h>
1 h% Z- Z, X4 c/ v6 |+ E' B6 z2 d2 Z#include <linux/module.h>2 F5 H( H, P3 Q. `
#include <linux/kernel.h>' S6 Y# l, e% b- B5 J/ E
#include <linux/types.h>: f, }; \1 X( t& x! o n2 E1 f
#include <linux/gpio.h>- U% L$ T9 b: d& I
#include <linux/leds.h>
: f0 A( b2 M- E' [% G/ O% i#include <linux/platform_device.h>6 F$ C0 d& v. B. s( u
6 f( l( q/ @$ @4 p4 n& Q
#include <asm/mach-types.h>
6 {! a( `+ N. r#include <asm/mach/arch.h>
5 j3 B1 d8 y# _#include <mach/da8xx.h>5 O% T j/ J j/ Q! F
#include <mach/mux.h>9 h1 q6 c0 x L4 O7 W
* `4 i" {$ ?5 A# B9 V! v) y2 n$ O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 ^. P. W: x) t ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- x7 H: u Q* f9 m) b/ R( P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# O: ~2 D; U0 p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 j2 s! Q+ K" d. z9 c- d
- O2 t5 D/ A% o/* assign the tl som board LED-GPIOs*/
1 V5 A# O u) c) ^; @% Z- Z% N! \static const short da850_evm_tl_user_led_pins[] = {8 h6 A5 z1 @, I6 V
/* These pins are definition at <mach/mux.h> file */5 s5 {8 D" J* n% h( N! \7 y4 q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% r' B# ^% O+ r, m/ k& E- n. @5 J
-1+ V" C2 o9 B* h
};
$ u: h, D$ f& n6 G; J0 g* I( A1 m2 O ?8 A
static struct gpio_led da850_evm_tl_leds[] = {; R; z3 ~$ v* |
{
/ _8 A9 x3 b7 G1 X9 S .active_low = 0,1 y3 {2 P. M5 t5 I, W+ {: C
.gpio = DA850_USER_LED0,
2 z6 w/ {/ X( ] C( b. \' b/ K# B .name = "user_led0",
5 W2 C( q0 n$ G% M1 ]; Q; X( K P: Q .default_trigger = "default-on",% ~* B) P4 O- z i% B' w, l
},
) P4 u# v! A. C$ ?+ k. U0 `/ V {
: }+ l/ \2 ?# n( u& W* G2 t .active_low = 0,
/ M7 S9 F7 r# F8 d0 h, T, k+ j .gpio = DA850_USER_LED1,
- g4 U. s* N+ \6 e# D) R7 L .name = "user_led1",) X; s% {/ l% y( F4 P
.default_trigger = "default-on",' n/ W; |) c$ m+ o, F6 `
},& r% P9 x* D$ C4 o2 S
{
" n; T" v8 v0 o- V4 e6 n/ ? .active_low = 0,/ F: q) L! W: t- P/ ]4 M
.gpio = DA850_USER_LED2,
/ V* J6 M. ~9 T .name = "user_led2",
' z! X8 N5 B% F; n3 g .default_trigger = "default-on", a( |8 Z1 k4 B; j) N& o! ]' j
}, ?) I) j0 i" @: R3 ]( j! p& b. i
{
# I" t/ h. f. y6 _ E7 y w4 ^1 G .active_low = 0,8 C0 u2 o- ^8 H# Z% F# A
.gpio = DA850_USER_LED3,- z O. y' ~ u3 W/ V, j
.name = "user_led3",8 u; ]4 e$ N& u* d
.default_trigger = "default-on",2 N# g+ |1 q0 A; r! Q. `
},
0 h# I% U6 k5 U9 y, b p};
6 G' {, N4 T/ y* b3 C% W9 `0 q- o1 L+ {9 j; f5 x5 x$ N' R4 Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! Q, K# v$ A( w2 ]5 T8 g
.leds = da850_evm_tl_leds,: G8 n* O: |, m$ W. E
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 [, W# @2 u; m! n$ W
};
5 R( B* Z. W6 t7 y- ?& ^! J! K' s/ M& s
static void led_dev_release(struct device *dev)
# E {0 B& P* `$ K{% H q/ l: F# F! b+ o9 c
};' p" R4 r5 [) k* l8 Z
9 q" D+ L. u) c* hstatic struct platform_device da850_evm_tl_leds_device = {6 X' x5 C. w" a
.name = "leds-gpio",3 J V, \5 d l5 ~
.id = 1,$ U9 R0 }* ~) U" \
.dev = {* B" J! P; {( Q: }! m! \6 { I# K
.platform_data = &da850_evm_tl_leds_pdata,
, W0 Q" b! a) n) u" E9 d4 d4 [ .release = led_dev_release,
4 r' g. M8 c* L2 @ }
" f* G/ a* Q9 ]6 D4 j8 M2 M" K};
8 Q5 ~9 Q H- h+ T/ k9 O& S( j1 @$ n" S' c: b/ `
static int __init led_platform_init(void)
- x! C( `, c& b1 j{
, f. F8 j, F% m s4 Q4 m int ret;
% x, @8 H& x' Z% b1 g3 V. q4 z#if 0
0 `' K5 p; Y+ J$ b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! k3 E0 I" K) z if (ret)
8 A7 Y5 a/ `- K4 m4 J pr_warning("da850_evm_tl_leds_init : User LED mux failed :". Z( b2 ?7 g1 b8 h+ k' g6 |7 s
"%d\n", ret);3 [) a% \, M* I& ?
#endif
; C; W1 t# M4 w7 X* m/ s ret = platform_device_register(&da850_evm_tl_leds_device);5 ~* T" G+ \& R& o5 a+ G0 X
if (ret)& E* {& }! |1 c
pr_warning("Could not register som GPIO expander LEDS");
, o; R% C: l7 s1 R else- C0 v$ S6 D7 h8 j4 ]
printk(KERN_INFO "LED register sucessful!\n");2 @$ }( r8 B/ @& B. x: V# B
2 R" @. N/ X0 I0 @$ X& Q4 }6 m
return ret;/ W1 q- J& O% E
}1 n% d1 Q! t! }$ M4 }. U
# U: _) g) Z% }: ^
static void __exit led_platform_exit(void)8 f' i) c& {" r4 m$ y3 y3 V1 \
{* B1 S9 `9 { h* V, G& g7 c
platform_device_unregister(&da850_evm_tl_leds_device);
8 J; e* z+ J% s$ c
+ c9 G0 N V k! m# o+ z i printk(KERN_INFO "LED unregister!\n");
5 t& v1 l5 g1 v& N}8 ~& ]$ _2 C; m' ~# s$ @/ }, S
" C/ a' N3 l2 g; C# D
module_init(led_platform_init);' o( r# |$ Q( v% l, ?# _
module_exit(led_platform_exit);
* @, D9 ?+ b3 t% R4 Q% b9 [5 s J7 E7 {7 ?2 P" l. _0 Z2 `
MODULE_DESCRIPTION("Led platform driver");
8 y' `6 m# p- h" h1 [8 bMODULE_AUTHOR("Tronlong");
5 E8 ]- k# a5 }. B' s: C% @MODULE_LICENSE("GPL");* O, Z3 c1 C/ s* _1 U
$ e: q: \( y" D' J
|
|