|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 W. B: b; O! R4 s! J: U/ b#include <linux/init.h>( w, W# ^8 o* |' V
#include <linux/module.h>- b( P& \6 y- T! C) C- l3 M
#include <linux/kernel.h>
; M7 V! v& O* \) ~* c/ y#include <linux/types.h>
* n# }2 E8 P9 ]9 A2 l, `#include <linux/gpio.h>$ B- r3 f) t+ U7 b$ N% q( \! z
#include <linux/leds.h>5 w) w7 N5 e/ Z( d& r! Z
#include <linux/platform_device.h>" C8 Y( r% r P* E" ^
2 m. O4 _! b' T! r
#include <asm/mach-types.h>% ^- _0 |7 \3 @1 E0 M1 A
#include <asm/mach/arch.h>+ A( p0 a# V. F1 @. a: ?# h& I9 h
#include <mach/da8xx.h>
0 u6 ^$ G: W) I) B- i* Y#include <mach/mux.h>* V8 v! k7 P7 l/ C+ R! K$ _
! j& Y' [; U- O( S1 K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 e# W) d% B ~. d. y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) n' P r# I# C
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). L/ c; u6 n7 F. ^0 [7 T$ A) F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
x& I( X# ~; S& s9 a) L( @
+ b' i3 h) h4 R2 I7 Q ]/* assign the tl som board LED-GPIOs*/
9 f6 u) g |! G2 [static const short da850_evm_tl_user_led_pins[] = {
+ l3 Z6 ?4 @4 T1 A- Y4 F( r- } /* These pins are definition at <mach/mux.h> file */
% n+ d1 P- M$ x) Q }, X8 @9 o+ r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 W* { ]( T; z -19 e' p9 X5 g( G: Z- T4 u
};
$ i7 N3 b4 F+ e2 @0 q( ~; b2 E7 k6 ]& s& f, T ?, Q
static struct gpio_led da850_evm_tl_leds[] = {
2 I- q T) ?1 K* U' E8 L/ }' b& X5 @ {* B2 X! i9 w( t0 b& N+ m. E
.active_low = 0,
7 z# a- Z9 n! q V7 m. q& K .gpio = DA850_USER_LED0,
5 k5 K( U3 Q$ w/ { \ r .name = "user_led0",
" m* K4 x+ M' ]; J8 U' t" H .default_trigger = "default-on",
Q- {* t' y) l$ |8 g8 u2 i },: }; }; p5 k8 T; G- {4 O+ z* q; I
{1 o( c" f" ~$ ^
.active_low = 0, f P D% m& u. g$ [
.gpio = DA850_USER_LED1,! o+ p2 M2 M8 r& v X9 {
.name = "user_led1",* v/ R" `( r6 \
.default_trigger = "default-on",
# K4 p8 B n! s z# q& ] },! G( U b5 u: O( ~/ E, i5 l
{0 {, u6 I; O" M! ?* ?
.active_low = 0,+ r/ `4 Y5 G( z" D, c, E
.gpio = DA850_USER_LED2,
* c- x( D0 S: S9 A/ d .name = "user_led2",0 z2 e! f) ^7 F2 |9 P
.default_trigger = "default-on",
7 }9 n- b; }8 u ?: S },
; U" F0 D& A' H, p {
! }! d2 `4 ^1 f .active_low = 0,' R1 t9 o. N. D8 X/ p3 s
.gpio = DA850_USER_LED3,7 V/ i1 Z! Q7 h, i5 V, `
.name = "user_led3",
8 L2 p$ I' V, b9 Q3 Q .default_trigger = "default-on",
7 l" Z- C0 i( A( \# f1 k },
/ N! v0 @) B! w. N};, D: O# p( r& W4 p0 t' K' d
& C! E% q5 { w' L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, j9 X8 M% \" Y( D! B6 e .leds = da850_evm_tl_leds,6 \+ { b, l9 y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ s1 G( r1 L4 f) b5 t5 i
};% V- x$ ?1 Q* g; ?/ i2 k; T/ T
, c }% x7 I7 P5 o2 U7 Vstatic void led_dev_release(struct device *dev)) K9 t3 a( V, S; w. _7 i
{$ [" @0 u1 d: K k2 R. u
};6 T4 b: _7 h4 f% P
7 B: R7 j8 j3 I/ y2 r* j# _, v- @! J3 ]static struct platform_device da850_evm_tl_leds_device = {
$ y; Z! o5 S& y4 l9 m/ h* n .name = "leds-gpio",' n( O! E1 a3 X
.id = 1,6 ^- x; k; R1 |. c! K J6 r
.dev = {+ Q" w9 x1 o' M! E
.platform_data = &da850_evm_tl_leds_pdata,
! W4 X$ C8 O' z; p5 q5 g) M: v .release = led_dev_release,) @; G& p& E* h8 H' m* |
}# K7 e0 y9 ?; ?" G6 y! I
};6 u$ ^) K3 f1 F1 v; h
+ O7 n9 r! V! b
static int __init led_platform_init(void): b3 t6 g4 ~5 o/ C$ |, ^$ j5 G( z
{
0 D7 t0 @3 @; I& K0 }* F( t int ret;
* m) {$ P) h `9 y8 u1 `/ _#if 0( {4 ~$ k+ d' D6 k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ Y" }* g: V* B4 m; F
if (ret)! S! i& S! `: c4 [9 W' ], W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
E+ Y5 m( o' h, h v& L L9 p "%d\n", ret);
4 H0 g7 a1 ?5 O5 Z4 q0 z! M#endif
, l* r5 Y+ A( K% F8 ?: O% Y ret = platform_device_register(&da850_evm_tl_leds_device);9 P H8 D% @4 G0 J
if (ret)
4 d( g* f* _: j9 s' f0 [ pr_warning("Could not register som GPIO expander LEDS");6 Q$ ^7 |; F% n) Z
else {; M$ r7 e. O/ p
printk(KERN_INFO "LED register sucessful!\n");7 M- |$ H6 [" S" M& F! A
3 D7 Z- U" S7 x9 w) D: h5 z
return ret;4 g. D4 M( m; X" P1 Q
}# B& V! W. o3 C5 H- J3 V' r
: S4 J+ o4 Q; L) c; R7 z! v
static void __exit led_platform_exit(void)
) [3 A' ~6 u, q5 \; d, v{
5 k* n, W. y0 \3 }, u. b platform_device_unregister(&da850_evm_tl_leds_device);
1 ~* x" r, n3 l E1 L% s1 h1 j( h
2 g8 _6 S( B" F3 b/ v6 u: N printk(KERN_INFO "LED unregister!\n");
% ?+ Y+ c2 S* A- s9 ]}
; m4 R, p5 g! R3 g m
6 [' Q8 _2 P+ {. U- ymodule_init(led_platform_init);
' O9 b, K, c3 } \5 zmodule_exit(led_platform_exit);# B( f, n. @. J# n
% C b0 C' |* oMODULE_DESCRIPTION("Led platform driver");. }# ~/ \3 t+ c1 @% [2 k* o! Z' S
MODULE_AUTHOR("Tronlong");
* Z' d) y4 O# W: f. Z0 h/ k9 wMODULE_LICENSE("GPL");" @2 U7 o) M5 b R8 d. h
$ d- U' u) q6 s
|
|