|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ N9 |0 {- M6 A: |: r; D; N
#include <linux/init.h>
4 L( L& f. ]" }2 _1 A. b#include <linux/module.h>
. M9 s3 ?5 t y6 P+ h#include <linux/kernel.h>
% w9 K# i: o0 p3 ~3 G% i#include <linux/types.h>
: b2 a% D. C" }% M3 p/ U5 U& y$ ^#include <linux/gpio.h>% o1 b; `, ]) s( n/ U* t
#include <linux/leds.h>
6 B" p7 Y; n1 {#include <linux/platform_device.h>
% v0 A5 n/ x& P3 j2 I' J, v ^
# i1 L$ q& r7 ~" @9 B* P& L8 k#include <asm/mach-types.h>: E2 `. X- O8 m# l' P3 p( ~* ]6 U
#include <asm/mach/arch.h>" L, d. _# M+ }
#include <mach/da8xx.h>
6 Y- j+ _' h! ?# r#include <mach/mux.h>/ [( g1 ]5 P4 n: V* G t7 q
P9 O3 _8 R8 o: q# M3 L) y5 T* K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 y6 n) S8 O7 X4 U# ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 ]4 Y x# m, Y% K2 u) J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 X4 c$ J/ V! |) k6 {2 j+ F* n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" T {/ p3 o- D# g" B) V7 ~( q' Y: S4 C0 j9 P5 m7 Q
/* assign the tl som board LED-GPIOs*/
% n5 ^, c# ]+ ^; Pstatic const short da850_evm_tl_user_led_pins[] = {
4 {, R. Q7 `1 c5 J" q' d5 i /* These pins are definition at <mach/mux.h> file */
/ ?" G; R4 `4 d0 |8 o4 G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 u+ W3 u1 l, k1 z
-1
0 d: Y* W }+ P! G! Z2 x};
0 y4 J) W: s D" T9 Q2 N! k6 ~/ k, B7 C6 p) V5 w
static struct gpio_led da850_evm_tl_leds[] = {" n7 }- F" a$ M7 |
{/ ?7 J% v2 Q) S. S
.active_low = 0,6 Q7 |% d5 o% f# {' t# f' r" [
.gpio = DA850_USER_LED0,
; @' i: v5 n, ^ .name = "user_led0",
2 f/ L; N8 x1 y, @0 {! { .default_trigger = "default-on",
9 E5 M' x( _( k( w, i& Q' n },
+ T* m4 \7 C7 ^% m" h: A {* t, n9 R, j/ r p
.active_low = 0,6 J- S" G8 [: }3 _" I
.gpio = DA850_USER_LED1,$ m7 b) Z1 v& _6 @3 d& `/ g. h* C2 ~
.name = "user_led1",
' O0 Q3 h5 o" Q- K) ]0 z) A! } .default_trigger = "default-on",
! M4 m2 L7 b, {4 s- i6 m4 A },- o$ Y" Y6 C' l$ {% M% u
{
; K' L+ n' C5 }2 i- y .active_low = 0,+ a; k& k5 W( e3 G, Z( V
.gpio = DA850_USER_LED2,
, ]" w" c8 ~; L5 F: ~5 T6 I .name = "user_led2",- Y/ _5 X @! T0 F
.default_trigger = "default-on",
6 V9 g0 x( u, z, x Z8 B },
3 h9 k+ E0 \9 n+ L! p {
d: w8 u% V) M7 W( s- \, @, p# @ .active_low = 0,' }% G+ N3 x) I' ]
.gpio = DA850_USER_LED3,( `" A! K' M% I1 X" z0 ]% m
.name = "user_led3", f) c% Q3 |" E4 }0 c9 V% l( e
.default_trigger = "default-on",
9 [& W6 V2 t7 s' G },
9 @; z9 e1 I6 f$ Q( ]: V) l};
! _. q& e2 r, w& A- V8 x6 w/ ]9 ?* |! O5 ^3 i- x+ N- E7 Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& F- Q& V2 u. f( R8 g9 ^* t+ A' g
.leds = da850_evm_tl_leds,$ c+ v% Y3 T# [1 Q3 l. }
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& n! R6 e' ~; W
};4 q1 t- |" f; V- X$ k9 v1 o& Y
6 G+ s& o9 f6 Z* y; F: [
static void led_dev_release(struct device *dev)
& o$ d* g- m4 B( [{/ O' D+ Q( [0 P( L% J
};& t" f- m6 ~' l) V! E5 d0 @% o! _" C
2 R6 G, ~7 {2 r- i
static struct platform_device da850_evm_tl_leds_device = {* u% u/ |# I2 @0 t+ k2 ]" Q
.name = "leds-gpio",
' Q- V4 O1 `1 u0 c .id = 1,
7 W% Q* ^; s: R( r .dev = {3 T% S* o# r; T& ]! e3 W# s
.platform_data = &da850_evm_tl_leds_pdata,
) V5 Z( O% z, h- v% ~& P .release = led_dev_release,0 P% e6 T3 b/ s6 @
}3 z7 U& h3 w# c H" d7 Q+ v) a
};' p) S) q$ v* l& x
( ]% g/ j+ K$ j$ [) c
static int __init led_platform_init(void)1 U" @. c- R4 o4 c; h7 i! p
{% S* [( Z* n9 W1 h. D! C
int ret;
* I' m# ?; R: _. V) I#if 0
' A( R5 C+ n' q' }) ^4 O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* M$ ^& w6 F' P* j5 ?
if (ret)
9 B# x" x/ ?) P4 e6 G* R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& s5 L3 L6 C% b2 E" ~9 z "%d\n", ret);# C4 j# c u, J0 f
#endif
- s; w; v( Y! `7 w ret = platform_device_register(&da850_evm_tl_leds_device);$ C4 y3 P( G. m$ |5 J' {0 n
if (ret) O( V& G% @8 ~ K, H3 a0 d* M
pr_warning("Could not register som GPIO expander LEDS");: \1 k' z( P/ G. U* O7 u9 a# n i X
else
! [7 {! Z+ a* n' R/ F% G printk(KERN_INFO "LED register sucessful!\n");0 R& M, k5 Q s$ [
& F: j# }& s, O( ?
return ret;
& G1 j2 s7 G9 E c}
4 L$ N8 k5 I. ?9 [
1 T. a' ?" K. Ostatic void __exit led_platform_exit(void)
) j6 O1 P: s2 u6 z{6 b: H' [" Z) M
platform_device_unregister(&da850_evm_tl_leds_device);
- x( U4 `0 Q, G0 a% b9 T* j w ~, h0 X( g& o d$ C
printk(KERN_INFO "LED unregister!\n");4 j d$ \ P# y. Z8 w
}0 T1 T& ~8 `0 ?4 @: S
" D3 L8 K, I0 q9 v8 C
module_init(led_platform_init);
# o1 U# X! H C5 Gmodule_exit(led_platform_exit);
- r( p( N/ K4 v+ J0 E, C* a' D, l3 Z" U" Z7 G D
MODULE_DESCRIPTION("Led platform driver");( S$ h" A7 K! Q2 y5 o
MODULE_AUTHOR("Tronlong");: ?4 O) R1 o# n3 v1 p
MODULE_LICENSE("GPL");- r% w7 t4 }0 k6 p( L5 R
1 j; X+ |, e2 P0 q! u
|
|