|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 W$ c. L6 Z% `1 m4 y
#include <linux/init.h>' ?% o9 {" I4 }" B, U* D
#include <linux/module.h>
8 V, T- W1 q" L/ v4 Y#include <linux/kernel.h>
7 i0 Y( v9 z/ B#include <linux/types.h>
, ~. F7 x0 ~& `, r1 M- {#include <linux/gpio.h>$ {& g6 s; t# S) V& h$ y" j& [
#include <linux/leds.h>
) U6 L& e. D) u. [#include <linux/platform_device.h>
' {: P0 ^ X2 \8 Z; @9 D* h% w" u9 Z# Z" D0 {
#include <asm/mach-types.h>! r0 U% q- ^! R4 K% @# |) S" Q$ \
#include <asm/mach/arch.h>
. B6 h9 v, h% P#include <mach/da8xx.h>
1 Z4 p7 Q( k* V+ I ~. A6 a, j#include <mach/mux.h>) j4 c% s* Q* _. l4 F5 O
' C2 Q" I2 x" c; N1 ^, U! _5 m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# k: H4 W" L; G! Z( e8 C& o#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; N, R& e# e, m* ~8 H- |; |( \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ S, R# C# v4 d8 x( ?! ~- ?1 ~ b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 G; S: T8 l l( ~& v2 Y
$ L4 e: x( [# \' T, _% Y/* assign the tl som board LED-GPIOs*/
3 A4 T8 l2 V7 J' e! ?, y- Z6 K2 `. }static const short da850_evm_tl_user_led_pins[] = {
$ f, e0 o. M2 ~5 ]* @% J6 m. e /* These pins are definition at <mach/mux.h> file */
& p! @6 l3 J0 z3 ?* r; g- C% ~5 m# F& Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 M6 v/ L. s; P( W8 y& K4 U2 k% t -1
8 O: ^+ q, A5 \* _5 p( k};& w% r9 A! Z" g
' K S+ R1 R0 n7 n" B6 V; ?
static struct gpio_led da850_evm_tl_leds[] = {
( P) i& S# @( s" @/ F, [ {6 \1 D u9 D4 Q" ?+ Q' O
.active_low = 0,
+ C) V; |$ i# ?2 S; K, p% _3 [ .gpio = DA850_USER_LED0,
9 ]$ t) [+ O O; d+ o5 g( n .name = "user_led0",
@( p4 ~: p$ A1 z9 S5 G- q( Z4 J# i .default_trigger = "default-on",
/ D. o- L( o4 [: D1 a, G },
* M* x' x0 x2 e. I3 R0 @ {# O0 s+ ]) w2 r1 k" Z
.active_low = 0,0 |+ Z& W( v7 }+ c$ A" q
.gpio = DA850_USER_LED1,
" P- q8 f4 B# Y7 H l$ z/ H' L$ | .name = "user_led1",+ C( V+ u' R% i( @6 g
.default_trigger = "default-on",+ Q( L* U" G* j% W: q$ ?
},
4 l6 T6 { @8 m {* y9 |% N! ^1 m8 H
.active_low = 0,
$ s" I2 S% m* u3 w .gpio = DA850_USER_LED2,$ y2 p' i' _1 w4 S/ g' s
.name = "user_led2",
. U+ k0 d" p8 [ .default_trigger = "default-on",1 H) ~: G2 |$ X
},9 S" g/ _( _; u9 ]
{3 X: I& x; p& j; K, p* @% ^
.active_low = 0,: ]8 S q8 q. f! l1 K! b+ n& S
.gpio = DA850_USER_LED3,/ Y' _( \) o- R0 [! z3 p* k
.name = "user_led3", y4 x- v( N5 K& I- ]3 u8 o, B
.default_trigger = "default-on",& Q+ W2 `; t! f7 {
},: S- ^2 P/ \$ i/ ?: q
};
+ L. k2 m) y7 B7 L/ _4 q( ?! p4 e
0 \2 ]( U) ?: z+ hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 B$ D$ Q6 A. B$ t
.leds = da850_evm_tl_leds,2 w! [) U3 I1 h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" ~* k4 @! g N};
% e* \' F; e! x3 b
2 ?( z5 _( D% q& w" H+ {5 Cstatic void led_dev_release(struct device *dev), g% x0 J& p6 j, h
{! a6 @+ n: o4 v
};
, s; ]+ _+ q L* ?' E8 ~7 j5 L
/ s) x H# t; l4 Zstatic struct platform_device da850_evm_tl_leds_device = {
# h4 K J$ G A) [. @3 G$ c .name = "leds-gpio",' }; J V1 ?; o! k3 B9 g
.id = 1,
2 D; l8 }! D, D) p% I+ Z/ k# g$ j d .dev = {3 e4 Q) [& F! \* X
.platform_data = &da850_evm_tl_leds_pdata,) c V2 e$ w& e- W! p/ l$ v
.release = led_dev_release,
4 |6 O5 D5 z& p$ e6 ]7 f) D" j; d }% L$ m0 P8 f! F6 i( |# n7 |% E
};
: E" t* S6 A5 @2 R% X; Y @1 S( m P
static int __init led_platform_init(void)
# ~- m& t0 X, a8 Z6 q* N{" h( C0 c$ Y$ ^8 h
int ret;* q) M1 Y: V3 v6 ]8 s6 W6 H
#if 0
, m% A& l2 Z6 m! i8 v: O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 a8 G9 B) k# r2 {' a+ m, Z8 g8 @ if (ret)
0 k9 [# g5 K! L8 A+ q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 M' D8 }* r- R1 s4 V; L, R2 W "%d\n", ret);7 J% [ x& T% i2 h
#endif
8 X- z" w3 m+ N0 s% G0 k' L- V/ p ret = platform_device_register(&da850_evm_tl_leds_device);
$ o3 q2 T# T6 P6 C. t- O if (ret)3 H9 l6 A9 I# M3 n
pr_warning("Could not register som GPIO expander LEDS");
4 C6 p5 d& q& O6 ]" a5 C else
2 K7 S. d. ^1 d0 Z printk(KERN_INFO "LED register sucessful!\n");
9 p9 Z9 E, v4 }: \) e" Z2 _3 y( b. k, I" s( H# d1 N- c2 X p
return ret;
; H1 a; p) Z- A}0 ?: p( c7 ?3 T; j9 Y
/ J6 t/ L1 G" I9 ~" y2 o9 e7 G% B
static void __exit led_platform_exit(void)
- f" ~- x% V4 E! R% w: L3 M# F3 n{7 E8 f2 u A' r- S4 x
platform_device_unregister(&da850_evm_tl_leds_device);
! U4 \6 E: C0 y1 Z6 Y$ w4 Q4 |, D3 R ~
printk(KERN_INFO "LED unregister!\n");7 S0 V8 _5 {) U8 L8 s$ \ K
}
$ y) Z9 w4 L1 A4 U$ \5 t
/ d5 T9 ^0 M) P$ l6 {( Tmodule_init(led_platform_init);
4 x3 E$ s1 f6 |module_exit(led_platform_exit);
. l% r) L3 v Z* b# E
; y3 t# c( m- I! X, {MODULE_DESCRIPTION("Led platform driver");
* U+ M9 z6 ^; z0 YMODULE_AUTHOR("Tronlong");8 {/ Q$ X; B! S
MODULE_LICENSE("GPL");$ a* z( [6 `) B' w. o
8 t: r( R8 G* b$ O$ f3 H
|
|