|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, H$ d% X* Z A#include <linux/init.h>
1 O% }; j6 z7 m5 E1 G" g+ m#include <linux/module.h>* w8 _. _" H$ G
#include <linux/kernel.h>3 z6 j% Y4 s+ E' }
#include <linux/types.h>
+ E) |- U! \0 {! a#include <linux/gpio.h>
9 D( L3 Z& X" e#include <linux/leds.h>6 i; y# F4 K" b7 w" R* N
#include <linux/platform_device.h>
" C! q2 _% |6 \ S9 l
m' f) P# L1 V3 b#include <asm/mach-types.h>2 F1 z9 a, A! ~8 m9 e+ g# h
#include <asm/mach/arch.h>3 B0 P$ h( p0 }2 `8 ?8 d. G8 w
#include <mach/da8xx.h>
; z# y1 |! d p' I$ f: ^+ }#include <mach/mux.h>
3 _, X( ?; L+ P" O9 [
\) y5 L, V/ \2 H& d j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* t& L2 x9 q$ ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ ]5 s" y, P$ w @6 i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): f6 v2 P$ W" |4 T# j* i" D/ V7 c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). B3 P2 r! F/ W/ p% n( v) r
/ v3 M" {6 ~# ~$ e/* assign the tl som board LED-GPIOs*/ W5 r1 b. w4 V
static const short da850_evm_tl_user_led_pins[] = {( `; n1 `4 v5 `( L0 W" T/ J9 U# @
/* These pins are definition at <mach/mux.h> file */$ D- h' _4 y7 j+ z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% x* U3 N4 X3 |* W$ U3 s) a
-1
% A+ U, k X, L) d( \};
1 E& u% P) |; K4 O8 p( g& U$ E" g! J# R+ [% _
static struct gpio_led da850_evm_tl_leds[] = {
0 H& s( V( c+ k. m {
0 J W; H! ~0 ?4 O S2 ` .active_low = 0,
1 h! J# {6 K) s E .gpio = DA850_USER_LED0,8 [. {% ?: J4 G3 ^- K' w0 M& J
.name = "user_led0",
. L u7 Q8 z4 u: _8 c: Y .default_trigger = "default-on",
5 V% J2 W9 ]# B% ?1 g },
9 _' U5 O" I P3 q {6 s/ o. y1 [1 d$ {! E* L
.active_low = 0,
: ]& a/ g$ }, S. F .gpio = DA850_USER_LED1,
! O& a% C- G$ v' g6 F .name = "user_led1",: E% ?- o0 v# W
.default_trigger = "default-on",' j* \8 Z+ G1 x( o' C
},
( T; h I! w1 F* o! [& ^( C- p8 i {( U, a! r' L$ U" o+ v
.active_low = 0,
' q# T+ F; c3 Y! R+ J .gpio = DA850_USER_LED2,- f% u# O) [" B2 O) t. a$ V
.name = "user_led2",
* P0 N. {& [6 t6 n( | .default_trigger = "default-on",
4 c2 s" C, `' G, k$ {7 h. C$ Y. ~5 K },
; x; m3 K+ x& d3 s# Z! H5 u" T {
8 l& }2 w( R d1 s .active_low = 0,. A% ]# {+ p/ B( E( a2 k
.gpio = DA850_USER_LED3,
( v, {& N; ^8 i: o& z" H$ ^ .name = "user_led3",
) Q' C$ Y& {- J .default_trigger = "default-on",
! c. n$ m8 m% E k1 O6 b. B# S7 S },$ H% s+ V6 ^% d* w
};
; u' v2 A5 n" P0 c+ h) I% [/ o1 p* @0 z9 v8 _! p/ @ F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 B6 h. J6 R7 C3 |9 A9 {* u
.leds = da850_evm_tl_leds,3 E& b& Q8 _" i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 K3 Q3 F6 l5 R) X% C
}; Q6 S! X, |2 i" t, [: U
/ L+ z# `2 s7 [/ M# Dstatic void led_dev_release(struct device *dev)8 g% g5 l2 D0 Z, t, A% z
{ }3 Z9 G# h* z* f0 Z# X, m
};
+ o. \7 l. H! N+ V1 n' B7 q2 o6 H) M
static struct platform_device da850_evm_tl_leds_device = {- k* t7 [" e7 f) D8 g8 a
.name = "leds-gpio",% s: W8 L' {7 Q. V& ?$ a. g9 t' ` [
.id = 1,
) U z4 O( b) ]3 G9 H6 ] .dev = {
2 H) T4 l. f% b! k! ~ .platform_data = &da850_evm_tl_leds_pdata,
; M: {4 e# u9 d3 T: r9 L .release = led_dev_release,
( m$ t+ X+ q/ c" q% m# O }
5 b% S- Y8 i- N4 p};
" h9 q9 }/ c2 Y) k2 ^3 G3 q
, U$ f" W4 [2 lstatic int __init led_platform_init(void)* n5 ^+ R% Y( a/ L) F3 [
{& I5 l9 u2 W; _% D( N
int ret;8 P; T5 k5 [* u, Y2 o
#if 04 d# f3 d5 s3 W6 y* t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& B5 d1 _/ Z) p+ b# n4 o, C2 p
if (ret), ?# H! V/ u9 k* @! H7 J$ G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" B7 m/ I; N! N3 t7 Q. U
"%d\n", ret);
9 F4 U& Q, J+ g#endif
/ i- x0 `8 x6 W/ v) d" z: Y ret = platform_device_register(&da850_evm_tl_leds_device);% q" x- R' V; @8 |
if (ret)
4 z! z$ w9 o3 B& ^# n7 F4 M$ j2 F8 Z0 @ pr_warning("Could not register som GPIO expander LEDS");
% C2 T- h: ]* R else
9 u% w0 K( c& y2 {* S printk(KERN_INFO "LED register sucessful!\n");
% B& c: n8 Q; V' I- Q/ S
* [& w$ k( H, t6 R: ` return ret;9 y) _, ]* F/ L$ ?- g% u- W
}
) {1 M) o+ f3 c# \
/ A' ^* O1 A* j" b5 _, v" `$ ]static void __exit led_platform_exit(void)
; s3 }( e/ w4 J! D" x{
5 F, n( Y4 Q3 b( ] platform_device_unregister(&da850_evm_tl_leds_device);
p- T8 ]" ]% R7 g5 v+ @; ?8 u, G% f- a( P
printk(KERN_INFO "LED unregister!\n");
3 t# B" ]5 m# A}4 z( d% c: H, w! w
$ c/ k( ^% t3 l! S* h% s7 P
module_init(led_platform_init);
8 I- G8 X2 O% R" ^+ bmodule_exit(led_platform_exit);
1 ~" H4 k7 d r9 I& [
: K8 r2 p6 _4 f4 Q: YMODULE_DESCRIPTION("Led platform driver");
/ J, l% J3 R3 k# D- KMODULE_AUTHOR("Tronlong");
* I. ^& M& k6 e+ hMODULE_LICENSE("GPL");
6 l- Y5 \ a" q b+ [- `+ A) n% C; \' V' c3 }, ~! E
|
|