|
求大神给下面的程序做注解,请稍详细些,谢谢。 N1 A& C0 C: Y8 Q( o7 S
#include <linux/init.h>% T( f5 j; z( G4 O+ M. d
#include <linux/module.h>
* C( L+ c& T/ G0 x5 J/ E, a& g#include <linux/kernel.h>- w3 `) z6 w k3 e: L- [. o
#include <linux/types.h>9 E0 ?# S5 {, c7 A
#include <linux/gpio.h>
- h+ L5 L: ~) Y6 m" Q% }0 H/ @#include <linux/leds.h>; [, {: h9 M3 [. Q* z. A( R4 J* Z
#include <linux/platform_device.h>
7 ?6 j3 s9 p% u p5 w- n6 |' B3 n& y! s6 \' i8 ^
#include <asm/mach-types.h>
2 u7 C6 e; E" r6 g5 I#include <asm/mach/arch.h># q6 H! \7 O0 x$ ?+ G; m
#include <mach/da8xx.h>2 U! Z: }5 u3 Y6 |* H; h, g% F
#include <mach/mux.h>: ?; r+ V& H3 v# h/ m
- K% x: ?3 r1 b0 @1 y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 u/ \5 y8 l6 u$ ?) H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ {' [% O' x+ ]2 r; I; j+ \5 H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 p2 n- |( K7 Z5 O4 i% l1 D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' \. d# o& Y/ E
: i9 Y/ O8 J) R# W5 L3 d/* assign the tl som board LED-GPIOs*/6 v7 s2 Y# h6 _3 A8 x i
static const short da850_evm_tl_user_led_pins[] = {
1 s+ E+ p0 h/ [7 R. ]: o /* These pins are definition at <mach/mux.h> file */9 L Q$ m6 ]5 E3 n7 Q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. j2 |5 p+ N& I! b -1
1 k u) e9 r/ Q$ o& W% G6 S O4 I};
$ U p; ?- R- Q$ j$ G
^- F. A3 S$ }1 L8 s3 b# Jstatic struct gpio_led da850_evm_tl_leds[] = {% V R: `9 F1 x2 D( L
{
$ n3 j8 V& A& X2 F; o6 c, Y" I& E .active_low = 0,
- l4 G8 }6 _7 O8 j. R4 a .gpio = DA850_USER_LED0,
8 l0 A- f! x0 H$ y% [+ W .name = "user_led0",
l2 a% E+ c: Z) b( E .default_trigger = "default-on",
+ d, g5 U6 ^6 o },
; W: Y k0 M# Y. V {4 f, K! m8 S6 t' R
.active_low = 0,
+ o% R+ z+ B! E6 e: w5 v .gpio = DA850_USER_LED1,* y& u/ b7 r. ] M
.name = "user_led1",, u' N# y/ l7 _0 y ^$ S+ U# D! o% M
.default_trigger = "default-on",
( J! [- s& t% w2 I7 d& _% l },0 ?7 Y( C9 k9 z5 P1 T+ ?
{: f; r8 j) K( h9 P
.active_low = 0,1 s* M% m( W/ w; `4 m) o
.gpio = DA850_USER_LED2,
% K% {/ K3 ?+ s, w& W r .name = "user_led2",2 h3 o" x; ]" |2 a# M
.default_trigger = "default-on",4 A7 @4 o- i2 T6 ]& u2 g
},
% M- g; u: |3 O8 |/ u {: c' Z1 }" R# j1 w H A
.active_low = 0,
- m/ \5 T0 j0 `! ~ .gpio = DA850_USER_LED3, ~3 E1 V2 I& d- n- E9 Z% l7 l
.name = "user_led3",) D$ f; @- B: ^. N0 O
.default_trigger = "default-on",
* X3 T/ X3 l' i+ Z/ J },
! f& D6 f) c! ]1 Q" K) w) ?};
! r5 \) p2 w. N! T( R" ~% o3 m' N/ V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { w, A4 W; \5 o3 e& C9 _
.leds = da850_evm_tl_leds,3 g; e4 l, Z5 X% r! t! ?; B5 E4 t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 n8 [3 q7 U; @7 X/ C; v0 S7 `};- X" E/ |% W/ W! |
L& o. N; R& N2 g9 i5 Lstatic void led_dev_release(struct device *dev)4 r# F; T3 P" \/ Y: t
{- @: q4 I9 g% b' p
};" c8 z" Z# a5 O2 {
; f! j1 U; Q* } N0 W1 qstatic struct platform_device da850_evm_tl_leds_device = {. F. o! E6 X. S2 v) T
.name = "leds-gpio",& b3 m+ Y, \( D, q+ N2 e
.id = 1,
2 y5 L8 c( ?" ^! u% F6 j) n, t .dev = {0 \- D* x$ W' q% R7 H. o1 q( M
.platform_data = &da850_evm_tl_leds_pdata,
2 q5 I4 A% L) K$ T# }: c .release = led_dev_release,1 K1 }9 {4 W2 w V
}3 D b' m1 e) H2 Y) d% D6 U
};) a$ r8 l* I; B; A9 Y
! I) C+ ]; u2 i6 S! ]9 q- P% ~- z
static int __init led_platform_init(void)
2 p1 w% y3 J. [( o! W$ y* X; `{
$ j l( K& Y7 `4 u4 v) l int ret;3 V/ a! |6 B" j0 R! G
#if 0
3 E! @0 z) n p& E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 {1 r9 W5 l- I: V5 \+ r if (ret)
- }+ V3 k3 a7 C) ?* Q5 n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 F' E6 `& m3 R "%d\n", ret);9 J; Z" K' w, d& l: q6 Z
#endif
+ G v1 u8 ~$ T) E- D ret = platform_device_register(&da850_evm_tl_leds_device);, O R5 n/ z9 W* g) L' C
if (ret)5 l. v/ @- J% f0 j( a# {! G
pr_warning("Could not register som GPIO expander LEDS");8 U; o; f/ e% G
else6 h: J8 a8 T: k. n* u+ r$ ?3 i
printk(KERN_INFO "LED register sucessful!\n");
- h1 }- |+ D& M9 \
+ P2 a. M% p6 j5 v0 Q return ret;
6 B* o) }4 Z( ^8 G1 Z4 k}
- o. \: i' D- D2 p+ D+ |3 s# U2 Q, @0 O: ] S9 K; v; O
static void __exit led_platform_exit(void)
! X: k' ]/ D* \# w& S' A{8 r& ~% c, t' O, V2 g$ Z! S
platform_device_unregister(&da850_evm_tl_leds_device);, q5 |/ S9 _' Z3 A- ?
- d! R+ k, L: D; a4 L
printk(KERN_INFO "LED unregister!\n");
7 }2 r. R! M) O- U}
. f, l( @" b8 a6 E" S
& S7 v0 u# W( i$ U) Wmodule_init(led_platform_init);" H8 @" V5 }4 w$ _" L7 y! f
module_exit(led_platform_exit);
9 U9 T) ^ ~, r) s- y$ E9 W8 H% F' p4 |4 ^( }0 w, X
MODULE_DESCRIPTION("Led platform driver");% F. i; V; u4 B" C- ~# x
MODULE_AUTHOR("Tronlong");" B- [" ~! f+ v/ _& R
MODULE_LICENSE("GPL");" X+ Z. N: l! b' z5 Q c" D3 C3 |
3 u) F/ o2 i2 P b {+ p |
|