|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- |. d2 e2 `" t8 @7 S' ]
#include <linux/init.h>
5 R/ d9 F9 M, }#include <linux/module.h>
6 \% P7 n( J. ^& C( X7 [! |#include <linux/kernel.h>' X4 Q7 y1 Y# H5 \+ T
#include <linux/types.h>
6 ~. n, D" ^# f#include <linux/gpio.h>3 X/ e( k$ N# E- `8 B C
#include <linux/leds.h>
9 C" U- d. ^6 H. B1 x#include <linux/platform_device.h>
" \. ?/ A$ Z3 ], z3 e! `/ F7 L% G" d; r2 N) |7 S
#include <asm/mach-types.h>
$ Y! L9 M o) ?+ E, G: v6 q#include <asm/mach/arch.h>0 _' [; m. o8 H: {9 j5 K
#include <mach/da8xx.h>" y* D n$ V; i( M) ^' @
#include <mach/mux.h>
' e3 i/ o7 o4 w7 U7 i! h, l3 A0 i+ H- L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); y4 z# A4 E; ? x" V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! Z. M- ^3 ^2 v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 Y2 C3 W8 M x% ?+ @! ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). \/ f" f2 y! w. _6 L W
3 a/ V+ V# q7 O P" h: [' t/* assign the tl som board LED-GPIOs*/ q, x; n5 H2 l: S; T% [
static const short da850_evm_tl_user_led_pins[] = {6 |4 [5 f1 r7 |1 X1 o
/* These pins are definition at <mach/mux.h> file */
( A' F8 G5 S; m, U9 D" m+ J0 \" t DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 D% i& p$ D1 }: T
-1
/ r; @& K$ {" ?+ X- E$ F0 Z0 r3 }' T};
+ H5 z: L% I, U- f$ u( W) q
7 a V+ e( A& `static struct gpio_led da850_evm_tl_leds[] = {% X! t& Z- Q1 x8 ^) Y2 `
{ ~; K5 W/ S& t. }7 G( u+ a9 N
.active_low = 0,1 X# H% p- o0 f% C3 U2 F5 @2 Q. k
.gpio = DA850_USER_LED0,
! E/ M8 ^" E* L7 g4 ~6 I* X* e .name = "user_led0",
: L4 L& A0 g* H! N$ ~/ O .default_trigger = "default-on",
1 L6 F$ y* F1 _8 L& T },
6 B. R( o, f2 n7 _ k {
0 @: Z* B4 {% V7 L$ Q+ M .active_low = 0,
+ i0 }# V5 s+ ]1 s5 P' ], m) e9 @/ d .gpio = DA850_USER_LED1,
2 n4 n/ r& F* i5 t, L .name = "user_led1",
; _! ~2 D3 X m; E8 {% z .default_trigger = "default-on",
3 G, H4 a1 Z, w, |' Q( S4 Q+ H },
3 `5 W" ?" H1 [; k {
' c! B3 ~0 G& r( U: z .active_low = 0,9 \6 d5 r2 f: ^/ O
.gpio = DA850_USER_LED2,2 T" N) o( K) u6 N1 q! O
.name = "user_led2",
6 \& j6 F$ @) i. N8 k3 K& I .default_trigger = "default-on",
, ?& |: b+ A- C },
0 k2 T6 r; h8 p3 w; h {
Z7 g' M; ?: K- X! b# |2 H .active_low = 0,
5 k# \! h) L) x" ~0 l8 q/ m; o0 J& P" q .gpio = DA850_USER_LED3,
4 F+ R) \2 m1 k4 ^ .name = "user_led3",3 X# H9 [+ p, U0 m/ X& A/ N
.default_trigger = "default-on",
/ p0 \& \" U0 Z },
& s& s1 T# r, _' \ M! @};& X2 \2 X m; I8 K; w, U
* o: l% t0 ~% Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" ?# @7 b8 O4 \2 \2 l. C
.leds = da850_evm_tl_leds,, N: [- C0 j+ |" A! n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. p/ s4 ]/ Y* p; T' V};
( r# t2 S& b3 U3 ?: \
8 Z+ ~8 u2 |5 fstatic void led_dev_release(struct device *dev)
% E; T+ N7 o6 ?. Y{
9 ?% i# O# M' q3 r% o, O) e' X};7 o' o( D9 p O& A% s0 |- A; w
1 W& w2 L: k( f) ?
static struct platform_device da850_evm_tl_leds_device = {
( I. R. [1 e- X( c+ h5 [6 _0 I" D .name = "leds-gpio",+ w/ U5 T1 v: w) d f0 J
.id = 1,
8 y! l4 c: N- T' s .dev = {- T+ f2 j" d( R8 [
.platform_data = &da850_evm_tl_leds_pdata,
4 E2 \. y3 y, r8 R% Y/ E( V. r) Q .release = led_dev_release,. N2 a6 [, w$ A
}- S8 C' Y2 F0 S
};' V3 B( a: O- \
# A5 \" n6 C- }/ T, U- i& cstatic int __init led_platform_init(void)( m. K6 ]6 b2 }
{
1 L) I: |& W. { int ret;
" h- j% O, i6 Q) d# g: I#if 0
: O, J: v, v* {+ h1 O! {9 R6 h0 q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) z* R7 z$ I0 A3 n
if (ret)3 Z5 q% X0 d" z {( P' }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# |0 [4 |5 r7 j2 c "%d\n", ret);) E) Q9 q% }# t
#endif
+ h1 a% W* a( B ret = platform_device_register(&da850_evm_tl_leds_device);' \' v& q- G0 H r4 V( `
if (ret)7 {' x! ], W8 Y: D8 p/ k1 G7 }
pr_warning("Could not register som GPIO expander LEDS");7 |2 v1 C- R- v) W7 L6 {
else
* m: `: ^: G! J$ O j printk(KERN_INFO "LED register sucessful!\n");
$ o* t( ^. }# Q* [1 X
+ n0 G( T. o& z0 I `0 B. ? return ret;2 d A) [, J }0 l3 r+ @
}
2 j- d7 r) J( w" U
& m G; o# s* z9 istatic void __exit led_platform_exit(void)( l& |: [# H; A4 J9 Y$ c% y
{' D, e& j# W: }7 I( f9 u7 b* z
platform_device_unregister(&da850_evm_tl_leds_device);
6 n: u$ i% d8 W% z, x: c$ E5 i+ F
7 R+ S U; T5 ]2 R printk(KERN_INFO "LED unregister!\n");1 Y/ e' m2 K" {$ f5 x6 L" \" G6 }" Z
}' s, K! R, ?# Q; g6 w
% ^3 N/ d& X% {! i, U
module_init(led_platform_init);6 X- W; O/ H/ v0 I: n
module_exit(led_platform_exit);- v0 q9 N1 |8 }7 J3 v
4 u: X/ @6 w$ ]" X) }& CMODULE_DESCRIPTION("Led platform driver");/ G9 n: o4 K- ^& u2 }/ G0 Y
MODULE_AUTHOR("Tronlong");
4 ?, n5 p9 {9 P8 K% LMODULE_LICENSE("GPL");
4 G$ o# ]7 V( x6 x- Q- ?
" V# N; s/ l( S& t# D6 x9 Z S9 c |
|