|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! a9 o: U8 \5 s) c#include <linux/init.h>
; y. k4 ?' q9 X* E% z g5 w- U#include <linux/module.h>2 H9 O- T/ K+ g
#include <linux/kernel.h>
1 t& O6 o3 p9 z$ V9 m8 K#include <linux/types.h>
; H% E2 D$ A$ s2 j- B% T#include <linux/gpio.h>; h9 z& R. ~7 B6 B* {
#include <linux/leds.h>4 _4 I* g# V1 d) B' e8 x9 b5 |
#include <linux/platform_device.h>5 d: e3 k# H1 W' N' X. O& _" q
! w9 c; N/ f8 W2 f7 I) H! z: N$ W#include <asm/mach-types.h>
4 n; Z8 P) z# a6 h- z# R% ?7 c#include <asm/mach/arch.h>( S/ P1 e3 {& \ G4 k/ m% l
#include <mach/da8xx.h>5 m$ D' _5 N- F8 {- i
#include <mach/mux.h>
2 M' T q) D- [4 o4 O
& D m* K, y. x) A: c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 @5 j; u7 k2 Q0 t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ C0 X4 I, |# Z4 X1 Z/ D4 O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 G3 B. [4 }, {
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 p$ A9 A% z3 t) b$ W( H
" m8 B1 B1 c' Y4 K. C/* assign the tl som board LED-GPIOs*/
- c7 N0 u( c) q2 ]static const short da850_evm_tl_user_led_pins[] = {
7 `& P- Z2 F/ @+ j# t /* These pins are definition at <mach/mux.h> file */
. D7 j" k$ M/ R# E N" | w3 R" a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& C' q% l% M+ c! n2 a
-1
6 P- X# G. q L; R9 `+ z};
; J0 { w9 t5 v, B1 O( I7 U0 x4 ], c6 q% T: l+ {2 O! [
static struct gpio_led da850_evm_tl_leds[] = {1 f& K' k) o& W3 l3 |4 z
{$ b+ D% ]. @4 r* ]' r( t8 m
.active_low = 0,0 x6 n0 L5 H$ O% V( _7 [5 Y( U
.gpio = DA850_USER_LED0,
; q& c3 E$ r7 R/ G9 B0 b& S .name = "user_led0",' u& N6 T) A. d
.default_trigger = "default-on",
! o* q9 m% e" K- q0 `1 O },
& T; Q$ k7 v9 H& [3 x! D& ? {
0 R8 `' [9 y' A: M" F .active_low = 0,/ p3 \$ r7 G4 k4 ?
.gpio = DA850_USER_LED1,$ D E/ } ]! R8 V. C
.name = "user_led1",3 G/ X, e" p" W) v2 Y
.default_trigger = "default-on",
+ {$ \2 A, c! l* C9 p( j$ q },
8 M, s3 o9 q- l' H8 V {( N! G4 A& X* W9 A
.active_low = 0,
\3 }9 l2 X' N" o9 ]- Q .gpio = DA850_USER_LED2,! x1 Q5 @+ C3 I9 h* A* K4 \, b2 Q9 t
.name = "user_led2",' U2 G% u6 [2 J1 R' U' x
.default_trigger = "default-on",9 v4 Z2 b# x ~
},; D5 f, O b/ K3 e
{3 [% L x" t5 |* k% u
.active_low = 0,
: z1 E8 j! Y8 E, r% z+ C. z" M .gpio = DA850_USER_LED3,
6 @8 M$ r; J1 N2 f .name = "user_led3",
1 H6 _$ L4 ~5 }0 m4 }$ l" L .default_trigger = "default-on",
: k v. J) J% F$ Y+ }* L. l },
6 r" O: L8 r0 `- v8 H& U- ]! g};5 L0 ~0 n: `6 I4 g) `
) r& k \. i$ h9 Q& Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 q7 p$ m' M/ t8 e- D8 t1 U .leds = da850_evm_tl_leds,
+ `' {2 ~5 a& c* f7 `+ M2 d8 v .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 s) z" M" }1 A+ ~5 i4 z" [& w};
' ]% m: L3 M& }. P, ~( a
8 n4 q" |* ^: a' l8 @) b6 Xstatic void led_dev_release(struct device *dev)" }0 g( G* F/ ]- [
{0 D* O4 g7 z( y$ q- G
};; `; b/ H/ u" g1 I; j
9 A- _& m( V! a, X4 {9 \static struct platform_device da850_evm_tl_leds_device = {! Z E7 J9 r) Z0 P7 r- t9 I$ H
.name = "leds-gpio",
9 X: ^2 V* W1 r* f) v( \! F$ D+ H .id = 1,
; W: G" q# l _5 m& y5 n .dev = {
$ m. [7 X, c$ f0 Y4 | .platform_data = &da850_evm_tl_leds_pdata,
' F! M) x. L& O/ o6 _ o .release = led_dev_release,4 g2 X8 c$ b6 G O, z$ q* h
}2 C# A% U2 Y- V7 d: U( i, a
};- Q6 a: F+ `& A7 O t! B H
- l7 X; g; p" B* K
static int __init led_platform_init(void), }. J; K7 k# _9 x/ J j
{4 A q( ?( e/ x5 N- m; M: X9 T: e
int ret;
. k; `8 ^6 |! c+ o#if 0
2 H. F4 N' y \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: t: V2 x0 C3 _. B
if (ret)
. ?( f1 h" h1 }4 Z$ j( |, ~* J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- U6 j3 _" [& k/ |# Q2 q
"%d\n", ret);! C) O# O' f3 S. \& U
#endif9 p! U# Z6 [7 U3 \
ret = platform_device_register(&da850_evm_tl_leds_device);
4 r. F: A( F& ` if (ret)* ?1 o: o& ]/ K# c; \: ^
pr_warning("Could not register som GPIO expander LEDS");
& ^4 n A0 b$ k% l1 i: s else
5 E0 ]1 w. ]) x printk(KERN_INFO "LED register sucessful!\n");! A# f9 ~/ C! U" l7 {+ z
" \. l& |, |5 I0 L8 } return ret;
! H/ Y$ C! }6 k: ]! U* s; _}5 d/ G- R; K. n) V9 L- I3 R: l* u# D
( W0 U; [8 m( w/ jstatic void __exit led_platform_exit(void)
5 U+ Z( j% i+ h8 J0 B{, d) r; c9 R, s8 u* g
platform_device_unregister(&da850_evm_tl_leds_device);! p2 L) j7 g2 T6 z$ \* f, U
1 o, F: a5 Y# ?( J
printk(KERN_INFO "LED unregister!\n");
' _ E9 c: d6 N9 s) d0 \}
2 Z- O9 g l- y/ I; K& x
0 R7 i6 ^* n1 E( O/ x8 I3 Tmodule_init(led_platform_init);
" V4 I; ]5 u0 I" B% m0 F2 I3 j2 gmodule_exit(led_platform_exit);
% b; }/ S6 N, r- V% c& Q) O5 M3 }8 F4 b
MODULE_DESCRIPTION("Led platform driver");
" m! ~% @! _- s: ?3 RMODULE_AUTHOR("Tronlong");
* U! D* c, D4 oMODULE_LICENSE("GPL");
7 C& h. d; d4 s. S. n4 k/ N
7 u( u% ]6 r4 F, K0 n' w |
|