|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 A! B8 a- d" `# H4 j#include <linux/init.h>" m* e# |1 i: N w c
#include <linux/module.h>
7 x: p7 g& {. ?) a% T! K#include <linux/kernel.h>
0 Z! B @# I3 r#include <linux/types.h>
# F' v/ L8 M; p' @3 \) q#include <linux/gpio.h>6 J) i+ ^: M+ A$ e
#include <linux/leds.h>
& C" o2 n6 ^8 J9 C2 H8 k- L- ^#include <linux/platform_device.h>$ @% Q7 }7 n! L
" Q9 d6 `! V% O% Q
#include <asm/mach-types.h>
. c, Y2 x% W- F' @( _2 j+ U4 H#include <asm/mach/arch.h>
- s n+ e, U- ~4 m#include <mach/da8xx.h>
. O9 A! r% o+ C4 k#include <mach/mux.h>
- _2 K3 a% h! k3 Y7 b6 u1 U# E1 y) I' b% f! M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ L: e, i* ^7 l* O1 f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) C" ~! E2 U `% H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 e' n% d7 m- q2 R& l, A+ T, o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 ?5 E9 y$ t, X' S/ {
D' B% [0 e8 t$ h. g5 p/* assign the tl som board LED-GPIOs*/5 P6 o4 `7 L6 F# s( V3 C
static const short da850_evm_tl_user_led_pins[] = {5 O" e* ?. `: M2 @
/* These pins are definition at <mach/mux.h> file */8 z/ [9 K4 k( i8 [7 `# S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 z* e+ `; W8 g7 S& k
-1
) G+ ^* X& H6 e8 b+ O};
8 P- y$ ?, ], o# P+ G8 ^1 o5 u& T. e/ g4 P
static struct gpio_led da850_evm_tl_leds[] = {
9 v1 W1 [) D d2 Y- g+ o {
3 {$ V0 E/ a5 |; g2 J, A .active_low = 0,% y7 N: C8 M8 l7 P: _- G
.gpio = DA850_USER_LED0,
# J, u! @( `# o- b% o" G3 P .name = "user_led0"," B8 f$ ?& v& p: ]% E* H8 p+ R+ f a
.default_trigger = "default-on",
, Z- l7 m- z! |' L$ Q. i. Y },# R) Y* g6 c+ B( |% U* w2 K0 K
{
. o2 ^7 n9 K. q4 b5 q1 F; W/ I .active_low = 0,
( O" U0 t9 N: r$ i .gpio = DA850_USER_LED1,
9 g8 A# L5 ]+ G% w, ~ t! { .name = "user_led1",
* ]- p+ ?! A' }: B! | .default_trigger = "default-on",+ B" T. C" e& S0 {! R
},
# e: `! M/ Z7 a5 l {
" w8 w) n9 p6 f d, V* B" G3 ? .active_low = 0,; ^0 p- A7 c w- B' ^$ O# k& k
.gpio = DA850_USER_LED2,2 y; i4 e* |; O+ f/ Q* _
.name = "user_led2",5 r3 s% t& ^, V" ]; U4 A
.default_trigger = "default-on",' x+ w( a8 y2 D; t
},5 H; m5 g8 X: h) Y( Q3 h
{. T, C% e# g& J. Z) ^7 O. D
.active_low = 0,% |8 ~9 C4 g2 C( P w% d( j
.gpio = DA850_USER_LED3,' t/ r# o$ d/ a% A" _3 c F2 A
.name = "user_led3",' t. n/ K+ Q( W% t$ b& O6 @
.default_trigger = "default-on",
' H1 r+ g0 a, m" X( v },
) ^0 U- f+ _" k9 U};
) Z9 b& x; d! g# T9 l" }3 [; C1 I, H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' m% r7 _4 b3 Q; N
.leds = da850_evm_tl_leds,
* N' O9 z* M* c- M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- X' X* v6 T" z9 e( W/ ~};
% a$ t+ t, k4 o: ~/ ^; I. e4 d, O- b
static void led_dev_release(struct device *dev)
2 ~/ G1 m% S) j3 a6 z{- D; b4 _+ R6 g' ~) X# b
};' `/ N' A$ L3 P8 [
/ K; A3 u: p+ q2 P0 K5 astatic struct platform_device da850_evm_tl_leds_device = {/ [ Q0 T7 x8 H N
.name = "leds-gpio",% G& Z* Z& S' w* U' i
.id = 1,
$ y& S0 ^5 A# g. T( V .dev = {. q2 i5 v7 c8 j4 _$ t
.platform_data = &da850_evm_tl_leds_pdata,
: O: h! F5 \1 u! _; O .release = led_dev_release,$ G# t+ j! W% B2 H) j2 A( \
}
, i0 K, P9 v& y};/ c5 `6 M F7 ~1 g9 y
* R$ d- T* y) j6 Q9 x& |& X5 I
static int __init led_platform_init(void)/ p/ e6 i, P" o) N2 K: q- l
{) i* x6 D9 V* V6 Z8 ^% B; s
int ret;, a. ]8 k/ a }1 E, k- t
#if 04 T" [5 u& V% J+ c" ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 T& d7 p0 T, E' z9 N8 n Z, U% [
if (ret)" D8 P: {. |. ^" r+ G L) e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", E/ E' c) I7 Q" Q6 S0 Y( t! a
"%d\n", ret);
0 \) P3 l/ e6 @$ W5 s3 f#endif
. R! E+ e- `6 [+ v# | l ret = platform_device_register(&da850_evm_tl_leds_device);# ~- c, F% t. U0 g9 T9 j
if (ret)0 d5 {7 z: u, S. D' b$ \$ t: ^
pr_warning("Could not register som GPIO expander LEDS");
7 f- S+ ^0 h; {# v( Z+ J7 r else
1 V# C) o M: [7 x* { printk(KERN_INFO "LED register sucessful!\n");. Z) W8 j& U& h1 d
& L" w5 }, I0 p1 ` return ret;- W# h* X, j( l$ L7 u" H3 C- l
}3 w5 k# u3 o; A
& l( r+ B+ I# G! q- y' l
static void __exit led_platform_exit(void)
\2 |/ g' g1 q; l6 ]- Y{
( X; z, s* k6 d8 U' x w! B6 Q; F platform_device_unregister(&da850_evm_tl_leds_device);* A! F4 G* ?% C* p
5 U" Z; ^- ?) Y3 I; n printk(KERN_INFO "LED unregister!\n");
8 Q+ a4 B. S0 p}: w/ {0 t! M) W! @6 M" o7 M
' ]7 C+ { C5 t m5 H/ |module_init(led_platform_init);
?3 N2 z/ d5 [, b2 {( g2 G& w0 jmodule_exit(led_platform_exit);5 c. C4 n& G. @4 [
9 V! W1 p. [, r2 M; SMODULE_DESCRIPTION("Led platform driver");6 T/ x, e( G: i. G% \( Y
MODULE_AUTHOR("Tronlong");2 f4 Z& X$ R3 X5 E
MODULE_LICENSE("GPL");
/ d4 \* |7 A9 F/ X8 |4 k1 S4 q4 r" c" t
|
|