|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* {- @6 s/ `- E/ j
#include <linux/init.h>+ o4 @ T, G ?8 @* B
#include <linux/module.h>
" U7 W# M0 j( Z! ?* y0 ]" ]#include <linux/kernel.h>3 v- J& m! ~6 n: N3 g6 ~
#include <linux/types.h>8 E5 K+ O1 o; r, b0 R( ~0 X
#include <linux/gpio.h>
& A1 G/ h' J |7 \( p#include <linux/leds.h>$ R7 _1 f6 X" R! r: V! N' O& B8 u
#include <linux/platform_device.h>
3 _1 ]# B# k& Z5 u5 M7 c* o( b8 `; m0 g
; |% J, F' E& U#include <asm/mach-types.h>, |3 y, K, s* B2 n! k
#include <asm/mach/arch.h>
' `, z- ]$ b" y( n( K i#include <mach/da8xx.h>% m: z& |3 H7 v( J
#include <mach/mux.h>
: F8 L$ h# P9 H9 u. n$ u6 R+ C2 {3 v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& ?$ i2 T4 s `' w x9 |4 ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; W, w5 O; b5 `$ s" a3 G* S; c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" i! [$ p) D5 P: P5 |# h( T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* Z, m- P9 I0 C; X2 z+ z* n( V7 t# Q$ ] P- e1 R2 E( ~" ?
/* assign the tl som board LED-GPIOs*/
6 H5 J8 x3 I& X" p1 m) ostatic const short da850_evm_tl_user_led_pins[] = {0 `( u7 x" c3 d" P7 N
/* These pins are definition at <mach/mux.h> file */
+ Q# E' Q- m# f: [$ e, G/ N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' |/ B0 L9 ^2 O+ t8 F0 S
-1$ L! A0 r" {: }0 i' s5 o
};
8 J- _. }. s# H$ P- }2 z. d' _/ U3 K% U
static struct gpio_led da850_evm_tl_leds[] = {
2 D2 V/ e6 i! u2 d3 Z# `. T+ n Z {
; D6 w8 V9 |" v .active_low = 0,
( q2 q, p4 X: q* a1 G .gpio = DA850_USER_LED0,, D/ J0 q R! x u- b/ I: L
.name = "user_led0",
) @3 \! z# ]8 G .default_trigger = "default-on",0 n, X4 y) U, E1 s3 s1 b ^$ t
},3 @/ ~' ]# ?2 u0 e/ I, L' Z" y' M
{
+ d5 L! W4 A. x* L n& P2 m, ~5 e, ] .active_low = 0,
$ C; H/ C% n$ x; ~2 J* x .gpio = DA850_USER_LED1,
$ L# K+ u Z1 y$ O) g9 F .name = "user_led1",6 [' z9 b) T) d
.default_trigger = "default-on",$ ]$ z/ J9 v* I+ {1 q3 h
},
6 n9 @4 n& R" v- X; b! [ {
. p; C0 L$ U! |7 X: R5 ] .active_low = 0,
- u8 p# I$ S! W4 e3 ^# B/ V W: O .gpio = DA850_USER_LED2,
7 T. |8 H, O+ e* Z2 \/ G/ K7 y .name = "user_led2",
1 h9 \& a( Z# [4 `+ y; l .default_trigger = "default-on",
6 \! {! F: c3 ^* q },0 u( o5 m) h8 @% @- u2 o% r
{
; W. m: J; r) Y .active_low = 0,
% m( _6 R% @# a( ~8 z n- Z .gpio = DA850_USER_LED3,
1 B$ b' r) g G .name = "user_led3",
. [) |1 p5 z5 ?3 U .default_trigger = "default-on",% ?( C+ l) f* e& C R# ~
},
) R3 ?4 T+ \5 P4 X% @};$ P) j/ p1 v1 ]. g$ n$ f
+ a6 `6 I: w6 J9 t$ {8 F; D+ ~. hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 q! p* r S" Z1 r7 @- o
.leds = da850_evm_tl_leds,
- H% H. ~7 C. ^, s: x7 q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 r8 `. C: f* y& Y) e. ?
};! H' _5 U+ C6 [, _6 _* b9 G" ]
* _% d7 y" U, i: L5 Q! j
static void led_dev_release(struct device *dev)9 _$ @, b! L) i7 Y* I( g
{: M& h) M. Q% G; n1 _0 c
};
/ F, w- L! x) F& G0 i9 x, [6 Z Y- V* e0 g# e9 t5 z
static struct platform_device da850_evm_tl_leds_device = {$ f7 N$ l: [3 U! B8 H
.name = "leds-gpio",2 d) v* }* L2 c# {1 {6 y' i
.id = 1,$ x, v& y: l1 q! c7 r( w! h
.dev = {
' A* O3 e( k9 U: W# Q. ]. p .platform_data = &da850_evm_tl_leds_pdata,/ Y s" q1 T; Z4 {1 r! V! a8 Z
.release = led_dev_release,
: g- B' \2 ?- j+ L }+ d$ [4 ?. N0 c- d
};% ]. H( ?! q, [9 y ^- n! i
" C% [, c! ~4 `# ?) d6 M
static int __init led_platform_init(void)1 l% D2 @( r# k
{* I9 u4 c0 [- X
int ret;( k6 _; s ]* N+ P4 y4 a5 U' y
#if 0
( J- L9 i: Z" F) z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ P* \* C& L- g if (ret)
+ s, d/ @* L! U2 [& n9 B( y pr_warning("da850_evm_tl_leds_init : User LED mux failed :". b# k n8 z0 i2 D; w' O2 S( K
"%d\n", ret);. ^9 O; x- t1 e: V* T) K' H5 g* F
#endif- S, D, v% d5 U" x* K
ret = platform_device_register(&da850_evm_tl_leds_device);
. Y2 F- D' x* P7 E* P if (ret)
9 [( X7 }% k& ]1 K& Z pr_warning("Could not register som GPIO expander LEDS");
& Z; x: c7 m U+ _( r5 L else
& o5 k3 |* e. w4 d- P& x R; K printk(KERN_INFO "LED register sucessful!\n");
! y, V) u$ w7 i2 l
, a8 k; L3 G. \7 V" K: s' @0 E% X return ret;
: B( C) Z4 c2 M% T) g: N& ]}
7 d m, G' ^* k$ r- s m
6 r, K1 `) i' \, O8 f$ j" t5 Zstatic void __exit led_platform_exit(void)
, {3 X7 p$ }4 C; g! a0 i2 ?{
' d V' U' R. V' [8 t1 y% {' B2 B platform_device_unregister(&da850_evm_tl_leds_device);
6 }4 l2 Z" m( ~2 Y% L# [) ?- ~' R# g* E
printk(KERN_INFO "LED unregister!\n");% O! q0 w4 R6 i% W( [
}1 }) m' w, Y. [6 Y5 F. P3 W. J
3 f5 D, J) v ]9 B* i0 c& @
module_init(led_platform_init);* P9 b/ W( G+ m& h- m
module_exit(led_platform_exit);9 r# v+ G3 ^1 L, v
8 Y9 O; U; D. J, v+ i4 p$ @MODULE_DESCRIPTION("Led platform driver");
$ v% j, h4 h2 ~1 D2 NMODULE_AUTHOR("Tronlong");0 M; W: F; H, T+ F" q* n
MODULE_LICENSE("GPL");3 h, Z4 s8 Y A& }# T
8 j) }& n/ x! e2 f; ^# P |
|