|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. C }3 Q9 V* z; G( j6 n#include <linux/init.h>
9 F; {7 S( B: K: B! R( Z) e#include <linux/module.h>
4 V" \6 @, r' q7 H2 d% }#include <linux/kernel.h>. ]8 P% O0 |- n. y
#include <linux/types.h>
% V& j- w" T& h0 W% f#include <linux/gpio.h>6 k* K8 O+ `% C
#include <linux/leds.h>
! v" z; X9 C$ i! X* R5 P#include <linux/platform_device.h>. U' f0 k! g* j, W; n
|% T, K0 k4 {% q0 k3 T: E+ k
#include <asm/mach-types.h>3 p/ e# Y9 g: L% K; H
#include <asm/mach/arch.h>
0 Y. p4 x1 l& e+ U! |#include <mach/da8xx.h>
. X5 d$ j% [$ v1 [#include <mach/mux.h>( O3 L, v8 j7 f; F4 Y
& o9 [4 Q: s2 N9 t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 M! ~( D/ N6 v' A" b: S( \: ?5 H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% f/ V; ~3 S* @/ r+ l+ l4 H% z9 q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); K$ j+ k' x( E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 {+ n+ i1 S( P% x* |, k- q+ I+ y8 [8 a
/* assign the tl som board LED-GPIOs*/- G# v# B* Z. [9 M$ i; r/ w9 M, C
static const short da850_evm_tl_user_led_pins[] = {8 Q6 ~3 m1 z: K$ i7 r- N
/* These pins are definition at <mach/mux.h> file */7 U: C- R/ s: V/ q2 X# t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% J7 k# b" T* T4 _4 B
-1& `! Y3 ?- C3 N: o) u, }5 T
};2 e' k8 c. S W% e7 v- ^
% s1 n' V$ c0 g) G8 a" w" ?. Ostatic struct gpio_led da850_evm_tl_leds[] = {/ n" C, D; J% D0 U/ v
{
" d& k/ Z' @8 |: ` .active_low = 0,! B' t$ L" H% y0 x
.gpio = DA850_USER_LED0,- U0 J: z- l# e4 u# n% g: c
.name = "user_led0",
$ _9 `; o$ }/ u6 ^* [2 r .default_trigger = "default-on",* `' T& l( }; u
},
" g' y. ~+ D2 [& F {0 B3 E! w3 f7 x" b
.active_low = 0,
4 ?6 A/ F6 c4 Q .gpio = DA850_USER_LED1,
$ B0 M! X& }* s, Q/ ]" x! v" @) h3 P .name = "user_led1",
& l1 I8 I, g0 r& W5 | .default_trigger = "default-on",
2 P5 P1 P( |8 j6 L },; V) ^# v6 _ s" \7 u# c
{# E% y( ?$ \2 E' m5 [! E
.active_low = 0,
u* [7 b. E$ k: g' b .gpio = DA850_USER_LED2,7 g+ m+ k9 P8 d! \- {
.name = "user_led2",5 o* v6 v; m9 N; Z: R
.default_trigger = "default-on",
" t1 S2 o/ [6 M |7 s },3 ?' ]1 }7 R! l1 }- G3 W
{
6 {7 n5 l4 U. }) k .active_low = 0,
* k# x. R7 r4 u) e; N+ ?) p c1 N .gpio = DA850_USER_LED3,: C7 K/ }' B: N% W5 e
.name = "user_led3",) X( c( W2 b+ R/ h
.default_trigger = "default-on",
7 ~$ f+ K+ F3 K2 i# x5 {& F },
- `/ d) P, L, ^! u( R};" T% w; p" c( t8 b2 p
) ~) t, C7 w9 ~* T0 V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& u3 X: W1 w5 L1 b# X0 P5 [! ?' x .leds = da850_evm_tl_leds,
( h, d' e6 Z" j2 [7 N2 X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 l% f. @; q7 J) ?( e};$ ~" v& L% P( X0 h4 I' e" _" p
# X5 { B e: c
static void led_dev_release(struct device *dev)
- I5 f5 Z& c& E6 Q! q# c1 d{8 |. y" x0 S S0 v
};$ n- Q6 @; x" x/ x2 N! l
L& d4 w$ U5 p1 c* X" v& J
static struct platform_device da850_evm_tl_leds_device = {
; C" X# L9 ? `8 W G. h .name = "leds-gpio",
6 x& H/ H! I" j: V. G, S .id = 1,# P$ R3 J% O3 D. [( ^* A
.dev = {
7 j- I$ o2 R7 z5 U5 l) { .platform_data = &da850_evm_tl_leds_pdata,
4 C9 U! p( r+ [ .release = led_dev_release,
0 V" ?7 a0 F* D0 D$ C( Y: B }- T7 u# z1 Y* r+ d0 s! U3 w n
};1 N. g& o0 x- @: @ x1 m. b
; V5 \7 u) ?7 Istatic int __init led_platform_init(void)" T# Q+ F7 w0 t1 U% j( a& c
{+ h" z" o' J1 U" G2 _4 i5 ^) ~
int ret;8 i. ], ~3 l; i- l7 f
#if 0/ |3 o# o2 R# b* E! S4 V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 R/ p: Q/ S* [
if (ret)4 `$ ^5 m% c$ d; Y. j* h1 I. _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". i9 B# ?/ n+ O' S
"%d\n", ret);; Z6 n8 D o2 J
#endif
+ w% z% Z3 o) {3 {* d+ W3 G ret = platform_device_register(&da850_evm_tl_leds_device);, d3 r, S$ ]+ J! D' ~
if (ret)6 ~- K5 @7 w# j# v; ^4 H S
pr_warning("Could not register som GPIO expander LEDS");
8 m: C! `/ g3 R. W& L& o& b else
3 {1 u$ u" p8 ^ printk(KERN_INFO "LED register sucessful!\n");
0 G% u, c5 v+ o5 u% f. ~3 G( y8 [" E; w* F. {- I+ f) ^
return ret;
6 t, i1 d7 l9 L$ C7 Q( A x b9 E}: f# t& f8 @) u8 n+ G# w8 g9 R3 @, V& n) e
R+ f7 @' U, t5 ~6 h
static void __exit led_platform_exit(void)
9 D, w7 L, T8 w2 j+ P, G{
! X' _8 n) {$ c' m3 R' a" H8 N4 d platform_device_unregister(&da850_evm_tl_leds_device);' U: o0 C, ~( a, F7 w9 `
1 }7 R3 g# K' `2 Z, D9 `! C printk(KERN_INFO "LED unregister!\n");' k/ Q8 V4 y! v6 h6 s3 b8 W
}
/ C c6 H6 K k1 z% P1 w% \, d8 M
1 @2 i. t+ P7 f4 B O# dmodule_init(led_platform_init);
6 i6 k* s3 D3 g( z, z; @# Zmodule_exit(led_platform_exit);
% S% j& d8 Q! E* O! ~2 r; y
- ]+ i4 `$ x: T5 PMODULE_DESCRIPTION("Led platform driver");( @ Q7 O& l9 K# ]( m0 U
MODULE_AUTHOR("Tronlong");
7 u. \! Z% T* q1 ^MODULE_LICENSE("GPL");/ Y7 Z0 t5 J" S3 R* O: d1 x
1 W5 s# h g3 ?( T$ d" a! C& v) X |
|