|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 d# w; C/ G# \ d; Y
#include <linux/init.h>
B g) f& ?! H& k#include <linux/module.h>; C& D1 X) p) C) _: @9 t* z
#include <linux/kernel.h>
1 l. f4 J+ S/ e: K0 V6 I#include <linux/types.h>" n" a& q: r" x$ G
#include <linux/gpio.h>
6 R0 J# W2 [4 z#include <linux/leds.h>
2 c: p( o7 l6 O5 L& [. q, q; } z#include <linux/platform_device.h>
* d- N( j4 Q$ f" c" F0 N
: v* L/ h1 M) U8 l#include <asm/mach-types.h>
c+ d/ f" `9 n$ D9 K$ h#include <asm/mach/arch.h>8 h: W' q$ K+ E4 X
#include <mach/da8xx.h>- x4 X( B2 c+ t- O
#include <mach/mux.h>
; ~+ ~3 E3 G( V) R) O! ~4 ~' C1 ^# F! _. e& Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 Q. n# N4 c1 X5 ]: s3 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ }8 E6 a* V7 Y$ q% w+ ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# c" X/ @" ~. D: K J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ Y+ a5 X3 `1 }# M
( b/ { Y( M- }1 a/ h/* assign the tl som board LED-GPIOs*/
+ Y; ]. A$ Y" Mstatic const short da850_evm_tl_user_led_pins[] = {
, ?6 V; a7 e) r, G. r /* These pins are definition at <mach/mux.h> file */; G, K8 ?" c" k7 l) o! A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ a# u3 e8 L, V+ L& J
-1, N: E+ l" W G P$ ^
};% f0 J4 a/ F0 j. ~3 T
4 F. J s- a+ y; m7 }3 o& Jstatic struct gpio_led da850_evm_tl_leds[] = {
& r5 \9 y9 Q- p l) _! k {
+ a/ n0 I8 g4 D& H .active_low = 0,
) W, D5 U4 P0 m: S4 l .gpio = DA850_USER_LED0,
' C6 O5 E5 q1 m$ B ?8 E5 `1 M" V6 { .name = "user_led0",: }/ V9 p" C5 i/ b7 F% |
.default_trigger = "default-on",
* ~4 t+ v4 D: ]/ h i+ r },
, p9 @2 ~+ \0 Q' H1 w" X* [ {8 ^" q% R9 z/ Y0 S* F, ~
.active_low = 0,
0 k# @3 A) B' I8 Z- p .gpio = DA850_USER_LED1,
# O6 X4 I9 H- Y" @ .name = "user_led1",; c. q. `* L% Z8 d* o
.default_trigger = "default-on",
- }( ? } x1 J& K7 V },' ~$ w2 U7 j9 I$ i$ l8 F& r" g
{' A$ q! C# R# F
.active_low = 0,- s7 K! Q( C* |) [! Y
.gpio = DA850_USER_LED2,
6 c; @) H6 q* G) z .name = "user_led2",7 Z" h! S$ x+ ?* R
.default_trigger = "default-on",
& T, l6 Q; j' Q, U. C& c },
" s2 _3 C3 G$ R3 G3 i; n: | {& H' J ^" n$ u: X2 _
.active_low = 0,
3 R1 z: [: ]$ x9 |$ L2 \# o .gpio = DA850_USER_LED3,2 d, a' n/ H* B+ I8 d; |
.name = "user_led3",- I; H1 x' h7 i7 [# A# O
.default_trigger = "default-on",/ q3 q0 R. e* b
},
5 X' Y! l+ N5 ^- M5 A3 @3 e/ t& h$ f+ n; z};
' O. i' T7 {5 L) m0 ~" s2 _2 U, L5 b+ s R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
S8 F/ \3 `8 V .leds = da850_evm_tl_leds,9 K$ }* A" }( O5 x8 m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, _8 Z, O2 N! Z2 e) k; v4 ?
};9 D- c- _+ b9 [0 S0 q
" M8 a6 }; [# |' q/ ?; j6 L, C% d
static void led_dev_release(struct device *dev)
9 r" l, o4 c. z{
& P6 c. j/ v( y- g% Q9 V};
2 ~. y. t. y9 t: a$ o) p2 \2 [( o1 h8 N. I- H
static struct platform_device da850_evm_tl_leds_device = {$ |% i$ p9 b+ c5 |2 g& @/ x
.name = "leds-gpio",
2 Y) m5 b( o: o5 Z1 {" ~ .id = 1,
_5 k* f/ m. Y+ S .dev = {
1 d6 a6 ?, u, f( c' w% M .platform_data = &da850_evm_tl_leds_pdata,
) N; u$ D5 L) ? s6 P/ i .release = led_dev_release,% g) ?- g$ n) _( e) a
}, N+ g& {+ }3 W7 {( N7 {
};! Z0 ^2 K! l# i, A3 M
6 x: p( {3 f! }. `9 O. k4 H L6 E2 U; ~
static int __init led_platform_init(void) R7 C8 `, g4 `' B0 q0 G
{
" ~% N# @5 G. T) ~2 v7 i8 e int ret;* r2 K- a6 _/ t N& q4 Y( ]% N
#if 0* t9 h; M* g: m3 E/ S6 e% b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; h& K! i" o) s$ ?* K7 C$ h! b$ } if (ret)& h$ x& b3 n5 y1 r' ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" e1 h) @. L( |% d _$ N6 J "%d\n", ret);
. j( {7 \: p# _' k" [$ Z#endif
( D' `- L. _$ S# L4 a& a! n ret = platform_device_register(&da850_evm_tl_leds_device);
0 g# }# B' J' L, j; u if (ret)
9 Y% S* A1 z6 {7 l$ d0 U pr_warning("Could not register som GPIO expander LEDS");
: K, Z0 C) z& h8 E else! E6 {+ i$ p& ^& S0 r7 j
printk(KERN_INFO "LED register sucessful!\n"); r0 n% Z3 O6 ?3 H6 a- _" d0 D
/ a6 l. O& ^; O
return ret;
2 c( f. Q% q* v [! x}0 q+ @0 w: ~7 c' F) T0 H6 [
( E/ f x4 N* ^: W
static void __exit led_platform_exit(void)* t' R7 }& v. f* U. ]. X6 p7 p+ N
{: g ]5 V0 n+ g+ f0 x7 k, s
platform_device_unregister(&da850_evm_tl_leds_device);( Y& i r$ ]9 j! S
8 z0 x8 S% R- A/ S# x2 Y printk(KERN_INFO "LED unregister!\n");
4 h( q5 U/ N2 z. t; y( t}- m# e3 u0 t% r( O
0 z; `$ \! [5 a
module_init(led_platform_init);
t' T J/ \, [* imodule_exit(led_platform_exit);
- `. d8 ~2 ~, }" E1 A! k
" Y& d& K ]: H, B4 m. TMODULE_DESCRIPTION("Led platform driver");
6 t1 s# F8 w1 r6 `# J8 IMODULE_AUTHOR("Tronlong");
# `/ H1 ^3 p7 `4 V" XMODULE_LICENSE("GPL");8 s- ~/ L6 T& g0 f0 n
' W9 I& v( k7 [ y4 ^ G; O% H
|
|