|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 p, C( N0 s5 [ ^% t0 N* H
#include <linux/init.h>
) y7 u/ e8 t8 f' E8 }4 Q+ |#include <linux/module.h>3 A! x, n3 n* q$ a
#include <linux/kernel.h>
1 H/ |- ]* P7 O1 w7 [4 Z#include <linux/types.h>
5 R& M# N- a! N/ E& [. ^/ L#include <linux/gpio.h>. v0 W2 h1 S; ^) u
#include <linux/leds.h>
: g# o0 Z% T; i7 L8 t# h#include <linux/platform_device.h>9 u8 y" |- |" {2 ~! D* f5 n2 ?
4 q, p: A, K% Y* `( h
#include <asm/mach-types.h>8 F+ l0 l0 X6 A0 Z! }0 @1 A; x L
#include <asm/mach/arch.h>
6 C2 b- H4 _% I3 ?#include <mach/da8xx.h>- s; O6 y/ s4 j" j5 _0 L
#include <mach/mux.h>
- Y& {) q7 \ {. g7 C- h, k$ R4 L7 S9 @/ }! l2 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& {$ T, e7 v, D9 I/ ?( O/ g; }+ b% K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 v8 D; a l* Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 j6 X& x1 F4 ~+ O3 E1 X7 P" M9 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 _, V; g. B6 F- W
* a" h" P8 `+ u0 E8 _( V& X% I/* assign the tl som board LED-GPIOs*/# A( n. a, s2 s4 ?5 G0 m8 {6 r- Y
static const short da850_evm_tl_user_led_pins[] = {3 _) ~% H( ?2 n! g" [; P. P
/* These pins are definition at <mach/mux.h> file */
; A0 R5 b7 F& M/ p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 _8 t- r/ D$ t9 K, t. g4 o -1
7 U1 ]# ?! Q; N2 u/ q$ B5 k6 G};
+ c4 @: B6 M* n# e+ V: d& l |) X" h6 d5 V. J" y% V
static struct gpio_led da850_evm_tl_leds[] = {8 s/ R' o( B p+ E/ y
{
* Y/ W) d8 o p2 ^2 b/ V. T* Z3 p .active_low = 0,
2 d0 F* S% B& e9 z. u9 Z .gpio = DA850_USER_LED0,3 M2 g! S8 n/ b4 D. y R/ n
.name = "user_led0",
: T# N0 j4 z% F& x% B .default_trigger = "default-on",
* s/ C0 N& m' R% U },' ]2 r" N5 F5 h
{
6 `, x, s5 T9 N: Z) P: d9 I7 p# Y) L .active_low = 0,( v @& z# v$ z; G! `
.gpio = DA850_USER_LED1,) O9 v' ^6 e" I! j* |* B: q( v; m
.name = "user_led1",3 I J/ S* W9 Z9 C1 z; F* V2 W
.default_trigger = "default-on", Z! X4 u0 H* D* o# m5 v! u
},1 i2 t- G F. k6 z
{1 @1 d! }# j+ M3 C- N
.active_low = 0,
$ O6 k+ C5 T, n. R$ O' ]9 u .gpio = DA850_USER_LED2,
j9 i8 K9 p+ v .name = "user_led2",( q- h& o9 A; S2 m( U
.default_trigger = "default-on",
2 I/ Y# ?& u3 A1 y0 {5 C5 Y },
% i2 M; @$ Y/ t5 ?3 O) { {
7 |1 y1 \; q' O4 ^ .active_low = 0,2 j% t4 C7 Q, r& \; _ f5 G# j
.gpio = DA850_USER_LED3,
6 ~4 ]" [& ]* ^( } X) N .name = "user_led3",
) {; C, D E+ i& F }4 w .default_trigger = "default-on",5 R3 E) i" h- `& D7 F* }5 `
},$ P; s; d" k; h3 Y4 x
};" r7 P2 | }+ B9 K8 J6 n
0 j0 I2 @2 d3 }. ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 s0 z8 `+ q0 F. g, L
.leds = da850_evm_tl_leds,
8 ~( R' I9 O' x: x% i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" f1 X+ x) r) v};
5 g+ H- y4 |3 i1 m) s: w
: r* b% V$ O6 d8 o; [7 o3 x# astatic void led_dev_release(struct device *dev)
% _- }, d# E/ k6 X% M{
' N8 F1 }0 u0 k6 H4 F0 s};
, R6 W; R3 h1 p( N t: H
4 M) [4 `+ I# U5 c$ Nstatic struct platform_device da850_evm_tl_leds_device = {" f, \8 f5 u& c8 ~% n5 x
.name = "leds-gpio",
. C9 m, m% _; X2 w .id = 1,
6 R" v' B5 H' z; R h, W! l .dev = {
- D1 x0 C: [% S! b9 A .platform_data = &da850_evm_tl_leds_pdata,$ {; N f/ o: s5 r4 N; C0 i# F7 c
.release = led_dev_release,
# v) f# c8 j% U" t; x }0 c6 T" J+ U, J. U! ~. ^2 S
};: `( y! R& C% y
, q+ G/ j* u, Z* {7 A" P8 g, b# X; `
static int __init led_platform_init(void)/ Y9 Y$ H+ ^+ I1 p+ `9 F- V
{9 u$ v+ ?4 P9 A6 M+ a! `' M' @
int ret;
2 k( i) x' X& D, i1 W" Z: c#if 04 D j. b+ ]1 g* K5 i4 q* U( _5 d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( i: U& {# X) H, H [/ n5 }
if (ret)
6 W) H: ]: q) R/ H. q- X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' a* B, x) I( g# h" I: w% Y9 D+ s+ j2 ? "%d\n", ret);
$ G" I9 t# S8 t7 Z" U- m#endif6 o5 t( ~. q# H3 J/ S
ret = platform_device_register(&da850_evm_tl_leds_device);# _7 x. @& U9 v4 F7 c/ c
if (ret)3 T* B5 q3 m6 N! N4 \
pr_warning("Could not register som GPIO expander LEDS");
, W5 {% C$ [% ~3 k# x! w4 ~ else
# k I, b M& d) }( m9 i- o printk(KERN_INFO "LED register sucessful!\n");+ w8 n2 a+ R2 U+ L
& r4 A/ j. C" ~% ^, B" S
return ret;5 S K4 ~) H; d$ o' C
}
0 V3 K6 P# m3 Y% x6 w" M) M+ x* ?1 i9 J7 I3 Y) Z: A
static void __exit led_platform_exit(void)
9 j# e! v+ Q' j* M+ O{
. Q- @& m) a- C platform_device_unregister(&da850_evm_tl_leds_device);+ f8 l2 J/ c }, w% [, P' j
- c& `0 A* E S0 }/ S, \
printk(KERN_INFO "LED unregister!\n");4 d! c/ L J. ^, D+ u% K5 H& h
}
& u9 J' C3 A: O p% X5 l. }# E+ U H% f$ C" S# N
module_init(led_platform_init);# m7 V6 n3 x! l
module_exit(led_platform_exit);
# T9 W2 h# u: J. ^- J; Y$ M( k2 V+ Z
MODULE_DESCRIPTION("Led platform driver");
( e- f7 z7 c, [! N: `6 }MODULE_AUTHOR("Tronlong");
! A5 s- ~% W8 T0 wMODULE_LICENSE("GPL");
6 j; Z1 S+ O! H. A& o; x
2 W0 C* S; U, ?# Y+ I |
|