|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 h. p% I( Z) ^0 j3 ?#include <linux/init.h>
8 Q/ e" I; B: _4 [$ t3 D#include <linux/module.h>
# E2 v: i" a! ?- i. {' Z+ C#include <linux/kernel.h>' H% j d; n1 }% O8 S$ J6 F9 g
#include <linux/types.h>
1 e. l p6 m6 z# V; @#include <linux/gpio.h>% R) T% a4 c5 a0 v+ X
#include <linux/leds.h>% e3 G( P" m- C, u# W2 [
#include <linux/platform_device.h>
* j! ~6 C& G. r2 u' d
9 Z1 b& V$ W1 h; B0 W% ~#include <asm/mach-types.h>
& Z" q* \4 g* K) s) D#include <asm/mach/arch.h>" Z3 ^- ]" E/ U% g" @( H' L
#include <mach/da8xx.h>
/ A6 E% N7 v( A4 G: p#include <mach/mux.h>
) r) C$ Y- [1 o9 h0 ^- _' ^
( j- I. z$ m& s' F+ D* E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ T/ O$ @+ ] g0 S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 j' ]( r$ S/ D5 a1 V9 a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 {' K5 }3 g3 l' A+ v* P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ a; X3 S, h6 I" a! }/ v) M7 T% l0 ?/ S' b
/* assign the tl som board LED-GPIOs*/
( T' U3 a0 h9 F1 kstatic const short da850_evm_tl_user_led_pins[] = {3 r0 g7 p9 u2 P7 t
/* These pins are definition at <mach/mux.h> file */
8 M S0 O: V, c; O' _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 V5 |! @3 l7 _
-13 C' I, a/ G) R- F B: N9 r8 S
};; S$ Y$ Y: P# B( j/ U- V
: z2 V5 p9 q$ q K8 w3 X, v
static struct gpio_led da850_evm_tl_leds[] = {
. q3 y# F, A& |, W* Z7 U9 ~5 ` {
8 i6 R; f5 t0 H9 g* `2 w .active_low = 0,
) s6 n, h% Y+ w+ A6 z( Q; n .gpio = DA850_USER_LED0,/ _+ H) K. l% O; U1 |+ W8 @
.name = "user_led0",$ o P, H- j6 u
.default_trigger = "default-on",- I* K# I4 Y4 M# G- p
},
) e" G) d' Q& c8 u- n) e3 e {+ B* Q4 o9 L j
.active_low = 0,
8 H* l; l6 u! H: Y7 U3 |6 y. T) Y6 e .gpio = DA850_USER_LED1,9 H; ]" @3 f+ `6 E% _/ |3 Y
.name = "user_led1",6 S0 I- d+ S+ s& c+ s" k& G
.default_trigger = "default-on",
( u! d4 u; Z4 F },
* A$ I* I* A/ ~5 r {# u9 y# ]1 ~- V- _0 l! Y% F
.active_low = 0,
. k2 R; c+ @% q, u3 V .gpio = DA850_USER_LED2,: y( O z( o+ i5 \ x
.name = "user_led2",- s& H7 R. X" v" P3 a: H
.default_trigger = "default-on",
- [! p5 j7 r& w, H. s% d },
, [5 a$ [* W( O/ K7 v0 z {
6 r/ m5 f: z5 a .active_low = 0,% ]! T2 r* f, V2 i# P
.gpio = DA850_USER_LED3,; @. U3 t* t! j
.name = "user_led3",) c* v& W- S/ U* F3 M# ?+ [* m! n7 t/ K
.default_trigger = "default-on",
; N+ v; q( d4 e" { },
! U% m! m. m3 V0 {6 E1 T};3 N# }# S" N- W* w4 s- p$ m2 y
9 A j0 Z8 u2 c! k5 hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: G6 s( e! J+ W! n. a! P* M .leds = da850_evm_tl_leds,
+ F; N0 O+ t. ~- D) Q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 w; \5 j& K$ e0 }1 E};+ c' e3 s0 S/ {! g6 s2 |) n
' G0 s8 G' f, j
static void led_dev_release(struct device *dev)
9 {7 Y0 Y, ]& z6 j* `+ x{
( x, `# b7 g0 t7 R) ~};
# ^; @0 c# Y4 l2 X# N% q
, T+ F) ] J( S) xstatic struct platform_device da850_evm_tl_leds_device = {$ k B5 f$ a# {3 G; r
.name = "leds-gpio",
" E, ?/ [) J# k: ?5 ~ .id = 1,9 y' S6 |+ N p* s
.dev = {6 \4 C! n: P B# \
.platform_data = &da850_evm_tl_leds_pdata,
# T; y7 R2 B' S8 X+ F& f3 n .release = led_dev_release,8 y; n8 ]! q1 W% R: x
}: R' O: y) i1 P1 O
};/ D ^ o! h t! J0 A
5 S4 _9 b* Y4 kstatic int __init led_platform_init(void)# w. ~2 |' t# h' _$ M. R
{
0 B& d5 u- q( c& Y0 l int ret;5 M! ?$ [9 d5 @" @: |2 i W
#if 02 h9 }5 |6 l: K4 k' Q- n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 G6 f, S3 W% y4 p
if (ret)2 y8 Z! t- D' y0 e7 Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; \5 X% x9 T+ b( M. `& ^8 S! S
"%d\n", ret);
( L7 I: R5 D! U& N6 g5 X' K6 W#endif
# }1 U8 b: {6 T ret = platform_device_register(&da850_evm_tl_leds_device);5 b% V$ o" W5 T/ H7 E1 k
if (ret)
" i$ ^* x+ E/ [+ K pr_warning("Could not register som GPIO expander LEDS");
5 K2 ~ K G7 @+ F; v else( ?# a8 ]& M( ]0 @2 V
printk(KERN_INFO "LED register sucessful!\n");. v- S3 J$ f2 T! f9 o- f: t
& q. J. |8 S& x. t8 W- r return ret;+ `2 @& L" }. g9 M# K' I/ i
}
+ l- M4 c7 W9 ]3 F
0 F& ?, Z% G/ D3 Hstatic void __exit led_platform_exit(void)8 I: q0 w% I3 U7 ]
{0 J+ U" m+ _8 g$ z
platform_device_unregister(&da850_evm_tl_leds_device);
; B+ b8 S3 Z- n/ p) R8 Y9 s% T5 L3 g! b7 U
printk(KERN_INFO "LED unregister!\n");
- @' @& R% H7 S( C# J; x4 d}
% c+ B7 @; ?& j. }, ^- t# \: s1 z7 j8 a
module_init(led_platform_init); ~" O. E: c& T; b; n6 h s$ B! e
module_exit(led_platform_exit);) V) H) I6 \" {4 G6 L3 t
, b/ k4 l' f. {, Z7 R0 i6 Y
MODULE_DESCRIPTION("Led platform driver");6 o6 ^( Y# T0 O' q
MODULE_AUTHOR("Tronlong");
; v& Z4 \& K' f0 o5 m1 `" |MODULE_LICENSE("GPL");
4 C4 q4 N( p6 ]: o0 a
$ Q; N& g4 d' z: d+ G2 o- P |
|