|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( J5 G1 ?/ n* e2 E. J
#include <linux/init.h>" r* w1 e: J* l: ]8 G
#include <linux/module.h>8 G& ~& z6 V0 d$ k) m8 v6 j
#include <linux/kernel.h>! ^' C% M7 f# I7 @0 N2 u
#include <linux/types.h>
$ S. Y1 Y3 R2 I' I, Z#include <linux/gpio.h>
+ m' T9 }7 I3 E% }# K+ k#include <linux/leds.h>
6 ]0 }' h) J5 o- Z2 i/ L#include <linux/platform_device.h>
2 A0 n N- z T5 r# [; z1 _) K+ ~! Y" ^
#include <asm/mach-types.h>* O7 |: v- }) o
#include <asm/mach/arch.h>) t( V, R' W2 _. R
#include <mach/da8xx.h>, ^4 c1 R. J$ J* _: x
#include <mach/mux.h>% K6 }5 S ^# F
3 V' _, b/ o; G( R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 _! a( N% D% X6 D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 J) z+ K V% N( E8 b* }$ S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 X( x. J- F' s5 L+ x9 ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 n7 Z; ]9 D# n. s5 ]
, Q& {: s6 d9 o! A9 [0 X
/* assign the tl som board LED-GPIOs*/$ P7 h6 ? H9 R9 e* Z, ]
static const short da850_evm_tl_user_led_pins[] = {
- y) a h: }! Y8 c+ s J /* These pins are definition at <mach/mux.h> file */- E6 H5 v" Q* q' j. h6 W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 X- E( _5 c4 b( F; S x
-13 M, `; R0 B, s# Q
};
% L8 c* R$ i5 I) t8 @3 @9 G5 n7 r
8 n' O, |% u! l0 d Dstatic struct gpio_led da850_evm_tl_leds[] = {
: I& b7 P% R# L/ t( r {' T. j/ f" G4 o: u. Q% _
.active_low = 0,* r. k" D' c s2 h$ t! [
.gpio = DA850_USER_LED0,
4 D, Q* z' `4 N7 \0 _0 J" J, J .name = "user_led0",
4 n5 D! r# E3 Q .default_trigger = "default-on",
9 F) E- v( @2 f$ E6 q },
5 z B, A* |" J( C$ R, \ {5 Z0 r0 v5 D5 h
.active_low = 0,
8 @3 e0 q+ i# I) o1 e3 t5 y3 R. ? N .gpio = DA850_USER_LED1,& L7 _0 r, P' y' S% P
.name = "user_led1",
$ U# F h* |! ~$ s8 m# A; l9 k9 _) F" P .default_trigger = "default-on",# H# f: @5 l) {9 v+ h" T
},
- D+ |2 h" X" o4 M0 f6 e$ J {
0 ^3 l( p3 L4 M4 _ .active_low = 0,
0 d7 H ~1 t+ V+ u9 Q .gpio = DA850_USER_LED2,
9 v6 h6 n4 A2 c: n+ ], {6 p; t .name = "user_led2",
# ^& o; ?! l: E/ r5 d .default_trigger = "default-on",
$ y: o( `6 _% b+ ^ },0 U1 H7 D L! Q, ]9 b1 [( B' W
{
; k$ c4 h( N! x* R4 F8 H .active_low = 0,# \! }1 I: V+ ?
.gpio = DA850_USER_LED3,/ @ J) z- q4 T: O, x
.name = "user_led3",
) d, W" D' }3 D) d' u .default_trigger = "default-on",
* x V2 J. ^( a },7 M4 H. m5 W" g. i
};
9 X& \3 G" [- S R2 A) v. r2 q. {5 E; e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ P9 b5 R! N0 b9 {1 R .leds = da850_evm_tl_leds,
; U H! L8 _- G7 h% e/ D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 I3 d z: Q/ O" v
};
" f6 ], h% R5 x; o5 c. [1 m
7 F2 W/ s5 e1 t3 y; g0 q( w# Pstatic void led_dev_release(struct device *dev)0 i* s1 t6 T' a, N Z3 ?: A1 T
{
- Y* G# {; j; c8 m0 ]! y};* y9 ~# L! Z: M! [" n
+ M4 x( |; h! X- ustatic struct platform_device da850_evm_tl_leds_device = {* j3 k! u/ ^2 X l! d
.name = "leds-gpio",2 j1 |6 N. w* y- F
.id = 1,
0 r7 ?* o5 D; g }7 D .dev = {6 z! Z Y+ I& U7 E9 f4 t9 |- l
.platform_data = &da850_evm_tl_leds_pdata,6 L# n2 r- N' l$ u7 G
.release = led_dev_release,
/ d3 X% Z3 t! A0 M% |: S! Q' h P }: Z; L% d, d( q. g$ a7 y
};
- u) B" l+ p1 w: `4 H# b: R6 ?
4 s3 {; i; b* ^. l) _static int __init led_platform_init(void)1 s+ v2 d! l" r. `
{- l2 o. [( e) X0 P; q% [* V) F2 L
int ret;9 G7 Z! j' V; A6 {5 M, o3 R" F- }
#if 0
% @) `- ~! {6 p, p6 b$ k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 h( O. [9 a0 f: j9 ~
if (ret)" d" W+ T# A$ p ?! A' o' ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 T) y! I$ t' U, s% F
"%d\n", ret);; R; a2 f" ~6 _+ L
#endif3 _. ~& U/ {* M: v- x: Y
ret = platform_device_register(&da850_evm_tl_leds_device);
9 y8 j' @ ^0 e/ X if (ret)/ z( v3 ^! q; m8 y% R3 b# m$ b
pr_warning("Could not register som GPIO expander LEDS");1 v' H' y4 C' C" a* M$ f$ X
else
0 c/ t" S+ o. f( g4 [: L printk(KERN_INFO "LED register sucessful!\n");
- V8 F/ r K. R; f& @: M3 Y& s2 ]
1 ?! U9 F$ Z; h- O. K8 p return ret;
" ^; D8 K# `2 [ ^! }* [9 t% ?} f) o0 _+ P* `" v
' X5 z+ {1 e1 _" y
static void __exit led_platform_exit(void)
; c, Z ]4 B3 V7 R$ z" e# z) u{6 _% U' e. w8 I$ `6 y+ y/ W x
platform_device_unregister(&da850_evm_tl_leds_device);& G6 m6 ]7 n5 b! S( h
) Q. w' D: J' O5 z9 R- X9 x# E
printk(KERN_INFO "LED unregister!\n");3 i) D/ |% @$ D9 L9 X( X& O
}. Z3 r+ M$ @$ i, m( g7 Y: }
4 z8 w0 H. s- ^) v5 c$ W# T
module_init(led_platform_init);
/ T) N$ w# p4 x5 ^) T v! ymodule_exit(led_platform_exit);
5 h; b' p% }9 I1 K# ^. v; Q& W7 W2 e) X) B/ M
MODULE_DESCRIPTION("Led platform driver");6 L% O9 J3 ~& j" n. |$ l! S
MODULE_AUTHOR("Tronlong");: a9 T, y8 B& _; D5 K
MODULE_LICENSE("GPL");) }/ X$ B8 E, ]8 R' V1 S
8 i; X1 y0 N h# b* U+ Z4 \
|
|