|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, W& ?0 f6 z0 y# s#include <linux/init.h>
3 ?: L* a' ~" s# e. a#include <linux/module.h>2 R& _, s6 V4 |7 `: | a8 e( x
#include <linux/kernel.h>: Q4 f6 Z" B7 B( k4 Y W7 `) C4 J
#include <linux/types.h> O" z% }) D# M }% v8 i0 k+ [; I
#include <linux/gpio.h>* `/ A; h$ y/ i5 y& Y
#include <linux/leds.h>3 P0 d2 V) y3 o; ?
#include <linux/platform_device.h> B7 F4 T4 F' i0 J4 J8 s+ {. _( m6 Q, C, A
1 S/ N5 q8 |. j) C* V
#include <asm/mach-types.h>
$ G+ s8 a* m2 l% n: a#include <asm/mach/arch.h>+ ~& ~3 d2 Y% [3 P) b9 z/ H
#include <mach/da8xx.h>
8 ?9 w" _2 T: x6 S* z#include <mach/mux.h>
! ~; q' a: f, B& k$ ]
: o2 h- ?0 G6 ]" Y" c- ` ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; @) H* s4 ^$ }( S0 L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 ^: h7 ?2 n$ f& n8 N; \& ^2 v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( S; m$ _0 L* V: ?#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); ?) |( c/ D; d/ i5 u
]) p; p7 ]$ j _ I( t4 O7 `/* assign the tl som board LED-GPIOs*/
" v& z' o* \# E( {: }static const short da850_evm_tl_user_led_pins[] = {
, W2 ~7 Y$ X- B4 S* N /* These pins are definition at <mach/mux.h> file */( T) D m7 b2 } i F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 W5 l% y- V, o' _0 V -1 G" A/ j, B7 F' V; x: ^. \
};6 A3 {2 e$ o5 ?
2 H8 |, A( J2 Q# q% E/ m" rstatic struct gpio_led da850_evm_tl_leds[] = {
5 W9 _0 k; ]1 \% r7 V {( b9 L4 q0 d$ v+ z+ b. k
.active_low = 0,
: Y6 M( w! r) h) Z) s+ ?, S r9 v .gpio = DA850_USER_LED0,
, m+ q. _! Z/ S6 L C) D .name = "user_led0",, } x+ h/ R0 {3 k7 d
.default_trigger = "default-on",7 }/ }5 {1 C5 U# k0 \
},8 e, F, D- R. F" |. k$ ?
{7 I9 y2 X9 o: J0 {/ F$ m% K
.active_low = 0,( L! m* Y+ L" e: M+ a2 ^
.gpio = DA850_USER_LED1,$ b: F) N" h3 P2 E2 j# \9 S P: c
.name = "user_led1",
' P3 \6 d" O$ ]. v9 g& f .default_trigger = "default-on",
y- F y. E, V/ y2 ?" ?. P }, b3 B5 P; _) O. ^5 G' f
{
% S5 f+ C$ C- o" Y+ n .active_low = 0,
! |9 ?0 V% s4 P" w o& a .gpio = DA850_USER_LED2,
/ z# N- _. M+ g8 E& X .name = "user_led2",3 `+ ?# o, D0 Y, x4 n
.default_trigger = "default-on",
: S7 M( G N/ M' b },
0 v$ r# j* y9 w+ T$ J, O& E8 S {
9 `$ U4 o+ Z% ^% w) v( ~, k+ V .active_low = 0,
d' w0 y$ e L .gpio = DA850_USER_LED3,/ V* {1 H4 w* U
.name = "user_led3",
c! A: H( c$ F& L( {4 C! U; h .default_trigger = "default-on",/ J. @2 N* A' m% c) Q p
},8 G0 P+ V! _. a$ h4 J% [
};8 @9 B8 G8 c* N( i' ?
! p( R2 c0 _; V1 N, P# ^6 V& |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 d# r4 l+ X! p4 {
.leds = da850_evm_tl_leds,/ w# f/ D q* @- j5 Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- M w/ p; H; R; i
};
- _+ C& |; I. u% n- c9 f( ] I* T' e& a. F$ q0 p
static void led_dev_release(struct device *dev)
! R+ @' r6 r# u) B{& B1 o* i5 s, p8 [* d: o
};
4 Y: I& n. Z$ u* u! o( c7 _
1 b% s8 X( T$ ~2 Estatic struct platform_device da850_evm_tl_leds_device = {
8 D o1 k* r( x" Y/ |- f2 _& j .name = "leds-gpio"," N5 c1 [5 G7 P% {5 [5 i
.id = 1,
! D. C* c6 F" ?: o% Y .dev = {
8 h; H- L T. {! L1 h: G .platform_data = &da850_evm_tl_leds_pdata,
) |) V M( r2 X .release = led_dev_release,
U% n: Y; c' H' G }# Y- s9 k% i5 K# a6 F. g2 i; F: t
};/ J; o1 q: X$ f; i! f. U
4 d2 x7 `" [4 y
static int __init led_platform_init(void)
0 n: g4 S# d# Y$ @; k. \$ s{- {- v+ ]0 h# w% Z
int ret;9 s/ Y9 Z0 C* n$ o+ T) J
#if 0
* u1 z, F, {% j# {: D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- o. d7 ^+ H2 ]$ A if (ret)9 D. U3 [/ w4 j' Y9 b" M* q" x% z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& m! T- s) x, K0 U
"%d\n", ret);
; j: }0 h8 n6 { `9 B#endif( N7 H. j6 u* h! K
ret = platform_device_register(&da850_evm_tl_leds_device);
. I" {, t. K! S# }9 k if (ret)
- C% _" K0 L* E8 z7 I pr_warning("Could not register som GPIO expander LEDS");
) t" `: X( I* i$ c% d* U) S' c7 U' J else7 l+ i: M( g$ h- ?1 \, {( z3 c* K
printk(KERN_INFO "LED register sucessful!\n");! z( j/ T' |$ J9 f1 ?
/ m( {& M# G9 t
return ret;2 [2 o6 ]$ \5 A5 G* Y% L
}" h& t! a. G2 p
5 r: q( m* \! o3 t2 mstatic void __exit led_platform_exit(void)0 {& V( f* A. @7 k- u/ t/ E
{$ @' P6 B7 r; A1 K+ g
platform_device_unregister(&da850_evm_tl_leds_device);+ C8 _3 z7 H$ I* k/ ^+ {1 X, H$ c9 E6 y& R
N- L6 C0 U# y0 s. E |5 s0 Z
printk(KERN_INFO "LED unregister!\n");
0 L9 o+ ~' C+ m0 C! ]}
4 A6 w H) ?! H$ d, q2 w& k' g2 z5 y+ x
module_init(led_platform_init);
) X; W& m+ h+ ]2 Ymodule_exit(led_platform_exit);9 Q6 i* d' \: `* A7 S3 z7 s
- e" Y1 M9 C: ~+ j# C8 D7 \/ |. K% h
MODULE_DESCRIPTION("Led platform driver");
9 ?1 L8 X' H0 GMODULE_AUTHOR("Tronlong");% p4 Y f4 S0 v, M* i
MODULE_LICENSE("GPL"); Z# g+ z# |5 V4 x4 Q
. _5 Z3 H* A0 Y) I0 Z: T E! m( E
|
|