|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 E' J2 J; B; i. |: M, d7 g/ x
#include <linux/init.h>( x) T, v7 U. T2 [5 y% i4 u
#include <linux/module.h>
, u, A" F# u$ \2 n& C#include <linux/kernel.h>
e# ~( d, d0 Q- {7 V#include <linux/types.h>, q2 P! y6 r" @( S$ i4 {
#include <linux/gpio.h>% H0 {) R4 N8 ?( S+ ?8 i
#include <linux/leds.h>
* B: R' R+ g8 w! C, ~/ X#include <linux/platform_device.h>- u2 H% B* ]4 T0 M, R2 h$ `
; b S \- N' [9 G7 X! n; L
#include <asm/mach-types.h>9 _6 _6 v. K1 i3 z/ U1 n# E
#include <asm/mach/arch.h>6 [+ I) w$ j: |3 M1 J
#include <mach/da8xx.h>+ g4 W6 \9 K* V* A' _
#include <mach/mux.h>
5 x* O1 Q ]( P( c/ [, ?. L5 r0 C2 j o# [0 Z, {+ T7 {( I% m: p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 r) ]. r \6 K2 d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( L) r2 B) O9 D" q/ Q( b# p# r, _+ `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 d5 K( {5 O2 b6 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- h3 D+ \8 B7 c. L( a) `, p4 s$ E; W7 d! n4 Q) t$ \
/* assign the tl som board LED-GPIOs*/0 Z$ {, |- L% T5 T0 L
static const short da850_evm_tl_user_led_pins[] = {+ k: q4 U0 D8 w5 ]
/* These pins are definition at <mach/mux.h> file */
- }4 J# q) O" A9 U, A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 _, `" ~6 X9 c" V -1# ?4 M0 u0 [4 r7 B4 e$ V7 {( ?
};/ a* Z" r4 J5 U& e5 P
( y# n, M8 X) p1 @. J( T+ jstatic struct gpio_led da850_evm_tl_leds[] = {7 |8 z/ K# O$ w) X! j2 R) W
{7 v9 f7 ~2 V% U1 v* f
.active_low = 0,
. l* B+ E* K+ I; t( v% c* \1 S .gpio = DA850_USER_LED0,
' a, y7 D. u! } .name = "user_led0",8 a" K# V6 {/ k: T8 \' Q$ ~
.default_trigger = "default-on",5 Q8 l R9 y' B Q; o5 j. g0 }
},& `2 l& @ ~' N' l
{* w7 J$ k8 ~ U" w3 g
.active_low = 0,
7 L" f3 q; [; @+ k( y& ? .gpio = DA850_USER_LED1," p e( A; D& ]5 ~, g9 _
.name = "user_led1",
- B/ e# I) d! U' \0 h8 Z* _ .default_trigger = "default-on",7 T' d T G/ |- f/ l
},
v' ` M+ p+ ^ {/ ^9 A$ {* d5 W; a3 h( Y
.active_low = 0,1 r$ W) [- d1 f4 u' ? m
.gpio = DA850_USER_LED2,
7 Z! q# ]7 s6 x0 Z& J' l .name = "user_led2",; @: Z) |. b: ]3 O: Z( W m
.default_trigger = "default-on",
' }! z2 O* _' U7 w; ]9 ~3 Q },* X R) |8 ?4 V4 l% _1 g# _ @9 R; Q
{
: v, k) }$ D+ {' V& | .active_low = 0,. F3 z1 p0 U8 _1 h: b5 J& [
.gpio = DA850_USER_LED3,
7 D9 N. U" i9 X: O) | .name = "user_led3",
! E8 k7 g! ~; a, I# H .default_trigger = "default-on",% c( B( q) h" |, D1 D9 t
},
- A7 h1 G1 R4 D: l};, Z- d p* w. k, T
! }; `1 {4 _2 ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 [: G( `& N, W3 v1 q
.leds = da850_evm_tl_leds,
2 D9 X% V! g% i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
h# y' N4 q9 l};
* ^ C: M6 D2 c* x9 b/ Y% D! w
; t. U( V: v L6 ?5 c8 ustatic void led_dev_release(struct device *dev)
9 `4 _8 l% p) s( _3 u' B* p( f{
, b% O/ p: R2 L: e( u0 r};2 r3 E. t' o0 X8 N3 H3 ^
9 Y4 ?7 d6 V, d) Tstatic struct platform_device da850_evm_tl_leds_device = {
" @) t+ T% t& [5 R* G5 U .name = "leds-gpio",: q1 {# |8 @! t( ?( Z
.id = 1,
7 q; B: h; I7 c8 z4 K' N( [' h" y9 \ .dev = {
' D$ C; N# D0 a7 H* t .platform_data = &da850_evm_tl_leds_pdata,' c5 p7 H7 d' x4 u+ ]" q7 U
.release = led_dev_release,2 V4 K |; e' h6 J4 K& Y
}
3 D* ~9 H# x3 z' z2 a};
. M& M; V% B: u* l" C) a7 g3 \1 G( I: `5 ~
static int __init led_platform_init(void)
. W8 ]3 u8 @9 K1 S{! J2 c8 u# @' n# H2 t( C$ h2 r
int ret;" \) a7 t) e2 n2 G$ m
#if 0
! k, x9 |& g5 N6 Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( R) Y- y+ Y# B+ s if (ret)+ |% d: \; v8 |, p2 C9 d
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% U3 U% F2 J& ?
"%d\n", ret);/ c* l0 p3 Q# d0 m' ]) Q5 e% _
#endif1 x8 l9 K1 \* i) @ {0 P
ret = platform_device_register(&da850_evm_tl_leds_device);
. N9 ?, a3 s0 b5 j3 C: d if (ret)
& C, h+ F) o" A( b9 s* D+ R0 _0 H. X pr_warning("Could not register som GPIO expander LEDS");' t. X1 n! L4 Q* B( f: l; ?
else/ n+ I& o) j9 o! v
printk(KERN_INFO "LED register sucessful!\n");
4 G3 @* J5 s/ O1 _2 e0 E* g; A+ \6 y. P) H4 p6 x
return ret;$ q. S; } u: V8 I5 [# b. m
}
$ l7 c/ ] O9 U' T! w" z! ?
, _* e6 ?! C- d1 Y& b$ L8 M4 Ystatic void __exit led_platform_exit(void)
3 L& p( t' Z$ f# p) ~4 H" V% Q/ D{
8 Y4 e' A) G: K) \* k& }9 V platform_device_unregister(&da850_evm_tl_leds_device);
; d% c* h2 i* R# ^4 a4 [. z8 q8 i3 n2 G" D( ~! D
printk(KERN_INFO "LED unregister!\n");5 S i& ]* r5 J* V( B# `% V
}9 V1 D/ a1 }3 r# f* p5 ^) Y+ L
7 p: K" m) E% a, L4 c
module_init(led_platform_init);. S. m- G3 }8 d! _
module_exit(led_platform_exit);3 G# N4 S! y, F: @
' U8 H4 C8 S* FMODULE_DESCRIPTION("Led platform driver");+ \. j4 \4 g! L9 A) b6 P
MODULE_AUTHOR("Tronlong");
- E- W( P( g7 O$ E/ DMODULE_LICENSE("GPL");
' E6 r: M5 {3 _9 y' b
/ J% B; E# @9 s# U* ?6 C% _! \" [ |
|