|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% Q& U2 y& Y0 x# N/ Y7 T1 j: e#include <linux/init.h>
2 R; T4 V3 Y/ o* {#include <linux/module.h>
$ K8 o( u, S7 I5 N8 O+ Z/ W9 }0 s3 G- u#include <linux/kernel.h>3 e" d$ r! \) T
#include <linux/types.h>
) l0 L3 N/ \$ B5 D, ?/ P# n#include <linux/gpio.h>
) |; M: c1 V8 i0 G#include <linux/leds.h>( r) R& n: ~" R# d% n9 S$ w
#include <linux/platform_device.h>
; c3 y4 A' H4 V9 }6 t5 T- j5 x0 j; Q
#include <asm/mach-types.h>2 H( |$ C+ i2 G0 |$ u
#include <asm/mach/arch.h>' D0 l7 {' n$ @8 _# |
#include <mach/da8xx.h>" y% L, D0 ~8 \( z o- @" S
#include <mach/mux.h>
: ?" h+ h9 T7 `) n1 `8 ?) H* R' M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), d3 ]) u1 L% E$ ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' F. Y3 z0 C; Z9 S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( Z( N+ O/ H5 k2 F" q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). A7 h( j9 H6 q& F7 o. D. @
) u$ G) I- C- J8 M& `1 b8 e" A7 q/* assign the tl som board LED-GPIOs*/7 P, I" u( n7 A8 F7 A
static const short da850_evm_tl_user_led_pins[] = {5 }2 P) a" N4 U$ p( _; h3 C- V
/* These pins are definition at <mach/mux.h> file */
# E! `, M7 t$ Y; w0 U: u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 k0 N0 y y* t# o0 o; K+ c -1
; f6 F" X) R8 ]3 l& O};# ^! D2 X5 p1 n& L: E
' t- ~- l; t: r' a
static struct gpio_led da850_evm_tl_leds[] = {. r5 T4 F4 Q0 O
{
5 i2 J: J* H/ Q. M& f .active_low = 0,
9 H5 ]2 h! t- z4 V .gpio = DA850_USER_LED0,
4 c' p5 M; i% U5 B# Z. o1 ^' } .name = "user_led0",
2 c- u) J% p0 i! x2 l& c .default_trigger = "default-on",4 w! }6 @0 l. |2 Z9 c" g, \
},
+ E v) a7 j3 ]& b+ a* {: q2 U {
7 T0 v$ q; v4 E% s0 P .active_low = 0, @2 T- H2 M" L
.gpio = DA850_USER_LED1," ^' y2 T3 r3 l" E+ h4 s4 \2 k4 C* U
.name = "user_led1",
0 b' p i% [& R0 H .default_trigger = "default-on",3 G2 H/ \9 L+ R- U5 ]) Z
},3 _1 e4 Y% u9 ]
{
! }! Y) X; J3 f: U2 p. I' K& v, ?' `5 w .active_low = 0,$ j2 M5 Y. B& `# D }
.gpio = DA850_USER_LED2,# V$ O/ @1 j) O( O
.name = "user_led2",
K# S; |! M2 T$ h! c8 n: z3 P .default_trigger = "default-on",
; W5 [+ m4 {+ l$ V% o },
- o. e" W( J: M( e {
& @: B+ B/ m5 M( f q .active_low = 0,
/ j: U- v% h M4 s" p L0 i Y5 g .gpio = DA850_USER_LED3,/ |7 a. C! z4 [ d$ C: k5 t& c& Q
.name = "user_led3",
& ?- y6 G+ O# j; y, D0 |( B9 `' e .default_trigger = "default-on",
" {5 F A& I* ? },
* {# s0 S E( @3 q; o+ } v};5 \3 W! ~* R) X$ |! `3 I
; ?% J5 O, E1 w' fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 s( p( |" n% ^8 J" P .leds = da850_evm_tl_leds,2 ^0 ^1 R5 r% O2 }' y" Y: x5 M9 x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* Y \/ B1 L P& v1 e# t o};
* s3 G0 ^ x! X/ m$ i% I: H% d; r6 C1 [: h' q7 `, y& t
static void led_dev_release(struct device *dev)
, u2 b( o: F8 P, g/ B q/ {{5 s3 l$ R# Y+ k) y: K* y+ V
};
+ q8 y0 {$ }2 O# V7 W, [* `
$ R6 j1 d' h9 f v! E) H' I( {static struct platform_device da850_evm_tl_leds_device = {& J) D7 E9 K ]' x' X
.name = "leds-gpio",; q" j6 c0 k) s8 Q) i0 ~0 m
.id = 1,
. `; @( U; c* Q" W .dev = {
$ F; v% F+ B* r. O .platform_data = &da850_evm_tl_leds_pdata,2 C6 ?1 G* ]' U
.release = led_dev_release, k- o C; P3 m7 r6 f
} g( C7 t g7 h. z# m3 Q/ }) v
};2 v! f' Z1 I+ L
' ~7 ^& J# v8 N) @( zstatic int __init led_platform_init(void)
: w! D8 a5 I5 y3 a/ q4 O{
' P0 T' l& n5 E% c2 y% i [4 W$ c# T3 c int ret;
. [/ h4 V5 r Q |- U#if 0
& d# r1 f& w! \& N; x1 r( D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 i9 k0 K3 N8 j, h
if (ret)
5 Z" C; T" z) ]4 [* \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- |' R( r' P+ E% J
"%d\n", ret);
. @- N! l$ P# e1 V! J4 K9 D2 v#endif
: B0 O8 \/ \/ `7 B/ I, s6 T/ c ret = platform_device_register(&da850_evm_tl_leds_device);
' r, z' v( d- v: ?. L if (ret)( B4 w0 ]) l% H2 b* |" L
pr_warning("Could not register som GPIO expander LEDS");5 v9 e* j* J* [; K: u
else
! s6 u4 c) k! i7 @ printk(KERN_INFO "LED register sucessful!\n"); i3 I7 _& g7 A3 i ^
* x2 B5 X# b2 r+ I9 s: u return ret;
7 T5 d! L7 u: N; M$ i}
' u+ I1 P+ Q2 [5 G9 J/ m" F4 d+ \/ t7 w
static void __exit led_platform_exit(void)+ A+ m, m# j7 x; h$ }9 T+ B
{
+ n- b( M' A+ c* y- P; c3 X platform_device_unregister(&da850_evm_tl_leds_device);
$ f. P: ]9 K5 Q; X% j
! D+ W9 n/ W* Q7 k printk(KERN_INFO "LED unregister!\n");
E9 m" @6 [, Z8 Y}
4 g+ x6 b! T0 B% R4 ~7 O, C S# u( W$ u& n' M0 f6 g: R- _
module_init(led_platform_init);" T% f/ i! \5 x. A% @2 x& j
module_exit(led_platform_exit);0 ~3 `4 e3 s8 N" W/ E
8 g, L' F; F; u+ z# t2 K' x9 m
MODULE_DESCRIPTION("Led platform driver");2 d( U$ H4 S7 N/ K6 q# G F
MODULE_AUTHOR("Tronlong");' X) Y4 l: m1 ?* `2 z. h) m
MODULE_LICENSE("GPL");! j; D$ t+ D% O* ?! K
" i2 x" }' @4 Y% n' i
|
|