|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* f7 o2 e; O. f. b1 s#include <linux/init.h>- U( `% `9 z# U
#include <linux/module.h>% K; X7 L' {* x2 j
#include <linux/kernel.h>3 F9 g7 M ]9 U9 h
#include <linux/types.h>; ?7 y* l( D' S) v! {2 a3 R. R& d
#include <linux/gpio.h>$ H. r0 i# W N8 s# m9 Q% S
#include <linux/leds.h>9 u, D Y# C9 [9 D; l) L
#include <linux/platform_device.h># X5 \. Z4 h4 ]' s: D' P
) G$ F& S4 S. F; K4 C1 p
#include <asm/mach-types.h>! u- T9 Y2 H/ P3 t1 C6 x9 ~; ?' z6 N, l7 ]
#include <asm/mach/arch.h>
1 d: w% d8 u' r, d( m( m( O#include <mach/da8xx.h>
! V$ ~, B- H6 I4 S6 P8 s#include <mach/mux.h>
4 |3 X( ?/ V& X. b; J: n5 O0 Q" X, ~ ^. f3 a) K r7 q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ w$ v0 L" \( v7 e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; w# S& Z A9 i6 f# X; T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 j3 c2 g) v% j* J# N/ ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 v* w2 X- ~ w- q
& q6 P4 l, Q& [; a" j
/* assign the tl som board LED-GPIOs*/# J& z7 K$ ` _% L
static const short da850_evm_tl_user_led_pins[] = {
. `& d" X( Y8 U& d /* These pins are definition at <mach/mux.h> file */. E4 i1 a+ `, T" Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ l! J# }" `& p' u -1
2 E& Z' q" }# h' a$ P( b& F};
/ ^/ w) p. u" k, o. F4 h: J7 m; r$ k2 m/ z. _7 a* E/ n, ^
static struct gpio_led da850_evm_tl_leds[] = {: J ] F* o% X3 N2 d! M! S) E
{7 W3 _# A! U2 y' J/ u
.active_low = 0,
3 G/ w8 M/ w$ C" ^) _) A: W9 L .gpio = DA850_USER_LED0,+ ]9 s) A# Y& g/ X! t3 G
.name = "user_led0",5 p5 ^+ O; Y& V$ v$ Z0 w3 f/ b% t
.default_trigger = "default-on"," y% x! b7 U% j* u' M% c
}," _0 A" E: E: \* H9 M5 u! ?
{
; T) E' g% ]% F% C4 [ .active_low = 0,
0 e; x' X9 [6 H1 ?9 p .gpio = DA850_USER_LED1,6 ^) t! J5 Y+ l9 M9 [
.name = "user_led1",$ E$ ]5 ]& w6 d6 n% z
.default_trigger = "default-on",
, F5 Y+ Q* k. }$ u n& s3 c },
% `9 U0 r; l+ v: @ {
1 S# Z: m6 {9 c. g. ` .active_low = 0,
! D3 J1 T; m! c1 \ .gpio = DA850_USER_LED2,
% ~" g& x+ J* [9 W6 Z% y/ ? .name = "user_led2",# q2 F5 [' x q* E
.default_trigger = "default-on",1 V& V! r0 S4 S3 I. v
},
" B1 B- u8 d9 p2 [& X( d {
. h" J" |3 K4 g* e* V .active_low = 0,
5 U1 a6 {$ T" i( s, H* f .gpio = DA850_USER_LED3,4 | }3 g9 i3 w1 l, [
.name = "user_led3",
+ L. ^+ ], c+ d B# n .default_trigger = "default-on",
; `! O9 G2 } `+ ` },( {# ?* k: R: q% X
};1 S o3 j1 E0 Y
4 T f" ~7 C$ ` x: P7 mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ V" [, d2 P) }
.leds = da850_evm_tl_leds,
! z9 j% n' |4 X, x! k- c% u; B" i3 O .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 P8 I8 F0 C, a3 s! f8 R
};; Z9 d* m( W4 |2 q$ l
' o0 b7 S( Z8 Z/ N/ f! b
static void led_dev_release(struct device *dev)) U9 `3 |5 S% Q2 k. Q' c
{
. Y3 h1 {7 P; U; ?};
5 Y9 t+ h3 F# u( o! P9 F# q% M$ c, x6 O% T
static struct platform_device da850_evm_tl_leds_device = {5 O6 `( |5 Y6 Z5 z* k5 l$ A' w" M
.name = "leds-gpio",3 j# M/ r( M7 m" s$ ?1 p2 I
.id = 1,
* @. Q' I* g p# B7 C H .dev = {
7 I1 S' G/ a8 U% g {# s .platform_data = &da850_evm_tl_leds_pdata,
' a8 D/ @% t9 A# A .release = led_dev_release,
$ j+ i- h* g' x) m) ? }
* }9 ^/ G( L# h5 d7 T1 C2 k1 k};" n) C6 a2 k& |' W* ~1 u8 ], m8 C' e- I
8 y- H( Y' O5 bstatic int __init led_platform_init(void)
/ Z4 u( {' y H, ?6 V6 {+ v y{& s' i( Z n+ F7 y) Q9 F, u/ n
int ret;
/ v) q7 z. ~0 U#if 0$ h% a6 K: n+ z- L: D& e9 D( A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" d) E- }( a' O" H3 {2 i
if (ret)
) N2 Z1 C9 U A! x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 s8 V6 S8 R- [1 z* n
"%d\n", ret);
/ K* A. Z' q" a( i4 Z$ q& M$ T#endif
# H3 z% _0 M2 u1 v$ \7 R ret = platform_device_register(&da850_evm_tl_leds_device);6 B1 u* q) p6 e6 f$ K6 m. I
if (ret)9 v3 x: i2 v: g- L
pr_warning("Could not register som GPIO expander LEDS");
( K; [& h* r# O% ~ else8 d9 P0 x) X2 q% ?* M8 e
printk(KERN_INFO "LED register sucessful!\n");* G) `" m' M2 x8 C6 c& {% Z
0 H. }' o6 |0 C. e1 Q return ret;& w2 B, J5 L; U
}! N; k8 [; a" t9 I# q/ r' S% R) G
5 W/ ~2 L, i/ F/ ^6 q
static void __exit led_platform_exit(void)
* N" I5 m( K! x4 j8 Z{
9 N% i7 r9 c& Y, r5 e platform_device_unregister(&da850_evm_tl_leds_device);8 C5 G# n n$ P, P. w7 w
. O5 a6 U3 a$ E9 q+ b
printk(KERN_INFO "LED unregister!\n");
* N6 g- ?" e+ d}: ^, K' T' ` ~: H# ~( R# {
7 I& E( j5 O1 d6 |7 e8 d2 }8 gmodule_init(led_platform_init);
6 w5 _) v" O% lmodule_exit(led_platform_exit);9 v- X: c& A! ?' A" F1 M3 K6 A$ |
y: q/ H# a7 l! O( L) [+ F
MODULE_DESCRIPTION("Led platform driver");& Q3 g! c- X: |+ k* r$ X6 f$ O
MODULE_AUTHOR("Tronlong");# J5 E& c( P/ {' p7 i- k1 w
MODULE_LICENSE("GPL");
! J0 p8 u4 t! Q) B+ u6 W
& x$ N2 d m& }% J7 F |
|