|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 g5 n! X: c% l#include <linux/init.h>
# e, e* g& d4 i! Y! Q3 Q' R& {2 b#include <linux/module.h>9 c8 f! x, d; O$ q
#include <linux/kernel.h>/ m. e7 i2 Q0 P" q ~
#include <linux/types.h>
7 {5 M& T7 _ L& j$ [#include <linux/gpio.h>! w; @6 F4 _: f+ M$ x1 X' Q
#include <linux/leds.h>+ z# n7 V1 P+ H" D
#include <linux/platform_device.h>; V d0 O3 l& n/ D. T) I4 b
+ T: q6 }1 Y! C) t& x, K
#include <asm/mach-types.h>& f0 v+ M x8 w" E2 l3 F. A, l
#include <asm/mach/arch.h>
2 N7 d$ [: P; H3 P( B#include <mach/da8xx.h>) k% b& Q% ^/ q% J8 \: O, y x
#include <mach/mux.h>
& c; \7 f4 E3 U) c+ J9 `
7 W6 Q7 D: X7 c( P* c! A3 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ N# z& c7 B p' J I% |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 W% w" s; v& w G& ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( e8 [& D6 n% K- R6 i f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( i; g# y# d5 m
/ r$ o* x5 n$ [* `9 U* t/* assign the tl som board LED-GPIOs*/
( T5 z% H0 J C! H3 f5 L% ~static const short da850_evm_tl_user_led_pins[] = {
" A* c# _7 W- Y /* These pins are definition at <mach/mux.h> file *// x6 n8 a( [7 x& E2 v( S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& T1 Z* U9 Y' {& ~6 v -1
' Y0 C6 G9 z: o7 F, G& O2 Z};
2 Z: x( ~6 v8 C2 z+ ?( B5 \
* n+ E/ @+ J+ K6 H/ P1 d, Z$ ustatic struct gpio_led da850_evm_tl_leds[] = {5 ^- u& h. S: n0 v! Z- s
{1 m" x6 [2 K6 J! B2 E3 `* D: ^
.active_low = 0,$ }. a/ u; S& I9 _4 {
.gpio = DA850_USER_LED0,9 \5 O) u# a" P% m1 e8 l
.name = "user_led0",
) T0 T Z' N1 Y* l7 K/ \( T& B .default_trigger = "default-on",3 v8 y* c* G4 Y7 Q$ h) v+ H5 u8 [
},9 I, y1 |. t4 N/ |
{
- b- s: U; s% H% j& L .active_low = 0,/ O! t% h4 |$ W# W" Y6 ~ Q
.gpio = DA850_USER_LED1,4 ]0 r3 x/ Y8 V* s
.name = "user_led1",
4 [+ m( A, P8 u' f0 _& H .default_trigger = "default-on",; r' M+ _( z, Z! M' k7 _+ ^ u
},
) G% z( D3 A' c5 n- E8 ]# F {% h, G8 C2 j, P
.active_low = 0,2 w5 T8 `4 R! P& @7 T# W, {
.gpio = DA850_USER_LED2,, F% C( N+ |: @
.name = "user_led2",
* m5 ?, y2 q. q+ I$ @ .default_trigger = "default-on",
5 G! u. B. f v: E# @, c: P" N },' Y3 K/ k$ Q5 M
{1 @' F, p s4 p0 O
.active_low = 0,
: Y6 d" C( K& {) n; b( K t .gpio = DA850_USER_LED3,
. i1 ?* S* P4 @3 O! @2 V .name = "user_led3",3 [0 e7 k/ ]$ G# C- k5 g: m6 z6 ^; f
.default_trigger = "default-on",
: _8 I+ D8 [, s },! d7 F/ T1 v+ ~5 S
};
" O0 N& a, O; F! z4 }+ ~
( a! f2 T& ~7 E# c% lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 m3 P( G0 i; ]* |" G c .leds = da850_evm_tl_leds,
N: f- C+ I9 r' V9 G3 l$ P% n# M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 X$ o) I) e q+ j# q};
2 x! z5 ~3 U& } S/ }% I! s( Z
. `- I. h, x+ J- w5 W4 U& Ustatic void led_dev_release(struct device *dev). d2 [2 R* O" M3 j$ l
{
* A" k% \& e6 K/ L};
e2 t! z8 i" r9 ?! A# b! r: O: I# T% O
static struct platform_device da850_evm_tl_leds_device = {! R0 {0 b$ q; a. s$ k
.name = "leds-gpio",
) x) N% a, D7 s) t8 ^2 V5 x .id = 1,
* t$ T% ~ F( @ U8 r7 m N& Q .dev = {: C! }2 `+ h; u' j: }" {
.platform_data = &da850_evm_tl_leds_pdata,
4 [+ E7 P* u% C4 Z3 O$ J .release = led_dev_release,! O4 f0 C7 y" X+ o, M$ |( }0 D
}
+ m |. \0 C+ m" z! f};+ {- r7 B8 D0 [3 U+ R( h/ H
3 x5 g; y! f8 Y% c3 G& tstatic int __init led_platform_init(void)
5 Q) K9 E3 o, N5 n# v R0 y{+ u! n D9 b! Y1 @, x
int ret;# n9 K, x. J" R
#if 0
! P+ T- X0 U, C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( e3 E, @# r: N" [ if (ret)
. W1 I" `/ O+ `# m5 z' Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 N: q' K6 L/ C x8 H. l0 ^
"%d\n", ret);
; i- [; b8 X8 p! W#endif
& N: r. k1 Z- m. R- T, A. V ret = platform_device_register(&da850_evm_tl_leds_device);! I8 ]8 }" k- e$ p! J
if (ret)% ?9 t$ W' ^' c( L9 X3 b) K
pr_warning("Could not register som GPIO expander LEDS");
. X9 q2 s& @5 f' r: j else
4 T/ l5 j1 J' O. A* q0 @- c printk(KERN_INFO "LED register sucessful!\n");$ [1 B: X. X+ E$ ]8 ?" J
& j( O$ u/ K. N( J- @. S, E return ret;$ X7 q, H, c9 w/ T Y% J. `
}/ K9 k5 |7 s; o
/ q4 o/ I& b0 C7 v3 p' jstatic void __exit led_platform_exit(void)
: f, I$ @8 O& G; J{
! [( e. W5 q4 J6 p platform_device_unregister(&da850_evm_tl_leds_device);
- C4 J+ y* ^* A+ E7 t0 Y
" E7 ~4 {9 {2 ~4 l9 H' x printk(KERN_INFO "LED unregister!\n");0 {, f3 K# F) L% q+ C( l+ Q
}7 F" A/ _5 o6 p7 G% F
" {2 T+ D9 {' H4 b) Z( O0 l ?module_init(led_platform_init);
* V& B6 A$ k+ ]$ F, m. qmodule_exit(led_platform_exit);" j2 \* d) h* h" a7 ^+ y" d
2 c% D( Q8 d5 O& n4 iMODULE_DESCRIPTION("Led platform driver"); |0 b9 Q/ w' m$ ?; N
MODULE_AUTHOR("Tronlong");
) A- E1 v; @ m* f2 zMODULE_LICENSE("GPL");
7 a% w, e5 H: M m4 g7 l7 C1 G4 p9 K! _5 ?
|
|