|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 S. ?. \* A; h2 g" B7 p#include <linux/init.h># _( n3 h) n' M9 X6 @ }
#include <linux/module.h>
% r0 G4 q5 m. x' q1 s' L$ C3 \#include <linux/kernel.h>
J8 E4 ]8 c8 Q0 P$ H, Y* I0 c% s8 D#include <linux/types.h>
: r$ d+ y4 v* V- ^4 M: D L#include <linux/gpio.h>( \& B: b. c! {+ Y
#include <linux/leds.h>
% d, p4 |5 H2 m5 C, O- D# t, v#include <linux/platform_device.h>/ E& m, i4 B& U9 S- ?" u. @' t
3 a% R5 e- Y+ ~' l. t3 {
#include <asm/mach-types.h>
: P9 v1 _; ? u4 b" t: o" @$ B#include <asm/mach/arch.h>+ j) _! Z% @& C; ^2 c
#include <mach/da8xx.h>6 _' _8 I7 q1 Z z0 O5 d4 d2 N
#include <mach/mux.h>5 Z+ F1 _. ^7 e& M9 N; Q% L
2 K3 j9 O& D0 M4 D0 |7 q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): k0 ?$ w) n. N' L* d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' S9 @2 P) M/ D& W7 U2 @; W) T/ [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 h. `" `( _9 M; f* @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) m* o, }" \7 g S$ N$ E6 R; O$ L2 c0 p
; g! ~% ]; Y) [. a. T/* assign the tl som board LED-GPIOs*/( O9 r# i% A' a, w3 x, Q$ o
static const short da850_evm_tl_user_led_pins[] = {
2 ]! \7 a: \, A5 B7 A2 j /* These pins are definition at <mach/mux.h> file */& l9 A* U& r+ g) s' ]
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' [7 a2 B0 r" t( e
-1
- O/ P# L/ S* Z/ c};
6 F1 o* L Y( t# E1 s
8 Z: j% T- P7 m0 W G$ Ystatic struct gpio_led da850_evm_tl_leds[] = {
3 m. d' q- j. ^$ w( u) b d( E- F3 ^ {
9 u2 D8 q& i3 T5 l/ c .active_low = 0,* s0 p7 E4 a, {! D: g; P
.gpio = DA850_USER_LED0,
' m8 K+ l# Q8 ]+ \# S) H3 h+ a A .name = "user_led0",- b9 C y2 L" Z
.default_trigger = "default-on",
3 u- e/ p. |! p7 d# G k },
# e! f! A# Y% ]$ r2 V- n {6 F1 q* l' x' [2 B4 ?% H! y
.active_low = 0,' u S* f/ G- z; M9 x) ~. w
.gpio = DA850_USER_LED1,
b" ?1 d M c' ~/ | .name = "user_led1",( b# j* t9 ~" |+ s: e
.default_trigger = "default-on",
6 f+ b% L" g1 I4 R6 a3 R },
+ F! e2 X! p' z5 ]; \9 X {/ ?- J; B9 `1 j5 K" `$ C" a
.active_low = 0, L2 f! {! U- K2 }0 {" j! w: L0 o; c. W
.gpio = DA850_USER_LED2,0 R v7 U- n- X6 E
.name = "user_led2",
5 O! G3 q: o. W" y Q# |6 f0 \1 Y .default_trigger = "default-on",
$ A! [5 k. x; U8 C8 J },
1 |% F) s6 e7 ]$ G/ _7 u9 C* i {
: X- | X7 x/ C, U .active_low = 0,
8 w( y, `0 r" U$ |+ E9 } .gpio = DA850_USER_LED3,
7 D% @3 q0 K, Z$ }6 n' c% y .name = "user_led3",! H7 I/ n: y0 K3 t; S M
.default_trigger = "default-on",, g' W- k$ U4 _1 y4 ?
},
! N4 L9 |5 o( n; J+ g};# C( @4 H& B8 o
, T! s. x! r9 w! D) ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% W6 X% h3 n2 Y; F/ `3 Y+ `
.leds = da850_evm_tl_leds,
- \% [& o: r( }& U7 g+ m7 @ K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ ~/ k8 ~& v+ ?$ `. T
};
2 j4 I8 }5 T( \! C, l. j$ N
) p% a1 s+ W& [static void led_dev_release(struct device *dev)( K# f& y6 Z1 d3 u$ |/ s; K# Q5 A6 t
{. A: Y* \: _" M2 G) R
};
6 N3 j( r1 L; Q5 [ b; ~7 ^, v6 O7 K
static struct platform_device da850_evm_tl_leds_device = {
2 ?) m& f! z3 K9 G$ P0 s5 j# s .name = "leds-gpio",. J% L3 s+ l$ d) X3 G
.id = 1,7 A4 t5 p) [1 f, Q
.dev = {$ n( j M( ?+ X: W7 \. [
.platform_data = &da850_evm_tl_leds_pdata,9 k2 i5 R9 ^; @3 j
.release = led_dev_release,0 \1 r; C' A3 B( {% l0 d$ V
}
1 @6 j: x1 r' [8 I8 G};
/ }7 ?) d6 L1 v- c. O
* y0 U& Z9 Y$ W, |# @( D, Ystatic int __init led_platform_init(void)
) M9 P% s/ B9 E5 ~. d1 Q{* m* Z5 z: o" j# K1 w
int ret;* M8 L. A8 z( m5 J) P
#if 0
+ x+ Y' I, W3 _$ z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 w0 M! `+ }# |* c9 _* e if (ret)
# i0 [9 r* w9 G4 n6 n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# A) {* |+ }% E1 W6 S, U
"%d\n", ret);
- ] K3 B: m+ b#endif$ y8 H' @1 s& t4 c m+ h1 ^; H
ret = platform_device_register(&da850_evm_tl_leds_device);
& w& L, P8 T {1 @1 ?2 Q" D: X if (ret) G3 n' }7 [" |/ u+ }, F
pr_warning("Could not register som GPIO expander LEDS");
. z$ G( D9 T- o3 n g6 _ else+ r" D2 q6 O" ` r; w: K& E1 F' ^9 c
printk(KERN_INFO "LED register sucessful!\n");
. A/ R- h, s. M6 R( Q
+ m- M2 \) g9 L6 {, | return ret;5 f! m: H% p n9 z5 ~2 v h
}$ x3 w( p w5 ?% P2 k
9 E( i& r! L0 m& S9 Ostatic void __exit led_platform_exit(void)
% O" O; [; @# E/ h, h* K$ ]3 R3 i{7 {% H1 p& c& A& z1 l
platform_device_unregister(&da850_evm_tl_leds_device);9 Y- _7 `8 h* Y, P7 a7 B
: r& u3 K+ ^: e( U/ l
printk(KERN_INFO "LED unregister!\n");
1 w" e. s( [# M7 ~0 ^0 O. A/ S% ]}# Q9 p2 j1 Z! ]$ [7 G' R1 {, u
2 S) X; P9 G$ C- kmodule_init(led_platform_init);
; A" m/ g: o6 b, B" }+ Xmodule_exit(led_platform_exit);" ]: ]9 v0 w7 W2 `
0 c) K$ F3 s1 PMODULE_DESCRIPTION("Led platform driver");
% U) v$ r E* UMODULE_AUTHOR("Tronlong");% i* ^3 X( A% S4 u- D$ l7 T0 x5 }
MODULE_LICENSE("GPL");0 k, N) c/ h6 S" }% s( U5 t
4 T9 w( d H; `+ `$ H! i v |
|