|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 @+ ]2 R/ ?' Q# i+ O6 i7 W#include <linux/init.h>) B# Q+ D' p) }6 ]1 b+ @( ^' I9 b7 \
#include <linux/module.h>( h' |' V) D: q: c/ w% L4 V6 ]! h! _2 p
#include <linux/kernel.h>
5 k8 Q* ^% k, |9 B$ l! [- }#include <linux/types.h>
' K5 L% h8 V8 z2 | _- q, \#include <linux/gpio.h>! \4 f/ C6 C5 N- y8 d8 g& E0 y
#include <linux/leds.h>
1 i' {" G& b; |& R) a! O9 D( U#include <linux/platform_device.h>; n5 @4 _* I9 v( S
0 N& A- b* e0 P2 E( g; t0 X#include <asm/mach-types.h>
5 Z) r+ b- O6 O5 M6 g& j9 P#include <asm/mach/arch.h>
# D% `9 k/ ]' a" Z. Z#include <mach/da8xx.h>8 L% ?$ v" v2 x3 q3 K
#include <mach/mux.h>
/ _% h m; N* _! c+ ^ Y' v
3 c7 V4 w3 m) s' J- `- \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. Q3 B t2 @1 I' B2 y- D$ G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 _4 Y4 Y- g0 {& }9 C
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. T5 Y, @% L6 D9 ~1 Y ^$ w' _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. i( Q: G# L( |2 F" j% c+ p
; c( m8 ~) _* k' I( w8 S$ J0 h/* assign the tl som board LED-GPIOs*/9 t0 @! @3 m: X, j5 k* ^' h
static const short da850_evm_tl_user_led_pins[] = {2 g9 X w8 c' N
/* These pins are definition at <mach/mux.h> file */
' u& K' N4 x5 h4 @1 J& I$ B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ T& \+ W* m0 ?" p" w. w/ F- ^ -1
8 R; V8 E! v) s& J2 n ?# H2 M9 w};
% R7 v+ f, V; A6 J9 R* g3 U+ O: o, ~: W9 P( _
static struct gpio_led da850_evm_tl_leds[] = {
- V6 _& V8 n5 H9 |) z/ k6 }7 _ V {
3 F* g6 h" `9 n! S' H' _: m# Y .active_low = 0,
6 E' p/ Z; D% W' _# F .gpio = DA850_USER_LED0,' I4 T+ g' Z5 v2 |
.name = "user_led0",
u4 g0 a9 y2 b1 F .default_trigger = "default-on",
$ `* }+ k! _. A F6 F5 X },6 A- e2 c4 `/ n. H
{
' H% H) f) `: R7 J .active_low = 0,& |3 S( A# V6 j# s% d
.gpio = DA850_USER_LED1,
$ V0 l: K7 l0 V) V4 T) E6 K .name = "user_led1",8 c2 ]6 S+ ?& u( |4 u% S
.default_trigger = "default-on",0 \/ y- q8 i6 ~8 D
},% @4 T0 t: y* G
{1 e G. C: t( t, b$ f% v! p
.active_low = 0,
) ^# Z+ K. D2 x: y! B" Q% p .gpio = DA850_USER_LED2,0 U3 g$ X r0 Y4 v3 J4 Q
.name = "user_led2",
" Z" i* I. k8 ?# n4 w Y2 R .default_trigger = "default-on",2 G7 e7 T K4 {/ m \
},
- c. x7 N( U5 F {
, E$ e0 }, r" p .active_low = 0,# K5 t( c' X; x1 d
.gpio = DA850_USER_LED3,# D8 t5 b" c) l6 z$ ?) F+ s N) Y
.name = "user_led3",
B! h7 G$ \2 k" ^/ u .default_trigger = "default-on"," I7 O9 e+ r* P. x K V" c
}, a o5 y! n& S8 F" H, S* ?
};$ r4 {0 u! }: b
7 H& z" y& O7 I7 ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" X3 H2 m% t/ e" U) H' z+ P .leds = da850_evm_tl_leds,# N z: z9 t9 o W$ _( W6 m, o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- ^& L9 M$ k9 p3 R7 H1 o
};
2 V D+ k1 W* T5 l/ Y6 a
* q- `4 R% f2 t3 Ostatic void led_dev_release(struct device *dev)
( g& R1 H2 u; g& x% P' `{
9 j4 c3 k7 i, z5 r5 l0 s' x; g};& \$ ~1 ], U( a4 e& C
/ F) O; ?# T# \& e. B& ` r, L8 p, _static struct platform_device da850_evm_tl_leds_device = {
3 Q5 W1 B; l; {- r; z .name = "leds-gpio",
) Z& I3 W+ A6 U- u# V$ I, z% c. y .id = 1,+ c$ |) B! ^$ ?! r- k7 L
.dev = {
0 J% j/ I- C8 K- Z .platform_data = &da850_evm_tl_leds_pdata,# U7 ?! S1 X$ {2 }0 X! y1 Z& y
.release = led_dev_release,4 S2 E8 b, X4 r8 d6 X6 [. H
}
% p5 ~, S( M2 ^& p: v};
6 W. Z. j; P: \/ W; Y' m
& N, q4 N. |; Z3 y! h: @' h/ C* `static int __init led_platform_init(void)5 U' h/ R1 ^% ?* }9 v0 O- V
{ V$ D+ O+ u1 F( b% x5 B0 t. b+ P
int ret;, |2 S% P0 ?% ~+ y
#if 0: g' K [+ I8 J1 o& B" b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ Q% m4 h+ A0 W" U. D+ @- O
if (ret)
1 N0 f0 D2 Z: \! W$ u# Q" v3 q! S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, A1 d( [0 f' ^5 }# k "%d\n", ret);
8 T6 i) s8 R) R7 r' Z3 @#endif
2 d4 B' V# ^; e5 ]4 h1 W; @. l ret = platform_device_register(&da850_evm_tl_leds_device);
% O3 n. |8 b! x5 z) n6 w) M/ K# D if (ret)
0 T) [) r* O7 v$ C0 o* R: I pr_warning("Could not register som GPIO expander LEDS");+ O# A: `1 ^, w! t3 V
else0 h* w9 v8 o0 g) @
printk(KERN_INFO "LED register sucessful!\n");
( y( W* c8 p! z, z- _. U! t/ i) b# L* |* p7 K, e( u0 n5 m# A, {2 c
return ret;9 K9 {) Q1 ? X5 [$ A
}1 r' L& x8 O1 h( } w+ u" u
3 N! ?' A5 Y1 v5 v
static void __exit led_platform_exit(void)
( w* e! c `$ }$ D% c5 ~. z{$ ^0 T. Q. i, I" v& j+ a9 B
platform_device_unregister(&da850_evm_tl_leds_device);1 E4 X1 t( |4 @
# V. P8 I& M6 {; ]0 @- |( C
printk(KERN_INFO "LED unregister!\n");) ?8 m- K5 y' \- |8 F* t0 s' K" D
}
+ s' C4 [/ d" h1 `* Q% `2 G
. B, K7 I. J! |0 Y) nmodule_init(led_platform_init);
8 R) v d$ ?5 M0 B1 g# J2 z' Umodule_exit(led_platform_exit); T% ]! P- ~, F% i& G5 Q5 t
$ z7 u' m# x- m% D8 ]! V) r
MODULE_DESCRIPTION("Led platform driver");
# b* ]; u: }+ Y0 GMODULE_AUTHOR("Tronlong");
1 ~9 j! G0 M8 o% H+ JMODULE_LICENSE("GPL");
. O% q0 V) _, A: h% n/ c/ @9 o$ r* y: N- \% q6 T8 O
|
|