|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# @7 i9 M$ J/ I' M- A, s- `#include <linux/init.h>
9 R9 Y& j9 B' A. x, K" ]7 o#include <linux/module.h>
# P' W5 a% Y2 ^#include <linux/kernel.h>4 P( y U' y7 ]+ [( J
#include <linux/types.h>
; c% y- Q$ G1 M1 u$ y#include <linux/gpio.h>
" t* q) p/ t# N2 `1 A$ a#include <linux/leds.h>
& J3 N7 R; e8 _! }' H, R" v" S#include <linux/platform_device.h>
* i8 X% ^( K( q1 k% ]. k0 G0 l. E+ _2 i2 P" @* X
#include <asm/mach-types.h>
m8 O, b* E& ]' m#include <asm/mach/arch.h>2 ]: u4 A& h8 p
#include <mach/da8xx.h>& J5 H: g& R; o9 S( B+ u; h& B
#include <mach/mux.h>
) l+ {# s" f/ g4 p& E7 Q# ]8 F
# ~7 V; Z% \; J/ \8 B- Q" g: a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 V) @, F s: w/ A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 o. u# Z, S# W$ \% [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 R& M" l0 G! h* p/ Z* t) w; C* s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); ?( ]( b, K" }* e, u! l r/ s
% l* e2 @/ o5 M% Y) ?5 z: C+ k
/* assign the tl som board LED-GPIOs*/4 V% o3 t; i( O0 g# A" ]: I9 n
static const short da850_evm_tl_user_led_pins[] = {; k* a6 N k0 [6 f( r+ A
/* These pins are definition at <mach/mux.h> file */
9 \/ V) }: S- b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, O/ z) d& L5 o. O( B, \' ^ -1
0 g" q+ D; R, y/ d6 A0 V3 k, m};7 g2 ?+ W8 B" ^; |7 v* @
* ?( T& `# @2 v9 I" L
static struct gpio_led da850_evm_tl_leds[] = {1 Y$ r' [& p' H" {
{: U/ w* P Y7 i7 p; E# Z4 i
.active_low = 0,( v0 ^% w. W9 m% o0 ]0 O
.gpio = DA850_USER_LED0,
c0 c4 U; s7 f g* X% N r .name = "user_led0",
8 C% \7 T0 b' O# n- x .default_trigger = "default-on",
, C( G: u0 s8 `; q },6 v% F0 F- U! s2 D! C
{4 J2 ?% `7 @2 f2 ]# G6 K
.active_low = 0,
; n: G I( N3 S9 \! D .gpio = DA850_USER_LED1,
1 D+ J& t0 H8 r' ^ .name = "user_led1",: q, \6 M1 ~: s( U
.default_trigger = "default-on",
( Y1 x& A9 R& k3 r6 l },3 _7 G" S# w! r- X! [
{2 i4 n8 s0 n" ~ _; K
.active_low = 0,
8 u. u o u6 {5 ] .gpio = DA850_USER_LED2,+ m9 V i4 @: W. J1 _
.name = "user_led2",& Q: X: p( F# L. g
.default_trigger = "default-on",
7 ]; I" g W9 P! v) a; E2 L3 U },
) Q0 f6 K4 B) `( S4 X: B {' t2 C# Z5 q$ R; Z- C# S
.active_low = 0,
( t; `% Y0 I* ^4 B; B9 |1 j# o/ t- _ .gpio = DA850_USER_LED3,
9 o' N2 X5 [8 X .name = "user_led3",
" v7 s8 h5 t# Z9 | .default_trigger = "default-on",
$ G( O% f. s/ t/ A4 ?/ \+ f% @ },8 F; P, O' Z1 r+ o3 u" k
};
/ C% V% w2 h( P3 R. p+ O2 P6 J
, i' ]' ~1 D$ r9 N7 |8 gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# v, V% h3 |+ }4 [! f .leds = da850_evm_tl_leds,7 M* z/ ?- y" ?1 ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 m1 I. f8 K& c0 z};) {; R4 L9 R% b
! F( q+ m+ l1 G/ i
static void led_dev_release(struct device *dev)
! G5 @+ y% U; p* a{* H: S8 K, U# e6 w8 }
};
* c i7 B/ {2 O5 ]- S+ p
2 y J; i' Z# ~$ e i* E9 }+ |static struct platform_device da850_evm_tl_leds_device = {9 E5 a$ r$ z9 v( L# k
.name = "leds-gpio",' {5 k% j- l0 m" R4 r% i! W- G* p2 x
.id = 1,2 I& k7 q" i7 ~/ o6 O1 O# U
.dev = {" q8 K- G5 k' E5 p
.platform_data = &da850_evm_tl_leds_pdata,& d8 }' k) R8 b
.release = led_dev_release,! s$ m1 ]. v& W$ [; }
}! y. p# F' T7 E$ [3 ? d3 t6 g
};$ ?, a" [/ F7 k! e I) q; d
3 R! v/ K8 t* z' x2 L: i( i7 P
static int __init led_platform_init(void)
4 M- { q# Q. x+ K{$ y; Y5 Q3 A$ D# X
int ret;
% K, H2 f/ ~* @#if 0
- @! ]9 C! e: `; K+ p+ W$ x ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, U' B, {* G8 r8 m: l8 x if (ret)6 C! A& J7 x0 s0 T/ h
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") x5 ~/ }) ~1 f$ W
"%d\n", ret);
* U x4 o( ]& \; M5 L- W#endif
- C& C9 F# a% a% S ret = platform_device_register(&da850_evm_tl_leds_device);
/ a1 Z4 M; L) u: }5 n" u8 R if (ret)
$ Q. j1 |# e6 G6 D! R* M3 P pr_warning("Could not register som GPIO expander LEDS");7 e6 z5 k8 D4 M4 m
else
4 f% V! T4 M9 ?9 [1 W* p z printk(KERN_INFO "LED register sucessful!\n");3 N% h g" G! ~8 b0 s
" h; k0 t+ U6 V; e e2 _9 h
return ret;
! k3 Z- W& h; ^}- f/ t2 g. S! ?! a7 w
* Z0 T9 u. c8 P3 @static void __exit led_platform_exit(void)7 g: D" L6 B7 P, g3 T
{8 g8 N4 o$ Y7 m6 M1 ?2 d0 {- Z
platform_device_unregister(&da850_evm_tl_leds_device);; J0 e$ l2 G: a" @1 |
- \( G9 r. b) v+ H7 s/ f printk(KERN_INFO "LED unregister!\n");7 g: m9 H: r- E$ Z* K
}
$ `- b5 D+ T J" H2 v
& r1 h+ l6 \) F5 k! dmodule_init(led_platform_init);
" Q& B: ^1 c& B6 R5 J1 `6 [& x. mmodule_exit(led_platform_exit);$ l, ^9 F- m9 u% h
1 B4 H6 _) L0 n5 I2 q) h) }
MODULE_DESCRIPTION("Led platform driver");) a ?, {" k) t$ F% S( B- b
MODULE_AUTHOR("Tronlong");7 s2 g# t S' @- U
MODULE_LICENSE("GPL");9 p4 p% C' ? ~1 J$ e
% K6 j4 s+ I- l; Y" W
|
|