|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 ^2 \ y3 M: u% m7 k
#include <linux/init.h>
/ L1 W+ T4 Q7 x% R' {6 g/ p#include <linux/module.h>* Z' `# l0 F: S: k j3 S# G
#include <linux/kernel.h>
d' t* m& X4 d) P/ O( p#include <linux/types.h>" F9 n: |1 K- _! h
#include <linux/gpio.h>! W$ r5 V( E6 R; H u$ m
#include <linux/leds.h>
# [1 F/ s! K; [% V) b1 ~#include <linux/platform_device.h>
" i/ i0 U; L; L+ N5 U) b/ S7 g) c( W! ?, R3 n6 ^! G" ~( p3 f6 ~& {
#include <asm/mach-types.h>, P% D; p6 {0 R3 \
#include <asm/mach/arch.h>
6 g) ~5 j5 Y0 B G, T! B% Z#include <mach/da8xx.h>; _: V( i) [8 V6 U5 i T& Q+ c$ E, k
#include <mach/mux.h>
! o& P5 ^8 H ]
C0 `0 {! s0 j f1 ?/ L! {1 v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 i0 }! g+ \9 `: c# d1 A+ G5 B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 @* r7 k: G3 @" @+ A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# \- u8 J# t: n" s3 c% Y4 O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); q: ]# C4 F, t1 Q' W) v
9 c; A6 n, j1 ~5 Q: v8 H9 P/* assign the tl som board LED-GPIOs*/, r1 W6 r0 ^8 C& }4 w/ A6 C
static const short da850_evm_tl_user_led_pins[] = {* A6 o2 E% X) e8 }/ o( }
/* These pins are definition at <mach/mux.h> file */3 S2 x# J" _8 s+ y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 u2 ~1 M' w: _% P4 ?* p, |
-1
8 f3 S" U, J# ^* l2 {4 y! u};
+ B8 q* n1 [; j9 m5 F& ~( c9 q0 I% x
static struct gpio_led da850_evm_tl_leds[] = {
/ o7 @# y% p! C& U {
' Z' o" N2 J* i .active_low = 0,$ S7 K4 S/ C$ ?6 p
.gpio = DA850_USER_LED0,
7 b3 }5 @! ]+ r4 W0 z& w% n7 a .name = "user_led0",
% `1 z( F7 o+ t0 C& C$ e( j .default_trigger = "default-on",
$ s, n/ ?6 W$ _ },1 G r, m5 N5 e6 M) s
{
) s7 m1 Z/ L6 C$ U: b .active_low = 0,5 p9 b9 ]0 i( v, _1 Y* @+ m
.gpio = DA850_USER_LED1,( }% |" {% a" x+ S' J- ~6 u
.name = "user_led1", ?7 Q; z* \3 L3 u7 Y+ c( M
.default_trigger = "default-on",
6 z' \* f8 b' i },
* P2 l# s# u/ l. g& w1 k& f {
3 C1 d8 b; A$ T4 k3 [6 E .active_low = 0,% ]3 B8 ~& O& d
.gpio = DA850_USER_LED2,9 }5 j' A3 ?& x
.name = "user_led2",( T2 ?. j8 Y. @1 Y- f2 E5 U
.default_trigger = "default-on",
6 R2 c) q+ s) {1 F% ]$ j" ~ },
4 n7 v+ X. G6 f1 Z% v, G {8 N4 P+ r) a. E% f
.active_low = 0,
" y2 w5 t- y8 I& v( ^ .gpio = DA850_USER_LED3,( @2 V- e+ i+ S; ]! c& c! L3 [
.name = "user_led3",4 y7 F+ D) q2 \ u3 }' r! C
.default_trigger = "default-on",9 J; ]' _2 U9 f* p$ `
},
; e$ u; K0 g9 }, L. F! E* w# r4 q- R};: ]; m4 t- X4 X( b9 M4 b3 B
$ A% H& G8 |3 I* }7 H p- p2 i `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
R- r% r1 S8 }8 ~2 x6 z .leds = da850_evm_tl_leds,
/ i6 i( j5 |+ T* |! d& S: j .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
], `( p7 U Q. u};* a6 D8 F) o) A6 O# s$ v3 i' J# p1 ]* |
! ]2 F' g) Z& fstatic void led_dev_release(struct device *dev)
l; Z' C1 X7 s% M9 ^; P' }8 Q4 T% N$ Q{
5 l% w S' r0 ?0 _" A; ]' @};
% Z+ t. J. _# F# e/ t
7 A) f6 e8 P5 Zstatic struct platform_device da850_evm_tl_leds_device = {
8 ~8 C8 R. M# _! s5 i .name = "leds-gpio",
7 v6 y" X: X9 d/ I .id = 1,2 ^/ q1 I# c& u) h& f
.dev = {
$ n) n8 Y3 V- E3 m J' B( o .platform_data = &da850_evm_tl_leds_pdata,0 R$ {! w% n; _! r9 p0 g
.release = led_dev_release,) {& H$ B4 c# M7 w/ b
}) Z) C1 A# K$ o6 l
};: @7 _6 D) `+ m. z2 B% k5 E
) D9 ?& q) n& f, Q) u+ d0 H) N
static int __init led_platform_init(void)% M& d M0 J! }; U) U; j
{: w* g/ ]/ o! {0 ^$ Z R
int ret;
( j( T R3 A) O# w2 w#if 02 e/ _- p& L0 t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# o2 U, l2 c3 C$ x. A& {
if (ret)
9 M( W0 Y1 Z% W5 t1 l0 j" K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: ] |; z6 R, I9 j1 I "%d\n", ret);
9 i5 K2 S, E. x" s% g, R" u5 j#endif3 b3 H7 G |( _* i! v9 V
ret = platform_device_register(&da850_evm_tl_leds_device);7 ]% U0 v& ]$ P5 Q
if (ret)9 p( _& |) @4 f# t4 d# }" ~
pr_warning("Could not register som GPIO expander LEDS");
1 u% s a9 d9 e+ R6 N& z5 D/ i else
& J; ^' Y. N( l* V printk(KERN_INFO "LED register sucessful!\n");9 M/ i5 e; w7 ^0 Z1 _& e
6 x) a* f% p" @
return ret;
4 h- X0 n; Q4 |2 U1 ~9 h m9 F* ^) r" v}
2 c2 W1 c2 o8 q7 Q+ w# \
1 [* q: J% y( M. b3 v* ^+ \static void __exit led_platform_exit(void)
# ]" ]- w( y+ B1 n; H5 _- G3 b) o{
) A x3 M6 o* p. L& j9 u% Q# K platform_device_unregister(&da850_evm_tl_leds_device);
, f }3 I1 c& u8 U8 B p2 S) G5 S% h- j
printk(KERN_INFO "LED unregister!\n");, P1 m: A5 B9 @+ G( U
}
, s0 u# f1 z Q& g R w' J+ G n
module_init(led_platform_init);1 q( k! { ]8 u( N$ z) \
module_exit(led_platform_exit);, P1 b- A- I, m+ g
# A6 j3 k- k/ u* XMODULE_DESCRIPTION("Led platform driver");2 l5 `) o: R& i- W. K9 g8 {. b
MODULE_AUTHOR("Tronlong");4 ]- Q* D2 y) y7 m( n' } A7 D2 l
MODULE_LICENSE("GPL");) ]" ~ S' t: {8 k
" q, w/ D h" J$ ^: K+ O; C
|
|