|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' _$ @2 ^' P' n5 S5 X1 S
#include <linux/init.h>7 J! P" y4 l7 A
#include <linux/module.h>4 [3 h6 P+ Z' p' d% K. W
#include <linux/kernel.h>0 _8 ]: e! ]1 X; b6 [0 l2 n
#include <linux/types.h>
8 P w( \5 y& O5 r! l! P, U#include <linux/gpio.h>
% d' v0 S+ ~+ k8 F#include <linux/leds.h>" b2 w) N2 U6 l) L7 G: f
#include <linux/platform_device.h>
3 i/ A$ t, L- q# y( F- ]: j$ y! h7 `% V; c9 v4 | I0 m0 n* I
#include <asm/mach-types.h>
/ o+ P' K& N! ?- q#include <asm/mach/arch.h>
+ G8 ^1 g5 n* @7 Z' h#include <mach/da8xx.h>! {7 S9 U; ~% L9 K! ?6 E8 T9 Y
#include <mach/mux.h>8 o/ |4 l' J7 }# `8 z: @1 `3 c4 R& ~
/ H$ I- l0 r/ l% G5 L* S; w' p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 W3 t) B9 ~& Z/ c# ^2 B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) ^: }- Q- j& a: _! Q( P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 a" s! B( }( f! ]7 ?% p) W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 t; E" L2 g$ o& B3 m4 t0 g
- |1 \- D/ R% N9 v" V
/* assign the tl som board LED-GPIOs*/9 W \2 s/ ?1 x9 I0 b' I# @/ E _
static const short da850_evm_tl_user_led_pins[] = {- v A! P: F* p9 B
/* These pins are definition at <mach/mux.h> file */) M* z4 x: m/ ~- B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) P. q: E! H, @& W R1 I) W d
-1
& V& k/ A! J% Y};
_' [: {2 ~/ `% h: p0 E$ k% O1 w; ~7 U
static struct gpio_led da850_evm_tl_leds[] = {
' H# R* |. X! z {
# z _# H- l: Z .active_low = 0,
; H9 B) Q$ _2 g* |3 c' L .gpio = DA850_USER_LED0,
/ j; d2 |, a$ V1 h .name = "user_led0"," K: D$ a& d5 [. S! I6 Y
.default_trigger = "default-on",- @( D h' m! e6 i
},
W8 H& M1 J1 f {
6 m$ A2 d" y9 g .active_low = 0,0 H+ r8 r$ x4 T% o4 {
.gpio = DA850_USER_LED1,8 ]3 ~% [! }3 |) @: M
.name = "user_led1",
7 m" l; u4 ]9 i+ T' J0 t .default_trigger = "default-on",
& K6 L) J" w4 v) |. j: _) Q },
" J6 Q) Y3 N$ j6 M& F& H" {8 S {, G! {9 I N7 c; h* D) V7 O
.active_low = 0,% J. v, |3 W( r) c2 G% v( H( }
.gpio = DA850_USER_LED2,) ^" Q2 t8 {6 r/ D9 q
.name = "user_led2",0 M! Y7 x9 x' j' H
.default_trigger = "default-on",. i9 a4 I- G# v5 }: r M' J
},
& W4 E" X4 V/ @5 b0 n {
/ u0 G' M- T E3 H. G. ? .active_low = 0,
$ a$ n! F1 L$ \3 ^ .gpio = DA850_USER_LED3,: x* ~4 `5 F, V" {* b3 L8 v) |
.name = "user_led3",, p7 {/ X# v7 S/ h: s& x
.default_trigger = "default-on",: b9 X% O" \/ I# m
},
6 b! Z+ T' ~( n& b. t* v1 x0 ?% [, O};
; L3 j& Y: S: W& T/ q! l2 N: q1 l$ w3 Y$ T& l" ]7 F" V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" F1 A( G& _0 d- z, f& E .leds = da850_evm_tl_leds,
9 \- H1 L/ q) ^" _% P J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 e: d) O8 C- H" ?, B; V$ K};
2 @- A+ l7 t+ L' f y
H: B& ]5 i7 m @5 d' c, nstatic void led_dev_release(struct device *dev)+ o" a3 B# @" |& g" x& z
{& Z+ A3 M& C t/ C% M
};
' z1 ]+ B3 P b. l. N4 _* |
9 d8 E8 h1 L1 |3 m, F1 wstatic struct platform_device da850_evm_tl_leds_device = {* l/ t' R( \# t: z" y
.name = "leds-gpio",
7 G8 W6 ^+ [# _/ B! y5 X( f# K" a .id = 1,' M+ a7 d) t& _: X) B+ P
.dev = {0 P# \1 U L, L) h
.platform_data = &da850_evm_tl_leds_pdata,
. \$ A. B8 ^3 N! C2 p .release = led_dev_release,$ C; u9 {/ z9 u4 I7 @5 q( c
}0 Y; O7 f% G* L) f
};
6 H( O# q" y8 p" E8 M6 }/ E. F5 L0 p* v' Q7 x9 h
static int __init led_platform_init(void)5 Z6 a% s2 J, c* k) R
{$ t9 X) {# r: G% a6 r- U9 P
int ret;
$ z/ f! n* o' s/ T' M0 U& [6 I#if 0
2 C9 z6 m, G: c& G; J8 T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. y- z* _ `7 \/ J
if (ret)1 \4 @$ _) P, a+ ~ F$ j( X! v
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& S( r- u: [" Y4 Z. [6 j* d
"%d\n", ret);
- |$ u# D, X% G" s+ L9 B#endif
. c8 K; v5 z( W ret = platform_device_register(&da850_evm_tl_leds_device);
$ J; C: v& _5 d3 \9 [' @ if (ret)
- i# M& O, u4 q+ z2 H* b pr_warning("Could not register som GPIO expander LEDS");
5 s$ ~# P3 _# D) @1 h& \ else4 N' x2 @ ~& f- [5 ]
printk(KERN_INFO "LED register sucessful!\n");% J4 I2 Y: A7 s# s
- b2 X( ?0 N2 v( c" T5 h return ret;% U: i2 g$ H4 s7 w8 d& j7 J
}' A2 E, o# v% s3 G% j& M/ S
" n% ?! ]' e4 e* mstatic void __exit led_platform_exit(void)
. C7 L! n9 N$ i9 c4 ~{
( S6 G; q7 v) ] platform_device_unregister(&da850_evm_tl_leds_device);
8 |* v4 W* V: b- H: Z j
A. T, _' H9 S7 C Q printk(KERN_INFO "LED unregister!\n");2 }& j* R5 c# \% ?
}
1 H, C# Z' m* E* q+ P4 A
, C3 C/ i' U( f7 `! Hmodule_init(led_platform_init);
* \( x- A/ m! q' [' c6 B# p, R' @module_exit(led_platform_exit);7 \& p1 q: F9 B: K* Q% Q
0 e! x6 {$ c) `5 b1 ]5 t# a ^MODULE_DESCRIPTION("Led platform driver");9 r9 L4 Z% `1 B! d" H
MODULE_AUTHOR("Tronlong");
; O; @+ t w8 c' N- o6 SMODULE_LICENSE("GPL");. L2 U3 b& ~3 v$ n, ]) R' _
- v+ ~% g$ S o% @ |
|