|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( y. ^- y8 M6 @ H* ^0 K; e#include <linux/init.h>
, P' l1 y( S, Z1 y#include <linux/module.h>$ y# M: p8 W& i
#include <linux/kernel.h>
' A' c S& s. a4 u' P- N#include <linux/types.h>
5 |( P( O, D. e# l9 H0 [; L#include <linux/gpio.h>
, V. t$ W1 w( f( W+ Q4 p#include <linux/leds.h>
% K0 }- ]9 k- V5 w#include <linux/platform_device.h>" E0 [9 W' l( W: e
; N7 F; r: M8 M; i7 I) |
#include <asm/mach-types.h>
' T. y4 G! O( f* |#include <asm/mach/arch.h>
, o, S5 M4 c+ Z- P* q" ]! I( ]% J#include <mach/da8xx.h>
! e4 s) v. z. n6 F/ A8 H; O5 i% i#include <mach/mux.h>& u. v% Z0 ~4 }) o
( `( G! ~6 \, s6 e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), X! k: p2 B0 e& j; \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 }9 n0 z8 v$ C0 O8 T. A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 |0 I, l" L4 r# v2 ?. |# v#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
z- K! P C& |/ W0 M4 o2 \
% [$ b* M4 c5 A0 z% W/ q, i& W/* assign the tl som board LED-GPIOs*/
E" u7 L& o+ n/ p3 Lstatic const short da850_evm_tl_user_led_pins[] = {
2 _- x3 N; m- s: ]. H /* These pins are definition at <mach/mux.h> file */- t! R% `6 E! Z' R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ b T) V0 h$ W9 @/ Q; I$ U( z9 s -18 m+ `6 s" q* i ~7 P6 o; D
};
0 L: Z7 |" o* A( P9 q, r1 Q' R2 \ b
static struct gpio_led da850_evm_tl_leds[] = {
5 _8 P/ K( F( k- R {3 q2 P2 ?2 q |5 r& x! w3 O. O
.active_low = 0,( a) U: I# d1 x% d) M5 \
.gpio = DA850_USER_LED0,
3 N: R. ^3 e2 I. H1 I4 X' J .name = "user_led0",5 O. A, b5 A: M; a! \. e( z; D
.default_trigger = "default-on", F0 w$ L0 U" P- `9 o+ g! T
},9 c( o9 w5 Y } y, X, V" d- [3 G
{
7 O! O$ m* `$ s7 U .active_low = 0,
4 p0 M9 ?, x1 e$ v6 ^" ^' R9 T .gpio = DA850_USER_LED1," ^( d- g0 f5 Q2 _
.name = "user_led1",7 j# G7 q3 \; m' y! \3 N
.default_trigger = "default-on",1 T& Y, d& a" O# q4 c) r
}," |$ ` i8 i- K: y+ x
{ x% ]. H7 k0 W' v( x( ^1 { ^. H
.active_low = 0,
5 b* d+ t8 H; N' q/ W .gpio = DA850_USER_LED2,4 m0 l/ D, j/ S& t
.name = "user_led2",
: Y- V" S, M. p8 F+ i9 w; F( L .default_trigger = "default-on",
/ i% V2 {6 o3 z, m" ~ U6 {) ~, W },
3 r" f- O( G0 p! z. }3 ^$ K/ @& _& R" U {( {1 l' ~: H3 f5 H
.active_low = 0,
: `& v0 Z5 m; v5 f: d. g6 C .gpio = DA850_USER_LED3,
! u6 b. b& k' d5 s m3 i; D .name = "user_led3", c# U. U/ v) n' Q8 w
.default_trigger = "default-on",
6 F' V$ y4 P/ k9 Z6 J4 Z) k' V },, T$ ]2 a5 V* G$ S7 h* B
};# \( V$ U- _: v+ O, H1 O3 g
& l; s7 ^2 i: I7 e$ t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { Z# ~# b4 R V* _, L" B" y
.leds = da850_evm_tl_leds,
0 q, s* C6 w; o' y+ R$ y2 A1 d! f; d .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 F) B3 c/ d& Y9 c& ^& U, Y) w};, ?& e, {4 [( Q. P% R" O' V% x
9 s+ y# H' [& |6 E
static void led_dev_release(struct device *dev)8 N# e! R+ Y3 _
{& t! s" v. F' H5 U7 B; y0 d
};
6 E4 r a% ? l) F# _. G
! N# W# |9 j5 s N$ j6 \ Mstatic struct platform_device da850_evm_tl_leds_device = {
Z3 T/ H1 S6 b0 n2 P: I8 L g3 }6 { .name = "leds-gpio",
8 A. Q9 t" H3 c; \ .id = 1,% j9 X$ C1 X1 f
.dev = {5 ~. j# y% c( e' ~
.platform_data = &da850_evm_tl_leds_pdata,
) u' P. x- P" s* ?2 j- Z .release = led_dev_release,
' }9 x$ k' S2 z: g7 Q, m( `8 ~ }& ^/ ~! I6 m- w( t3 F
};/ G6 h. q& P d* R3 j0 s- U
+ O- }. T/ I \9 Gstatic int __init led_platform_init(void)6 V5 |5 e/ O" @) |' D( A5 V' D
{: ^) W5 m R* W6 T p
int ret;
% B ~& N3 J" s# \+ d7 I#if 01 g$ t# i4 c' }# D& k: @3 `6 R$ t2 M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* R1 J5 K9 k( n7 W" P: O
if (ret)
: w1 h$ A' [& I/ E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ c1 L, J( m' t4 y "%d\n", ret);
& m. a( [2 J' O* ~#endif+ j7 [# T2 ?$ h& _7 i. }% q/ ~
ret = platform_device_register(&da850_evm_tl_leds_device);
* S* H8 X& k/ e& |. v+ r7 d9 ]+ A if (ret)- `9 X& p( Z* K0 J$ G" W+ v
pr_warning("Could not register som GPIO expander LEDS");3 J* i; d. J5 Y/ P6 `' M2 N" V
else* `: S- \4 h5 h8 k( c" d, R
printk(KERN_INFO "LED register sucessful!\n");$ H' H3 B: L4 `% B
( B, t. ]& V5 M0 k
return ret;+ w( g2 d9 C; x& N% N) Q( E$ d
}
5 g: @7 H, F9 ?0 g" ?( X" f4 ]2 |# @0 u& I2 y
static void __exit led_platform_exit(void)
9 K4 a( E: ?& ?: h4 \, E7 m% m{
. J) X3 ?4 ]' I4 t F+ [( x# X2 O platform_device_unregister(&da850_evm_tl_leds_device);0 Y6 `' [8 x/ }' [- y
7 X1 r2 K( S$ F5 ]0 `1 n" c: P3 g printk(KERN_INFO "LED unregister!\n");
- V& r3 a' |+ @: J}
9 j0 \$ [& O* l5 P
- E/ D3 p/ |6 `$ N2 W0 P# l: E0 ^2 Omodule_init(led_platform_init);
8 N; o; @: E, F2 umodule_exit(led_platform_exit);
1 g$ K5 w- i3 S/ a9 k; L$ `4 U7 g, C' s* c
MODULE_DESCRIPTION("Led platform driver");
; n# y( i1 [$ r% J, i$ L1 wMODULE_AUTHOR("Tronlong");
4 s* Q( h' d& E3 t0 t7 |4 jMODULE_LICENSE("GPL");
6 b% \# e; H/ Q- c7 B* X# C% h4 n+ W8 x
! }1 H3 k! p/ K& _: _ |
|