|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 _( e1 D" f+ B# Z9 w; E7 s: N M#include <linux/init.h>
; ^, l& w+ m8 T, G- v6 E3 I#include <linux/module.h>7 c8 `6 ?3 }: y! |) j+ R
#include <linux/kernel.h>$ ?6 p2 _9 B+ r: b. ]" H/ M
#include <linux/types.h>
f; J; e2 S5 R" _& R#include <linux/gpio.h>
" H/ M7 s7 _/ {# w+ n" W% k#include <linux/leds.h>
0 Z: ^+ {6 D5 T5 G#include <linux/platform_device.h>
& G8 c2 ^4 `7 k9 {8 g: |; Y
" [2 \6 F$ [* L h9 c' m#include <asm/mach-types.h>
( g) n$ U. ?; a: [#include <asm/mach/arch.h> G x' g( z" _5 ~
#include <mach/da8xx.h>3 R- B# o4 a9 J
#include <mach/mux.h>
( k; @/ g" Q5 P' M W# f/ H7 I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 Z3 U7 B. w/ F, c, h; Q( Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 ?7 [; b# R' o, ^" s+ p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 c4 M9 f2 k+ [" \6 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 P, {; S9 h" g2 u* ]1 e1 {9 R- Y, o6 J; e: i8 n! L8 V4 X! }
/* assign the tl som board LED-GPIOs*/
5 N2 G; y [( T: ^' Q4 \6 J. f0 |& estatic const short da850_evm_tl_user_led_pins[] = {
. C) l v1 K6 Z% N- y$ p /* These pins are definition at <mach/mux.h> file */( v1 Z3 P2 k' R# J! i2 V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 Q* c2 q9 A5 @$ ?# @7 I -1
+ b9 R; a* o% Z; |+ W};
* c: y. M* p- Q
$ r( _1 r( K+ D& V' d# J q4 sstatic struct gpio_led da850_evm_tl_leds[] = {( s! ?. r5 N/ L6 ~) w7 K
{( ^9 f* K) t7 M# [* E
.active_low = 0,
6 c# H* P2 y- R# U: C8 C .gpio = DA850_USER_LED0,
. n' O# V4 n( K: A% Z0 }" D+ `! S .name = "user_led0",; ^6 f: R3 L7 z* o( d* s
.default_trigger = "default-on",
+ |( `0 g4 E8 F6 H6 b },
8 u' _- J$ T5 g, Z {
; L$ i' g0 {% R .active_low = 0,
3 O+ [! q L/ c' ] .gpio = DA850_USER_LED1,( {2 \, J. l' h' @" b
.name = "user_led1",
! w6 S* S x* U0 o: X9 N) [ .default_trigger = "default-on",1 r2 I+ }2 \4 s6 Q+ d. X
},, X. {6 \% |1 _" u9 n# o8 X
{: n) A+ |7 b' W, h' u$ Q
.active_low = 0,
# H7 ^8 [# l) h H9 W$ m* o .gpio = DA850_USER_LED2,
5 F0 h8 y! A9 v2 d' W .name = "user_led2",
, D6 @: q$ f% R3 ~; N a! [5 I .default_trigger = "default-on",6 {7 J) E1 f) D
},
( ]8 `# l* R0 J9 Y+ {" R {: C4 _) q8 r4 c( k6 x9 Z
.active_low = 0,
- {! C! l! C& w6 R# v" U O. _* Z .gpio = DA850_USER_LED3,
* J) s9 I: v5 v! n5 Y* V .name = "user_led3",; I k, T t8 k+ R# F# ?% L
.default_trigger = "default-on",; N5 E" l$ _; K% S1 ]
},9 T4 P9 S4 v! E E _6 k) \
};
2 N2 w1 \4 p3 i$ v0 i% c
2 v. v6 _6 C5 n5 i. D* [static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) d; O3 h% T" u% E6 x- x
.leds = da850_evm_tl_leds,9 ~9 |8 f- q, i- T2 [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 n. F* U$ ]) d; }) C8 i! ]0 }
};
( ?( {2 n& \! S- k: o
' Z; I/ `# z% O Q% `& k+ `; A( {static void led_dev_release(struct device *dev)
4 q$ ]/ V6 ] u( N- v$ B{: b0 ^2 r. |: c
};
0 h" Y- _8 |0 z7 v/ v2 h2 N- L# W4 l7 N( d: }9 x
static struct platform_device da850_evm_tl_leds_device = {
' M3 F! z# k5 o# Y5 C s .name = "leds-gpio", y9 b- [& I! G4 W
.id = 1,
0 _3 S, \/ d' c" t .dev = {
6 ]1 @; A; j) V .platform_data = &da850_evm_tl_leds_pdata,8 A) P8 U0 U+ L4 [& b
.release = led_dev_release,9 ~7 @1 _4 y" U ^0 t" ^
}8 v) x/ P% g' \4 Y
};7 w ~& }! B' v0 [) y! e. ]
/ H( F& L& V4 ^$ h: ~: u. T# Vstatic int __init led_platform_init(void)5 T1 S) j. }: j, y3 V& N8 u
{1 D) `$ D. V3 f4 n; ~ _9 Z* Y
int ret;# B3 L' q: i1 }& z. W9 ?( X
#if 0& B) j; U7 Y( T4 ^. }7 n i/ p! K
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* }" z! V8 O! L3 l2 L" ~3 a
if (ret)6 O" U$ t' m$ f: A# r, M; Q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! Z; B# \0 D+ e$ ?
"%d\n", ret);$ H) q! ^0 M4 Y2 F4 r9 C
#endif9 Z) x' g' }5 |0 [
ret = platform_device_register(&da850_evm_tl_leds_device);( B" g8 s, u( }9 B) p
if (ret) i$ p8 F& ?8 I, [
pr_warning("Could not register som GPIO expander LEDS");* _& v$ ^1 J. \
else! K6 ~- r. w' w( A( A8 Y( x
printk(KERN_INFO "LED register sucessful!\n");
) @! U* s: ^6 b5 J; E# ?; ^* x
* Z" \1 d l @) ~8 q- s+ D return ret;
& N% R: _" `2 d; O# H, s9 P}
4 Y6 u7 _3 f& g: D4 y' Q9 v' `8 N% H% ^+ d& _4 w
static void __exit led_platform_exit(void)" t" E1 T: I" H6 u( Y
{
5 G9 n0 C+ A) M( T" S platform_device_unregister(&da850_evm_tl_leds_device);
6 a7 S- _) ^3 W; d, A
t" O" `1 u* l- e printk(KERN_INFO "LED unregister!\n");& C. \; }. }. P: T
}
q4 ^# w/ b- w4 r0 U5 l$ C4 _/ A& G9 F* {# h P
module_init(led_platform_init);4 C; ]* X- _ L/ O( O' U
module_exit(led_platform_exit);7 \* [) z) c+ C5 M
2 T; Y2 Z, V8 ]* y7 r) u3 P3 ]/ \
MODULE_DESCRIPTION("Led platform driver"); D/ w, D" k2 L4 c3 U( N* @4 I! v
MODULE_AUTHOR("Tronlong");" S7 U9 x! P% A! z
MODULE_LICENSE("GPL");( I. X+ o! K& u0 j) d# E" v
8 r) C* [2 X b6 e5 r
|
|