|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 {' _) _& s/ |- n2 n#include <linux/init.h> q6 R3 v) J) s6 j
#include <linux/module.h>- M6 Z1 E W" g# v4 C
#include <linux/kernel.h>
2 T* x$ v- x$ l' Z3 i$ w#include <linux/types.h>1 n h. r. f" x
#include <linux/gpio.h>
( \6 H4 E. C* @: s#include <linux/leds.h>3 S, i" ~9 w; K; y
#include <linux/platform_device.h> T4 E4 X" m7 `( z; o! U0 s
7 `3 l# @' x2 ]+ s+ I6 ~4 M7 n
#include <asm/mach-types.h>
( e* `& O9 t# {5 m- n% {4 \( Z( c#include <asm/mach/arch.h>/ H( O4 v$ T1 L$ W; Q" C
#include <mach/da8xx.h>8 U) x# f# I' _/ {- v- L. n
#include <mach/mux.h>
T* k( ?0 H) @1 c$ \. X* g" }: x6 R: j( ?
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 F+ O& m+ b6 c, }1 [, ]* H1 f9 g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- [* Y# O# F) C/ Z, A5 c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 o9 Q3 Y9 O8 L+ c9 t7 J! e. Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# n ]8 W3 x/ ~5 T* U Z! [0 O& Z" }0 ?: ]3 U
/* assign the tl som board LED-GPIOs*// n0 E3 _5 I$ _* N2 E
static const short da850_evm_tl_user_led_pins[] = {
, u: @: @! K' f( v& _* |$ Y! K /* These pins are definition at <mach/mux.h> file */, h; C" E- h8 \ }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
R/ k" C2 E- y4 y3 F6 _% R -1
" I. H+ ^) k% b# S, x: l1 L" d- f};
9 M6 e, k" y9 J6 U/ I- |% b0 L. z e+ F1 [+ G# t
static struct gpio_led da850_evm_tl_leds[] = {
; A* ]% H0 F6 I" e+ b2 ^" b {9 o8 S( G# I$ l4 z5 }8 A
.active_low = 0,5 @+ Y3 c! ]# V) r& ?
.gpio = DA850_USER_LED0,
" G u# X% W4 n/ |3 W3 j3 R3 b/ @ .name = "user_led0",/ G2 Y, L; h) j2 ^2 j/ y; v
.default_trigger = "default-on",
7 F+ Q* x- n( c0 B6 [$ M9 p) X+ w },, R d6 M$ u( q
{
8 T( [- @* e, H .active_low = 0,5 \8 v$ I% h" E" k3 S
.gpio = DA850_USER_LED1,
) J+ k; p' h) R# W' |, j; g5 H .name = "user_led1"," r5 e ^: V# t6 t9 [' p9 v
.default_trigger = "default-on",( l* L* B3 V" l' M3 R
},
* D( ^; y, \6 g" S) C9 X$ S {
$ U- j* F% }5 y .active_low = 0,$ R1 l0 a8 Y5 n/ U: a1 ^( L
.gpio = DA850_USER_LED2,: H! w* X9 l' |. g$ q" b$ w
.name = "user_led2",
+ p$ W3 F0 z1 S% C1 @+ j .default_trigger = "default-on",
5 E& j. g3 `0 ? },
" H$ }% `' S' a) E( ?6 L! s {0 m3 {5 L) \* }7 `
.active_low = 0,! X5 V9 `$ S' G- ~) Q; N
.gpio = DA850_USER_LED3,
& L4 S& {8 G3 @) n- w3 A1 I1 v .name = "user_led3",* ]/ y( L/ P& ?1 O
.default_trigger = "default-on",7 U. O: ^, v3 S0 t/ Z# v
},
% q1 f/ R; S: q- d};
4 T+ f8 J+ ]% m1 _& i, f; i% q2 E+ U7 _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; X! d/ K5 d* n7 p; w( { .leds = da850_evm_tl_leds,) a" ^. l5 u; ]* ^# u1 i( X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) _2 T3 i0 Z, u$ K& l7 x" K; [
};/ k& R3 Y$ u8 ~* J% D; b! E
" s; _" R$ _# N. R K6 U
static void led_dev_release(struct device *dev)9 I; V( Q) C% M8 z4 v: d0 k }+ p
{
! o1 Y& F2 j9 Q$ z0 k};
, e9 `& z/ u' I! K# Y' Y, j7 a
+ V% G- n! x$ J) E5 S. hstatic struct platform_device da850_evm_tl_leds_device = {
' k1 G5 P: ?; x1 Q) _3 J' J9 c- E .name = "leds-gpio",4 w9 @. t1 }/ b0 z$ [$ @; y. Z
.id = 1,
$ }; q3 C `: T5 d1 o .dev = {
3 F+ g$ {' ~& w4 |6 i: G3 D' @ .platform_data = &da850_evm_tl_leds_pdata,
. L. {' d t3 C/ N+ P- z* F. A .release = led_dev_release,
5 C7 ~2 ?* s3 f& Y- X0 i) } }
5 G* m; b5 L, W}; c4 ?% I" [& a5 ?: _' y
% P; N7 E, c4 y1 ?1 Q. X7 s8 K
static int __init led_platform_init(void)) d* t0 U5 A) e
{& z4 }0 \1 j9 a* T* Q7 [. ~
int ret;% Y6 ~' }5 x% w) e& z' {# @
#if 0: J% C9 H& H- C# {3 `5 `* w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 u- l) ?& h2 B
if (ret)
3 d8 X0 R, S2 d% E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( g; s7 p% ~! n" h
"%d\n", ret);
A X% @% O; Q! D% q( A#endif
! ~) @. r* l: v! g6 W; _' j3 e ret = platform_device_register(&da850_evm_tl_leds_device);! R1 \: W: i: L5 j4 o
if (ret)
. b/ | q: Y* _$ ?- |3 t8 O8 ?, J9 w pr_warning("Could not register som GPIO expander LEDS");9 |: V0 f; R E+ G
else3 D4 d$ X# @7 x5 s. s: I
printk(KERN_INFO "LED register sucessful!\n");
+ u: `' D; y+ `; Y
n0 U' N$ [$ c! | return ret;
" U( S6 O3 U% J7 l$ N: Q}" K! j( o% m7 Z) _) t( c
8 Y4 \) u; E0 d. D' k; R$ Gstatic void __exit led_platform_exit(void)" I8 k, D. `/ L7 h0 g8 L9 j; w
{
4 L% C8 e+ b0 s$ \5 E) D platform_device_unregister(&da850_evm_tl_leds_device);% m U6 x& k. [4 W" c& F P/ K
" A/ L+ G5 }/ `! x2 j& U$ y" l$ ?$ i. G printk(KERN_INFO "LED unregister!\n");# U) h, ~1 W0 G! z- {0 ? _9 T# e
}
2 Z0 f8 s1 O$ o6 ~% w0 E5 T
/ x' _5 E# m4 z3 F( O; m. Lmodule_init(led_platform_init);
" f- @# f! @# mmodule_exit(led_platform_exit);
0 j+ R6 v! m" g! j8 N8 P" u
- g/ b% U; K& Y' kMODULE_DESCRIPTION("Led platform driver");
* ]4 ^" C `( o+ Y* P5 hMODULE_AUTHOR("Tronlong");% t R# w4 b5 E1 ^
MODULE_LICENSE("GPL");
% f1 z- x/ w6 e- F# K' Z
. Y5 w) b. n* W. w4 v' E |
|