|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 r. s! g+ t3 ~, i! H, k( Q
#include <linux/init.h>
: L9 F& Y- g( D#include <linux/module.h>
8 H$ G+ \$ D, s#include <linux/kernel.h> O3 ], J9 W5 |) K1 Z* }
#include <linux/types.h>: s9 l0 e; M+ g+ _' R
#include <linux/gpio.h>
( h* J3 }! a# v+ I( z+ t0 j: K#include <linux/leds.h>
4 f' X: t7 S6 u#include <linux/platform_device.h>
. A4 X# N: S. ^ [; n, j7 `
& J" {' S1 B0 c7 A" ~#include <asm/mach-types.h> \2 q& s. ~4 K& {, k8 D6 |' B( M
#include <asm/mach/arch.h>) H' L& T' F3 d u/ t$ B8 Q
#include <mach/da8xx.h>
6 @1 c q0 I. T#include <mach/mux.h>7 k1 {8 ?8 X/ r, d8 H
# j& I5 n' J' p1 D( Q; T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 s2 C$ X6 S8 {2 x" D4 w" ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& t/ Z [7 H+ H+ \/ s7 S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ J1 Z! Q* Z3 V* P0 W( E#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ h8 _7 [( f4 _0 W% _- u* ~$ I. S9 I
4 A" ]. n* J0 |% H8 K! [/* assign the tl som board LED-GPIOs*/
/ M. v; m& v$ t8 z9 Wstatic const short da850_evm_tl_user_led_pins[] = {
f; m* h" H7 p /* These pins are definition at <mach/mux.h> file */ j1 v9 {* m9 B6 B' g; Q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: X+ A2 Q# V) \& p
-1
* G p; D& j7 N' h+ r: R1 ?};
# J; N) J) y. m9 q9 H4 p: n% J1 k: ]9 D" H, L; b
static struct gpio_led da850_evm_tl_leds[] = {
% d; ~* Q9 q2 {% X {
( d9 I* ^* e9 n }2 k. |' W* y) d. d, |- ] .active_low = 0,' G# ?; m( j% ?) G/ M! ]0 i; M n* o) `- K
.gpio = DA850_USER_LED0," N$ C7 M: S, N7 m
.name = "user_led0",$ a8 d& d* W/ \! w. \
.default_trigger = "default-on",, C" k8 O- C+ }1 S7 S
},+ n" h! b3 A V) ^2 p! f0 V
{
2 H+ b# f7 `& \( p: a6 g .active_low = 0,+ W/ b: t2 x& X
.gpio = DA850_USER_LED1,
: J, T6 h2 a) a* ?$ c! I( H9 V/ D1 G A, i .name = "user_led1",4 D. X. q, V8 X" W( x
.default_trigger = "default-on",; a$ e/ x9 @1 C8 F- ^
},: \; C9 w, I$ T! o; r
{# R2 U N6 t. ]8 @6 K- R5 Z
.active_low = 0,# u5 D$ d, F0 r3 C O/ W
.gpio = DA850_USER_LED2,
& @2 j6 ~( Y3 d3 @ .name = "user_led2",, u8 k' {! g8 ~
.default_trigger = "default-on",0 w+ m% v7 v3 H z
},
7 o6 c3 b- V1 s/ X8 P4 J. P2 O. f {
0 q) O: S4 G+ n. ~, f .active_low = 0,
+ w" q7 `2 q# J4 c, {- d& s4 Q* A4 x .gpio = DA850_USER_LED3,3 y+ G/ l, B& I9 h8 r0 q& T" B _
.name = "user_led3",
* ?; \7 j* v8 `' p .default_trigger = "default-on",
6 l; `2 W, c& N1 c0 i: F4 ] },
4 j0 V+ D8 M. Z$ H8 y' P K- m( R, A/ c};' L5 n, h/ o0 a
7 D) N( R( V% o4 E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 M0 _9 z8 w/ N6 w3 V7 s/ n9 v0 p .leds = da850_evm_tl_leds,% n0 \9 g: I& _/ X( w3 r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 V2 j* c( K, L( Z# G+ q3 M};! S% ] j& {; V. x' i1 ^9 B
$ T, a5 e0 h/ ^+ n! V3 cstatic void led_dev_release(struct device *dev)! i9 @, i7 o( y/ u7 @4 k, j! k- E/ x
{' ] C# n& t0 {
};0 n% |! r4 P0 v" t" R; M; x: y
* f# u( E& V, K9 Vstatic struct platform_device da850_evm_tl_leds_device = {% t% n8 g8 \2 {: `2 x' \
.name = "leds-gpio",+ ^% D1 ]. v L- [3 a% |3 W
.id = 1,
1 N+ n; ^! F; b, h- U .dev = {/ y3 P% ~8 G) ~& F+ V
.platform_data = &da850_evm_tl_leds_pdata,; f1 f, Z: f" \6 N
.release = led_dev_release,
# s. h2 Z6 e; W }8 g) G8 [. ~: v
};, y% k/ P- s: `" L
5 k, }8 O8 J- Kstatic int __init led_platform_init(void)5 P$ n* b, ]1 ~9 L. O: B
{
9 E" F3 I. g j$ {& _4 q) B int ret;
9 C4 d4 }# H, R#if 0
# Q) d. ^ Y, I9 E' z& m( X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, D# g! r) @2 Y% K if (ret)4 |, ~ c7 P. e! z/ B8 ~2 n3 H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :": H# D# L1 j# R4 M/ p/ w
"%d\n", ret);
1 D# L* H. D7 _/ ^9 m; \#endif
' f2 {6 K6 B. h) o+ z ret = platform_device_register(&da850_evm_tl_leds_device);- Z" }3 d J; E+ F6 p9 j% U, M
if (ret), V: T& u. g* J' u+ ?- O9 t' A
pr_warning("Could not register som GPIO expander LEDS");
* l9 m# s/ \6 S5 X2 O5 t else
3 M+ D" ^1 U8 [# Q% t z4 d printk(KERN_INFO "LED register sucessful!\n");% P" K2 V A2 J' R8 x; ~, u/ y
% {3 z* b4 [9 f1 r
return ret;+ b" I4 `) D# M" L, N
}
+ u% \* C# m' g9 M, U3 U# Z
: |: b3 S6 u4 `& x8 _static void __exit led_platform_exit(void)( X% K6 u l) c' X: r
{& q/ M4 U7 S1 Q$ ^
platform_device_unregister(&da850_evm_tl_leds_device);$ m* t; l- {) f
9 R% C7 u$ N; B! P printk(KERN_INFO "LED unregister!\n");
: i9 R/ A n! K, W" n# t3 D" N}
: w4 |9 J1 k7 l6 G2 w# R" u" z# y8 v# q5 L0 r/ X
module_init(led_platform_init);% U6 u8 |! {' Y, |: i$ W! C
module_exit(led_platform_exit);
# F3 E0 q" p& Q7 |5 g. Z) z$ ]! |- n# M; s* |4 ^
MODULE_DESCRIPTION("Led platform driver");3 x; y, D1 G+ i+ L Q6 _; ~! h
MODULE_AUTHOR("Tronlong");
, c/ R z% A4 d5 T$ @MODULE_LICENSE("GPL");' f' L# b; e* ?: p, ]
8 o1 f$ ~; i2 { |
|