|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, u0 @: g' A& E: ~! a
#include <linux/init.h>* y5 e% h9 N r
#include <linux/module.h>6 U4 D1 |# _- D$ {" J4 z- b
#include <linux/kernel.h>
7 D% F3 G: N, d* l4 X% b#include <linux/types.h>* D% j0 } }$ v( n% G f. b0 V
#include <linux/gpio.h>) j X/ p+ Q. ]: Q: F: N
#include <linux/leds.h>
* z9 K- n5 L" d, ?2 P/ ^#include <linux/platform_device.h>
% j( Y+ i3 V2 v
' }/ _# F2 u* y/ a3 ]! k/ u#include <asm/mach-types.h>
+ L8 ?. w3 @4 U#include <asm/mach/arch.h>
4 X' @* u3 C3 L3 t6 H; S# |; k4 x% x#include <mach/da8xx.h>( A8 Y- ?, n, t6 Y4 }3 {4 G. s+ ^
#include <mach/mux.h>+ L8 \- R H2 d8 U% x$ Z
7 l; f+ ?* e! C' \3 g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* h3 `* L* N1 b0 S0 m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); b; X/ a# V8 @* ^+ A# J0 v) M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 S" L5 B3 ^9 [# f2 \* F/ o" T#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" `5 l; K# h9 u9 {6 w, h+ v" H
! Y- ]! n& A5 Q& J
/* assign the tl som board LED-GPIOs*/+ F% r6 \$ |, T5 \, V* \0 D
static const short da850_evm_tl_user_led_pins[] = {
3 n5 g s% w& ^3 D /* These pins are definition at <mach/mux.h> file */
6 C+ V& m+ C; [) Z. S0 J/ B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% I4 @$ r% O- G6 w9 `
-11 [) M6 g& m/ F6 K: \
};/ O5 w5 }1 n" r6 w
1 r# g: J6 u; ^! Sstatic struct gpio_led da850_evm_tl_leds[] = {/ l4 @. O8 C q; _
{+ ]2 \* x8 o z
.active_low = 0,4 x; q8 L: ^9 A1 N z
.gpio = DA850_USER_LED0,
, {* Z) r2 g) S .name = "user_led0",
1 c2 w; h$ n; [# p$ _9 ^6 n .default_trigger = "default-on",$ R7 E+ \4 I1 w3 [, D5 f% v
},2 @1 Q% U& o" t5 g2 R& A8 a
{! n( d: o. G- u. V, K \" ~, g* a
.active_low = 0,& [ n! U- M6 e8 I( ]
.gpio = DA850_USER_LED1,7 B" d# d7 i4 r. Y
.name = "user_led1",& c( ~( {) t; a
.default_trigger = "default-on",
6 @5 n' q8 ^- ?) U' y },
9 z/ I, F' [+ [ u4 S* z' S& U- h {8 d& V' H+ B- }6 g% C H4 _
.active_low = 0,
6 [' B% N& w3 D ^2 j .gpio = DA850_USER_LED2,
* q9 P. R$ W' P .name = "user_led2",
5 r6 X* L5 M0 Y* l* Z" V& ~' f .default_trigger = "default-on",( e6 p. _5 Q+ `# k8 f3 P) y
},6 z- x0 c- v/ T3 {
{9 \" `' M2 E1 S X
.active_low = 0,) P% _8 p w, y: m% h! R/ z
.gpio = DA850_USER_LED3,7 P5 q5 D5 {; N a) U/ h. w) g
.name = "user_led3",
5 Z5 T' W- M( d .default_trigger = "default-on",- J3 Y! K* _5 a
},$ ~ ]) K5 k5 O: Q, ^6 B2 x
};
/ ?8 I0 J4 c( h. ~# E$ Q: t! R7 c" m% e0 Q% d9 v+ D2 s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ I: Y2 C/ i- D( Z! Z
.leds = da850_evm_tl_leds,
9 C, s9 m+ }9 w% C" [( T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" Q: ~: N+ ~: ]2 i1 L* s& V};, }& w: B6 G* t) Q5 m" W
+ F" ~# w! k4 b( y( m0 N9 A
static void led_dev_release(struct device *dev)# C8 `& E f2 T/ Z7 t P4 ]! T: y
{
0 |5 D6 m9 W6 ?/ F) P" p M3 N};! [2 _- }" s# X' p
# e4 a2 H2 W {& q6 qstatic struct platform_device da850_evm_tl_leds_device = {" D2 ]$ {' M. ]6 p
.name = "leds-gpio",/ E* `! k7 l8 M, ]8 V' O& Y. z$ f$ q
.id = 1,! Z0 E3 O- g" D, b$ t. J% Q
.dev = {" l# D& y" U1 ^+ B8 b$ {
.platform_data = &da850_evm_tl_leds_pdata,% T4 v8 b9 Y5 h6 ~
.release = led_dev_release,2 ?% s: B- [. S* u5 d. t3 O0 G
}
a: ]8 p5 W8 G/ G- {};
: H( l P# w3 h
7 {3 M, }5 Z. c( J. gstatic int __init led_platform_init(void)* z. u8 w8 J/ j* E( P# b6 k1 h
{9 P% n4 s$ R/ V+ k, O
int ret;
4 K; E! b8 W; W7 |& z0 C6 ?#if 0
0 C5 Y: I8 |- n& Y3 W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 A; w9 B0 J$ x O- x; W if (ret)
. J% j4 e) h: k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 A. g) W. s! ^( C "%d\n", ret);& r* r! I; Y$ ]) j7 n
#endif; l3 ~; q7 r2 k3 \- y
ret = platform_device_register(&da850_evm_tl_leds_device);6 Y/ X9 z1 _8 ~0 R
if (ret)3 }, x2 H, U5 Q- ?; N2 _
pr_warning("Could not register som GPIO expander LEDS");
_. `$ V( K8 x else
# }4 ]9 e3 e% Y6 R I printk(KERN_INFO "LED register sucessful!\n");
( e8 c4 L- k Y5 ^* C& g" c' Y9 Z) s
return ret;
1 W( d* c( i. @* a; T" @}% m" T4 {2 p% G
0 d+ _/ i) Q* n8 J3 g3 l
static void __exit led_platform_exit(void)
1 k/ s* o/ k# ^3 m8 r4 V! N{
; |" A. Y. h9 _* B! X platform_device_unregister(&da850_evm_tl_leds_device);
8 D# d* _! A- [3 S. s* w) R3 i4 g- O! p* V% b; z+ ~
printk(KERN_INFO "LED unregister!\n");
# h2 @, G/ X0 r- x}
g. P9 r( N( g( o7 [
5 Q/ K w8 p. s- _9 [2 f0 nmodule_init(led_platform_init);* I o3 e8 q( | I7 H+ h- o
module_exit(led_platform_exit);& E6 n2 b1 m7 u7 g
* E7 D1 k3 z: v7 P2 n8 D% P
MODULE_DESCRIPTION("Led platform driver");
0 H$ E: ?! @/ Q" ]' h- ]MODULE_AUTHOR("Tronlong"); j& ]" x1 K2 P4 K- M' `; Q
MODULE_LICENSE("GPL");
9 O( J+ `6 _( i, g. ~/ M+ h' h" O
g$ q4 x% e# y4 @ |
|