|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 Q) i- |' B) y/ L9 t$ {+ q# O#include <linux/init.h>
; Y7 X, X) w1 b+ E1 W#include <linux/module.h>
& i; J* b/ U: a, ?#include <linux/kernel.h>% R0 a8 i1 e/ d7 p, U5 |3 s
#include <linux/types.h>
. C+ t1 Y) i" L) K( e( F8 ^* D#include <linux/gpio.h>
$ c8 x4 m9 h: F" \' ?0 C$ r7 C#include <linux/leds.h>
' _; ]9 S$ {( T#include <linux/platform_device.h>
: ?8 H' @4 S* N8 V
3 |3 s) Y# p; E; o#include <asm/mach-types.h>2 t1 X4 ]/ W2 |7 B1 Q9 R1 s
#include <asm/mach/arch.h>
9 B [7 C6 B5 D# P! R% g#include <mach/da8xx.h>- _. \8 j+ S1 s7 ~6 z
#include <mach/mux.h>
, K, R* r R! K& \- E$ K3 f" w9 {
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( U6 |, c5 x8 [. Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- f, z/ N; ?& c' X7 c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ G$ E& @. F5 n# Y) ]7 o" C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 O% Z3 E/ i( W2 }$ _& J5 g) V) u: D4 _3 g Z' \' I
/* assign the tl som board LED-GPIOs*/
$ N/ e; L7 W. C: _7 |static const short da850_evm_tl_user_led_pins[] = {5 {0 C& @$ E) @8 h" H; ~9 ^2 b
/* These pins are definition at <mach/mux.h> file */% j" { l/ m# x; @: E/ y( m5 K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 L$ p9 h- H4 f) G: Q1 ] -1
% b6 r, w+ j9 n( j: U/ ]};' L" T- `) x8 m6 [
G3 Z% K3 T6 x/ ^3 ~9 y
static struct gpio_led da850_evm_tl_leds[] = { B+ J% k! _" j6 G5 E# C
{
0 A' K8 X; m$ p6 Q1 }. ~+ U! P% i .active_low = 0,
- `' u+ f) R6 p4 p& \* J `% e .gpio = DA850_USER_LED0,
6 H" [: O1 ] Y: C; E .name = "user_led0",
. D) Q4 m3 v3 F/ o, X3 [. l .default_trigger = "default-on",% m1 p6 z/ J2 Q; K7 c5 w
},
h0 w3 O+ W: g: J$ O# n {
* S K& K c5 d% E0 Y( M .active_low = 0, m4 x3 G3 y. K
.gpio = DA850_USER_LED1,5 f1 M9 Q6 f, r5 {0 L4 B9 A9 o ^/ w
.name = "user_led1",
6 r5 B1 w; f0 s: m. }7 }) E1 | .default_trigger = "default-on",
9 I* x M0 h% @; _& i" r" E },
3 Q4 k5 c. y0 w' o9 y {7 J0 U3 N* ^1 Y$ s6 U' b% P1 ~
.active_low = 0,
+ W& [3 V9 w; X. A) y6 c .gpio = DA850_USER_LED2,
G9 V3 O1 j2 E$ M1 Q/ J .name = "user_led2",
: a3 g" `% i( |* x( r .default_trigger = "default-on",3 t7 e7 a: ]$ h1 B
},; O; D( A0 A p3 [8 N$ V
{+ h7 V; e+ u& B' r5 {3 | W6 V+ E
.active_low = 0,
3 d% }6 H! W6 B- E c* @/ m1 p, `: ~ .gpio = DA850_USER_LED3,7 H8 z8 ?) M* a$ H7 W
.name = "user_led3",# K2 K6 ?& w; s! F
.default_trigger = "default-on",
8 y( k. G' U* `$ R/ h+ k% X2 k },4 @% s' X# H3 T8 R& S/ @0 }
};
' q- o' s: @7 d i& f, p% s- }; y$ d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 I$ u L2 v: C' | .leds = da850_evm_tl_leds, V8 d6 h3 `; n2 Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# l0 I" _+ Q0 @7 t+ o};
% D% A4 ?( H6 N. Z: M8 o
* a- l; A2 e: V( y3 @static void led_dev_release(struct device *dev)
- Z* Q" I$ f1 P, w- s{
6 G$ W$ c/ ^" \. M& { t9 `};
) U/ \# ^- X( H* @! x) d/ i' c5 X. ?5 {' A
static struct platform_device da850_evm_tl_leds_device = {# v7 w' }2 e4 Q: D0 E
.name = "leds-gpio",
6 `3 W2 ^' C' E7 u( D% B .id = 1,( K# @! X* S4 R- J& [7 h( J
.dev = {
" K% y7 I& {' p: l .platform_data = &da850_evm_tl_leds_pdata,
5 O, N. d3 ^; q- X+ B .release = led_dev_release,
. K- k7 t, x. \; g }
; c! G2 J; R% A};' C0 Y. ]; N$ E" W& w
9 Z ^0 ^" f$ b3 [7 R- w
static int __init led_platform_init(void)
8 s9 w, n& m; t% C1 l{& n+ x+ r* W! d
int ret;
+ ^; D2 }' ]! }" ?#if 0
2 b, K$ A( E$ \) r9 \4 d8 l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: D3 N! C2 y2 X if (ret)
; b5 G" ]6 \; z& B. Q3 k$ Q r; J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 E! E8 p' K. f) ?9 m$ E "%d\n", ret); `) l9 M5 h6 _" N+ j0 d1 Z8 _3 |1 R
#endif
' H6 g9 M8 ^# j, I ret = platform_device_register(&da850_evm_tl_leds_device);+ e/ ]* a+ F; `7 w1 F. [
if (ret)6 X4 ~; o8 {& G% J+ w
pr_warning("Could not register som GPIO expander LEDS");
) [8 E5 {& ]1 Y# R else
3 d& b7 ?0 w" e6 `9 ^* o printk(KERN_INFO "LED register sucessful!\n");9 [8 Y; k6 W- E5 G. J; N, ^. |
; f/ q6 H! w% y$ T9 a return ret;
' j' P# E0 L# m* E7 j" R}
# E, h5 @' Q* ^# w9 S- B" S
9 O6 E# w$ Z/ f' l+ e! z/ f/ i! bstatic void __exit led_platform_exit(void)
. K' [; _! B; ^6 t{
! W+ m: V$ Z8 V9 K8 V7 z platform_device_unregister(&da850_evm_tl_leds_device);
. U# B- L1 o0 T7 y0 q- f6 z5 E3 K( F# N: f& ^- U! |. p
printk(KERN_INFO "LED unregister!\n");5 A5 {; ?" L7 e8 a
}
5 \- ?* d3 ~7 }9 m9 t* z: @( i8 }2 p
module_init(led_platform_init);
: l: J& J7 K7 J1 u5 Y8 gmodule_exit(led_platform_exit);4 Q; W n4 s D% \5 k
( a4 y+ U# Z- X
MODULE_DESCRIPTION("Led platform driver");
/ u# t/ [" ^+ j. l. g6 HMODULE_AUTHOR("Tronlong");7 `' K: @4 V& I
MODULE_LICENSE("GPL");
+ T/ ?. O% q& N) N# O
! J8 b3 ]& G0 Z! P |
|