|
求大神给下面的程序做注解,请稍详细些,谢谢。- v7 i( t0 n% g% Z
#include <linux/init.h>
0 c. t4 z' V% {#include <linux/module.h>7 W) {% O- Q# g- [$ ]
#include <linux/kernel.h>& F$ S/ ]; S$ u/ Y; C. y# \& d& G
#include <linux/types.h>
G6 [7 r6 O [4 B#include <linux/gpio.h>
5 ~5 p/ I' `. x: d) o1 l#include <linux/leds.h>" I4 I4 m1 A" z. P/ z" ]
#include <linux/platform_device.h>7 f( @2 S4 T8 D* d: |- Q
* a% ?% m# e, O l' u" `7 ]: g1 ]6 m% \
#include <asm/mach-types.h>9 s4 s: ~ g: y7 e, n
#include <asm/mach/arch.h>) f# Z/ n6 U, L# k+ x5 I
#include <mach/da8xx.h>. {/ R z5 J; c+ y
#include <mach/mux.h>8 \0 o& D7 s) S3 @
% T) v9 `' ~, G1 }: q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 `! `8 R G7 q; a1 R+ ]8 }. A* S) u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 h) `3 T- I7 m B/ ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& _! W* C* k/ C) S# ~6 C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' ]( Y [* ?8 J0 r% ~) o
1 y9 g9 q( R1 y+ o% R) @( S/* assign the tl som board LED-GPIOs*/& b, v6 p8 ?: ?+ U
static const short da850_evm_tl_user_led_pins[] = {
: C! U0 z* c! v4 c" P' h) H$ b /* These pins are definition at <mach/mux.h> file */
2 D+ j( i3 T; B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' {9 Y* `; L( G" a/ t* Y7 l; } -1. c+ R- S9 C$ T ~- _. l; m
};
; [, n$ I1 |- I: n) U. W! _# M& N7 P l
static struct gpio_led da850_evm_tl_leds[] = {
& c, l: ^) ]/ n" }" f6 J) P2 h {5 S" R0 H7 D! O& E$ J/ O* r% z
.active_low = 0,
2 e4 T) C9 v7 R' v, l/ ] .gpio = DA850_USER_LED0,
' \. H6 e2 [0 w/ s3 } .name = "user_led0",
, x2 Z6 [3 D% |' B1 A4 x }" \' j6 g .default_trigger = "default-on",0 o% [+ j. `) U* o3 Q: W$ W6 z
},
- o5 V, T# l% o; a5 x {2 d, J4 s6 D8 v9 n' \$ w
.active_low = 0,5 q- m/ J' J+ b8 v
.gpio = DA850_USER_LED1,2 n+ e% Q( X) w7 u
.name = "user_led1",
: \( a% \$ c+ f& {# x .default_trigger = "default-on", L# o3 `7 w# |; c x4 x
},
& j# [3 S$ U7 y( W; ~ {% P; F! P- r" O& c3 o
.active_low = 0,. @& v4 c- c5 G" _; N
.gpio = DA850_USER_LED2,( l+ f; u$ f/ R; \1 f
.name = "user_led2",
7 A' _/ ~2 S1 Y6 g9 O( T .default_trigger = "default-on",
- U3 q5 a. i# o },
) w0 [* e5 |8 v# u* x1 ^ {% x; [5 H5 o7 [- P
.active_low = 0,
) {, J$ N% o- T. U .gpio = DA850_USER_LED3,
9 {. H2 W- w3 R ]1 d7 \2 w; p .name = "user_led3",
2 c1 Z5 E6 u/ D s% }6 a .default_trigger = "default-on",
5 @1 k: C1 E! w4 L, y },
# L2 \ V( [5 K% I$ F};
( d# i5 P; t. i7 E5 v8 D* r& r7 K: E* s' K9 t+ i0 Y/ C7 j. k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- K- N W! O9 r
.leds = da850_evm_tl_leds,
! Q- \8 {/ E3 l5 H. S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 _9 p0 H6 o% ]- e, |! u
};
: O. D5 [' ~! T& {5 V; ^
- @5 `. B% _5 |, C6 Cstatic void led_dev_release(struct device *dev)
; R: m, k/ T! k6 o6 Q# Q3 Q{' I W2 P9 N: u: j. q& h
};
! D2 v& Y; S3 K# x
2 a# G; [' m. y( V0 G7 vstatic struct platform_device da850_evm_tl_leds_device = {
5 X8 k7 e g6 b2 T .name = "leds-gpio",4 u: E! {9 u8 ]' a( w$ |
.id = 1,
& ?2 ]5 F. o. c0 H" R+ @ .dev = {
! \! \) s- \4 F' V4 W4 Z .platform_data = &da850_evm_tl_leds_pdata,4 n1 N5 ^8 O' k0 @1 F
.release = led_dev_release,4 |$ R+ {" v+ j. q& H1 M. o
} M- Y- k7 }" e: M0 g" x: Q
};# P- ^/ p0 [# p' f& ]
& m3 J) _7 M! w+ qstatic int __init led_platform_init(void)6 Y& u, x( L' \. j
{
( t7 ?% ^6 m' { int ret;; ~4 y& b( |3 B
#if 05 E# u/ K/ w4 G) @2 u' A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 N \5 v) k7 v4 \4 N if (ret)
, `+ w G3 G, T5 |( X; t' i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# A% r3 F; @0 w I T! W/ p* q( h "%d\n", ret);) ]" F: f* V' z( A
#endif7 L1 U5 J) ^& N, \8 J" @
ret = platform_device_register(&da850_evm_tl_leds_device);, g3 o, {; F8 x3 L; z9 E9 y
if (ret)
7 R, \3 x& [8 n3 L pr_warning("Could not register som GPIO expander LEDS");2 g$ s9 z% O! E
else X8 _" h3 l z6 c+ Y) |
printk(KERN_INFO "LED register sucessful!\n");6 S B- Q/ v# f5 r3 a; E6 o
) l, ^4 x+ b3 f" u
return ret;* G$ W# c* A U" t
}
$ y4 a6 P& a. C4 K3 ` z4 Y9 S# ` p" F$ e% ]
static void __exit led_platform_exit(void)
2 a; a4 n& F/ K6 ]5 v{$ S6 p# w& O3 r6 B3 w. B$ q
platform_device_unregister(&da850_evm_tl_leds_device);2 k$ } D& C5 V" F3 F* Z
% o: U! ^% w$ H! ^- C0 I printk(KERN_INFO "LED unregister!\n");
9 Z9 l/ m- f& X1 _9 X# e}
: x5 {: {# j3 A. o. u+ I0 Q% E
5 G5 u/ b* v! N. P2 Z! i% c' bmodule_init(led_platform_init);( l7 |2 K$ n8 T; M
module_exit(led_platform_exit);
$ a7 K. S: A4 ~3 ^# s7 H0 J. _7 j) C9 E. ?% Z. r7 X. o
MODULE_DESCRIPTION("Led platform driver");
6 g g8 H* w+ O kMODULE_AUTHOR("Tronlong");( b! I: }7 g. V- v7 G4 a
MODULE_LICENSE("GPL");$ a* ]3 f- v9 h0 z8 p4 X
* q5 z ]5 a5 a" ^ |
|