|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ f C1 C& T9 _4 V/ ~# F#include <linux/init.h>
D4 ^; O; |, z. V2 M+ y3 E' ?#include <linux/module.h>5 @. { W: p% D: k3 Z# x
#include <linux/kernel.h>4 a9 v, q* }7 E2 m' c1 X
#include <linux/types.h>
& D: Q! j: \+ t% ^- W# |#include <linux/gpio.h> ]* b, x1 M* J' C) R8 @* ^! Y
#include <linux/leds.h>' @$ \5 V* G1 P
#include <linux/platform_device.h>9 ]9 c4 \. Z8 O" D1 \* L* h* a" a
1 h; W7 |+ |; M
#include <asm/mach-types.h>; W7 R* C& L. y5 M4 V4 g" t% e$ C
#include <asm/mach/arch.h>5 ^4 J0 u: Y, ~$ g! G4 R
#include <mach/da8xx.h>
4 a; Q/ ?6 S% E# b2 N#include <mach/mux.h>: y* P+ U( C7 V3 y1 O$ d
( i: H% o1 i; l e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 R% [% D* M3 A# V; r7 h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 H0 f5 K% Z+ i) K4 r9 t ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 ~9 p* K$ ~) s( _4 c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& ?% H, }! F8 M
+ N, @+ b0 X8 n; E, j( G q; z
/* assign the tl som board LED-GPIOs*/
& l c4 V3 v1 B) L8 `' w3 b4 Bstatic const short da850_evm_tl_user_led_pins[] = {: ~- I2 @- [. Y# ]5 l/ E
/* These pins are definition at <mach/mux.h> file */# l O, V1 z8 f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: C6 w8 P, D% f r* I) d -1
: k+ ?; S; ?( h& v6 A5 M$ J# }% \1 ^};
x. H" Z N" u2 j) _0 D5 O1 Y/ ~, \/ d! I
static struct gpio_led da850_evm_tl_leds[] = { _2 U2 n; Y9 _1 `2 s
{
' w& }+ N: w$ ~9 t7 g .active_low = 0,
: @/ s5 b3 r( k6 ]' y* n7 G5 S .gpio = DA850_USER_LED0,
7 U. o/ [3 v7 {' J5 p$ B, a, ^$ k; o .name = "user_led0",4 a, N; B$ v# O% t
.default_trigger = "default-on",
2 H* n1 S! L# J7 j" \ }," s4 a. A3 Y i7 ^" F) E5 b
{
4 u, M2 B* `) n* Y8 N# T$ ?1 u- X9 { .active_low = 0,
. O' L; O; S6 p7 W1 N( L .gpio = DA850_USER_LED1,
]! B$ h) j9 S9 S .name = "user_led1",$ ?3 N5 n9 X# C
.default_trigger = "default-on",
]5 A. c7 y9 y- s j },; r! K3 g5 s' U( X) b0 r i4 o
{8 |4 K/ t2 E6 P3 q# l# z2 v) s
.active_low = 0,
2 ^- ~ H( x- B! n .gpio = DA850_USER_LED2,$ j) W! o7 Y& c5 m# Y- D
.name = "user_led2"," k* a/ Y ^0 T) H- M6 U7 s
.default_trigger = "default-on",
* p+ Z! z1 s0 a9 ^' d* _6 } },2 v9 }; i4 ^! b, m
{
7 [3 G/ Z% j0 P+ B% x .active_low = 0,; {6 j- ?' x1 G! K- B
.gpio = DA850_USER_LED3,/ a4 E* n4 `% C, F# C
.name = "user_led3",
2 v( A: @2 ~! _ .default_trigger = "default-on",. L8 E( U% m# O( h+ F3 u
},
8 D& m; b1 E2 l% D% A};! o6 j4 n$ G" r1 {' d( X
1 o, ~7 u1 m1 m; B# s4 J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 _3 Q. C- V( i# H .leds = da850_evm_tl_leds,
7 X. X2 E0 d- q! H( e: B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 S0 Y, h- z7 X! n3 q9 _; }. m
};
+ G( I( X1 p. f: f+ k$ A1 y4 w3 W% V6 Z! H w! L6 ~9 P' M
static void led_dev_release(struct device *dev) h& A; Z2 T" E6 s. Z* C2 g
{
Y. i+ f7 A) M5 P0 s8 {};, [% X( K6 E: r& i
0 T* x, \# x/ x9 k; f/ G4 tstatic struct platform_device da850_evm_tl_leds_device = {/ B+ X( M7 T$ W& s1 U2 g
.name = "leds-gpio",
. L" F7 S& ?. S+ _* n- K# `6 I .id = 1,
* Z$ o7 h+ B: p$ b5 I .dev = {8 C; ], u) @2 t/ k) O$ I* a
.platform_data = &da850_evm_tl_leds_pdata,2 B) N/ y9 j1 G% W4 g! Y0 A# L
.release = led_dev_release,# e* O6 J+ w0 z2 r' f+ t
}* z! |& m8 z/ N' @, I
};
# `/ y# W% V& @: E
0 T1 g5 v# g; @' O( b- qstatic int __init led_platform_init(void)+ L! Q7 U+ }. V7 @7 [
{
) q* {( i C6 h- R int ret;( H- H3 t. T7 T! V
#if 06 m7 ]* y+ X" C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, b" B4 E) N0 F% N2 _% n if (ret)
7 _9 P, ^7 ~: t$ C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& R) t& L; I( j: c2 K' R9 M& M
"%d\n", ret);
0 B8 d7 g8 x( \6 ~2 w#endif
# f# \$ M/ m% e' L O* `- K$ f4 K4 Z ret = platform_device_register(&da850_evm_tl_leds_device);
- |: Y% ^# u% J* |6 g% G, M if (ret)
$ I) V* n) @2 {! Y( k( b pr_warning("Could not register som GPIO expander LEDS");
6 R4 }# ?* V6 s+ v( p0 f2 r else
/ u2 w d) e- s, A printk(KERN_INFO "LED register sucessful!\n");' Q+ y) B& p6 P# b2 s; R9 g5 b
# _5 P: d r3 I/ T. f: ] f Q' k- \ return ret;
' {8 y0 G5 _) A}
' b, W0 z. @& X* D/ W/ ~9 W% ^
. n( K, C. k3 Y% Mstatic void __exit led_platform_exit(void)
: q1 E$ }+ P3 s7 D2 m{
2 b* m, e5 n7 p3 X8 b8 n/ n platform_device_unregister(&da850_evm_tl_leds_device);: y1 @( l) h5 Z# m6 N' H
# @ Y3 M+ H% x4 c printk(KERN_INFO "LED unregister!\n");
) H# v# T7 X$ Y9 B$ A: \, i8 \ X) G}! N7 t4 t7 t$ O3 ]
# u" r% `# o ^$ l6 Zmodule_init(led_platform_init);8 a7 e6 ^3 u5 f9 B8 ]0 ]3 T7 Q
module_exit(led_platform_exit);
& h _, @9 P$ g8 U/ n/ X
/ y0 \% T! }( H& t* s( iMODULE_DESCRIPTION("Led platform driver");
) m7 h; q- b, LMODULE_AUTHOR("Tronlong");& s9 b d+ T' s k( [
MODULE_LICENSE("GPL");* f3 Q& f/ k7 Q8 p( E0 {
8 ^1 e" [/ \* s) g; ~; s; l |
|