|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 J" [8 i2 A5 }. x" _+ G
#include <linux/init.h>* r* f+ q2 @0 Z7 f* f+ M
#include <linux/module.h>
4 R- Y; H3 T! I+ h" w#include <linux/kernel.h>! H% f) z7 H- _" e" p7 f. m f
#include <linux/types.h>
" t) F8 ^# I9 z8 f5 K% l ?#include <linux/gpio.h>
/ H$ J' P: H3 O+ R7 X#include <linux/leds.h>6 Y5 X/ ~. N7 { b/ Y2 H5 c
#include <linux/platform_device.h>
! V/ U I, F7 ~8 T4 ]# R7 y( x6 U+ B5 u$ @% z4 ?% d
#include <asm/mach-types.h>
# d9 A2 H% \& y8 B5 U#include <asm/mach/arch.h>- K+ w( [% h% @1 j1 r
#include <mach/da8xx.h>
$ V! ~( ]) ?' T% g d9 D( n; q* |#include <mach/mux.h>3 y( n0 }' z( r* q2 M6 t x7 n, r
& g8 G6 w; h) B/ x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) ~% S6 X Z1 k# J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 @4 K5 T" \3 v7 q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 @/ G8 S; `# w0 T3 v0 w( U#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), \$ y9 o9 j6 x/ X, V
' }7 U9 o+ F) Z2 ]
/* assign the tl som board LED-GPIOs*/( B3 c0 C8 o m2 @8 W
static const short da850_evm_tl_user_led_pins[] = {6 _' d# f4 W8 o& v' B
/* These pins are definition at <mach/mux.h> file */
( D2 R# R3 g+ I3 y$ h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. T% y C* _$ U1 B, _7 u" P i0 k -1. I3 r+ d! C; l2 ]' [6 f5 D4 |
};
& B4 G$ U" P8 n' D* {" X" Q
1 X" Q& a. U( g. _; }; u7 istatic struct gpio_led da850_evm_tl_leds[] = {
+ [1 _9 |5 m; }- J { Y" B9 k3 d! M2 I/ j& O
.active_low = 0,$ C. ^6 w# a( F8 f3 s, }
.gpio = DA850_USER_LED0," Y# Q! x2 G; M/ d
.name = "user_led0",5 H( F- y6 o6 {+ [# z
.default_trigger = "default-on",5 G: [5 K4 l: T* c1 j9 b
},
! [- I" V, @7 B" \ {4 U1 X2 t- E( [3 C/ w
.active_low = 0,+ n; r" F% [8 v% u
.gpio = DA850_USER_LED1,
: i" N0 L9 S N% W( h0 \0 Z .name = "user_led1",
1 X6 U5 f1 [: k( j4 N6 B" s .default_trigger = "default-on",
& l7 |+ y7 [9 t+ C* l9 A },
A2 ]: f# E. N% T5 e( }! [ {
! s+ ?9 }3 m' A5 @8 q2 {3 g .active_low = 0,
( `0 w$ \& R+ P p .gpio = DA850_USER_LED2,7 a/ Z6 @, K. H
.name = "user_led2",1 r/ m* \/ A1 q
.default_trigger = "default-on",
9 n# z! R" R9 j3 C },# ~- c/ \ a0 o
{
: G- h+ j: A2 S6 {0 T' w f6 a- ^ .active_low = 0,
. a$ Z4 M# p. [. o5 i/ Q .gpio = DA850_USER_LED3,0 }" c# n4 A# s6 @ H* N% G% V
.name = "user_led3",
7 B. I+ `; H/ H7 `, C# s; I .default_trigger = "default-on", ~ D4 n/ w& v) Q7 l
},
& k+ b- @+ ?' d$ S+ R8 I};- E+ a$ i' [( k0 w6 ^
0 A; R# x D3 m; i' W7 Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% j+ g8 K, T+ u6 Q- L
.leds = da850_evm_tl_leds,0 H7 p/ x$ Z9 E4 ?+ {% n4 X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 h; y. D2 y0 e8 F};
& X% f) j% K! k7 j5 Q% `& i( u: a, I, ?3 j/ `4 U' U
static void led_dev_release(struct device *dev)
' q9 ^, y- g# m{. F( j9 c! ^' c. q \5 F; L0 {
};7 I7 W1 R" ]+ q) `/ z: g
6 `% r/ Y& J, D4 w) E+ Rstatic struct platform_device da850_evm_tl_leds_device = { w' \) Q8 `* M
.name = "leds-gpio",
/ H( G @; X. C' J2 x .id = 1,! v( e8 }& w9 `; G
.dev = {# [* b1 A k, ~" Q9 u
.platform_data = &da850_evm_tl_leds_pdata,: Y9 ]* j( V7 \. m2 Q
.release = led_dev_release,
) B, m# Q% V" t }
: u# i* p9 _, K0 ]3 W};; s* O. `2 f, H) B7 r
, v! T$ d8 O" r9 f# T7 \' K0 c
static int __init led_platform_init(void)- u, f. T+ R* G* I; B# x# V+ \
{. }6 a. G- C3 E" l: f1 H5 Y
int ret;
4 K! d' M/ q a- h" c- U% `#if 0
9 a# \) V) _' h7 K1 L ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ N) F8 s# @6 e& A+ q; l if (ret)8 _- ?8 T8 X3 u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 y3 w4 L5 i9 g& A+ w" Y/ l" Q: j "%d\n", ret);- P8 t) B. y5 o: D; I
#endif. d+ p$ C0 T5 x+ F& X0 ?& _" Z
ret = platform_device_register(&da850_evm_tl_leds_device);3 f( J6 l: H' x+ F+ m! K3 V7 d
if (ret)* E+ t# r3 W, V6 `+ x. G& i% O6 h
pr_warning("Could not register som GPIO expander LEDS");# N o$ P3 n; H( ]- w8 s# S F7 y/ J
else5 y' p6 X4 g# M" \4 a
printk(KERN_INFO "LED register sucessful!\n");# ]8 o) B( d8 p8 L4 U) q) j
9 A1 {4 v+ `0 x* Z7 @
return ret;3 G, D" x7 f" R9 ~- U+ ~4 f! U
}+ d: d! O9 x3 {& h6 t0 z4 D
$ K: Y1 ?# c$ } d! Estatic void __exit led_platform_exit(void)
8 S6 D( |9 @' O6 x{
5 {/ E- b% G3 l/ o1 Z4 y. X! B platform_device_unregister(&da850_evm_tl_leds_device);) g) |8 S. |7 W, |( k
* |1 j; O$ }4 H3 o0 S" z
printk(KERN_INFO "LED unregister!\n");& n4 g; _3 a% x" c& B7 U
}
- {6 ~( e. \* V. \, i2 B) A" V9 N# H" P5 }9 F$ L1 }
module_init(led_platform_init);
9 d1 h. z9 t( s- J0 Dmodule_exit(led_platform_exit);
6 L/ j. r% g" W
1 a) s; @ i% d+ mMODULE_DESCRIPTION("Led platform driver");
m* U6 j; N8 [3 o' J) m* @MODULE_AUTHOR("Tronlong");& a# M2 ?5 q) p: j! o0 _& c; a
MODULE_LICENSE("GPL");" B- j' j0 u) |* y1 {
: W% ~" b& E% t |
|