|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 M/ f5 s" s# b* W; o
#include <linux/init.h>
' B- s: e) Y$ i#include <linux/module.h>" d8 s" d4 s. l3 ]( v3 Q
#include <linux/kernel.h>
: o8 s8 c1 \6 t( Q: X' p7 S9 l l#include <linux/types.h>
- f5 O+ |+ P$ C# E#include <linux/gpio.h>2 T. A4 A; ~( m# Z7 Y8 X
#include <linux/leds.h>9 m1 [0 N. p1 D( c
#include <linux/platform_device.h>: I/ D3 p7 l( r
' T* o" q; C3 j0 i& \
#include <asm/mach-types.h>
; y6 `- Q0 t; X" x+ B3 y#include <asm/mach/arch.h>- ~$ U' c2 i( d6 `5 @# B6 d$ K. g
#include <mach/da8xx.h>
4 ?2 D4 S7 P; }/ @2 E#include <mach/mux.h>
, B z# x( r, i* m
& W6 p5 H- Q. M, s& w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 N: }9 V/ \8 |) K
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 B/ K- P8 W3 w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, {6 a v; C$ \, x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); u; U8 N) s" `* z- a2 w
1 u3 [3 V& ]: c h v- r/* assign the tl som board LED-GPIOs*/
/ c; D2 ]. l& s5 m& Ustatic const short da850_evm_tl_user_led_pins[] = {
1 _+ p) m% O: X, z8 g /* These pins are definition at <mach/mux.h> file */# F% K) @" B4 x8 Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ A9 [8 c+ o/ `6 w -1" W5 m+ Z5 z1 } [* `
};9 x1 v7 G* R8 C: u% ]. G
6 a/ W$ _6 h/ h% X; g
static struct gpio_led da850_evm_tl_leds[] = {: h4 ^, e# X' B/ T
{
0 d- R2 C) x8 h' b .active_low = 0,
* e0 x; q: C4 M$ `6 _9 K" g+ P .gpio = DA850_USER_LED0,
7 ]/ U: P4 C7 k .name = "user_led0",$ n$ i, H% A2 o3 L6 I& G8 W6 ]
.default_trigger = "default-on",
- q+ t0 t( g5 \ },
1 @' W! ~; q' h8 G% ^. ~2 j; @ {
( u+ K+ b. d! k. ]" J% m" @ .active_low = 0,
2 x k2 z! i* K1 `. b2 Z! W6 [ .gpio = DA850_USER_LED1,
7 G8 B \5 Y& a, {! l .name = "user_led1",
, ~6 k- s8 v* d .default_trigger = "default-on",
1 y1 Z% e% M; r1 | },! B% K! ]% U+ g, U& }) f. }
{
. y2 \/ c) H2 l- W; M/ p" D) _ .active_low = 0,
* S; S6 W! M0 X. Q/ M .gpio = DA850_USER_LED2,+ [: J. \' H( y# }
.name = "user_led2",
/ x2 B. P0 ^& [3 ] .default_trigger = "default-on",
1 c0 R4 X" J2 h; }! u8 D3 B },
3 H: f2 d* M1 n c1 R {
+ V9 Z/ k% I6 _" C( ~1 b& n* I7 j .active_low = 0,% ?6 h2 p/ w0 c2 e
.gpio = DA850_USER_LED3,# w4 H' {; n+ l
.name = "user_led3",
3 H9 D) e9 m% j1 F; D. |6 y6 \% b; C .default_trigger = "default-on",5 h9 r3 L5 G$ r0 [/ t8 p; s
},
; G4 T* ~) r" W8 D: r3 P, _};) W9 ?4 v- G' B: T* b7 |8 i
# h. O) V% ^7 `' \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 v# x+ j9 W/ Q, u .leds = da850_evm_tl_leds,
# U D0 S# C4 q: v9 n" C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" |) C. Q+ J; n2 X% s$ c' B};
3 j `9 }* d5 i W. f7 n% q" y( v& G
. p! H$ t* J9 m8 [1 B. `) o1 Wstatic void led_dev_release(struct device *dev)) y2 U# y7 a% i# q0 U3 F
{. }* {) v; f/ ]' @! a! Y
};1 _& u6 d. M, m, Z: P) C& K# I
9 b1 `3 N0 d( J: ?" } Y
static struct platform_device da850_evm_tl_leds_device = {, [- U) W; y _) C! ^3 _+ b+ M1 v4 ?
.name = "leds-gpio",; @. [) {( P, @% F% Z2 I
.id = 1,
& ~: b6 N* v1 b/ R: X .dev = {8 [: p0 Q0 w( {( h. u
.platform_data = &da850_evm_tl_leds_pdata,7 d6 g7 ^/ i! r7 g# L6 @6 i0 q5 {
.release = led_dev_release," }& G. f3 t! C. B1 M& a
}' }( W" N# V1 t$ I8 {3 ]
};
4 l4 @8 C9 ^# n7 U0 S1 T u' G' ]
static int __init led_platform_init(void)7 m3 ]4 ]$ j& E, a9 T5 e) @
{
( m S, }+ Z( \- [' I$ S int ret;
" K3 ?$ s5 t/ n; S! u- ?8 V#if 0; @' q5 D8 {' Z& J
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" T- R1 @3 R( B2 B* w; \
if (ret)9 A( X& Q5 K, p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. j4 t5 k. b- x$ @( x- o- N "%d\n", ret);
0 I& b' [5 j0 ~) U+ \#endif
1 C H, d x4 B! [) w ret = platform_device_register(&da850_evm_tl_leds_device);
r( y, f$ s& {7 J if (ret)3 h# x5 Q4 ^' B4 ?
pr_warning("Could not register som GPIO expander LEDS");
0 y9 B. f, n9 @7 _3 q, L+ [, ?) k else
+ d0 B- k% `" d, n/ ^3 q F" D printk(KERN_INFO "LED register sucessful!\n");: X+ E+ _7 m, O8 t- ^
$ E9 l, g2 S$ B: F! t: z return ret;
5 v7 x6 d' s/ [ ?2 k( l$ g}
+ `( H2 \- w& C6 F4 i9 t2 o7 x' H* z; _8 q) I( f9 r5 a4 D7 q
static void __exit led_platform_exit(void)6 c. V' M& ~. @: o2 [3 E& i8 g% Z1 B
{. i% P0 a, L6 g% R& g' y: i
platform_device_unregister(&da850_evm_tl_leds_device);7 P3 `- H9 ^8 n4 Y& p
9 T, |/ Y' ?7 P: Q0 ^4 J# s) m
printk(KERN_INFO "LED unregister!\n");
: d3 L( l6 m0 S1 f) d7 ^}
6 y' a4 E8 ], X& N3 Q+ j7 D0 _
$ H4 B( L8 J7 y; P' ^% O# Gmodule_init(led_platform_init);
p, g8 U' e6 gmodule_exit(led_platform_exit);
2 p& z3 G; \1 Z" M7 y* B' S, W6 q0 z/ m1 g0 ^
MODULE_DESCRIPTION("Led platform driver");# o& H( C" C* a$ P0 j
MODULE_AUTHOR("Tronlong");( K6 K$ E% H7 l+ r1 J# u& M7 p
MODULE_LICENSE("GPL");3 v" |! l& }( Z4 N1 c+ g; ^5 g6 a7 j
( T4 Q w, f% n |
|