|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( m' I8 K- O- S4 q7 R, R#include <linux/init.h>
6 q8 K3 t# y* p/ i#include <linux/module.h>- A0 L/ ^! G0 S& l" X. a
#include <linux/kernel.h>
@6 K* r$ r! H" g7 Z! ~# c' K#include <linux/types.h>- N# u) ]/ D# U" ]$ ]7 u
#include <linux/gpio.h>
4 H) q% U4 e6 v) U& B2 a2 r( X( g#include <linux/leds.h>5 W% I( h- g: ^( |
#include <linux/platform_device.h># c* {$ e9 E, W4 L: X" J
5 x9 V% I' k) `" a#include <asm/mach-types.h>
% O, ~) i2 V0 `7 C( W% {6 E#include <asm/mach/arch.h>, M' _ R" V5 o$ W0 T- ]' m
#include <mach/da8xx.h>
8 D" y& R4 Y1 p#include <mach/mux.h>
* ]* {9 c6 c. O* b* R) x' ]' ^# `6 _5 Y7 b, I4 n. p- a! c- w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( `$ S) p1 K Z- m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ j0 ^; H% M, {2 T% @! Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 |0 A, w' h0 x& m8 o; x0 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* r* W: D. S f, V/ q. m9 ~: I: {4 M$ H& i: A
/* assign the tl som board LED-GPIOs*/2 W5 B a- ~$ B3 _' t4 |2 F
static const short da850_evm_tl_user_led_pins[] = {
0 |6 ?0 B: \- x /* These pins are definition at <mach/mux.h> file */' d: t& Y2 O2 P- S; ^) n: `, H- r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' f, b' H6 {0 K) a. A6 H; c -1' H9 i6 z2 L6 T4 S" t) ~! k: H
};, Z# W2 D- N1 L6 n: p5 }: P
" G# a* L* e4 B+ ~) g$ lstatic struct gpio_led da850_evm_tl_leds[] = {% j D( V8 _- p0 m9 j# t2 \
{
2 | M; H7 P! {$ ~, w0 L .active_low = 0,' B. K2 G0 M: a$ k7 g' s7 n6 Z$ O
.gpio = DA850_USER_LED0,
2 \& a- a" ?* O& \% \+ N .name = "user_led0",
# j4 h7 Y V( n9 j% n, A2 y ?( n .default_trigger = "default-on",
! {1 O" [9 M S7 Z* v },
2 h: d8 X" S' p {
6 A2 L) G: l3 t( U- k4 V& }& g .active_low = 0,
2 |; d0 Q9 F! q8 F; @, A" P .gpio = DA850_USER_LED1,
9 t9 [9 C& |1 o- n& K .name = "user_led1",
+ [' ?6 ]1 d. ? .default_trigger = "default-on",
6 a# x( u$ R7 T9 _ },
* y. s: D6 m" t# S/ J8 I6 T {, m; Z2 k7 K9 X. L% ]% \: r
.active_low = 0,& H% t" }6 H* t
.gpio = DA850_USER_LED2,
$ t+ n& S. x" f k! ?5 v5 I+ L .name = "user_led2",
. v) k+ |7 ?- I4 U4 H/ y .default_trigger = "default-on",
7 }. i# W, F/ Y9 s! K0 I' n },
; O7 ~$ D6 H- C; L' ? {( x2 r7 F' H; N, g7 b
.active_low = 0,
2 Z* M- N2 G* C& d1 s .gpio = DA850_USER_LED3,1 N0 N# k- d4 t: o: s* c! b, K
.name = "user_led3",* J9 w; Z3 K! E% S' C& N) E
.default_trigger = "default-on",
9 |$ N' j# T6 B ~, p2 d" v },
) h- r7 \8 g" u, w$ S$ y# Z- k" X};2 V) A* v, m# H. W! q/ [! c7 l
/ p6 `2 p5 v& P+ S3 ?$ J# |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( K! _. b% h! M* s; C
.leds = da850_evm_tl_leds, `7 B4 `7 S- l6 f0 u3 {- M
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ P7 O+ X9 `- R) s0 N" ]};# d" g* _5 C* {/ |" s: j
" E0 Z2 V$ Q6 ]& I, _3 ~: z' zstatic void led_dev_release(struct device *dev), R( t& q0 O- @) b
{# B9 ]( k0 [+ r
};
$ A) z( j1 O/ [, ], ?
4 I/ K+ I( ^6 Q: w+ a- Q) ostatic struct platform_device da850_evm_tl_leds_device = {/ a9 N1 L$ j1 k8 j+ K
.name = "leds-gpio",: v6 ^ ^# `: D) O9 r
.id = 1,
$ _* e& n8 e2 ~* Y .dev = {! D, n6 @4 o* Z: C! \
.platform_data = &da850_evm_tl_leds_pdata,
0 o! {; K( f* ^1 k" H3 C) T9 s! @ .release = led_dev_release,+ f1 f& Z2 p9 V* L! ~( b
}6 i( p: {- j5 ]. A# d2 v' F v
};
* Y8 R: p' Y/ n1 L# S8 ^' K% V1 n4 k' \
static int __init led_platform_init(void)
) W; C7 h- j8 V( P{
$ d2 ]8 q3 y4 O: O# d9 R; L* x% N int ret;5 a! C4 n% ?; v. t8 z6 l5 }! l
#if 0- V- T1 s8 ^/ i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ G! i5 |) V9 J. h/ G+ P* o if (ret)
7 v5 Z& }3 V5 y. D( S( d8 a& K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. J! o/ j+ v( _5 H3 Y" p "%d\n", ret); Y5 q, M; ?2 e: X" {7 k4 H
#endif
7 R) D. I$ _ ~ a ret = platform_device_register(&da850_evm_tl_leds_device);6 A, ]& a0 e6 b( C
if (ret)
9 ?* i4 L" N! S9 v( ^. l- i pr_warning("Could not register som GPIO expander LEDS");0 B# b# m! S( i k
else6 M1 A8 d7 l/ v2 X( P1 L, }
printk(KERN_INFO "LED register sucessful!\n");- ^8 n( t' K2 N, O+ X
; Y5 ~9 T) d* h+ D return ret;0 i+ {7 J6 J! m ]7 O
}
" o- K3 S4 {! k
1 F; ~/ {! \# z: X& o+ v& [# o$ cstatic void __exit led_platform_exit(void)1 D" ?) Q, D# M( _& \! E" r( o
{- c- h( s/ D X) @$ z8 S$ L2 J- |3 @
platform_device_unregister(&da850_evm_tl_leds_device);9 A. ?6 I J" H& J& C
6 f# }4 d, j5 f3 @% q2 c
printk(KERN_INFO "LED unregister!\n"); o* }: q+ W# ?3 w3 F Z$ ]0 U6 C. w
}
3 J" {1 A: b% g! o6 _
" S* P7 m& @7 ?6 V h8 `3 Zmodule_init(led_platform_init);
, J& `8 C5 u, o6 @' `. Qmodule_exit(led_platform_exit);: R) R( K9 _/ w. M2 a2 ?) D! y
# e o4 [/ e V: W
MODULE_DESCRIPTION("Led platform driver");
8 ~( O2 m- |3 A( P5 e4 O; `MODULE_AUTHOR("Tronlong");- W6 Y, c+ i& _# B ]' c
MODULE_LICENSE("GPL");) b) p9 l$ \! R: D! `% X/ o1 i o
) e5 m9 X, w) s/ Y
|
|