|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, m" \! F; S. n+ J5 \ H
#include <linux/init.h>+ R, e, j. c& l
#include <linux/module.h>6 D2 M* m) |* a4 b0 |% V
#include <linux/kernel.h>" @$ ?' j7 C! n; u1 T2 b3 P8 g4 ]
#include <linux/types.h>
6 K9 Z8 o) _2 ~& k#include <linux/gpio.h>( h4 A% A }7 }9 s9 n# z
#include <linux/leds.h>* \; g4 E9 [) U5 ~: e5 R
#include <linux/platform_device.h>; N/ x0 |. }5 i- l+ E' _/ ]
: m6 ^; `# b* T
#include <asm/mach-types.h>
, G2 P" g7 A4 Q; S" [( O9 ?8 U#include <asm/mach/arch.h>5 W# f0 g8 q; W9 g' N. f) Z; v
#include <mach/da8xx.h>9 r# o" j- L; ~: T' c
#include <mach/mux.h>; T( M; X9 i3 h: e
. b2 j7 I G x; |) x y. _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 D0 g- Y. E6 N, T8 V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! B1 ~- ~; U: w ?2 S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* G5 x5 }5 J0 P% }, S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 k0 ]' O: V, _- X
6 k- k, U2 I4 O0 E6 c2 A! Z& a! S/* assign the tl som board LED-GPIOs*/" Z! C2 g: b3 N; v5 X8 {
static const short da850_evm_tl_user_led_pins[] = {7 Y$ ^6 C8 }3 `+ Z; u
/* These pins are definition at <mach/mux.h> file */2 {( T, a* y( ?3 v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 a% n3 v1 w5 O9 K' u8 ?- j; r
-10 b- ?* J4 B9 z, {: [
};
4 g3 R! O0 h# K; Q+ U0 p2 d0 i7 o K' c
static struct gpio_led da850_evm_tl_leds[] = {
# e+ ?( `9 t4 |9 _/ l) l {( m( c/ N& P$ X) C4 U. H7 I. r$ a
.active_low = 0,
8 i1 F' ]& G- O6 K V .gpio = DA850_USER_LED0, ^; c* ^$ w0 V
.name = "user_led0",1 Z, L d( f7 ^2 b: F
.default_trigger = "default-on",
, R5 t5 r: D0 d3 U Z },
* n0 @( }9 Y+ _ {# h z; g/ \; {' Q+ r3 b4 R" ]% Z
.active_low = 0,$ Q& z4 o3 w* M1 S* x
.gpio = DA850_USER_LED1,
- m% J. H1 a7 f2 H! y+ w' M .name = "user_led1",: R+ A3 z+ H {+ G8 _! x4 m% l
.default_trigger = "default-on", x" H) s$ `* p% X @3 W
},
! u2 b3 }3 ]4 E% A: s5 c' c {3 S0 R" C: @8 ?; }* ~0 b+ w
.active_low = 0,
2 `% T0 X" K4 G* A .gpio = DA850_USER_LED2,
1 }) d% b8 @" b; [" } .name = "user_led2",
8 g# C# e- }9 {$ B- E( b/ C+ A .default_trigger = "default-on",- X+ f0 @9 `' Q( |5 f! J
},# E _$ E4 z$ N
{, g2 A- A) N- {4 q5 B: z
.active_low = 0,
0 D" ^5 M) V3 r' {: G .gpio = DA850_USER_LED3,7 k- }' \. p$ s0 W: i2 s. T
.name = "user_led3",& V* n8 o# h" L& j5 k- C
.default_trigger = "default-on",
2 Y+ M0 e6 |; e* u b8 ^* t2 r, l },! }1 z! \" v/ U1 S
};- n0 k. E8 r# o9 Y0 H
1 U- \: d: @- F pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 k% m9 d" a: L7 A .leds = da850_evm_tl_leds,; x9 z! i/ y$ Q, U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," z' ^6 f* {/ O% ]) M
};$ Q) t1 d3 A- [$ f& Q( ]0 j! [
9 f" X, |" m6 `# Z! xstatic void led_dev_release(struct device *dev)
; |0 Q+ s. w# C7 s3 l{
1 F L2 h, O) J};4 x! ]' m$ O2 V) a' {- U9 v$ Q
! u S% F( ^' }+ l- |5 X
static struct platform_device da850_evm_tl_leds_device = {* R g- d( j l0 y5 B. A6 P
.name = "leds-gpio",
. Y# l& @4 \, j3 c4 U .id = 1,
$ l, D5 t; k) M .dev = {
( c9 a" g/ p! o7 H .platform_data = &da850_evm_tl_leds_pdata,: Y8 \7 o U: B( n
.release = led_dev_release,
" z' E0 L3 m _ r5 w% W! l }
' w* l+ D3 T6 \5 C, [8 D2 f};
2 B; Z4 ~* X4 ?! B, r" ~" L* U( v: Y4 _4 y6 k
static int __init led_platform_init(void)
: e1 _5 @# Y, Y# p ~{- i4 s0 z9 B: i9 J
int ret;: S2 R( f4 v7 G x1 \
#if 0
) \, q8 ]0 Q6 m$ {% [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! \, U* E- V, L" F n
if (ret)
) C2 e% h( b: x' f+ U& b) m3 i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: k5 v( ~9 Z8 v R' B# ~ "%d\n", ret);; x' j) I% i$ T8 f, g6 U& D8 h6 {
#endif9 o6 A- z5 V1 N% U) h
ret = platform_device_register(&da850_evm_tl_leds_device);2 Y, N& y9 t! j
if (ret)
c' {" N& q- B! C' ? pr_warning("Could not register som GPIO expander LEDS");8 T% ~1 v) v$ ?1 y
else
0 F* q+ {0 q' I printk(KERN_INFO "LED register sucessful!\n");
, V% X, L" B8 g4 J. P8 b
0 _4 Q5 i% n9 L$ o. {4 I return ret;( G* C( }) d, @# Q$ X
}
2 N9 y2 ^' x) e, G, E: d8 `
- N. g; g$ j8 h7 ]) o' Y2 Vstatic void __exit led_platform_exit(void)7 f3 f/ Z8 d: t/ R/ o
{: D5 D- C G* D
platform_device_unregister(&da850_evm_tl_leds_device);
/ W4 O. p# W7 M2 I7 z: `: T$ V! s. H- H
printk(KERN_INFO "LED unregister!\n");( K# G! H$ V% |
}" Y* i) q7 R3 c0 C# @: u
; G# O& N- R9 L5 [4 \' m6 a2 n
module_init(led_platform_init);
4 D& e: |6 [. c$ N3 s6 e; }$ Bmodule_exit(led_platform_exit);
/ R) I) v* O, y* ]: R$ |- q# u% p( l* J4 W, m3 n
MODULE_DESCRIPTION("Led platform driver");; K" J* L) J5 \! |' i
MODULE_AUTHOR("Tronlong");
& @5 ^- [9 w9 W# A# |1 ?; y( O3 z; CMODULE_LICENSE("GPL");# F: v/ a T6 b& c5 Q8 n! b& R4 F
! @$ e9 ^0 I: r4 h. Z5 c2 j, {! q
|
|