|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' n* p5 n( F& E
#include <linux/init.h>
) [5 d9 x( |+ x0 y#include <linux/module.h>6 l" h7 p2 w+ U: W- x) `2 S1 @4 z9 u
#include <linux/kernel.h>+ w0 ]2 a7 M0 ^ e* E* B
#include <linux/types.h>" ^7 `$ @" x& F$ d/ ^- Q
#include <linux/gpio.h>1 n5 B& y D4 O& i+ Y
#include <linux/leds.h>' d1 I5 z' L* D+ p1 {
#include <linux/platform_device.h>
. A# O- {2 ^+ `& r, a0 l9 b
; q3 U: c8 `8 h( b8 }5 }1 E$ v#include <asm/mach-types.h>
7 N% n2 ]2 a- z7 ?#include <asm/mach/arch.h>
3 U+ j, f$ j2 `#include <mach/da8xx.h>
* h9 l+ ^9 u9 x, g#include <mach/mux.h>
3 ^; b; ~5 P$ [8 C+ x
4 q t1 a$ j1 j# ]6 R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* |7 c i2 x: V8 B5 }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 b5 j/ o# k Y; {+ e; z" N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: c% ]' N! f) A7 I/ ^$ v#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 J' J7 s- r! ?" f
" j& v) M0 `/ h3 j% h5 k
/* assign the tl som board LED-GPIOs*/
+ m1 L1 r* b) s1 U! gstatic const short da850_evm_tl_user_led_pins[] = {
( z+ L9 ]+ w$ n5 Y3 Y0 h( I7 D /* These pins are definition at <mach/mux.h> file */% w2 H3 y' t7 f7 U9 d2 k: K8 F. D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 o$ T3 n, Z; ~2 u+ L
-1 t1 C% ` _0 `1 ~/ Q$ W" G8 x
};
# M. j( t) U* L
/ k& G$ e1 Q, d1 nstatic struct gpio_led da850_evm_tl_leds[] = {9 X3 l$ F: c" N0 |6 j2 Y
{1 p4 M3 l; w+ ^; I4 l1 \
.active_low = 0,
' ~7 N- \! c+ q8 I7 x .gpio = DA850_USER_LED0,) B& P+ C1 \% x4 n
.name = "user_led0",
! o3 }0 X! F8 b! c( l8 N" ^( L& ]9 S .default_trigger = "default-on",
6 i6 g; ^7 P1 y% V" t# S* d! P },
4 Q/ M& ~9 }1 d8 G+ B4 i' l4 G {
$ F7 R$ [) h0 c. T) _; V .active_low = 0,. G/ K$ _0 ~' f* t' x, `0 j! Z5 p
.gpio = DA850_USER_LED1,( y$ Y- d$ F; `; }# R1 |, o0 {
.name = "user_led1",
' p. |0 c) t8 k$ f+ e8 E; H0 F .default_trigger = "default-on",; K6 Z. K: @' l) a! v" @
},8 _7 I* A/ Q( A8 k
{
/ {$ [7 o" u/ b8 f6 \( l- ~ .active_low = 0,
6 m- @% l$ t8 Y* l7 @ .gpio = DA850_USER_LED2,
J6 p4 J. @- K+ f; ]% @( s .name = "user_led2",
7 j" z/ w# g2 q: s' p .default_trigger = "default-on",
$ ^; }7 ^ M% z- v1 A },
$ e. F' h: B8 Q {+ a$ Q9 D) v+ v, @- ?
.active_low = 0,
p& R, U r% h4 ~; k9 G, Q+ a .gpio = DA850_USER_LED3, P- v5 ]" E" g& N( v% c
.name = "user_led3",
n* h0 ]* o' c# V: o/ b .default_trigger = "default-on",
+ Q* S% Z! K, s& I4 [ },1 Z# J9 F! X3 z, a( e
};
W1 f$ r/ y9 Q; q T# l" H, P' c5 x3 M8 p5 B* @, V# Y. {2 K3 _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, F' A/ l. L" R; ] .leds = da850_evm_tl_leds,
6 l. y/ l0 A" f0 c" } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# e7 L$ d. a4 N4 M; i2 T3 t};
$ u! o9 ]9 e) e0 y$ j$ {9 {, S* | E) {6 `5 m( h4 q8 n+ W X
static void led_dev_release(struct device *dev)1 m0 N) }) a* c- {' R, z
{
! @, j4 R7 o& \4 ~( K* \};: r9 q; C3 d3 E# N v5 S% O" u, J
: _% D. Y: i2 T' n/ ystatic struct platform_device da850_evm_tl_leds_device = {9 C* |0 O# f& I: T1 X
.name = "leds-gpio",
2 G: M) |8 E, Q" C; N .id = 1,9 h4 G) @8 i+ k+ j
.dev = {4 ^6 @, r: ?! p; U I [3 `
.platform_data = &da850_evm_tl_leds_pdata,
: r5 A, `+ k5 x3 Z1 } .release = led_dev_release,' o, H' K/ ?% A( a' k8 t7 R, P
}: q! N; y; R5 C" [& y& D
}; |9 l5 w) Z8 j* h* S- u5 G& s
: m2 y5 Z) A) M+ U! {: t$ Mstatic int __init led_platform_init(void)
; Z. s l9 k! Y# m$ C! u u- }{0 f E8 r/ G O/ m$ }; z
int ret;2 m* b& l$ U, \ O2 F* j
#if 0' X# Y& t) w% Y8 f8 d2 i6 R: x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ @! M* V: |, @( K: O+ u1 s
if (ret)
) y: Z8 Y8 [1 i+ r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 e6 h, X* W, C+ x: w3 S2 E6 ^! o1 c "%d\n", ret);, J& R$ c k. h" w/ E
#endif
, P# M" Q" Y( x1 y% t5 X ret = platform_device_register(&da850_evm_tl_leds_device);
, }9 O, ?3 a7 u* S( q if (ret)- {. G$ N3 ]4 a' r
pr_warning("Could not register som GPIO expander LEDS");. a$ K7 C6 v( R9 r* r2 M0 V- w
else
' Q$ Q0 D/ g' j3 M printk(KERN_INFO "LED register sucessful!\n");' S- H- o! H7 x7 |8 w6 p
2 E4 V4 O. h" a4 F2 v5 ^
return ret;# [4 q, U; I7 _8 `( S; r9 x+ U
}' _$ s9 h% G7 Q( Z9 A; I
$ F! O8 u) r+ [# v9 E, _' l/ ]static void __exit led_platform_exit(void)4 i9 _; k' Z0 f
{% f+ @: ^8 t4 ~ K
platform_device_unregister(&da850_evm_tl_leds_device);- c6 z2 b! a# B. I" _1 V' G. v
( E# }) y! @( }: [- i- C. U( R printk(KERN_INFO "LED unregister!\n");) y' c4 D$ r9 [. s' I
}
2 \: j9 a. Z6 F' a \
! A _9 W1 N$ c; _9 Fmodule_init(led_platform_init);
- v$ f5 `' X9 |; Qmodule_exit(led_platform_exit);
/ @1 O; l8 Q; s$ f( e0 W- s4 _; I3 m( t; X4 W/ ^) W! L% _. _
MODULE_DESCRIPTION("Led platform driver");/ b& U9 T2 a( v Q8 |( K+ {: X
MODULE_AUTHOR("Tronlong");
6 F5 P% N; l/ R" DMODULE_LICENSE("GPL");
: X n# k2 I8 q3 U% k3 V' w& _7 g: k4 M/ n3 H3 h
|
|