|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 f) |; n* ~4 _ q
#include <linux/init.h>
$ r: Q# \2 Y6 M#include <linux/module.h>
( N0 ^1 }- [1 U: B; \. m1 W#include <linux/kernel.h>
2 m: Q! o/ ^2 d6 G( L; v#include <linux/types.h>
' W; S5 A* N# Y6 F+ W9 p b0 |7 i$ Z5 D#include <linux/gpio.h>' @; ~+ x- X: B7 @/ `3 ^+ U
#include <linux/leds.h>
; {. T. c& c9 n6 }; ]#include <linux/platform_device.h>" H5 X' g: y; \
+ s* e% k. [8 \
#include <asm/mach-types.h>. l: R9 b9 E, g) s# B
#include <asm/mach/arch.h>
; n1 O" Z* y9 O/ O$ q#include <mach/da8xx.h>6 w* q* m# G3 f
#include <mach/mux.h>
/ c& ^( A. d9 K, k K- @6 t
, k5 x( m! [% n( W$ f. E$ i% |#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ i. @: o" ~( i* C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* Q3 \8 P; z* f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: g2 @* t( W; |2 r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 `7 C. ~! K8 w/ O. O
$ n& L1 n+ K* O
/* assign the tl som board LED-GPIOs*/& F2 M' b) L. I8 v. n
static const short da850_evm_tl_user_led_pins[] = {
( U F5 {+ {8 {1 t# `$ K9 h8 v7 Z. ` /* These pins are definition at <mach/mux.h> file */
4 [# a6 p. ?7 K' X: I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( c# D9 O% I$ ]8 C# H& K4 K
-1
8 ~* z2 W8 z9 K i0 @' |1 k: f; b};
+ O5 u, F$ u& M' Q5 B0 _9 C7 u# A" k" J8 E P( ~7 O
static struct gpio_led da850_evm_tl_leds[] = {' p+ b1 H% F) K4 H; {7 s
{, `; I) A/ h, o C
.active_low = 0,
3 M; ?+ R) w' K .gpio = DA850_USER_LED0,6 g0 t( D0 e/ k0 g3 ?3 ~1 [
.name = "user_led0",
5 F% ]" @, {( Q" b: k9 h& {) i' Y .default_trigger = "default-on",
7 r4 P# p- B/ d, w3 L; ?6 c },8 \$ V7 Y; j) [1 g: T
{5 F* `; K! C. R+ N8 r5 `
.active_low = 0,3 }/ A9 |# i1 z$ ]
.gpio = DA850_USER_LED1,
8 B2 S7 r1 [4 n/ N7 u5 D .name = "user_led1",
# s9 p4 M |7 I) v9 S O .default_trigger = "default-on",8 x7 G# r* B( C* |! ^
},, _0 K. U& I' C* ?7 }4 }3 F
{
6 G* l( J, a& N4 d/ ^ .active_low = 0,: N) c/ ?. c! E. x! z9 U
.gpio = DA850_USER_LED2,
+ ~+ D' u- a9 r' I .name = "user_led2", p+ E! T" d2 h9 T- m( E) `. o
.default_trigger = "default-on",
2 y) C" `5 C7 Y/ @6 v0 P- r },
6 V) A8 ]& K/ ^ {) q, b8 ]3 D B
.active_low = 0,
- s' I! X9 S( X- L .gpio = DA850_USER_LED3,5 s3 |- x3 | F
.name = "user_led3",# ~, X+ [: h$ \1 ?
.default_trigger = "default-on",
4 A, X1 |8 f; s0 r& ] },6 e! `- ?: v6 U$ @ c' p
};% B- t5 ~5 |, C3 \
" i/ H' ~; R! b ?" }: X2 b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' P% s/ a" N8 Z3 n( i9 { .leds = da850_evm_tl_leds,
' K1 o" A# P% E% c# h. S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 _- L2 Z0 O) X1 G
};
- g& x# Y3 w+ {; u1 {1 G8 E
$ U' a; c; Y! s# wstatic void led_dev_release(struct device *dev)1 b T! K9 O2 [0 o
{0 y& @5 K) O. g
};7 O/ @. K* Y; p# d! [* A8 V
: ?& `* Z+ V. q- e/ I
static struct platform_device da850_evm_tl_leds_device = {" a F& a9 k" }. q
.name = "leds-gpio",
7 J9 m0 d9 Q3 E! J3 E: n, w .id = 1,
- g' Z) X( N. P .dev = {
$ F- d. l' l9 D- Y .platform_data = &da850_evm_tl_leds_pdata,
& P2 {, P7 i; x0 O; b7 q .release = led_dev_release,
8 o4 _) N0 U, g- e/ }/ y }
4 m" g4 @' @4 |4 k0 F$ V};' s' R; e/ m0 P
; E/ F4 Q& h, R! l' d! a
static int __init led_platform_init(void)! b6 f4 H# S: P% r
{* }. @" g) c1 J# j0 O2 y2 a
int ret;
; e4 x& ]0 V1 S2 J& F& @#if 0' R1 r% A" z6 ?1 E2 a2 H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- U ^2 D* X% ^4 Y" T8 X& ~
if (ret)8 z4 q, h$ }, G! B! V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", b/ N4 l& ^, x/ P
"%d\n", ret);
) V9 k+ S5 \$ I& Z" J6 Z% n#endif
# ?. m' @4 ?1 O7 w ret = platform_device_register(&da850_evm_tl_leds_device);' o7 F! I, m7 F+ }6 ?5 v3 m
if (ret)
* _) J, e6 h1 I5 K% U pr_warning("Could not register som GPIO expander LEDS");. [/ l$ H) j: O, t2 W' e
else) E+ O7 H' p- P1 l- V5 D8 f6 p
printk(KERN_INFO "LED register sucessful!\n");
/ F! x3 O' M4 B" c0 y( H" ]& C. U8 @2 D! s- H0 D) {5 g
return ret;
! t- {% m* S1 }8 O}
4 ^/ i# n$ v+ M6 G/ }+ `
1 a- b4 T) c/ e* ^3 Mstatic void __exit led_platform_exit(void)
7 r2 q) Y% ?( q' H# i7 W{" \8 d4 U6 S l9 o4 G$ I4 D# [
platform_device_unregister(&da850_evm_tl_leds_device);
) b7 \- L8 X, j2 R) E" \/ G9 W/ A; F
printk(KERN_INFO "LED unregister!\n");
4 u8 A9 A3 ~1 X5 G}+ _% v% g7 z& m5 F+ T
1 R3 I& z9 w: G" u& V* O* @
module_init(led_platform_init);( T# S) M, J- P( \/ f$ P
module_exit(led_platform_exit); P4 Y" c6 q8 Y. G
7 M. V7 U" |! J% QMODULE_DESCRIPTION("Led platform driver");0 h6 y- C4 J. |
MODULE_AUTHOR("Tronlong");
8 I8 {' \! |+ i- }MODULE_LICENSE("GPL");* c+ t% O8 V" L) @4 ]" \
( P% ^: }0 C m5 @& U9 o- g9 X8 U; E |
|