|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ p1 y7 z; ]' e) e n) h% O
#include <linux/init.h>
$ u' a: E! B0 {( I#include <linux/module.h>6 j7 A$ a# O3 v. j3 T# J# M
#include <linux/kernel.h>
% l! |# X2 S w0 N/ Y#include <linux/types.h>
8 f$ F, k" m0 V#include <linux/gpio.h>9 b `# m& I) K8 N
#include <linux/leds.h>
( t# M8 Z+ [- }2 ~#include <linux/platform_device.h>) P4 S" u$ ]3 w1 J' V7 |
* ~/ Z9 a3 ]+ i1 w4 y" ?+ [
#include <asm/mach-types.h>
& g0 ]. v1 a3 o) m# [#include <asm/mach/arch.h>
* A; i7 N3 m# k, l% t#include <mach/da8xx.h># I1 |5 W. m3 `4 `
#include <mach/mux.h>
" O! z0 E O" e- S& E
1 R& v# L" S$ [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 l: F; [% `4 Q. M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% }3 z. A: N5 T, V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); J* c, o) \: S# }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! \0 }1 P: f5 t" k" J$ x& u7 [) \% P- u2 y( Z
/* assign the tl som board LED-GPIOs*/
[" d, ]5 B; ]+ [) T, p( }static const short da850_evm_tl_user_led_pins[] = {
E) s7 V- X; v3 W$ l. o /* These pins are definition at <mach/mux.h> file */6 i5 G: h' L& x( `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 f) t: m* x! K6 _: L- |! R+ s
-12 x! }6 [& s y8 h0 o+ U& G
};7 m1 p$ R# E! @5 F5 @) \
5 y5 u1 B& i6 m% C3 e0 l: Hstatic struct gpio_led da850_evm_tl_leds[] = {# i) M2 ]# k* `3 W) X
{
- L |4 ?9 A0 N! n8 B7 ~: ] c( o5 i4 C .active_low = 0, i) I$ G4 |' f0 B
.gpio = DA850_USER_LED0,, R; g8 ^3 u {/ w2 o5 s
.name = "user_led0",/ x& A, y3 p5 t1 K
.default_trigger = "default-on",7 ?7 i2 `# N8 t
},
* B: e9 ]% g9 ~% n, O {9 e2 F5 {6 [- M$ h1 g6 Q. b6 m# f0 ~
.active_low = 0,
3 c1 d( Z8 F4 }# |) ` .gpio = DA850_USER_LED1,! K: s0 x7 `$ O( L; n
.name = "user_led1",
+ p' M- q! l5 }& R; G7 m6 @ .default_trigger = "default-on",
6 D3 y8 s: r+ V7 D },$ |! l' m9 _0 r# x
{: n2 q* C9 y! p
.active_low = 0,( j+ w! N$ }; m# K3 C) e4 w$ |
.gpio = DA850_USER_LED2,
5 r# Y2 x7 x- j .name = "user_led2",
$ m9 R- g+ t1 K% } .default_trigger = "default-on",
. x( B. W s1 v% Q/ X% p" X },
& s, I1 [- U$ u4 s- b {# F* p k7 w' I( e% A
.active_low = 0,
- ]# L6 X4 N! ^( z) |. ]. Q& W: h .gpio = DA850_USER_LED3,
( P6 a9 D, \; A5 Z$ K1 Z .name = "user_led3",- ]& w2 I5 H9 T% C5 O$ c# W
.default_trigger = "default-on",
5 z! y/ f3 W) h- J3 p1 @4 q },
* B3 _7 N7 a& `* Y7 ]};8 q7 s! c* T5 p+ a% E* s$ y7 I
& v4 @# W0 m5 A. Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 y6 t$ C b+ V% M* o9 K x
.leds = da850_evm_tl_leds,+ e6 V2 r l5 `1 j% b3 n4 _8 a& T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; a; o! t7 H- }# ?
};& @1 a* P/ K. e, R" {( T: M h1 v& u
: p9 @% W# ` J/ ?
static void led_dev_release(struct device *dev)9 a5 W6 r9 @1 c9 C: |- v
{2 C! m3 W d. W, ~; d
};
( ?8 B# `3 [, |1 S- K
. a" W4 D" ]% G! ~static struct platform_device da850_evm_tl_leds_device = {
3 y# m! u) g$ r .name = "leds-gpio",5 M# j% G) H& Z3 l: T
.id = 1,* J9 `6 I: z9 W' J/ I0 c- f
.dev = {
4 V9 N8 S$ U3 O) _% t .platform_data = &da850_evm_tl_leds_pdata,. G3 L& W" g8 r/ w
.release = led_dev_release,& M; V6 G8 U1 F/ Y6 n
}+ U) Z: N# b2 v6 i! T8 W, n5 I4 N# A
};
5 |" Y! A0 q6 ?# @( d/ @1 |% u) \; P
static int __init led_platform_init(void)
0 B) x4 v5 ~# P* I# a{
, R' ?: }, W! S5 a7 S( a int ret;7 a& t0 ?" ^/ o' v2 s( l+ B* ?) u
#if 0
7 r1 }# S- n, N1 L3 g5 t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ u$ F0 I; c4 X
if (ret)
% m8 Z g5 M* `% i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ ?8 c E: i% y/ s# n) M
"%d\n", ret); `# L/ H7 ^ q% {$ K1 \, w0 M
#endif( |7 ^& D t2 o! n7 y7 y5 O0 h
ret = platform_device_register(&da850_evm_tl_leds_device);
' [5 c9 d1 B/ w9 `( f# k" b8 b if (ret)! w& a$ Q3 W+ h3 z
pr_warning("Could not register som GPIO expander LEDS");1 x1 x7 {' |& Q- ^7 C. ~' {& m' [4 o
else
! R$ a! A" f- ?9 b/ ~ printk(KERN_INFO "LED register sucessful!\n");
2 j( W2 f+ t8 g/ J
3 B, j5 y2 q: S return ret;
* D" W' w7 z! z. `}
- J! _* s% \) @/ ?0 q
- w" E$ }3 \% ?( e* ~" s qstatic void __exit led_platform_exit(void)
, O1 Z& j3 |/ T{
2 C+ I2 n/ ]0 u2 A9 Y* I6 c5 L% H; b platform_device_unregister(&da850_evm_tl_leds_device);8 {: J" B2 n% R9 o! V
% t# f$ a0 d: F- I; d
printk(KERN_INFO "LED unregister!\n");) w1 N2 [! }4 d6 u P; z% p
}
- t2 a8 z5 L0 X4 P$ f( h* Y" f6 P
module_init(led_platform_init);& L, v7 k& U2 t2 v5 w
module_exit(led_platform_exit);
9 N3 r( o( e* m5 j2 l* m: r% {
! P8 z D8 A$ A* ]; n# iMODULE_DESCRIPTION("Led platform driver"); A! i4 k" ]' [; c/ M2 g- `
MODULE_AUTHOR("Tronlong");
9 v Z9 m: N; ^8 qMODULE_LICENSE("GPL");
* Y$ q/ M! L1 B8 _2 D* j+ B2 f1 Y/ G8 w" D% X- Q
|
|