|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. c7 v% u+ x# y, y1 u
#include <linux/init.h>
h! {7 ~0 g2 W! q/ S2 J#include <linux/module.h>' R! Y, W$ E% S) ~( S
#include <linux/kernel.h>
$ _; M% o8 P5 M: U* f/ Y3 i#include <linux/types.h>
# w! h6 v. d$ U: {- x! X9 x+ d#include <linux/gpio.h>
" J7 ]; `6 Z9 V' h1 H2 |$ f1 f#include <linux/leds.h>
# X7 J% F5 I/ D- w#include <linux/platform_device.h>5 b! {" T! m4 @* A% I5 _
$ r3 D+ k# _" c# O4 |8 [9 M/ B0 }+ S* u#include <asm/mach-types.h>( p" T+ ^( c- N/ \4 w3 i$ ]+ Q- b! k
#include <asm/mach/arch.h>) J2 ^& r8 f- i
#include <mach/da8xx.h>7 J( Q1 |2 g1 V6 x9 D
#include <mach/mux.h>3 [/ W- A/ K/ n* r- S4 G, s8 g3 V
( l* y9 [5 t! G9 h" ]: `6 E
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 U# x+ b; J( o. r" ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 D+ r) f2 W7 l* {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, ?& c3 Y+ S, a3 k% f& B w9 D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 R# f6 g# _! J+ \ `" l; p9 m' g% a8 _& l
/* assign the tl som board LED-GPIOs*/
" K+ Q0 ? R% w# sstatic const short da850_evm_tl_user_led_pins[] = {" i. O' L# p/ A0 M/ f: k
/* These pins are definition at <mach/mux.h> file */3 [, C0 `$ B( L' ~7 H7 B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( h0 Z( _7 g+ J' x+ q' W7 W1 Y/ i -17 W/ `7 ]+ _7 S1 ~( i' F% x9 \
};
4 x; C e+ |* j! k' ?" {% S" g1 e$ o0 }1 R0 v
static struct gpio_led da850_evm_tl_leds[] = {$ x$ ?6 n# N: _8 L* T( o
{& U5 g+ t! O& w
.active_low = 0,
5 V* j- G0 v% x& p* | .gpio = DA850_USER_LED0,9 Y6 R4 n3 h8 u
.name = "user_led0",
5 {. ^2 {% `* W9 c+ L .default_trigger = "default-on", k9 D: a9 J. @$ V
}," P# [& J5 m0 r4 l. o
{
" P, @7 C9 r& W" y# y9 T0 q .active_low = 0,' c0 @; A, T2 S1 [4 e
.gpio = DA850_USER_LED1, d' B3 d5 b6 y, k& s
.name = "user_led1",5 s: b/ m/ _* u, R3 K
.default_trigger = "default-on",+ X1 b- t1 q6 h4 {1 {4 B6 K
},
! W3 J5 @7 j" b& D {! R5 w: s* d$ B
.active_low = 0,
- c7 r8 c3 j# O* h1 W6 ^ .gpio = DA850_USER_LED2,; C" W) T/ `: q6 S' ~+ v
.name = "user_led2",3 v# N( `8 c; i8 k5 W: W
.default_trigger = "default-on",8 g9 y/ V$ D, ^
},7 n/ \4 \% R# l% m( S5 |
{2 R8 @( d5 [5 ^; p
.active_low = 0," h! d% J; Z9 E" x& K
.gpio = DA850_USER_LED3,
& J1 P7 u0 K3 B4 j Z .name = "user_led3",( o( n3 I" M% J
.default_trigger = "default-on",
8 P! I- k# |& Y& Y) I },' r8 u7 {2 r4 e9 p
};- d5 [) Z$ X# H! Q6 _
2 x0 w, w0 k% T' b- C8 U' P) p3 T
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& ~% }, \/ A3 I% f7 R1 w8 c: n .leds = da850_evm_tl_leds,
3 `2 V6 i) T/ S4 j: v3 t c; B2 c4 F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 u* A) Y9 Q0 L2 L Y7 k
};2 M% C/ I2 L( k# o. Z; z5 n! A% c
! R/ U2 c7 X O3 ^) {% T7 ostatic void led_dev_release(struct device *dev)
$ }: e$ O5 d' @0 g4 a{% ^9 _* Q n U; {, d
};$ t5 y5 i% i, g* s
0 t1 ]7 m: F5 v$ O6 l3 j. k
static struct platform_device da850_evm_tl_leds_device = {$ C: v9 P( t# f j" x
.name = "leds-gpio",
$ w K5 G5 i& H) J+ @# U .id = 1,: f. B; d3 |& K% w: y' @+ V: e
.dev = {
3 f$ g% q% ^/ y- E# @, { .platform_data = &da850_evm_tl_leds_pdata,3 ?, ?, X! i( r5 _* a4 @$ n: [/ e) A
.release = led_dev_release,
+ x9 R7 y. b+ |1 W }# _( i0 U6 j, @* b4 [) [1 S- T
};" x$ _8 r" f! F0 j. b0 W% a
& v+ }( M6 y& W2 l0 c/ h) ~static int __init led_platform_init(void)8 g, b/ Q7 [- `2 t5 X0 c: y
{
& R: L& O1 J7 J5 J1 t( | int ret;- M7 x; i# W9 U& p8 C" _
#if 0
5 l" h, ?2 R2 l& H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) K! c0 [* e3 S3 m if (ret)7 x6 |" u+ E/ c
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( Q2 |# H+ U# s
"%d\n", ret);
+ P( q6 w( ?7 Q n$ h/ R#endif$ W% I2 c: L4 W* f2 M- T
ret = platform_device_register(&da850_evm_tl_leds_device);
1 ~" o, D/ k* ~ d if (ret)) r! j1 u# n: D3 m) ~: M
pr_warning("Could not register som GPIO expander LEDS");+ ^- x# g9 u& S- [
else
3 r0 Z% p5 A5 T, a printk(KERN_INFO "LED register sucessful!\n");1 d9 ?* O. k9 W |1 L6 p A
9 ?, u! L. |) A. ~9 C) @' z3 ~ return ret;9 d5 ]1 Z7 [2 j3 W) l
}
; K, \* x$ h4 }9 u0 Y- ~1 i: \9 e) }% z4 }; T. E
static void __exit led_platform_exit(void)
' s: ]) g7 F2 s `+ j{4 g, p; i1 ?! Y/ |3 \" u
platform_device_unregister(&da850_evm_tl_leds_device);/ k1 t6 i6 A( T
& W d; i' i2 A8 D4 v
printk(KERN_INFO "LED unregister!\n");. Q& t5 R. L9 q9 G7 O7 P \' \# }
}* O+ }5 D( A W- w J
- ^- ?6 S. U U! m) n4 k6 i& L: Emodule_init(led_platform_init);
$ U/ h* M; H% X3 [5 e- umodule_exit(led_platform_exit);
3 v2 ~, F+ u) @
" v1 W/ ]1 O% U6 GMODULE_DESCRIPTION("Led platform driver");
5 S3 M6 T2 {" q3 UMODULE_AUTHOR("Tronlong");. V5 ~, y* F9 y5 ~1 W8 |5 y* S
MODULE_LICENSE("GPL");2 g5 Y4 i& |; q3 Y3 Q9 a
- I0 W) y7 A) @7 k/ A2 h |
|