|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ `: e- z% @: g#include <linux/init.h>" e0 O5 M6 Z5 j" D
#include <linux/module.h>* @2 P3 z* H8 z' C6 L
#include <linux/kernel.h>
. Q3 ^- t, u% G! z R0 w#include <linux/types.h>
" k4 b' z$ A0 ]9 n. T( w5 A#include <linux/gpio.h>
* L- k& q! _$ t" E9 a#include <linux/leds.h>' c- r# M1 ~5 |4 k* T. t5 b
#include <linux/platform_device.h>
/ x' g+ F. e- l% a) p6 { L# |
1 P4 I8 d- T7 f0 Z/ \1 I3 _#include <asm/mach-types.h>
! f5 M0 n, i8 S9 v! K5 S6 _+ z#include <asm/mach/arch.h>
8 l1 Z9 b8 Y+ ?) d: g#include <mach/da8xx.h>
4 T% L9 z# A: n4 C, _#include <mach/mux.h>
: ^2 P7 Z+ G# w+ T
( F* o6 d; S' h0 p- O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 j- C6 J: `9 U; I& e& G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
j+ B* k+ D* W( @; G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& a$ L r J$ ^- p4 g) }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) F: b6 K+ U- R) H
6 H9 O, q5 l3 V- Q2 q3 Q$ U
/* assign the tl som board LED-GPIOs*/
2 N: H" ~2 ?4 ]) wstatic const short da850_evm_tl_user_led_pins[] = {2 n' `: Q& [& ~; W
/* These pins are definition at <mach/mux.h> file */
i* A6 ] E9 {/ ]3 u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
h" ^& D7 U0 |& ?( z -1
2 ?+ g6 Y) `5 p- h% U" _};& D5 {7 ~5 q d9 }3 v( C3 |
4 ]# P/ c1 z ~ Y! _
static struct gpio_led da850_evm_tl_leds[] = {
7 D7 _$ h" U$ {/ P1 q6 W {
, l5 m, G3 W& Z. j q; O5 o .active_low = 0,
3 }4 j" C8 Y$ u" N: j! e4 X& U .gpio = DA850_USER_LED0,
# S9 E& @) z: h .name = "user_led0", n' k. O( A$ H- A
.default_trigger = "default-on",( L0 L* |$ g- _9 P# p0 v8 u9 S: Y' M
},
7 R- u$ p+ f! e% N J {
* N8 e G S/ n" r+ _8 Y8 f" ? .active_low = 0,* v/ r }0 C2 }) t5 ~) b
.gpio = DA850_USER_LED1,
" [8 J' D9 C* c8 s5 q: P .name = "user_led1"," W0 l1 S. a3 J' b0 U
.default_trigger = "default-on",/ h& N% @8 t$ S! G, N% m1 t
},! S3 B4 v: B; |" Q
{
0 t1 N$ E. L1 z( ?2 L' B% t* Z .active_low = 0,& T1 l/ C, b- [* K9 \! b; f
.gpio = DA850_USER_LED2,# D [9 G/ B z `& P$ x
.name = "user_led2",
- V! [2 e M" Y# `; P8 S8 k4 t- S .default_trigger = "default-on",
5 m) C$ [- b* t3 d& z& p, r% g! f },
+ o* ?" {6 C |0 h {
. j2 @% p' W4 c7 n .active_low = 0,
& ^* h" C) ^$ W. q; m .gpio = DA850_USER_LED3,
+ X' `& T" {9 @; _5 z .name = "user_led3",
" W U! ^+ ~* p. T4 Z& n .default_trigger = "default-on",
7 G% y2 U) h. ^) I% E- M },
6 e. Y- c& V! ?# o};
8 o7 O2 U, M' l _( M& L: y8 [
M3 g: g, ]# p+ m3 r& S2 g: gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) l' t! @ x0 J
.leds = da850_evm_tl_leds,
u7 n! [9 j) E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' B; V J0 ^2 T5 D! G5 G9 t
};
7 `" u% O9 Z! j( o$ K, n( Q, Y. \0 D) U+ ?
static void led_dev_release(struct device *dev)( }9 Z- X0 ?8 ]
{
, y: P9 z1 h& S t4 N( ^- M ^, b};
7 x7 C7 B* K$ q- N
8 W0 U- @2 \$ {' w. Vstatic struct platform_device da850_evm_tl_leds_device = {% X+ W6 C) |/ @! ^6 C g% ]0 X
.name = "leds-gpio",
3 Y ~) ~9 ~. O) G .id = 1,+ o/ I& W6 w: A7 {2 \
.dev = {
$ Z% H+ K2 K: C0 D5 q' G- r .platform_data = &da850_evm_tl_leds_pdata,) K2 g1 r0 ~) N) f7 x
.release = led_dev_release,. j4 [5 O" t/ C! w
}7 E2 A0 I( E5 \3 |! |+ ~
};
- F1 J+ D- W9 |3 h0 n* i
. M* k# u t; v' b: }8 g9 _, Astatic int __init led_platform_init(void)
0 K3 ]! h* P0 N) D0 m9 M# W{0 Y8 _6 @( U& o" e# H3 A! J' M
int ret;: E2 p I2 m) Y C9 `
#if 0! I( K5 v' W* }0 J! G" x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 D1 x7 L8 S3 i4 ?( T6 M i* N
if (ret)5 n* A3 L1 F7 v5 Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 P- H2 B2 }) g8 n E7 t2 ^8 n: Q* ^ "%d\n", ret);# A* K. g }" u. k8 Q5 d( W# `/ B
#endif
8 C# i8 O3 u1 E ret = platform_device_register(&da850_evm_tl_leds_device);
. }3 _4 @' }7 \6 Q if (ret)
# y2 [) g* ^1 I6 U; O pr_warning("Could not register som GPIO expander LEDS");% U6 a9 H+ O" h" q" U8 W
else+ z4 |0 p, L7 E/ k( `* c. _
printk(KERN_INFO "LED register sucessful!\n");, j" [* X5 Z/ H" ?
1 g1 h- D$ O$ q+ w" o return ret;
' u4 C: I; J! f2 [9 `}
& k- Z3 W0 L1 U! X9 L1 U2 b: U' n
8 Z/ g' ^5 ~+ a1 ?static void __exit led_platform_exit(void); m2 E. k9 m3 Y0 y- Z
{3 F; g9 a1 J8 f1 T. ^5 L* g+ a- O+ t
platform_device_unregister(&da850_evm_tl_leds_device);) C9 H# M, m$ C/ F
8 {9 D: N$ Z# A) t1 w! f2 G5 N
printk(KERN_INFO "LED unregister!\n");3 |" R( _6 T( y+ [' r
}0 e N1 S( U. y- `$ r; t" c2 X; P
7 X" k( d/ s6 Z" I8 i8 l
module_init(led_platform_init);
1 T: a* d0 p# q- w. h! X+ Bmodule_exit(led_platform_exit);. h, d6 _4 O1 i: K2 \% p( W) b9 h$ w
- V& c. z7 `4 O9 a
MODULE_DESCRIPTION("Led platform driver");
2 g, v* h5 g- y# @MODULE_AUTHOR("Tronlong");: Z& f; [ \- z- I9 y O# N) n
MODULE_LICENSE("GPL");9 G7 } Z1 U( V; R( z# R
7 D7 _ W! j, t/ b7 h |
|