|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 C4 A7 n% p5 C5 H7 _#include <linux/init.h>
$ x- y; {* ?% m; j0 O: J" p' P#include <linux/module.h>
8 F8 Q3 s0 t5 `& ?; s8 T#include <linux/kernel.h>: f) m1 S: T3 t* V
#include <linux/types.h>- z# F* }, x0 m7 O" L2 L+ N( o
#include <linux/gpio.h>
2 ^ D2 ]/ [3 i9 G% X' j {6 `#include <linux/leds.h>
/ Q# H9 O7 e8 H5 S4 U, T#include <linux/platform_device.h>
- R; K5 b/ Q! e8 u/ e' u
6 @; ?7 x2 O& t4 R( M0 }. V9 z#include <asm/mach-types.h>
+ L2 b. g: R& r; E, S9 Q#include <asm/mach/arch.h># I5 i. @8 h% U; [- F: I6 D
#include <mach/da8xx.h>/ ]1 A. \3 t% i; d6 Q+ ?: x
#include <mach/mux.h>
6 g$ O% N' ^5 Q; V! o
+ t. f" A7 {3 Y8 E, A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 E% e) Q& v( V W* j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ m- d; F4 [0 i5 D% B0 p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 @4 W6 S4 V6 v7 b9 @9 A) W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* f; y. k3 O! |) ]' A% b5 q" w
5 X6 N: C$ o' C d: E/* assign the tl som board LED-GPIOs*/
1 T6 z& U6 \; P& u7 vstatic const short da850_evm_tl_user_led_pins[] = {( u# o2 }+ p+ }% J& f1 x
/* These pins are definition at <mach/mux.h> file */" Y3 W8 w8 f, V$ w% C, q" j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. y9 g) ~9 {4 e# Y8 F, J
-1
8 M4 @% z7 L+ D3 b, N2 R, |};
, X+ X& F: D- W+ R; s
+ O, E. s: h! Ustatic struct gpio_led da850_evm_tl_leds[] = {; E) V: w+ }, v. m0 m5 c
{' U+ y' b" ?- e) ~: N4 O
.active_low = 0,( E: c1 B8 Q. S5 s+ m2 @
.gpio = DA850_USER_LED0, Q5 o5 `" n! {' r! s# U
.name = "user_led0",
5 t( K% e: f1 A( Y .default_trigger = "default-on",) q: U( g0 P- g" w/ [9 s
},
9 @8 j0 S% \+ F7 ^$ P. q3 U3 u6 i7 L {' d- a, o% O/ I( e: j* I5 R. M
.active_low = 0,
4 ]' \) U+ L5 C! R# d" ^; L .gpio = DA850_USER_LED1,% a' [( I$ ~+ ]# l$ r, k* ]! v! y
.name = "user_led1",
* A l, t' _ o- J .default_trigger = "default-on",
% J1 O3 I0 K. z2 M. [$ d },
5 ]# k( U) j1 h {
* [$ j. C7 \' d0 O7 ? .active_low = 0,2 B+ i/ @: L* Q( V2 [
.gpio = DA850_USER_LED2,
% P; M- R, o7 n" U' S) c- w+ W .name = "user_led2",* x4 |( z3 Q$ ?$ P/ N8 ~% G
.default_trigger = "default-on",
) F4 K3 ~3 ?' j$ l },
+ p) l! D9 R2 V1 u, Y% M0 K3 H/ _ {+ P% F- O* q! J2 z0 V
.active_low = 0,4 X. {' e# M) P V. n+ D
.gpio = DA850_USER_LED3,- t. W9 E- r- q- u
.name = "user_led3",
- k! @( L/ F) o7 f* A% h/ g .default_trigger = "default-on",$ M8 x5 t, Q1 W* T3 J1 _1 F% [* ^
},
0 K: ~/ I: Q4 K};4 F0 W6 `' P3 x* h
2 A; o/ F' u9 t0 P) G, l1 Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# f8 g! S/ N O: p% l8 H/ K+ t
.leds = da850_evm_tl_leds,- @& H) T) v: _/ X4 S6 j& f9 O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' D& j. [( Q* n$ ?
};
6 K- R) Q' g6 s) ]# t0 H, c: A5 f: A3 d
static void led_dev_release(struct device *dev)2 y! A9 w. a& M4 ?
{" H: x8 T3 D1 |0 J
};
?: r, f7 W, o, B: X
! s+ n+ @+ _; k- J+ ]% N- L3 Y1 Rstatic struct platform_device da850_evm_tl_leds_device = {
$ c8 D1 V8 g2 K2 w8 }4 C# } .name = "leds-gpio",
: }7 c9 E& I) B8 s) b( ? .id = 1,
2 L4 n" k7 e+ W+ S# D! Y" G .dev = {
% n( f+ Y7 o: [3 C .platform_data = &da850_evm_tl_leds_pdata,+ `9 C# k7 x" c& t/ V, Z
.release = led_dev_release,
1 b) p+ A9 Z# w* {* [0 u }
% G# J+ F: v& M2 |};
) L- Z& \: q$ d7 {' X) t( K9 m5 L
$ V+ O0 ^. l6 F! @; Cstatic int __init led_platform_init(void)
/ ^0 f, N: w; i; _* M! h7 C4 x{
; T [1 X3 l/ I( e6 X- ]0 D* p int ret;
: s; M$ C2 F' t+ Z8 P/ y0 j' N# o#if 0
5 l% X) u, W @+ G$ E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: W3 u6 v' M; I- D% k8 R if (ret), J8 O4 O1 T0 T* A) |5 y! _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! ]& @3 S6 x0 [) k "%d\n", ret);
) t4 |" `- g) l N8 S#endif3 w, l6 S: r% n. _( W. g: m
ret = platform_device_register(&da850_evm_tl_leds_device);/ F' R7 P1 ^/ x( q4 X
if (ret)
/ u) m0 j" M, Z9 d8 F) N2 K" f pr_warning("Could not register som GPIO expander LEDS");
5 w5 Y4 z( u0 i9 D7 A# M. J else
( v* `5 ]" `; y- i printk(KERN_INFO "LED register sucessful!\n");" S% ?+ z6 s4 ^3 Y+ E. d: V
/ W2 ?" ]# a2 D# ~) {
return ret;. W' l) M9 v% ]5 B) x! i
}: ~9 A' i* e8 Y
! f0 I3 D; J9 P0 z" W- I$ j. |
static void __exit led_platform_exit(void)/ F- H5 i. x" ^4 k$ F
{9 t% [0 c+ ` t/ n2 u6 z" }
platform_device_unregister(&da850_evm_tl_leds_device);
@) U6 r+ z! e# H
[' t0 R x7 g( ~$ I" F7 I printk(KERN_INFO "LED unregister!\n");+ \" e/ i1 d: r# m: l8 k( C3 h5 L. T
}0 k9 c- i* V& G" y2 `! k0 [
, @. c4 D8 E0 j d8 E) omodule_init(led_platform_init);% r' _% b0 O! i2 {' i9 r
module_exit(led_platform_exit);# l0 W. _* |* P4 \/ `( D, t
! ?! H( M4 D& l- bMODULE_DESCRIPTION("Led platform driver");
! z1 f8 t4 i ]; r- L; GMODULE_AUTHOR("Tronlong");
; e3 W! |4 ~5 rMODULE_LICENSE("GPL");
0 D5 a5 ~6 J V6 n9 E# n; V: S- w# T& d T4 }6 y3 v
|
|