|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' V5 _" G; @6 g) j( a
#include <linux/init.h>
. ~* q! b( i' P& [4 K+ W4 U- n3 f#include <linux/module.h>
7 V! m5 g) u; C ^" U+ V9 a#include <linux/kernel.h>) U1 b* g$ e5 H; p3 [$ G
#include <linux/types.h>' J+ ~+ a" R3 w
#include <linux/gpio.h># Q# T x/ R$ `& M$ C
#include <linux/leds.h>, X4 F% u# f, K- H" K
#include <linux/platform_device.h>" Y$ S7 O" j2 s) u L
7 O/ ]! J8 K1 g9 R
#include <asm/mach-types.h>6 F4 B* Y# o0 o. q. `- V
#include <asm/mach/arch.h>; s6 Z# v) U! C% [" s
#include <mach/da8xx.h>
# s% g: s* U) N$ \5 `0 E#include <mach/mux.h>
5 M8 ^5 ^; g, N& O, ? j- Q C, z
( ~+ E: x0 N* f. `% y; X b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 Z1 A2 N! G5 M j% c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" p. e& j0 |0 r m- W# s- I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 l( @/ E3 e: c9 R) p2 A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ j4 y4 s! t# u" X! w. e1 K7 e
& l0 ^- G. f- `1 a4 q& ~/* assign the tl som board LED-GPIOs*/: W; ^1 J9 x0 j9 V7 c
static const short da850_evm_tl_user_led_pins[] = {8 [- G, B, C, x! F
/* These pins are definition at <mach/mux.h> file */
6 u' G, n2 o, ]0 Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 M. v5 u$ U0 m. l. t3 ]6 ?
-19 I3 ?! J" W3 X. v8 h
};- @0 X6 n+ H5 e2 w) t
1 H& `9 V' E9 S+ |3 w' ?
static struct gpio_led da850_evm_tl_leds[] = {
! f1 z+ _. B$ \6 M+ u5 S {; q9 ^; [# U$ c2 y$ l7 _+ l! m8 T
.active_low = 0,1 p. V7 q/ l2 O5 S; g6 B$ L
.gpio = DA850_USER_LED0,# i3 m' C8 w5 C: m* V
.name = "user_led0",
1 S( g8 d" M5 D6 i .default_trigger = "default-on",
4 i2 }( f3 ?5 ]! h. _ },5 a8 ^; x5 C* d) X2 V0 t
{, ^, r! u3 @- \5 G
.active_low = 0,, K- C% e$ F& W
.gpio = DA850_USER_LED1,) z. ~; _/ D, w, U: f3 R
.name = "user_led1",/ ]; x9 v& B5 Y: d; ?
.default_trigger = "default-on",8 L" J$ Z* v) C, L H* d, l
},
1 _/ T9 @& ^; }' R2 d {
* x' H3 d. J' V .active_low = 0,* ?, t( {. e, }5 ~5 R E) T
.gpio = DA850_USER_LED2,
7 f( F: k. C% O .name = "user_led2",
6 n) n$ W0 x) D) }( k" U .default_trigger = "default-on",
( D6 C- i0 G& U* ?/ m- U: U },
( P5 n( m5 c7 K4 Q4 n {) ^1 r; k0 a' n0 G4 N
.active_low = 0,
( O4 m* J. d4 P .gpio = DA850_USER_LED3,9 H6 L; C5 b" N+ c4 t0 I i7 P
.name = "user_led3",) I7 a8 B$ k' X! J
.default_trigger = "default-on",# b3 [/ S: ~ @5 _
},
/ s+ J: |/ R0 N: _2 `4 w9 a, F};
$ {0 Q3 ]9 v7 I Z- a6 P1 w: ?! _/ H7 |( Z% o. U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- S6 s6 m* ]* B: l+ W" |
.leds = da850_evm_tl_leds,$ \; o1 I, T: {! E' _6 w
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) R8 y2 }$ I# N0 N4 y! }' U+ L1 E};" N s6 A- f- g5 d( Z$ ^
/ F$ M0 ~$ l h1 T0 }static void led_dev_release(struct device *dev)- l6 W" C; q9 U% @
{
% H ^1 @5 J, d2 u! q$ G* |};% U/ j4 U8 S3 g
3 \% L2 r5 h Y4 B* v8 p, Hstatic struct platform_device da850_evm_tl_leds_device = {
; ~ E& V$ N6 i1 c/ @4 e, R .name = "leds-gpio",, B6 ?( G' @, ?% |& U
.id = 1,1 U- t6 l: P7 @: P# a' [7 ?) \
.dev = {
, e) s9 F# u" E3 E+ u0 w* V .platform_data = &da850_evm_tl_leds_pdata,
- t! [$ L% t$ S .release = led_dev_release,- W3 d: X) t2 T, a% ?% A' a' X7 u
}5 t3 h8 o0 F* p' O+ t7 @
};% \+ |7 H3 R, A* t
/ g$ l' i! r8 bstatic int __init led_platform_init(void)" m/ _8 s' T! q" B
{& ]/ M U$ ]4 n6 y2 \
int ret;3 }; }0 n( |9 J
#if 0
0 D) `4 `! X, j' J- Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ [' J. s6 F8 K2 G0 f& t if (ret); C3 l& F4 w) i1 u" J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 f4 a9 ?9 B1 k3 B "%d\n", ret);/ V: W4 I% x* N0 `, B* F6 \2 u/ y
#endif; e/ \2 u" S8 W$ l
ret = platform_device_register(&da850_evm_tl_leds_device);( `# W' S/ |& G. J! x4 X
if (ret). N! y; U" _$ n" l- ?* r
pr_warning("Could not register som GPIO expander LEDS");9 y2 B( x& b9 j' O
else4 |( t$ \& e' ^1 c% u/ a
printk(KERN_INFO "LED register sucessful!\n");1 S% k8 Q" [/ Y2 G2 o, t
" D9 t1 M- @# b* z return ret;
V$ J/ l" b2 H3 [2 b8 N}4 ?5 H: m* }/ U6 ~# B
+ J& o- }) f" K+ X1 k5 Sstatic void __exit led_platform_exit(void)( g$ N, s6 o% ^ [7 Z
{
: J/ s; h3 T" B# y2 u+ w platform_device_unregister(&da850_evm_tl_leds_device);, S) X7 s {9 G, k
/ d( b( ]2 B% h* J; I8 ^1 Z# h printk(KERN_INFO "LED unregister!\n");0 z8 j# p1 y7 D9 L
}1 i" W& d4 o" K4 e
4 ?3 }) n( {$ x6 U2 T( hmodule_init(led_platform_init);
% b w7 L; Q' f) M% c: I5 t) N, a. qmodule_exit(led_platform_exit);# |6 V2 k o) K+ U2 g* W- h
8 f, O: j. P# ~0 o/ z8 c) AMODULE_DESCRIPTION("Led platform driver");
5 @# v. N6 L; O9 O5 kMODULE_AUTHOR("Tronlong");
* y& K5 F3 w9 {9 ~0 ^. z7 p7 wMODULE_LICENSE("GPL");
6 S% d, E$ f! y4 P) v) C9 D" o! M/ G. w4 f
|
|