|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 j4 k7 K3 C' E
#include <linux/init.h>% ^6 X+ {2 H O0 p. [" \; V( e
#include <linux/module.h>
4 C" K. Q. N1 u0 q) P#include <linux/kernel.h>6 F* {. K7 W5 z
#include <linux/types.h>+ g) R$ ?0 W% z: A3 I# L
#include <linux/gpio.h>9 H- D8 w5 G9 R" u6 I
#include <linux/leds.h>5 ^5 }5 U' ~/ k/ c
#include <linux/platform_device.h>, K( b2 r2 o6 y; `5 f/ F
0 ~( d$ K3 ]1 O8 a: n% ]3 M9 x' J
#include <asm/mach-types.h>7 e' T7 c! O7 k3 t% P t
#include <asm/mach/arch.h>6 |* i5 F: {- G7 K. S
#include <mach/da8xx.h>' W, w. k) G7 i! h
#include <mach/mux.h>
" k) t! g/ e4 p4 l, u
/ t# H( n1 b7 |0 q% }. J1 ^8 B( ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( q; {* w1 ?6 D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. z7 M& H; G. u$ W0 q7 D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ `/ h! ]5 m6 G# Q5 C9 R' a" @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 A4 K! O2 Q$ z& Q+ O3 w8 z
' L% o- p( s8 g5 b) e. C0 t/* assign the tl som board LED-GPIOs*/: o. A8 n- `% z: Z# g* C' n
static const short da850_evm_tl_user_led_pins[] = {/ y4 S" u" O/ @9 H( g) |
/* These pins are definition at <mach/mux.h> file */
( W* U, V* q( r& W. _% s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ P/ J. y j! C2 [
-1! D: g5 j& _' T3 @- H
};7 W* j$ t2 \2 D
. j' G1 p! f% R' e& x) o
static struct gpio_led da850_evm_tl_leds[] = {" G6 o7 N: a5 }- r
{
* z% @# O& N G' L: U( P .active_low = 0,& b5 ?: f( l/ N( _( P
.gpio = DA850_USER_LED0,# d9 n+ d6 ^& ~+ B% C3 q
.name = "user_led0",
9 f4 d* [- _' v) T$ r .default_trigger = "default-on",
+ g! O" \5 D7 z# W2 }* y! d# F },
% J5 W1 k8 h1 Q+ y Z8 S6 f5 R {
' `( h$ V4 x" H .active_low = 0,! l, Y& r' g7 ?
.gpio = DA850_USER_LED1," |: x7 @( G8 ~8 V+ z
.name = "user_led1",
4 P: ?1 R# H& P" A! V .default_trigger = "default-on",! e5 {4 o3 |! r$ ^4 I" g* g
},' O" F V4 v2 c# L, ~1 c
{
6 w0 v; Y5 B: _- Q% O .active_low = 0,1 I2 a# n+ R# {
.gpio = DA850_USER_LED2,& \7 E; M# X% z- o# P1 e
.name = "user_led2"," |2 s0 o8 @% Z3 Z& `- ^2 h5 m/ Q. N
.default_trigger = "default-on",
/ s+ [2 s& v4 K& t# b4 K+ m },6 |6 A0 I. M1 ]' E/ t6 h# U
{5 M) a G$ i+ W& @0 u- f
.active_low = 0,) @ L) T3 U3 j
.gpio = DA850_USER_LED3,# H, J Y3 V- i
.name = "user_led3",# B! s1 m/ y& F
.default_trigger = "default-on",1 u3 B2 p, s+ M2 L5 k
},1 s h. h- U# Y& f/ F5 }
};1 l2 q5 m: S5 E# x' ?) ~0 K
$ h0 z. T |2 H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. g P. }/ [$ K) J7 G& k .leds = da850_evm_tl_leds,
( O, J; ?6 T o6 A: l; b2 F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 C7 |) W- x4 P' r- D0 i: K% c( \
};. V' \5 d& h8 Z/ E K
p6 @2 o# B, {1 j; dstatic void led_dev_release(struct device *dev)
7 [+ F+ |7 p r' w' o( r* k, E{6 ^' x5 P+ w% k& {
};
( }$ P: b7 K2 a4 c# b
6 q) C3 }- \0 L4 s2 @static struct platform_device da850_evm_tl_leds_device = {
3 d( `) e& ?2 P8 O( ~* Z( N .name = "leds-gpio",
: O9 @+ Q3 K* l+ d" t. t; F; { .id = 1,8 L' ]( _& Y, {# V! m" a- B+ M
.dev = {
+ l: Y$ |' U- o& J: V .platform_data = &da850_evm_tl_leds_pdata,6 k% N4 ]. w2 I. M2 `! H$ Z
.release = led_dev_release,4 F# R8 q# h% O
}
1 k( Y1 D5 r/ t/ O8 `6 H/ K4 Q( {};
- |9 F* b# f5 R9 b$ F! J; a+ ?; j2 |. p2 J. y# u# J+ Z
static int __init led_platform_init(void)7 M' e& k; L4 ^5 U6 U; F' E
{
- j9 X5 ~1 D+ W int ret;# O% a6 H- K( S E% H
#if 0
0 z0 u3 T1 c. H( n- S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 a _9 Q! \. Q if (ret)
5 |5 x! P9 |1 K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ c0 D! A2 Q4 c4 J5 [
"%d\n", ret);. ?" T+ j3 |- q# t# s( Y- B2 H' }) x
#endif4 i8 A0 a1 K. k$ r/ o" b- a
ret = platform_device_register(&da850_evm_tl_leds_device);* z2 U' U4 F; z7 b+ J* S
if (ret)
4 r8 L5 }9 l7 E3 w* X pr_warning("Could not register som GPIO expander LEDS");5 l Z. U0 r& \
else. N8 ?4 J) X+ q9 w& Q
printk(KERN_INFO "LED register sucessful!\n");
N2 ]) N. _7 d
3 y0 z9 A$ p2 A! s9 Q) ?% p- k, g return ret;
5 P* O1 u# m( T& q8 q0 A. i}
" g( C6 N- G- w% y, h2 V4 r# @% p S+ W! S
. n6 t! q3 [* H3 s& e8 V7 Nstatic void __exit led_platform_exit(void)
" v1 Q% u% m6 x0 } ~* F& s/ E{
) T& z; B. x+ T& I/ M M platform_device_unregister(&da850_evm_tl_leds_device);
# e: d6 w+ D; D' Z( Y( t9 ^) K' m
printk(KERN_INFO "LED unregister!\n");
+ ]- z% I7 t( |: `}; J0 Z6 m) }( Y' Z% w
. z4 j! S& Q cmodule_init(led_platform_init);0 D+ x4 T9 M/ c& U: a/ F6 n
module_exit(led_platform_exit);) ]9 S' |/ j% W1 S* ?4 O
! k- X: A8 _4 V/ X$ C: m
MODULE_DESCRIPTION("Led platform driver");' E6 \2 e) a& E8 w, N A( J
MODULE_AUTHOR("Tronlong");
8 l; r* T$ s. vMODULE_LICENSE("GPL");
: ~7 w8 A. K* Q5 i
% V9 F3 l3 N' O" h0 Y3 S B( ] |
|