|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: t# u. c- ~) F' ]
#include <linux/init.h>& N" J S- F# Q* ~
#include <linux/module.h>; C$ ?( l+ l4 K/ I
#include <linux/kernel.h>
& _! ~) t+ A$ a8 N#include <linux/types.h>
8 g H9 h% J( ]4 ]/ A% d" n3 a+ @#include <linux/gpio.h>! V) D7 a& [* x5 ^* s* w0 H
#include <linux/leds.h>
5 C0 l& @7 h' Z5 A#include <linux/platform_device.h>. @/ G: o+ Y' _* _3 n
0 W T& w$ ]8 Q5 V% t
#include <asm/mach-types.h>1 ~+ k5 u6 _3 I9 L* i0 u, S
#include <asm/mach/arch.h>/ O# S3 v3 E8 a+ y2 }) ~& u
#include <mach/da8xx.h>
& p2 c: E& U t. d#include <mach/mux.h>
* |5 u2 R% T5 |7 R4 }4 U, M; S0 p I d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( ]5 I# g2 k/ S7 `/ E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* L% F% U1 Z) F
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) W' {4 n- h0 D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ C6 s' o! L9 _0 ?2 T# p2 f
# _1 l2 B9 T2 G6 X/* assign the tl som board LED-GPIOs*/
8 ?+ I: H" G/ a5 V; Rstatic const short da850_evm_tl_user_led_pins[] = {) p& w( s$ X" H T3 e
/* These pins are definition at <mach/mux.h> file */
# [# R9 o# g6 @$ x4 L4 d: l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, i4 r1 }9 B3 R
-1# S+ K" h' V* j" Q, ` a' w4 Z
};* C( `% F# q A8 v# K* ]
! x q7 I0 P5 x. I
static struct gpio_led da850_evm_tl_leds[] = {8 D- p" W$ E( A1 ^/ q! I1 D
{
' Z% M# D' `; x0 @7 ]! V, e% _ .active_low = 0,
3 ~3 w; H5 b8 a: |; V& _ .gpio = DA850_USER_LED0,
# K; t+ @1 @% i$ T .name = "user_led0",$ d; O4 E! P# ~$ ]0 C1 E |! I
.default_trigger = "default-on",9 J8 n! ~ U8 C a
},3 G- Y _4 k$ W4 U8 G7 t
{" @( T8 ~6 `% C8 x
.active_low = 0,- j1 A, N$ {4 L7 G0 }, g& p
.gpio = DA850_USER_LED1,
' R8 i. n+ Y0 `7 ]3 t .name = "user_led1",5 t' d/ M5 b1 H( g& L
.default_trigger = "default-on",/ `* j; u: y" G, I, D1 b
},
; a ]0 t5 \( \/ N {7 C' d7 t7 _( Z. V G! C, J$ t0 M
.active_low = 0,
% N- f) Q9 P$ m6 e: I& N .gpio = DA850_USER_LED2,
1 _: Y/ o5 G8 ~2 _' ?, I .name = "user_led2",$ T6 r. |8 Z# A6 S2 Q
.default_trigger = "default-on",& H( @' X0 A2 \
},
9 d" g/ a; C+ v& a+ K8 }) h {
7 e8 g- I2 }, w' A2 R6 B* q- a f .active_low = 0,* r0 ]2 H- m) f3 u6 |
.gpio = DA850_USER_LED3,! m2 b, w$ J' S% y/ |( p
.name = "user_led3",( U+ R) h) ` _4 T
.default_trigger = "default-on", Z& H- R2 x( W0 s2 ^: \7 `9 O
},
) C1 t9 b, U# s/ T, f' _, B};* D% h- }2 Z$ O- L
) ~: ]' D& l# `1 Q2 v6 X+ \! C4 Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% W0 z6 L, e, U7 K- D .leds = da850_evm_tl_leds,
+ p9 ] _3 T9 w .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," v u. H& [" B! k7 [4 Q
};: X [9 e3 A# J/ u$ p
0 V" n4 F$ [/ [6 cstatic void led_dev_release(struct device *dev)
/ i: w' q& t- b. E{; d' @6 Q; v) k6 H6 B4 u! \
};8 L+ O8 `3 T, X R5 X8 x' P6 r0 l
4 o4 I0 @/ }+ d/ g9 D4 Q* q6 x# U
static struct platform_device da850_evm_tl_leds_device = {/ S8 q$ o. _% L ]
.name = "leds-gpio",
8 C! V3 [; @5 w: z .id = 1,
; ]3 A4 Q2 V5 q3 U( Q: _! N# }8 E% t .dev = {
8 z6 z/ ^" S7 _* C4 D* F .platform_data = &da850_evm_tl_leds_pdata,7 b! y" y k! D, @) Z! ?5 W. D
.release = led_dev_release,
5 w' j, U" j; ?" ?6 y7 V$ I }9 N: x% ]/ t: ^! Q
};1 K9 c6 b5 h8 y9 G Q. q
) N. y6 ^2 d8 o0 Xstatic int __init led_platform_init(void)
" b% g& [8 [3 l9 n d) [{
! L7 J- E% X4 I, G: Y4 K n4 U int ret;) S n2 n6 U+ e; L
#if 07 o* u! Y3 s4 o' I* @* x5 }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 E) c' s! b) A% [9 F ?- D ~5 k9 a if (ret)2 y _5 o0 K: a- Y) l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, ^ G: d) L, g+ \9 Z0 F "%d\n", ret);) b& l- _! W; K3 L& b9 J3 b2 v9 \' s
#endif
' D# x* U* a" o3 p: D ret = platform_device_register(&da850_evm_tl_leds_device);, B! G8 k: k) P7 Z$ S
if (ret)
5 N5 l) j2 q E( ^ pr_warning("Could not register som GPIO expander LEDS");
& I# J3 _# n$ j' ~% `0 J/ ] else
# I; ]8 V- p4 k% e, L" W printk(KERN_INFO "LED register sucessful!\n");
3 U4 j: Q D* [
- K- p# {/ n, u; z% |- v7 A return ret;
2 G+ L' J5 m# B! k8 k' S& K}
' b% k2 Z# y' I5 g+ V
5 W# S( ^; W5 S6 Hstatic void __exit led_platform_exit(void)1 Q b9 B9 S6 O
{
% ?! U) q4 @4 [! K( N& ^6 a h platform_device_unregister(&da850_evm_tl_leds_device);
0 M7 s4 {& _7 E4 i2 ?$ U W+ I4 n( Z: O G' g. c4 ]0 [; q$ E, i- Q1 K
printk(KERN_INFO "LED unregister!\n");# I% h' |2 s" U1 e, d0 K H: [
}
& M" ^" [& T$ E3 `3 b1 Y$ P7 M6 y0 p- V7 d# A
module_init(led_platform_init);
$ ]/ h# X2 T/ R) l+ Gmodule_exit(led_platform_exit);
" C9 y/ d! C8 A
" _8 i$ Z% X+ O7 ]MODULE_DESCRIPTION("Led platform driver");* X3 U* x" j6 t/ M! |/ c0 y7 J
MODULE_AUTHOR("Tronlong");+ M3 j/ g/ g, L' O1 U5 }) B
MODULE_LICENSE("GPL");4 c) ^+ {6 L- t# L2 |( p; F% \
5 m1 {- w6 `- T! o |
|