|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# i6 ~0 K2 Z9 x' U' J#include <linux/init.h>; I; B9 C" p# i! C( I8 l4 Y( ?
#include <linux/module.h>
+ |' W& a- J. ]#include <linux/kernel.h>4 C( E- {& ~/ X+ N1 P. l- L
#include <linux/types.h>2 E8 A0 r; @, G2 `: E* @, k
#include <linux/gpio.h>
* n& }% G' E' y W6 \5 o! |#include <linux/leds.h>
3 A1 a. C$ {; v" h2 |* P3 [. V#include <linux/platform_device.h>' I: G. @$ F( O3 P
8 Q0 B/ g9 x$ i0 ^#include <asm/mach-types.h>
8 ^3 A- e1 Y8 [; a0 P9 I2 _0 K; Z2 K/ \#include <asm/mach/arch.h>1 m/ l9 S4 l! u3 v8 |
#include <mach/da8xx.h>) `( [+ m; E4 K4 U
#include <mach/mux.h>1 f: z# C z. d- q9 Y c0 `5 [
. ~) o" Z- o: l! U# N0 K* \: k9 d$ F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: Q2 t$ J9 v7 L9 V) x6 m2 ^. D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* R1 K ~7 Y7 X$ x$ I5 N1 g; j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 ?1 [$ p! Y" @% P& O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 @* ^9 |: B- d8 v& a' @0 v+ j
* Z$ P0 \! h+ F% t) A& X! n
/* assign the tl som board LED-GPIOs*/
& T3 ^+ z( j4 K' M9 L Y: E& wstatic const short da850_evm_tl_user_led_pins[] = {
8 o( o2 x3 A; e; V+ Y /* These pins are definition at <mach/mux.h> file */
" Z6 L/ ?. d% a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," J1 [6 m, G; b7 L6 P) j7 O! H
-1* z; D+ ]) J, i6 o
};
4 h0 `. H7 I; P) F
/ Y, n$ y8 u2 n5 V7 l0 Lstatic struct gpio_led da850_evm_tl_leds[] = {
5 F; B( b! B z2 Q# _% v {6 w9 ]1 B' u5 n3 ?$ f
.active_low = 0,
% _8 k8 x7 s1 h% y- f' I: A/ x) f, j .gpio = DA850_USER_LED0,+ k3 I+ D; m: K$ P5 \, i
.name = "user_led0",' w. H. l( [3 b# O, G9 d' Z
.default_trigger = "default-on",
m& d; I8 j6 ]3 o- m/ d: v$ \8 o },
. D; J) r9 v: H6 J1 m {5 O. U3 I) p$ v! O& o2 H! a$ |
.active_low = 0,& Z- s) h! h& n6 k: {: c3 S5 a
.gpio = DA850_USER_LED1,4 Y: ]9 y5 D- Z, C- A
.name = "user_led1",; y$ q6 O% X8 P. @6 B z* s D: |
.default_trigger = "default-on",
R. S$ a/ ~$ d! s R9 c) i Q },/ e" _ t6 X! s: d T6 W
{7 w( G2 v6 E; T
.active_low = 0,
" o% S! c" i0 j; b .gpio = DA850_USER_LED2,
6 ]" q# K/ [4 {2 c7 w .name = "user_led2",# y' \* k9 c# N. d# q9 m
.default_trigger = "default-on",! P* D4 A1 ^3 X4 O; J1 Z8 U
},0 S/ t# O+ ^$ i& \
{
9 B( ~" y% z2 c% a( f3 p5 L# ?8 ? .active_low = 0,
( H' a* i; c, o# E1 N8 p .gpio = DA850_USER_LED3,4 d# l* W# H$ H% m
.name = "user_led3",3 ^; X2 l+ I, M0 i. V
.default_trigger = "default-on",: M; i; q4 a5 s0 g" W2 G( a9 T4 c
},
( M4 } u! @( Y6 ]- t7 R9 s};
( m8 t# f: R7 Y. u! X3 `& o# f5 z1 G( s8 Z+ h' ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 B* H# d; o. y) F# F .leds = da850_evm_tl_leds,% G+ @ ~4 U3 t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 Z) A- c; N ~+ ^$ u8 b5 w};
2 x! U3 \. C* }0 m2 ]
# I( o" o7 f- G a4 t: g/ w% n" Estatic void led_dev_release(struct device *dev). |, W$ a) z |; ^8 h+ ~! `
{, l/ e( p/ F. |' @! N- j
};1 }: b: h9 b& [8 U' ~) b4 q: ]
G- t. v+ S* @4 l6 ^
static struct platform_device da850_evm_tl_leds_device = {. m* w9 ?( Q8 k; `0 @5 y; T
.name = "leds-gpio",
9 P9 N1 B9 V8 X .id = 1,0 O+ ]5 S: n9 @& `9 A4 L1 j
.dev = {
+ S2 C. w0 w% m# I6 h' u1 u1 A .platform_data = &da850_evm_tl_leds_pdata,+ Q# R: T+ ~. R6 P' a' L
.release = led_dev_release,9 S; P2 i" X/ u
}8 u# k, \) K( ?
};* C; z" Z1 l1 b
" D8 h+ I" ^: a
static int __init led_platform_init(void)) V4 x9 P- N, S6 n) Z- Y; ^
{
# W* x% m8 |0 j3 z9 W int ret;
/ ]4 D8 t4 ?3 R- I#if 0
9 k5 \& x) G( u7 R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 q3 P$ e% v- F$ G, V. e6 G
if (ret)
2 t+ w1 ^+ F$ Z+ i7 B pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; J) {" V( v& H2 G8 x "%d\n", ret);
9 k5 U8 Q* g" M' R9 t/ }#endif2 r4 ]+ b; y. j
ret = platform_device_register(&da850_evm_tl_leds_device);
0 J9 i! {2 u% N) f if (ret)
9 T9 w# o: g s pr_warning("Could not register som GPIO expander LEDS");
7 D1 Z$ Y' a2 h' l) ]. v) Q; l else
, T. L1 Y5 k7 |* |# e# A V' u printk(KERN_INFO "LED register sucessful!\n");
/ ~: O- R0 \3 y6 {0 b+ S$ {6 F4 S; S N N( C8 Y6 e+ m
return ret;( G2 V. A2 }& q
}% q/ ]$ \* m2 Q# g$ w6 P
( [# x1 d1 M( R& Y3 astatic void __exit led_platform_exit(void). y% `" v7 b# a9 [4 C
{7 D. K/ r( V u6 x! n4 v
platform_device_unregister(&da850_evm_tl_leds_device);2 N! \. V [4 U: Y+ C0 E0 {
, W, o: w$ N8 l4 Z* S/ ~, x; ?
printk(KERN_INFO "LED unregister!\n");: f0 v: k: }# R% A1 G
}5 d! J1 ]+ P7 [# x
; \5 x* E" R) T: i$ y
module_init(led_platform_init);
* A8 J8 Z- e' L2 Dmodule_exit(led_platform_exit);
, j2 u( F( o& ^3 W
% f2 Z8 g0 l6 h5 OMODULE_DESCRIPTION("Led platform driver");
+ L7 p3 C4 k7 t( J nMODULE_AUTHOR("Tronlong");
2 z+ M0 g( ? X8 @9 ]0 pMODULE_LICENSE("GPL");
( B" y$ ]* N- h0 [* ?4 X" ~/ D6 Y; k$ z0 e# F
|
|