|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 e) Y2 Y7 D4 C E. ]
#include <linux/init.h>
4 s+ [" \4 M) A8 Q$ m#include <linux/module.h>; r3 H# `$ [9 z+ i9 s0 N4 s8 y5 `
#include <linux/kernel.h>' `4 O/ w3 O4 K1 K2 B8 G, x R
#include <linux/types.h>6 R9 A/ B5 C2 Q8 b3 a% X. G5 W
#include <linux/gpio.h>) a4 l: O9 }) Y. X9 Z. b! o
#include <linux/leds.h>
/ ^0 @0 S5 {* G D9 {+ P#include <linux/platform_device.h>
5 U, `5 ^ v6 O( f+ P. K) {8 A
* c( ^! V1 r4 M& |) ?#include <asm/mach-types.h>2 w. x' E8 a9 U. Z
#include <asm/mach/arch.h>: K& L# u* y9 K
#include <mach/da8xx.h>
* S8 m, S. Q: T( \$ e' B- g% A1 U#include <mach/mux.h>* b; X2 F" }8 [* I
j+ B( n& W' ]# c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 g- ?9 I7 z! R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 W0 K. V# S1 z1 N7 @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) E) }! O! L' _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ y! e& t0 d+ |& d! i9 S2 r) p5 L7 z$ H8 [
/* assign the tl som board LED-GPIOs*/+ \1 u6 x+ v5 O f3 `5 k1 T" _
static const short da850_evm_tl_user_led_pins[] = {
0 @' e4 H6 L& I0 j* ^6 Z /* These pins are definition at <mach/mux.h> file */
+ g: ?5 r# R4 F: `* v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- o, Q2 C% x" z. M( k
-1
: r3 Z) h7 }5 [3 l) x};
6 d6 \' O7 l$ x- M" M0 ^* x- B6 v: r% J+ V, _# V' |
static struct gpio_led da850_evm_tl_leds[] = {0 A, P* N% O2 Q: _4 I# c2 f
{
( B) K5 `" j, i9 W! T1 _+ V .active_low = 0,
% |0 w; X: r& P( e* A" ^3 u .gpio = DA850_USER_LED0,
8 f( F; c% M( T/ }% ] .name = "user_led0",! V2 o, P, I' k% p* `
.default_trigger = "default-on",* Q; F: D: b2 d( S9 ~
},
& T) K' H+ N6 b" m {" P1 O$ S! b+ ?1 D# }* Y
.active_low = 0,; o5 l# K& [+ }# Z
.gpio = DA850_USER_LED1,1 q9 Y0 _5 J, `) t
.name = "user_led1",. x5 C3 p: X2 y* z6 N
.default_trigger = "default-on",% r. J4 z6 z; H8 M1 M
}," q, r2 w4 A4 @0 N
{( [# K" M* z% T( R0 }! b' H
.active_low = 0,
# M- a0 ?) V! j6 D# O .gpio = DA850_USER_LED2,& A% t% U4 O! C
.name = "user_led2",
/ J% _- `4 k4 E+ T .default_trigger = "default-on",
/ M+ U5 |$ f+ X" ~ },$ |: v/ f* v$ L' Y8 f4 p
{8 Z# p# s) g( ^6 K
.active_low = 0,! T% r# \; g9 l% W4 o
.gpio = DA850_USER_LED3,
2 o8 t6 l& [% S .name = "user_led3",
) f4 S9 F2 j% b; s6 K" ^ .default_trigger = "default-on",
5 z" V* a$ s, O s. b" ] },
, f" j- n1 d1 _; u: \9 E& ] L};' ]" d! a+ N- e' C- K
7 l x+ H% Q R: g4 ~, H/ F) i4 I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( ]$ h$ j4 L/ N( ?. J: x* M1 M .leds = da850_evm_tl_leds,
2 z Y- B" @3 Q/ D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( I( w `9 h4 r# C+ o2 x" ]% F6 Y};
6 ?9 n' M# }. W/ ^& e' J: r; m& U% B: D. c
static void led_dev_release(struct device *dev)
: Q( i [7 l) g{" v' \0 t7 y" M6 C% n$ V
};! i8 ]" c2 B6 N* R
1 k- z, g' l# g0 z/ [# }& tstatic struct platform_device da850_evm_tl_leds_device = {
& i; R) h8 ^( J4 y% i+ r' s- A; g .name = "leds-gpio",
1 }9 K) p( E0 l) B .id = 1,4 d4 q$ ~6 ~) D. z- \+ v) X, g
.dev = {
4 S' h) m4 u1 a7 ?5 E" y# S+ Z .platform_data = &da850_evm_tl_leds_pdata,
4 ]' x, q# t3 K: f .release = led_dev_release,% ~/ S l0 a7 z- | l; }& T. f
}0 @0 T0 k+ o, I/ m0 p1 [
};
W) p7 k' o l w4 X8 w/ o5 y) t8 k! A3 c- F) n$ v. [) k' X$ s- B
static int __init led_platform_init(void)
$ `, u9 y/ U6 T9 o! l7 y. p: m1 t" W{: n% n$ Z* C8 v8 I& S0 q
int ret;/ C4 F) {7 c$ i6 ?) C1 [6 a2 H
#if 0
% o6 R7 Q$ G$ |+ D! U& n' }9 Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' i! S! o4 g4 I, t- T: P" n
if (ret)
# t! K7 b8 I r4 G7 R! B% y" ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% t" Z }/ |) z0 ?- t& C
"%d\n", ret);
- R, N* ?$ N8 F" R#endif$ q0 i9 `& q( y& B v, d
ret = platform_device_register(&da850_evm_tl_leds_device);/ h$ k/ l" V& A9 W1 Q3 R0 ^2 m
if (ret)2 p+ l0 r; N- d* `! f6 V
pr_warning("Could not register som GPIO expander LEDS");" }7 G3 i9 H( w' P6 x1 P
else
# U. G9 a' v+ Q0 e3 V# L printk(KERN_INFO "LED register sucessful!\n");* a. X; j1 H- e+ n8 A
7 y; a k: }: {) L+ O6 o return ret;
, F+ b, e, k4 r}
/ z/ h8 J1 {/ u' ^4 N# L: I# `
1 {; H; u& j9 L2 Mstatic void __exit led_platform_exit(void)" o) m9 Q T6 G) Q/ A( ~
{, m- I; h. ]% I/ _6 `9 j, `
platform_device_unregister(&da850_evm_tl_leds_device);
, ~( b8 O6 L5 x7 k) [ o% Z
1 P( g' V; t/ J6 B- U' \ printk(KERN_INFO "LED unregister!\n");+ w/ u! c+ R) n% l! ?
}
3 T5 k5 b1 j: A! i; X4 j# f; I/ J/ T! g2 @$ }" e& W0 J+ Y8 K0 ]
module_init(led_platform_init);
; m) w+ T n! [7 L! ?' \module_exit(led_platform_exit);
& v0 Z, P* _* ]3 R# R
$ S' [7 o$ U- c l# E2 u- i( NMODULE_DESCRIPTION("Led platform driver");
; p# h( ]: j' K: ~MODULE_AUTHOR("Tronlong");
" t0 A$ v G) n. nMODULE_LICENSE("GPL");( F# e3 S9 w" r6 m z, V) S
' ?/ S) o% @# E
|
|