|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; R. k# r S m* t- K: S1 l( u9 d#include <linux/init.h>
G; @3 h6 J I3 w( {6 U( P7 @* a#include <linux/module.h>
, N" x$ O' \- e8 ?#include <linux/kernel.h>7 [2 Q- C2 l$ }+ a1 D# V) Q$ o
#include <linux/types.h>: V- {# i Y* A/ A/ N3 p+ _
#include <linux/gpio.h>
+ t" f) g, @0 n* C#include <linux/leds.h>" {, `3 g- R. s
#include <linux/platform_device.h>
5 N% {% c R, G' {" n$ K- B( I) ^' n) \. B. h! t( M
#include <asm/mach-types.h>
- x; K- \' F- h. b# L#include <asm/mach/arch.h>
* s$ l$ H# F# t0 D#include <mach/da8xx.h>" o: m& r8 T- k7 r8 r: J" y& Q# b
#include <mach/mux.h>
2 C/ y9 M) N7 T8 ^$ T8 v- o6 h: ~' A, t' F: ]7 v) Q) `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& A$ e' C( N+ X% H4 n1 @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' q- s9 m2 z9 R% n
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& f" v; ~' ~' Y, M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), {5 I$ t6 m; M3 M! G7 H% R# {
3 L. J1 K" d) w/* assign the tl som board LED-GPIOs*/, W/ m) a5 x/ ~3 y2 Q7 X% d& f8 y6 G" x
static const short da850_evm_tl_user_led_pins[] = {
" ~# |: T# K" W, ~ t% f( z /* These pins are definition at <mach/mux.h> file */ T0 Z# v; m9 \) N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ G; N8 i$ c: l E* n -16 `1 a; B! |: f* C2 C% N6 c; x6 h; Y& n
};
1 W5 R8 n3 P }. `( m ]
9 b- @+ |# V9 o2 c( E% fstatic struct gpio_led da850_evm_tl_leds[] = {
* M$ E) w7 o9 m {
# X* m# W; U( v9 {* c; ?/ [- M .active_low = 0,
3 l2 W; }# y: e .gpio = DA850_USER_LED0,# v8 M! X5 B! X8 X
.name = "user_led0",9 F P6 r. g' ^3 H/ D
.default_trigger = "default-on",
; D9 f: w* d) L/ ^3 b },# n L2 e! \. l: Y- p& X& e
{+ n9 |/ K. u( x# j+ s! G
.active_low = 0,9 _$ B. T# d. Z: A5 |
.gpio = DA850_USER_LED1,
+ q& f d8 T& t. W" _/ Y0 ~ l* o .name = "user_led1",* D! e A I4 z3 |
.default_trigger = "default-on",7 ~: w0 b- }. h! f, X
},
2 D N4 S# E8 e7 x r6 T& F {$ O% i2 E$ a! c
.active_low = 0,8 `. g& l/ d' q1 d# t( ~$ s
.gpio = DA850_USER_LED2,
, X( a+ a% b; q% @7 g .name = "user_led2",/ ^4 {% r& ^6 h) S# V, F- F$ K
.default_trigger = "default-on",% y! s& l6 @: e) Q- d6 w! q$ d% t5 ~
},4 s2 c3 F) e6 M8 _
{
Z. i2 c5 \/ X9 p( q/ c .active_low = 0, j" f' I+ O- r' V. u; ]: _1 Z1 k! Y
.gpio = DA850_USER_LED3,
7 j4 J& S4 X1 Y5 S .name = "user_led3",2 {7 L8 C$ R" `4 [( z* T6 {
.default_trigger = "default-on",
7 d; y& Y% M- S: X4 Y },) ?: E4 g6 R& Z; C4 P( \( w: R
};
* K* l% G( Q/ { }. f7 w5 O0 v- U% r! b) ]% U5 P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 Q7 o/ E# x2 H, r# a/ R .leds = da850_evm_tl_leds,) Q v" W) t+ i a5 P
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ e" _3 b `: i# B# C! m
};
9 b" w9 ^" g( c7 O5 U5 ]( G/ p9 X3 M/ ^
static void led_dev_release(struct device *dev)
1 e! a; F( |$ i; ^' V{4 u* @+ E+ q2 o1 }+ }' s; }3 D9 S
};* m: a& O3 i$ G: Y( z u" b
3 P$ J; Q0 I4 n4 T5 Z# |/ jstatic struct platform_device da850_evm_tl_leds_device = {4 x: U3 @6 p" O- M6 T" U9 I& D" |$ a
.name = "leds-gpio",
( ^: b3 N* N: ]8 O" R .id = 1,9 t4 |3 s: |& O0 E
.dev = {/ |; y/ a4 c$ n5 \& ]7 d
.platform_data = &da850_evm_tl_leds_pdata,( Y, U! f, e8 |+ f( \8 ?
.release = led_dev_release,
; K5 u- r$ r) t) m9 M+ ?. R }
1 f" c2 b, M; b% i' e* e, R};3 |% B% l) w/ F1 ]
( a0 q, I# O4 e. s# ]8 a+ ?
static int __init led_platform_init(void)4 v" I0 i2 r& ]% w: M1 G; ?; y
{
& }: U% O0 r" z+ }9 ] int ret;6 A* V u% _( c7 p3 y3 h
#if 0! Y7 ?3 x; o, Z# s8 |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 r. |1 k- Y8 r# b; a
if (ret)- C; Q9 x8 h# Z; b3 G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" P" u8 Q5 |% w e: ?2 T. g
"%d\n", ret);. X1 q4 G1 F1 ?9 V! \
#endif
) H3 z7 N9 h4 |+ g1 g ret = platform_device_register(&da850_evm_tl_leds_device);
: p2 d9 v# h" a, l3 u4 S if (ret)
* z* [9 N% A7 G6 e! d% F pr_warning("Could not register som GPIO expander LEDS"); S6 g; J% U% r9 Y# [8 e* f
else
6 W3 w( H9 L9 t6 ]/ W/ c7 {) P printk(KERN_INFO "LED register sucessful!\n");: e( T+ [, L$ e9 t- f
X2 n! f2 ?" m$ I8 D
return ret;+ h0 H! j/ A1 X) e7 n6 E) L- D
}2 B4 B7 @5 j: ]
- a6 m% ?2 |; L% s" B2 v
static void __exit led_platform_exit(void)2 I* _# ] L% L7 k3 t" h
{
, t( O6 n5 f/ B5 M5 g. C- b# {' Z platform_device_unregister(&da850_evm_tl_leds_device);
/ Q2 G- d% W, P. j
8 ^4 ~0 e/ |3 j- n+ X printk(KERN_INFO "LED unregister!\n");
`% I1 u) u- _}6 e1 m( q# Q& M% x' R
" P2 \/ w" f6 R$ g, a6 b9 Y) { Kmodule_init(led_platform_init);
G. F# O0 S* O( i4 \: ~module_exit(led_platform_exit);
. N* L7 Z3 M8 q
) ]! K3 r4 O/ F% zMODULE_DESCRIPTION("Led platform driver");
6 x2 ^: i9 ^1 y& Y6 ]MODULE_AUTHOR("Tronlong");
- v7 p( b" \* p% A4 s/ D0 z; _MODULE_LICENSE("GPL");
- [* _% i+ I+ I/ M! [, S# B
% I) T* D, ]" R. N, h2 r# w1 F |
|