|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ H& H& X9 k* }) b9 R#include <linux/init.h>
6 y( |/ W, r8 l, I- [#include <linux/module.h>
: O( D9 }/ ` F5 V; |0 M. ]#include <linux/kernel.h>
. ] p: k3 V2 d1 X! l& K#include <linux/types.h>
. {5 D, q ^, ^6 n$ K1 z+ M4 p#include <linux/gpio.h>5 w- l* J& l1 N: Z
#include <linux/leds.h>
# E0 a, \5 m. h6 s" I0 b% g#include <linux/platform_device.h>
& S9 Z( G$ m1 e
) V* q6 R( y6 V$ l#include <asm/mach-types.h>- _. b9 V0 x H) K& }
#include <asm/mach/arch.h>) J, h! G6 S" b! a; o
#include <mach/da8xx.h>5 g5 x5 b# w6 T5 K" q9 A) o1 P
#include <mach/mux.h> `2 V1 T0 |' z4 K2 o* w9 g4 w
' e4 o( U2 o" T/ `/ m
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); f6 y7 ~! o0 ?( Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' r5 X! B Y) i, a2 W* x+ ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 t" w7 G6 H) n7 D/ n; E#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) G( }4 i8 u8 l5 J2 ?% ?& y
- E# E6 L3 B4 ~+ @/* assign the tl som board LED-GPIOs*/- T) S4 a' U$ S) `- Q/ D
static const short da850_evm_tl_user_led_pins[] = { A( z) }- K1 [* l3 j$ `9 ^6 G
/* These pins are definition at <mach/mux.h> file */1 u; L s$ m1 W5 J8 z8 {7 S$ f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
p5 F' P9 z- l+ z; t -1# b+ R r+ X9 ?4 R
};
9 K, V6 ~- ^) f5 S- f: \9 I
. a1 l5 R) k$ S/ U0 Wstatic struct gpio_led da850_evm_tl_leds[] = {' J4 G6 k! u% h( E; T) k& h1 M
{
) k4 {, i/ u( G8 L, R .active_low = 0,% ^9 r) M7 C4 S4 ~
.gpio = DA850_USER_LED0,
6 V+ x- r$ t3 T .name = "user_led0",
$ v; E' ~* k# `/ } .default_trigger = "default-on",
1 L0 o& q, k+ P( N, p: q' y+ z1 J },8 e& {4 Q( c( w d
{
" k4 }7 V6 A, D; p7 b .active_low = 0,
t- ?$ [. E& c; Q% n .gpio = DA850_USER_LED1,6 L- _1 Z% C* d0 K9 E
.name = "user_led1",
9 [' C v$ G% c& g" }$ \ .default_trigger = "default-on",2 K" z: _& \, e* r
},8 K% U! W) L( O0 q
{
! T/ t0 f5 ~ X8 ]5 N. ]- y .active_low = 0,
* H, u% ^( w$ @+ [% R .gpio = DA850_USER_LED2,# z- Q2 d5 v+ Z2 L M
.name = "user_led2",
) X, H2 Z. G, ?1 O- r4 d2 E/ ^ .default_trigger = "default-on"," [ G' k" H- q1 G8 _* {
},% `# R1 P3 V! j" k
{
% M+ E8 Z- J7 f3 F1 M .active_low = 0,7 @; S( F3 c4 F+ F8 u8 k
.gpio = DA850_USER_LED3,
8 \2 c$ q6 R. @8 O1 I! f8 W8 O# D" f( Z .name = "user_led3",
% ?4 t P, R+ s0 g/ K .default_trigger = "default-on",' \- F1 Q! s- c$ w3 Q F; h
},0 }3 m$ \% p0 a& \. C
};/ n1 o! b# I9 c7 i9 m+ j' k2 E
* S3 z: G5 c. u. v; p# Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. R" S$ c1 J% R+ E# i9 ~- l
.leds = da850_evm_tl_leds,
8 T! p" I: S0 |3 [+ O" B6 ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds), V( M; s' K! e+ z
};
5 s8 @& y) O+ {) A8 g9 n2 E# r G4 j! [
static void led_dev_release(struct device *dev)3 C& [( b! N4 ]+ z/ D, r
{
4 D5 l0 A, v7 B; u, M3 b};
- M; @0 F. j) z
* q9 E" q0 b/ D/ u3 R8 W% i3 rstatic struct platform_device da850_evm_tl_leds_device = {
3 g1 |3 | h* W1 |5 Y .name = "leds-gpio",
3 `* K" U# i5 h6 V2 l" @ .id = 1,
2 f. Q7 Z) r k: O .dev = {
C- ]: D; @0 M4 A& V1 r .platform_data = &da850_evm_tl_leds_pdata,
?, j% f! a2 D/ m$ G, e# a .release = led_dev_release,* A( w Z% Z2 N+ r$ _
}
7 I$ A) d: |: y5 V9 Z9 Y/ }. H};8 P" z- j, n( O* s6 u8 J y
5 E. T- S9 v# i/ d! S" y) p
static int __init led_platform_init(void) }, L* E6 Q1 p: Q1 t$ s
{
E. t7 D6 S+ W int ret;: o) P4 ?, u5 M8 m! }& W' w) K8 Z) Y
#if 0
& V" J( n3 q# l' H! m" K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! p4 H& S V: c8 \, y$ z if (ret)
# I' Z: Y$ U6 U5 V6 ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* R$ ~7 h* v; M1 C" F+ g "%d\n", ret);4 t8 \, J5 s; |) {! A, r' j8 o3 n9 \" ?
#endif
% I8 @8 j4 W0 s3 o ret = platform_device_register(&da850_evm_tl_leds_device);
. e* o% v# E# c4 D if (ret)1 r9 h) n; H$ ]+ V
pr_warning("Could not register som GPIO expander LEDS");
+ j) Q, o- _% m) ?6 y( _ else+ E% ^+ j3 S) e+ r% ^ w3 @
printk(KERN_INFO "LED register sucessful!\n");3 H5 I; h0 s& F* y/ C
5 V, S; D; p+ c/ E) m return ret;8 C$ b2 k' o8 G- o
}
+ w* S/ g8 b, I7 E' w
# A/ n( f$ r S6 [7 Hstatic void __exit led_platform_exit(void)
3 |: a6 i' @# U- Z{" S7 }$ G' M, W. d; e0 V8 |
platform_device_unregister(&da850_evm_tl_leds_device);: k' D( r8 F# ~1 A
& S6 N9 `- \. k( Y, h printk(KERN_INFO "LED unregister!\n");
; `4 G4 z5 `' e u}
. ?$ P- b5 R7 I9 I2 y) S/ s O4 G; u! {$ d5 P. o- B
module_init(led_platform_init);
, t0 Z; g5 t6 u' A% ~module_exit(led_platform_exit);: r, p& l% |" O& q2 F8 ]
A/ W- A) {. O# r4 v# M, L' J
MODULE_DESCRIPTION("Led platform driver");
% M1 _% s; l1 W' m2 j' D: k4 E! Q2 BMODULE_AUTHOR("Tronlong");
* n5 R( @+ A" iMODULE_LICENSE("GPL");, A, T _+ A+ h1 G* s
1 t/ B5 u O* l* {/ f
|
|