|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- n% w+ h. G1 u- [8 J. X#include <linux/init.h>
( p) K; I) I0 ?2 T( c6 }6 U- I#include <linux/module.h>" E6 B. `/ l; {1 X+ e5 D, H
#include <linux/kernel.h>- D% S' z3 {; s- M! }/ V; ~" M2 {
#include <linux/types.h>
( m# e6 i# A e7 `% m; b#include <linux/gpio.h>
5 x" Q/ D9 x; Z4 L1 ~! J! i#include <linux/leds.h>/ C6 F, I" C: S7 M
#include <linux/platform_device.h>
2 k: S6 a* Y6 {) y4 }* ~& k& Z# G' F. {
#include <asm/mach-types.h>: O/ k0 b' i @+ c- ~) ]' X% W
#include <asm/mach/arch.h>4 @4 r& n5 l6 ^
#include <mach/da8xx.h># T& z/ R- J: i3 q
#include <mach/mux.h>
& v. y* _# T2 c8 [- H6 h% M0 w! f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, v& G. P+ W3 F* s; |9 _$ [) i& B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 e+ l" y4 X3 q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 j8 C7 Q9 ^8 ^! [1 W" M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 e1 z1 m( x$ o; H5 M: l7 n D
/ b8 a/ f( H: e% ?9 g0 A5 w/* assign the tl som board LED-GPIOs*/
2 S* L! K- V6 \2 C8 istatic const short da850_evm_tl_user_led_pins[] = {/ X1 v# U8 i' D7 ^/ V7 ~
/* These pins are definition at <mach/mux.h> file */
: b# \# {& ]" k3 C, a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% D' C, t" B+ P5 {, [ _ -1$ J7 [, S4 Q) t% A+ U
};4 z% z, f4 r _- b; ]2 @6 Q
' c3 \7 o9 ?% j2 z% |' e8 Dstatic struct gpio_led da850_evm_tl_leds[] = {
% V3 F0 {! o( j, o$ _' x {7 I( O2 F9 H! {
.active_low = 0,% s& `2 t5 T* r$ Y' i- v
.gpio = DA850_USER_LED0,
' Y% c: m) d m0 Y/ K% { .name = "user_led0",
6 q8 Z& ^' ^! o1 T, Y7 B .default_trigger = "default-on",' D* ]4 A0 N, F
},- Q8 x/ G, S9 g- [& m( |- O& Q
{" m: _; [; [: c5 P T$ }
.active_low = 0,* o; ]" H$ I4 \3 K5 ~0 ~6 w
.gpio = DA850_USER_LED1,+ n3 Z j1 ~; \% S8 F" t! I
.name = "user_led1",
/ Q9 F% }2 O/ b7 M: y .default_trigger = "default-on",
- y3 g! [4 y$ \1 b, V) o y) E8 o },
% T- W" C# B# v9 j {1 B0 X+ e- S4 b, c" h0 @4 F7 [
.active_low = 0,+ @7 `* S! L( u
.gpio = DA850_USER_LED2,# H+ U7 P0 p' f) @- I& D
.name = "user_led2",
: _: I( z, Q& h o .default_trigger = "default-on",* A0 ^- Z" J8 g3 p/ \9 r8 ^4 C
},+ t; j4 L' L& ?! \" t
{! D2 p3 q8 K1 n
.active_low = 0,5 w I' L. a' W
.gpio = DA850_USER_LED3, v C, k! V9 G' J0 d5 }7 A
.name = "user_led3",
8 I3 U; w2 H, i! a .default_trigger = "default-on",
2 l; e" G! ~. N6 s8 w% n },
0 r% @0 n3 @3 `3 r) ^};4 H T0 l) P& g
; ? j& t! R" S$ {; H- gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 B! c, A# {" y7 t( C% w# k
.leds = da850_evm_tl_leds,
/ W! U3 n$ P* N8 X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) i. K+ [: c. Q
};
( G' P2 _4 i1 i" \) A( ~$ g F- j f4 D( a9 u$ {
static void led_dev_release(struct device *dev)
5 C0 Q+ R+ h; G! _{
' `9 A. |$ M- k7 D9 a};
2 `) D9 L% C3 w' X6 Z5 L
/ D5 `) o [4 i1 ]9 C* m$ m" D" estatic struct platform_device da850_evm_tl_leds_device = {
b$ p& P0 J, o4 T! h .name = "leds-gpio",
! `+ U) Y: Q- \ .id = 1,& S9 M6 a/ ^. z! d$ ~
.dev = {' J* O2 Q* V6 Q9 i, J
.platform_data = &da850_evm_tl_leds_pdata,
) F. s4 h' @2 @4 _: K0 f, q .release = led_dev_release,
" A# o& q: w! ?+ `4 f! r$ _ }0 E3 r8 m9 E6 _
};6 a7 }; D' d5 E* Y6 @3 t0 v8 P
0 v a& G P$ f- A: d( zstatic int __init led_platform_init(void)
; t, R, f; `0 u{
# @% f% A) _% ~ int ret;% h @$ r# A6 I* A
#if 0. `% k. {# p0 ^2 W9 d" }6 L8 T; _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. O) D p+ ]2 @9 O- V- z3 K if (ret)
" x" Z7 x9 j: q8 Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 p3 a+ h7 J2 f0 B: w
"%d\n", ret);& P) T1 Z1 g) ^! o/ V( L! @
#endif
# }- z- J2 O9 j$ |0 A ret = platform_device_register(&da850_evm_tl_leds_device);) [$ d$ t: r# b9 \: ^$ q0 n
if (ret)
s0 b) k- l- A Z& i' } pr_warning("Could not register som GPIO expander LEDS");! |3 }2 i; k9 x2 N1 c! D- E5 A
else& K- Z$ U& ~: \* A4 ^
printk(KERN_INFO "LED register sucessful!\n");
! m+ C* X" B/ i% d# }- c+ b; Q y/ F: i1 l
return ret;
$ [+ E) ~) R6 o5 [}
8 u- Z' U, C* Q) S. Q3 p
1 i% b& G2 C" ~- g) u! w, g! k0 Ystatic void __exit led_platform_exit(void)
5 u6 ?0 P9 O) T4 o{
( n" I4 k2 \9 H6 W S& d) F platform_device_unregister(&da850_evm_tl_leds_device);2 r3 l" K; N: A' \+ R1 ^& Y
8 r+ I" J; ]: b; D9 K) x" L9 b0 l
printk(KERN_INFO "LED unregister!\n");
9 y& w& H4 L) v5 Z: i( E}
: p+ L+ w* L+ S3 \) j( h* T
- g# Y& |9 N+ Z" Hmodule_init(led_platform_init);
/ }$ c1 O0 o' }; Hmodule_exit(led_platform_exit);
3 L9 d9 A& {+ r: z4 H& }0 e9 P- q6 s7 p6 e
MODULE_DESCRIPTION("Led platform driver");4 z# X$ p( K2 B- ]5 C+ k
MODULE_AUTHOR("Tronlong");) {& P. I: ?, b& ?
MODULE_LICENSE("GPL");
7 p, J' n( Z" U" o. [0 F, C: `0 @. X6 U( {5 ^! j- A2 e
|
|