|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 K; P' z e2 y$ ~, a3 K#include <linux/init.h>8 {: a# t8 J1 _7 U) A
#include <linux/module.h>
& S5 K$ `, d# _4 q; Z#include <linux/kernel.h>
6 Q: t, |0 ?. t2 S8 W' U4 f9 {#include <linux/types.h>
9 V0 K4 O2 T& U2 [& V9 M" \( q, X#include <linux/gpio.h>
; F- d$ D, o! Z2 Q#include <linux/leds.h>, K0 U' F& J; P' X" q* w! p# l
#include <linux/platform_device.h>/ p, f) B. A/ X
, V, |) Y( W# L0 F
#include <asm/mach-types.h>
3 n) x: N6 x i#include <asm/mach/arch.h>
6 g4 _/ g) L8 U#include <mach/da8xx.h>
9 ]9 t Z4 a5 K#include <mach/mux.h>
2 l- s. d2 C4 ]6 B- l G6 H2 ] u8 Z" ^! t' v0 Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' P- D! S# S% j+ W5 ]& O* n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 G" l) r+ {# E% Y$ ~; Z9 p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- T& A) l6 d: [+ p) s7 S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 `; e: x% u& E0 b
; q- s% i4 s6 V; {4 N* I) S/* assign the tl som board LED-GPIOs*/# e/ s5 k0 `! \; e
static const short da850_evm_tl_user_led_pins[] = {, `$ j, [* Z8 o( I, H/ \
/* These pins are definition at <mach/mux.h> file */( u) t o# Z% W& S; s0 Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 Y$ ], s) B- T -1
; j3 `6 ]& K8 O( ~. f};& G* Q h8 \0 R3 ~/ i* `3 G" T! f
% ]- R6 h0 u6 N9 I
static struct gpio_led da850_evm_tl_leds[] = {
( a, A0 R" y) A9 k2 ? {
5 l8 `: a/ m, G; Q$ q .active_low = 0,
; k- `8 _5 t2 l& r7 ^3 m, s6 B .gpio = DA850_USER_LED0,
. v$ u0 |- ~$ ]! c5 O+ M5 G4 U( J .name = "user_led0",
$ H$ A8 {# R* M" ~# M4 O0 T. v .default_trigger = "default-on",! x( a& K2 Z/ @, s3 Z( d
},
$ }5 v& n' `9 f3 q6 r8 o {
6 v7 ]% ?3 l. w" {' l .active_low = 0,
9 F, v% D6 I: T V1 d7 y6 n& z9 I) g .gpio = DA850_USER_LED1,7 {7 g* M8 ?* G. Q
.name = "user_led1",
- R6 U N. {3 Y7 O/ h& s .default_trigger = "default-on",) z6 K9 s7 {5 D) ^
},
4 X: g$ Q: S6 @5 u {
* d y9 [; f! h& V+ J .active_low = 0,
. R; ?+ Y6 {1 ~& \# @, U .gpio = DA850_USER_LED2,
; ?7 ~3 s4 n6 H+ S* _ .name = "user_led2",, |9 ~, f& a6 @' o
.default_trigger = "default-on",
# F( p2 \* N; ^4 j5 A8 ]1 N0 a },
: K$ O! f' `7 T/ l- j. C {
" [9 {* ]2 ]( f7 P* z1 m* w .active_low = 0,7 }/ L6 @" A8 Y8 Z" v' B
.gpio = DA850_USER_LED3,
9 {. z' w: f4 m- H) ~( n .name = "user_led3",- Y; t5 _% V6 \: @2 Y/ ^
.default_trigger = "default-on",
) Z* l4 P. j+ k+ ` },
6 n# ~$ o5 Z- B# L$ F; Z2 }& d};6 r) }( P) U7 L3 F9 K W
W+ m1 Y$ l8 { }: `2 |3 Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, ]8 M# p5 H* F2 w6 w .leds = da850_evm_tl_leds,
3 U1 m2 B0 F& N, q5 z0 p& X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- l/ G5 }$ c/ T( k" [5 H
};; Y, W$ M" Z( D% l& R9 \. v
/ E* z/ E3 x1 ]& K0 W3 K2 K7 istatic void led_dev_release(struct device *dev)
" M, }" J" k& G{) q( f$ z. P& k _
};/ j/ t- L1 `! E
; f1 b5 l: M& B
static struct platform_device da850_evm_tl_leds_device = {
7 N3 o% ^/ F! k5 s .name = "leds-gpio",9 @7 ^2 v7 C. }
.id = 1,4 k n1 b, m% z' v8 E# S
.dev = {
$ P6 ^! o$ ~. I) M% _ .platform_data = &da850_evm_tl_leds_pdata,
" S1 t; Z0 {# g D$ G3 L7 y; F .release = led_dev_release,
: }" x2 x5 T$ i" T }
/ x; Y% O7 G) L3 p};
& ?0 F% ?% |% ~/ V& \ m' Y8 Q+ a$ l" ?0 I3 A+ R' c4 k0 F9 i) Z9 d+ M
static int __init led_platform_init(void)
, a3 b9 T. L) e, ^{
; N" e5 G' U% j) T5 Y/ k& w int ret;
3 Q) c; K# A. n' r+ q2 M#if 0
5 X% K' o$ D! }+ @ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. l4 K) ]; ?$ F: i" A m
if (ret)
3 q8 N+ g( }; I' z) f7 z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 u) u, K% Q9 G. l
"%d\n", ret);
3 V% ^8 h/ \8 s6 w( g9 o#endif
: ~* P; U C- T9 y ret = platform_device_register(&da850_evm_tl_leds_device);8 K# Y7 V" I$ _) M$ p0 N
if (ret)
0 }. l) U& D9 B pr_warning("Could not register som GPIO expander LEDS");
: c- z% f* y# t/ J4 P# c else5 U0 P2 d, ^8 b; K9 S. z
printk(KERN_INFO "LED register sucessful!\n");5 n! z5 X6 F2 _' i f' ^
, ]. @( |7 s- j e6 ?9 p return ret;
, _! ~; y6 E' E. c8 r! {4 |}2 n$ Q) Z( F% a% C
" i X# }/ q4 [4 _* v# F5 dstatic void __exit led_platform_exit(void)
" H( V8 d/ d6 `5 a2 j3 j1 | c1 Z: m{
, `5 ?! J$ {2 z. A2 X) Z platform_device_unregister(&da850_evm_tl_leds_device);
, B, r) ^5 y4 p3 K
' k5 b) G& C, h2 m; [ printk(KERN_INFO "LED unregister!\n");, z T& m- _$ T0 D4 r$ {- J
}5 X' Y4 G9 W* D) c1 L" t# a
5 |2 P P, s4 f1 M9 @
module_init(led_platform_init);0 O& X; m6 v# L N3 i& J
module_exit(led_platform_exit);4 [3 f6 R6 p) L2 P
$ t5 Q5 D$ @- ~# x
MODULE_DESCRIPTION("Led platform driver");9 K7 ]- D/ @" l, a" {: z
MODULE_AUTHOR("Tronlong");
& j% F3 P; O0 v% U( m, b$ V' ZMODULE_LICENSE("GPL");" \9 @: X* @0 F7 b
$ m( d: p) ?" ?' m/ P! V |
|