|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ [( K. h: `% h- }) l% B) }
#include <linux/init.h>
2 h# B( x7 c; K( c+ q#include <linux/module.h>
, D k: h0 U. O8 [0 w4 X#include <linux/kernel.h>" Q3 O0 f8 z( @2 n
#include <linux/types.h>+ S% y4 G) h9 o% ?2 |' y, r# n: b C
#include <linux/gpio.h>
; t ^$ M, |1 h& ]1 `#include <linux/leds.h>
& x) C- P; N& Q) G#include <linux/platform_device.h>) ]! V) U9 a9 d4 V
- r2 E2 E) e4 a% {& z
#include <asm/mach-types.h>
; s# Y: P" Z+ l' G#include <asm/mach/arch.h>
! n, B! y$ l) J' h, E5 Z#include <mach/da8xx.h>" o8 p, m4 a# _
#include <mach/mux.h>
8 K6 R2 l# g, w& B: E" N+ \! c' P& a9 \' Y' }% w# r1 K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ q8 Z4 z: Q. E! Q) m1 _) Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 ~* O" _) l n4 n B1 C" ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% `" r% J0 ?) ^5 h1 u#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 j( E& s9 t& Z( [8 L2 ?" v0 x
$ q/ J6 v. ?' _# O# F; v/* assign the tl som board LED-GPIOs*/
* _$ l4 Q8 r; m3 r q2 B5 `2 lstatic const short da850_evm_tl_user_led_pins[] = {$ L* e7 B2 f# y/ L& B W3 ~
/* These pins are definition at <mach/mux.h> file */
8 u1 J1 ~5 W" k V% S+ f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" i4 j" A( W$ j4 Z1 _% W" V -1
% J% s. [2 W" P! P& v};
: y9 Q; S0 v/ H L7 J, d( M! }& T3 B* `" R! Z+ |4 m1 b2 l
static struct gpio_led da850_evm_tl_leds[] = {# v& a' D7 x" h
{
) n5 r+ @- B) Q1 D .active_low = 0, F4 Y4 P$ h' l8 Y5 l' L6 g
.gpio = DA850_USER_LED0,
$ }- z! V9 H9 [3 j+ b4 |2 t0 { .name = "user_led0",
5 z8 N6 s' s6 W0 c5 B; { z .default_trigger = "default-on",
6 \. X6 W/ M& R' s3 {- ?% I4 b },
B4 C0 G7 W" A9 E7 [" A j {
7 D- J0 D! K/ T; @# l .active_low = 0,+ l4 R: W( W; x( k& F& j
.gpio = DA850_USER_LED1,
" R8 E3 H" s' j; z. n) B .name = "user_led1",
/ O, F8 M3 e N .default_trigger = "default-on",
+ f+ M; e. X* `8 |+ k },
% `) ^5 d; E5 C7 B5 W* R {; p7 O& Y$ ~" T
.active_low = 0,8 W" V- p* V3 c$ ]/ b; A
.gpio = DA850_USER_LED2,' q% N8 ?, r2 S6 G0 a
.name = "user_led2",# j) P* n C( i
.default_trigger = "default-on",0 j, A+ V# ^& q9 B+ e4 ^+ m6 F
},. Q: b6 N; j6 O7 T9 M" S4 G$ c
{, d6 Z8 u0 W& K0 Y! t9 p& s' P
.active_low = 0, ^4 W1 k2 e! ]' X- a% q# ~
.gpio = DA850_USER_LED3,% L& e. ]: }0 f
.name = "user_led3", ~2 f7 U7 l3 d6 W; {: k I) j# s) e
.default_trigger = "default-on",
$ \9 }: S6 T5 I% A },
, H1 W3 P7 u; E8 X- ?6 y1 j, E};
1 a2 ^& v0 ^- k% L+ u, ?( |* k: V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ R6 o6 C% f* h9 _( @. J .leds = da850_evm_tl_leds,
8 g- U7 N* w$ s/ i5 b0 |' R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' q0 r. g' Y6 g6 a};6 ]4 r6 q( j) \/ i: A3 g/ [5 t
- W" Z% L7 D$ ]& Istatic void led_dev_release(struct device *dev); d; d& o9 o, E1 C l
{+ c6 i9 W7 l; D7 }8 K+ `' Z s
};
( @: K! e$ V8 ] s, p, ]/ S
0 ?0 g# P0 v, rstatic struct platform_device da850_evm_tl_leds_device = {" A& B1 p# L1 o+ G' w/ o* w( ^& @
.name = "leds-gpio",
r( l4 i1 C8 y( Y( N, n# { .id = 1,
; A+ q* W% T. I& o" u2 x: s .dev = {) n& L) k* C* d! N: N
.platform_data = &da850_evm_tl_leds_pdata,
9 ]4 r* G* A* I4 n- p. z .release = led_dev_release,# K4 ^, f r4 V: T$ l' o
}
5 u+ c) c& j$ V4 E3 S7 [};
+ o" B* _; @8 z8 ]6 A' u) h
2 n" b4 Y1 m: W1 ^static int __init led_platform_init(void)5 | J$ R* X/ r) E* N! w" A
{' s* X* |7 b: u; E/ J
int ret;
4 Y( c- c7 D/ K#if 0* l0 b/ Z8 P7 ^ K8 [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: |' {. g) y9 U0 u0 Z if (ret)
Q: V2 w; K$ i i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 _# N- L/ H P+ R. R "%d\n", ret);
8 l d+ K0 }2 w8 ]#endif
5 M5 w( o" P6 _1 c ret = platform_device_register(&da850_evm_tl_leds_device);$ y$ |3 {! e/ O
if (ret)
( U6 z) n( {$ d8 q) Q pr_warning("Could not register som GPIO expander LEDS");
" L+ ~1 h/ B3 x0 @% W else
. ?, N. L _% ^" w1 ?! q) D/ `2 U; q% `( a9 t printk(KERN_INFO "LED register sucessful!\n");
: ^. X) y5 r7 f6 K% |. _4 g* J! r, [3 }
return ret;
) C0 h/ n' l) h, c' B}
7 H0 _1 A+ U- `: o/ Z
( |: N- L9 p+ }( tstatic void __exit led_platform_exit(void)- \$ ^9 t3 i. b8 E& g
{. P! k B( |- d j. T9 ^
platform_device_unregister(&da850_evm_tl_leds_device);# T( W7 f3 ?' e2 j- h# ?
; o8 a' n* j) A0 U9 k2 a) h0 ]
printk(KERN_INFO "LED unregister!\n");
) a) t5 p8 A" W+ Q% w1 `8 O4 m}+ D% r: m$ b7 \) u1 S
' i5 M8 S- l; O, v# }- t$ `module_init(led_platform_init);
& k g: \2 C0 Z" I) L# I0 nmodule_exit(led_platform_exit);/ r a- u/ l. D D1 l/ ?; o
9 N7 t* x9 ]! T% ?2 @. J4 sMODULE_DESCRIPTION("Led platform driver");
( r: m J4 u* f @MODULE_AUTHOR("Tronlong");# X) X& U9 t. b9 h1 Q* ~
MODULE_LICENSE("GPL");6 I0 N& }" Y5 n) c
; \- K% t% `$ J: j* N |
|