|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 ?' V) D! @+ Z: F9 Y; c) c! n#include <linux/init.h>4 B- M# `1 S: J4 D! v
#include <linux/module.h>
$ V: m3 _" C( G, x7 N#include <linux/kernel.h>" @2 v) E7 N3 c
#include <linux/types.h>
4 J( n) g1 r/ s7 v; q$ f9 O5 j7 Z. s7 o#include <linux/gpio.h>
; R/ t( j2 \% I, e% V& u& X4 d#include <linux/leds.h>3 Q- x! V0 W: I
#include <linux/platform_device.h>" G+ `2 S3 e1 Z& ^# [
9 o! P3 ^2 P6 v5 S0 ~3 I#include <asm/mach-types.h>$ Q. b) M# Y& Q j
#include <asm/mach/arch.h>1 ?7 x5 S: h J. J2 g( B- G
#include <mach/da8xx.h>& g+ i! d9 |7 t3 O8 S
#include <mach/mux.h>
! f, a8 G* W8 x; I! R* Q
7 l a" H3 v, f4 v5 S& f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( X' U$ \% B$ {! ` s/ d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ A# t! z+ A. h( ^1 q( F4 j1 f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 C c \$ j4 m" ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 [. o6 F2 q9 V& k; X4 \, J0 e& S! k: G8 C' T$ E: c; {
/* assign the tl som board LED-GPIOs*/$ e2 e/ ~& ]5 r2 u% b, v
static const short da850_evm_tl_user_led_pins[] = {* d2 O; A) x# e5 ^
/* These pins are definition at <mach/mux.h> file */. l$ [8 m1 f, z6 }6 U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. e& A2 s1 u T -1
+ C& d7 y. s" n: A/ s7 p};6 d, F7 Y2 x9 Z0 l
4 j, h( ]. ?% h* N
static struct gpio_led da850_evm_tl_leds[] = {% ] U6 N" A" D! A
{& D6 U, E: r! J2 n
.active_low = 0,
* M6 [; d, i4 g$ H .gpio = DA850_USER_LED0,
7 c8 p- Q5 Z% ~% h, u .name = "user_led0",
0 d) X1 h2 W! J3 x .default_trigger = "default-on",
+ _; ~# b$ z! }4 V% X },' l+ {. M; ?8 }3 |
{4 ?+ b ~4 W% C5 A
.active_low = 0,; } P2 c+ n: x3 s
.gpio = DA850_USER_LED1," i+ @1 _7 ]; S W7 U. Z3 g; v* K
.name = "user_led1",, s: o- F5 D' K; ?
.default_trigger = "default-on",
R! ^9 ^* |9 \: n },! ^" ~* D) q9 S$ r1 c, ?! j4 m
{
0 Y8 `0 \5 N# U6 o .active_low = 0, P# W& f1 {+ X! n) q: B
.gpio = DA850_USER_LED2,7 J! {3 R# s [5 {) }1 z( d2 l
.name = "user_led2",: C. v: I* ?5 {1 Y
.default_trigger = "default-on",# J) L+ ?* A- W) G. F9 R# I1 L
},
5 _" J& r8 T& T& J0 E {8 d- }( c* s" p1 r; b
.active_low = 0,
; e; `& @( j3 w+ Y( [( P .gpio = DA850_USER_LED3,
# N" ` _; p7 J2 i: j* @% ?% B m I .name = "user_led3",4 S5 T; M. B0 c+ S- _" R: r1 k9 ~
.default_trigger = "default-on",* y% a, a" x I6 {: D7 m7 x1 x
},
( o3 e9 V( D" {1 F};' n. S$ b" M6 A
* s; l5 q4 c: D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" h6 }, Y7 K; ?1 m .leds = da850_evm_tl_leds,
6 X2 \; G3 [/ r1 H2 @: C" j .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ O( @* W% v6 e1 ]3 E$ Z* H2 T7 ~
};0 a8 e6 r5 N* k: T! ?* U4 h4 K: n
# p: ~+ k0 Y' D6 h2 w; m
static void led_dev_release(struct device *dev)4 Y' o3 s- t; x7 e# I
{, q3 z; R$ ^( _" [0 r, q
}; p/ y0 M8 A7 O+ V3 |" E
2 m8 D3 X( M7 ?5 t; |% |& z) sstatic struct platform_device da850_evm_tl_leds_device = {
" E: }0 z, k" c" ^3 r- z& L" | .name = "leds-gpio",# a( h: ~- \8 @! {
.id = 1,
$ _/ U. _ D. U& T. `) M# C .dev = {
W( g9 {- f6 _$ e$ g .platform_data = &da850_evm_tl_leds_pdata,
/ u% G/ P1 O$ K, H" \, i. R .release = led_dev_release,7 H6 w* k6 Y$ i& {/ M
}# i- k' F, W8 n0 {, E- C
};% G* ?- V- q& a; t$ |
% E$ F3 c$ x: ]' D$ O8 C7 c4 K' `
static int __init led_platform_init(void)
2 v: x* h" t& D/ [% d{
6 ~% D1 H+ Q# p8 ?" {8 c) V) q; R int ret;) f) r5 ?4 H, |5 V4 z9 k
#if 00 A y3 B0 [9 a/ n5 F* g; z- M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 u* C& C4 f, w6 G' S4 j5 c0 ]& c' ^
if (ret); I3 e) ~! V# |$ P1 R$ T$ \" N+ [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 H. d8 s# O/ I8 t "%d\n", ret);) ?' Y/ T9 [3 L( K
#endif
" l. B6 l# x* O( Z, m; r# T) W" p# \ ret = platform_device_register(&da850_evm_tl_leds_device);; x, C' G( j: |! j) S9 Q% C
if (ret)$ y, Q- a8 T& X$ `" n
pr_warning("Could not register som GPIO expander LEDS");" w' E, @" L7 {6 |
else
! a5 _* l; A5 R6 {" A' ]; m! `: V; p$ I printk(KERN_INFO "LED register sucessful!\n");
" o+ h$ s. K& U+ j8 d) w% W; G, _% J$ {% r! ~5 |. g% K
return ret; ^* g" a* \ w3 |9 T" e8 f) e
}( y% y- u8 V5 {6 c( J
1 l: s' S" `0 K, A: R
static void __exit led_platform_exit(void)& U5 d9 b5 e: S
{0 u; \, z I+ F
platform_device_unregister(&da850_evm_tl_leds_device);( S. P: d6 e: j7 x# g a: F
# p- V8 M+ X/ j( j9 |: y: n% {) d8 R( N
printk(KERN_INFO "LED unregister!\n");
& Y; v$ ]5 `' j6 p) E Z}
$ O, E& U& V6 x) ^1 r4 \. N
' _+ R# I3 u1 @module_init(led_platform_init);
( E% h; p" v" {6 rmodule_exit(led_platform_exit);
% J' \* a J7 \
; Z9 `) } @7 K8 q" l( |5 y2 bMODULE_DESCRIPTION("Led platform driver");
E: ]* e" u V9 U" L5 JMODULE_AUTHOR("Tronlong");
! h. ^5 v" T) }5 d+ l. ~MODULE_LICENSE("GPL");3 r, G3 j" s8 i W' L
) t( Z# {) Z8 i, d8 N* [ |
|