|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 r9 [, H' n& M. ?#include <linux/init.h>
; O% X; B3 U3 G; m#include <linux/module.h>
) L2 q- \ ?' O5 K5 l#include <linux/kernel.h>
, O" o ~* g1 ~9 ~( Q* z#include <linux/types.h>& _- S) g, @ i. o/ i
#include <linux/gpio.h>4 M N! _, |8 {
#include <linux/leds.h>
: j. A4 X& r! P% @9 L#include <linux/platform_device.h>7 R- f w0 l' z& n: N6 k9 Y, I
7 F. Q9 u S$ J5 ?; G5 B8 r#include <asm/mach-types.h>6 u" ?0 l( x- f1 E. h
#include <asm/mach/arch.h>9 K2 P- S: ^( g9 }! z
#include <mach/da8xx.h>
- }+ }8 h9 H6 ~* ]#include <mach/mux.h>- N& l0 M( b# X
9 r$ }5 f$ B7 Y* m: d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 d% S# O$ t3 T# A$ u. d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 I. V; I: s+ M/ c% C( P3 f. X1 _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 P8 S" u' ]. \0 w% [4 T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 o" h, y' N( X+ B. Y5 |. X6 E- v
6 J9 E2 Y' L" M I' R0 B; r* c4 ? T/* assign the tl som board LED-GPIOs*/; J4 S0 H# e# {- M: R! n" B( z
static const short da850_evm_tl_user_led_pins[] = {
5 p6 Z/ A$ D4 e y& N3 I: w /* These pins are definition at <mach/mux.h> file */7 B! H5 V! L7 P% m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 R+ u Z" G$ s# I' S# h4 U -1
Y6 ^# v; A( b4 @8 G5 u* w};
k6 D- z% c Z9 |# G$ }* n K9 [# \1 y* x; u K
static struct gpio_led da850_evm_tl_leds[] = {
5 u6 ]4 D$ O% D7 T, [, _ {$ Y" w; J6 C; _ R& S; N* j( R
.active_low = 0,& M% G- R: S+ N, C. ]+ ?+ b
.gpio = DA850_USER_LED0,9 T ^$ J2 n) t
.name = "user_led0",8 ~! W5 _# B: |4 B# _
.default_trigger = "default-on",
7 T6 c7 j$ e+ e$ {% R },
6 Q& {, g3 U" q1 V {
$ `$ U4 i! N: o2 a3 r7 Q7 w' M8 I .active_low = 0,
; D/ d3 i- [: U' ~. H4 x2 N .gpio = DA850_USER_LED1,! I, h0 L1 Y4 c1 { C
.name = "user_led1",# t5 Q4 t/ |2 n2 [- [2 W6 F7 S
.default_trigger = "default-on",* ^1 q* Y* k- n
},( j1 n4 t: m6 s. a$ a
{/ Y2 ]5 @. n; g- s. y4 l$ m. _
.active_low = 0,* s- c: R2 M9 ]& ?7 W
.gpio = DA850_USER_LED2,/ O. ?5 `8 f* V
.name = "user_led2",. J [' P0 ?% ]
.default_trigger = "default-on",1 _$ y$ t8 n W6 g7 h. q0 `3 v! p) c
},0 ?4 K. b' [# {6 [' m
{5 u- F" q% q6 G+ t- n* m; O! y
.active_low = 0,
7 e8 t$ S4 ?( P8 N .gpio = DA850_USER_LED3,5 M2 a! ]9 B/ n- a2 U
.name = "user_led3",
) S' g6 r7 S7 T3 o; B: v5 `( K, i .default_trigger = "default-on",6 @4 V d* I3 S+ E' }9 a
},
' S t1 v% L4 r9 ~7 O& o: m: p: j};2 ~$ ]* J. i& n, ^* Z$ w. w
2 D/ o7 @, O( b6 Z+ g4 q) F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( X, m. V2 z/ M* X( L ], x .leds = da850_evm_tl_leds,
0 }$ w- z* G/ X2 \! t Q8 m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; N( @( s* g4 r
};
: l/ k) z% `9 y% m! m4 y7 ]; D& ]7 y& D/ z' K' w6 I
static void led_dev_release(struct device *dev)2 J- Q) a/ \$ h
{) ]# d0 p. F) B5 c( A4 a& `
};6 x# A, ?0 c1 m1 O9 A! D3 K0 |
6 F; H' C) p: s. V$ x% _static struct platform_device da850_evm_tl_leds_device = {
2 y4 D1 X5 p3 _6 C& C. A .name = "leds-gpio",, l$ x1 a$ A2 o" K
.id = 1,% U4 N0 H- {+ Q, X! k
.dev = {1 U" S. [ Z* T) m
.platform_data = &da850_evm_tl_leds_pdata,
- x# a; @* F* R% g1 J9 I0 F5 O .release = led_dev_release,) ~ |; o5 G7 _- y& f
}0 i6 z7 I$ f. {/ C# K& ~
};5 Z1 z6 c, E0 R R( a) S
6 b; ~6 H( s, Y u) V8 z) C! gstatic int __init led_platform_init(void)
# G; Y, \- Y0 c& D9 K{. I& t' M) }1 }% a* T
int ret;
: A* i7 E* U+ r9 W& ^2 `#if 0
+ Q7 N" \0 m( f. p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- S4 ]% C- |9 ?. G( G; g2 ~6 ? if (ret)9 }& N! G2 Y9 f% T5 H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
m+ t$ o" s" x2 l( I8 v "%d\n", ret);
% F" h# w2 S7 ? W3 u4 F#endif( ]9 _) B; |3 L" N8 N
ret = platform_device_register(&da850_evm_tl_leds_device);
: z$ E0 B/ I. R" r if (ret)
/ x+ ?' I; ` N pr_warning("Could not register som GPIO expander LEDS");1 A" W; \2 H; g4 P# C
else
' D# Y& m- g1 [4 f, n; M printk(KERN_INFO "LED register sucessful!\n");
7 J+ {2 g. ], L3 v" V5 h6 D9 k
6 u1 v$ v6 |* P% d5 g' g return ret;, _, ]5 J( o, q8 l G$ X1 n; m
}
* ^8 ]5 J4 b! X+ r% G- r6 F
7 c9 ^3 W, v) istatic void __exit led_platform_exit(void)
! ]9 J" C# T" n5 C- S: @{5 C! G. A0 B0 A( a2 }$ P4 p
platform_device_unregister(&da850_evm_tl_leds_device);3 C- f6 r- b. _
6 W# A: q* w: T7 _ printk(KERN_INFO "LED unregister!\n");
& u2 V' L; o9 M+ Y( _: c# {}
8 g! H5 }, x! x+ E8 M- j$ b0 _. z% c4 X U0 J1 u
module_init(led_platform_init);
2 M3 v( F" f5 Z8 Amodule_exit(led_platform_exit);/ _3 |8 V3 p/ j
* o) _; D1 K3 d6 B" xMODULE_DESCRIPTION("Led platform driver");
( Z. p5 W( l2 h9 i0 ?! `MODULE_AUTHOR("Tronlong");/ Z+ M, B \- X" j0 S0 Z' s/ `
MODULE_LICENSE("GPL");
$ Z" ~7 _, B6 Y8 f& v/ d4 N% i/ z% P. Y
|
|