|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 {% z2 {8 D ?/ z
#include <linux/init.h>% g# @3 F% C' ~8 K( l$ x
#include <linux/module.h>
! f5 H3 g- R4 B#include <linux/kernel.h>
' `: g' `5 O! b#include <linux/types.h>
2 h9 h3 X5 K) h+ G5 ]) r#include <linux/gpio.h>" L& }1 N3 R, { B! r% s
#include <linux/leds.h>
2 J, E3 h# e* d: d# X4 z' V$ d8 H#include <linux/platform_device.h>
: x% e3 @: v$ T6 M1 W3 ~ w
# A% ^& ]/ Y- ~; y#include <asm/mach-types.h>3 C' Y) v; i* V% y& ~
#include <asm/mach/arch.h># ]7 p5 x1 U1 c! Y2 X# o8 s5 I9 D
#include <mach/da8xx.h>/ F! N* J. Z C& C0 Z/ |
#include <mach/mux.h>8 w" ^9 E% \5 r
. ]% K* i5 I6 A3 y0 v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% K9 M4 O) ?7 u# Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 {7 B7 x! M: {8 ^' Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 p, W0 \9 I( e: Z+ L$ }' K
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" J3 t1 i2 }# Y3 C& [
' ]1 \4 w. @" H) z
/* assign the tl som board LED-GPIOs*/
0 P" q& P8 L7 wstatic const short da850_evm_tl_user_led_pins[] = {
8 V- c& j5 [$ L# D /* These pins are definition at <mach/mux.h> file */4 E% [( l2 H# b, p% C6 V/ o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 w3 V e, ^; ~( X -1
+ `& x9 u- i0 G/ X% E6 `' A};
* J" p; b% S. g K7 {: f p" H
9 F. U8 e; i( U" [( g( m* H2 `static struct gpio_led da850_evm_tl_leds[] = {
; c! D0 S# m- _% f {
9 p' w, M2 E9 h5 ?, V) ~( c .active_low = 0,' n+ `! ?1 } b6 B! R- Q
.gpio = DA850_USER_LED0,
1 A6 C5 l0 ~& x+ K+ o3 g .name = "user_led0",
" P0 J- H/ U# Z9 x .default_trigger = "default-on",
1 @7 U9 ?, |! E' R# `( G# f( E ~ },
+ t9 [5 B1 X: i+ s) _ {
$ B# ]5 u5 | K% c% ~; i! B .active_low = 0,/ c/ Y% z; v2 O g/ @( \' v
.gpio = DA850_USER_LED1," h, ?& \1 o+ P6 B( l5 |/ L
.name = "user_led1",
9 c7 S! o3 D' h .default_trigger = "default-on",$ I; a6 J' U1 r
},
6 q1 o, j# w' ~; b8 V {
3 Z' N' x9 I j3 u2 d1 j( A( N .active_low = 0,
# O, b5 X( N7 J .gpio = DA850_USER_LED2,
& f4 e$ ~) [& F# w( J6 L: A3 d- G8 C .name = "user_led2",' Q! |# V# ^" ^0 _
.default_trigger = "default-on",/ J7 E& p9 I/ p$ g g
},5 t/ b( V1 R+ V9 g" O P
{
' E$ g$ Z* B2 E. g5 |2 r .active_low = 0,
1 n6 S8 ^/ G, C5 V( g- Y& m .gpio = DA850_USER_LED3,2 Z9 u) ?2 _1 ^5 s$ c) `
.name = "user_led3",# A. S( G& {4 H8 ~
.default_trigger = "default-on",3 x. y7 \) ~1 @1 y Y
},6 ?( \8 ^7 d$ d4 B" |2 o
};
- R6 }3 A8 R0 c& F1 q& p" t4 @9 X! q8 `" c4 O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# T8 ^! J# E7 o( R! R$ Z8 l, x .leds = da850_evm_tl_leds,
0 P t/ Z! h9 H( U8 S9 O# Q- o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 E4 w& S# c: R, C8 P( b};
* C0 X9 v/ \$ {) X) B' Q! \& [ d) f
5 \2 e5 B7 B/ _5 i/ \0 ]static void led_dev_release(struct device *dev)
. {9 E2 f# W; c% ~" g$ [{
( l9 T& K' y7 g. F};7 B' T4 a) J, W2 C3 K
8 ~2 ]5 M* C3 k6 t0 S$ ]2 p# m
static struct platform_device da850_evm_tl_leds_device = {
) T: I! v" w3 _) x$ L- D .name = "leds-gpio",
$ e5 D( D- r; o' C .id = 1,7 f( q# |8 i' g+ _+ D
.dev = {
3 i3 a( r) }6 X2 c$ P .platform_data = &da850_evm_tl_leds_pdata,' a; O& v' @# Y2 x% \' H/ {
.release = led_dev_release,
3 B4 j" M- E- g9 \9 g' L& U- Z }( |+ P! O& [! o$ ^# @
};8 V9 i2 b) j0 t; X
% U7 v! K: s& X3 t X* D7 tstatic int __init led_platform_init(void)
! j) x" \2 O! P! m# ?& ^{
0 n q7 X6 E, f( _$ F l% z! q6 f int ret;
/ Q$ `4 v8 Q a" v6 E% s2 [#if 0
B5 T0 e p% A+ y5 T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# G2 f. O/ n9 R/ }8 r& L
if (ret)
/ J0 W" G T m# w pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! y( Q. R- f0 R8 Z3 | "%d\n", ret);
c) H$ f9 T) F8 S7 n#endif
7 T! I4 I3 z* j5 h$ i ret = platform_device_register(&da850_evm_tl_leds_device);
, C2 a! \# {' k6 [6 M if (ret) j9 T4 [4 b+ x- M# ~' F+ c, V
pr_warning("Could not register som GPIO expander LEDS");
6 Y* q! p- ^5 Z8 y+ t else) L2 F7 D/ x/ i5 P
printk(KERN_INFO "LED register sucessful!\n");
2 z6 W) p1 m: o- w' |7 Z5 q. I; u# c9 w0 ?% C% @
return ret;
( S1 ]8 I5 J7 O3 K4 R9 _- S# C}, u7 H) I+ C9 D" c. I- B
$ {5 n# Y; t* R: r, d3 n
static void __exit led_platform_exit(void)5 r+ B- ~( M# D) b
{
& z3 m& G, d5 N platform_device_unregister(&da850_evm_tl_leds_device);$ r+ l$ i/ `: i$ H9 B* }
! h4 I; v/ S* d4 d
printk(KERN_INFO "LED unregister!\n");) x5 |) q f$ T6 `1 ~
}: i$ r& ~ t. k$ K0 t
+ Q) d0 G% H! V2 d/ p. D, `) i$ e. g
module_init(led_platform_init);
- d- N) V2 s( o' N# Cmodule_exit(led_platform_exit);2 V4 U8 }0 y5 p. u2 P
4 z6 _" l% a! Y6 RMODULE_DESCRIPTION("Led platform driver");
( T& m; A& ^7 EMODULE_AUTHOR("Tronlong");
. V3 ?# c- C- AMODULE_LICENSE("GPL");$ D" X! b @: m' N+ N
, `: v' }2 ~- C% \# @+ x |
|