|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 {8 z3 ?* M5 H#include <linux/init.h>4 }' ?/ `/ c" a
#include <linux/module.h>* {9 _$ M0 Y3 e
#include <linux/kernel.h>1 r G# Z( O5 v6 b& w. K
#include <linux/types.h>+ k t4 Q$ ^% J% T1 A$ u
#include <linux/gpio.h>; t. S$ [& j$ Z
#include <linux/leds.h># m f% ~" `, m+ n' |) x: ?
#include <linux/platform_device.h>5 b, F6 Z) n1 w3 M- i
& [7 P- |9 Z1 |$ b9 ]' y$ n* E#include <asm/mach-types.h>
1 \5 k$ G" y1 Z" I1 z+ } H+ E8 O6 V+ C#include <asm/mach/arch.h>
# K+ ?/ H' e9 d#include <mach/da8xx.h>
. @) T+ @9 h' X3 Z# z& t#include <mach/mux.h>8 v$ D/ B2 |8 ?# Y
4 u2 a, g! S2 d' O* W. i; b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 z1 {4 B# j9 N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ O" P1 Y( E7 k3 P9 A8 @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! H2 M7 N% w' @( l/ t#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% @6 }6 P8 X& Z, R+ `$ R% | D
9 T& ?4 S/ S. l) F2 }5 N% e+ h
/* assign the tl som board LED-GPIOs*/ l# O: f# Z. W7 F' X
static const short da850_evm_tl_user_led_pins[] = {: J- n |& K, o) v9 p
/* These pins are definition at <mach/mux.h> file */( ?& X0 Q) W7 s0 Y1 U& ]
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ ]' x0 Z/ P' A: m -1
2 v& u' V V! V- H& F};
/ u/ h" n( }- n, E" ]! X
# o0 a, Q$ x9 d8 Y: M- Kstatic struct gpio_led da850_evm_tl_leds[] = {
' R" l$ u* D w; A( a* K# E {
$ {3 z' M( S) D" b# j' h3 b- m* D) p) { .active_low = 0,
; j( c" O3 }7 K$ \. z% n .gpio = DA850_USER_LED0,: \5 f* V6 A8 k
.name = "user_led0",2 u! J8 N/ ]% ~7 H) K7 {# |* u
.default_trigger = "default-on",
& d/ |9 u L# E5 W# Z; l. y ~ },+ f+ J5 _& X( K' h8 C5 }: c
{
- I1 u, `' K( @" [ .active_low = 0,
( `" P8 Q/ K0 ]' V .gpio = DA850_USER_LED1,4 [! h; D& x1 S9 n
.name = "user_led1",& Z Q* ?& M& v. ?$ J& k
.default_trigger = "default-on",
8 b# M8 Y* V# _5 f$ _# ~1 z/ ~ },& d7 l# {/ i& l1 g
{
* _/ I% x g+ h4 B% ?, \5 v .active_low = 0,
\3 h2 ~" W* C" o: ] .gpio = DA850_USER_LED2,
. i; H5 S- S5 n, j9 S .name = "user_led2",0 s2 b) H) I9 L$ \4 b* P
.default_trigger = "default-on",& M+ s) Q0 v: @- j
},
2 O' J! I/ A# p/ W4 s0 b2 k {
: ~, f5 ^7 t6 @% [# Y; a8 `3 ^$ y A2 O .active_low = 0,7 u/ W* L6 X0 C. p4 e' B; e5 I
.gpio = DA850_USER_LED3,
' q9 K- v: K8 R/ g& n5 ^/ m .name = "user_led3",0 D2 A6 d. t u4 v! B
.default_trigger = "default-on",5 j- e* q* ^. z& R2 C. h, c8 p7 V
},
5 l, ]" \7 \. q8 I9 g7 f};6 u; p l/ H$ f0 i
' g7 j7 c0 e: `9 }# w1 R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- Z' }( i/ ]3 d) `; ?- o) j
.leds = da850_evm_tl_leds,
9 p3 f, P- A9 c/ E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- ^" E- L) W# I& C# }% f};1 M5 J* T# X% v0 u
3 q& |5 J4 x. r4 N4 h" a+ b% y+ astatic void led_dev_release(struct device *dev)/ T1 y" l; Q2 l$ Q
{0 |( m5 A. T/ \% ~7 ]0 S
};' f( O( ~$ I, |1 b" S7 a
_6 U( R( v/ n- w; z$ Wstatic struct platform_device da850_evm_tl_leds_device = {
5 k) |# Y& _; ^1 n5 U1 A, B .name = "leds-gpio",2 V: q/ q( S( z# m7 M
.id = 1,
# |5 L/ t8 v, b! J; u) A- ]! E .dev = {
+ W, v" c o% G J( L .platform_data = &da850_evm_tl_leds_pdata,
$ P* \7 O& n& g9 n .release = led_dev_release,
( ?' s$ r7 _* S, ~) \/ U }
9 E9 W4 v9 y. P3 u% t};
' K7 T9 v& X1 E
& }. i; R# n' h9 @, k Ystatic int __init led_platform_init(void)0 [8 A) C* q, @+ [
{2 a/ M( S: Y: y/ @1 c: D( L+ ^% ]
int ret;! _8 L0 c1 l# ~' U ]& a9 e
#if 0
& ^/ L! U/ |6 v) F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# g3 K) W5 ^4 \1 Z* z# N if (ret)8 I0 c0 e# g& J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ P" F; B$ ]7 f' B6 D" }, Y6 g
"%d\n", ret);
2 O/ l+ I; i: F. v+ N* x#endif0 ~1 i/ Z$ [$ V( S. f$ p* t
ret = platform_device_register(&da850_evm_tl_leds_device);
0 l. f; C* y0 o: J: J3 l if (ret)2 _, C7 u6 `4 Z# d
pr_warning("Could not register som GPIO expander LEDS");4 S3 R" @6 O* H, d5 j# T9 ~+ X
else* q. e0 l. k. e6 ?' ~
printk(KERN_INFO "LED register sucessful!\n");
6 [2 r% F* c( H6 [- [% y5 v8 S6 Y# Z+ f& e2 Y
return ret;( w& i- \* `# I$ }+ }
}
8 r. q" F. s( {4 q, W/ o! V# s
0 ^# K0 |+ y; f0 l: H8 Ustatic void __exit led_platform_exit(void)# K2 K- y& d6 i$ P1 u
{ Z! s3 ]4 e9 l6 r9 k
platform_device_unregister(&da850_evm_tl_leds_device);
. p' G) o/ c, k; I9 W t! z- K+ B( V/ p1 r
printk(KERN_INFO "LED unregister!\n");
: g% b3 C+ J5 P, G" H8 J}
0 i- c! U( N+ a/ J3 q/ f# s
: ~! \, P# A) Z( O1 Rmodule_init(led_platform_init);- u3 ?& D* O$ B( H
module_exit(led_platform_exit);9 \$ P: X/ b! l& K. e* X0 \6 `
% j' K. \2 X2 F/ M# ^MODULE_DESCRIPTION("Led platform driver");) f- f4 U1 f1 i2 R- D8 [; ~
MODULE_AUTHOR("Tronlong");
' x! o$ b1 h" N0 j# UMODULE_LICENSE("GPL");
! U2 i3 U) `* I: j' p1 s
3 w; k9 A" d/ Z( ^ |
|