|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 L! U1 @: S) f( A# u#include <linux/init.h>
& e6 o* x% a7 @! Q#include <linux/module.h>
* d; y$ ?; n N# {, K! N3 o#include <linux/kernel.h># ]7 f3 J! p- u4 F+ s9 b7 t
#include <linux/types.h>
% Q4 `/ S6 I& ? w2 H9 f#include <linux/gpio.h>9 X- l7 h2 x/ a) b5 p% q+ K: _% ~
#include <linux/leds.h>7 Z' d( O) P/ W6 y- B) T0 o
#include <linux/platform_device.h>
f% N9 {% R% n) Z6 f
3 e: F+ J- B3 a; ~! `( I#include <asm/mach-types.h>
( U& O. w% s6 z M; }% r+ z4 ^#include <asm/mach/arch.h>" @. X5 D6 g4 ?$ j* g+ ]% |
#include <mach/da8xx.h>
' U' c: G3 F1 F& x V& m# _( U+ \#include <mach/mux.h>5 [8 d @- C# E
j8 Y: v/ L' v8 [/ D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): k& A! x6 _& b% z2 c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" y* n; p. ~1 T% G! O1 R0 u#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 u* j- g# L# O# i( Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% p& s' c7 d; [; f& W& M6 D2 ^6 a8 H% r3 u# ^$ u
/* assign the tl som board LED-GPIOs*/0 h# B# S- v5 ^- J
static const short da850_evm_tl_user_led_pins[] = {
; o' E0 Q% q4 A2 d7 H% a) l /* These pins are definition at <mach/mux.h> file */' ?* L6 \( @3 w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( r! k; C# b. h5 D, O# b
-1
8 I* s+ c+ z; i$ w8 i};, S: ]+ x; D3 r
& |5 J1 ^) n9 w A6 ]: G& |
static struct gpio_led da850_evm_tl_leds[] = {# U5 V7 S, i+ @" z; n- t+ i
{
, k) ?8 V- U, u+ P7 V4 D .active_low = 0,8 K$ d$ W, n: v; q7 j8 [0 T% R1 [
.gpio = DA850_USER_LED0,' a5 ?: V! s2 Y& o$ J7 T8 `
.name = "user_led0",/ }7 G$ z, U" i: \, {
.default_trigger = "default-on",: c8 M$ x5 T3 `/ B, m
},
% S2 T% E# }+ v: V) A$ e5 A- N3 \5 Q {: }. m/ _9 c' E+ Z- d" a
.active_low = 0,
* N9 b w2 u3 H9 X .gpio = DA850_USER_LED1,( ]% l1 L; N( f1 a5 o" `, ?; U' l
.name = "user_led1",) r) O Y! k( Z+ P( Z- G; a
.default_trigger = "default-on",
/ Q; w4 x* y+ u* _- D9 i },
* A- _ R- |0 v1 T {
, R8 M; b, z0 Z7 c .active_low = 0,$ d9 y2 p# m/ Z9 M
.gpio = DA850_USER_LED2,+ k- L( O1 | |3 e& x/ q
.name = "user_led2",
* ], C. e+ _4 ]( M6 P4 K .default_trigger = "default-on",
4 ?8 s4 c. V# ?& T },
$ V6 ]: H2 Z W2 g B0 Z {
0 f# r5 ]/ D( O4 E .active_low = 0,
$ O" w& v' H. F .gpio = DA850_USER_LED3,6 o, F* z+ u9 k( f' l
.name = "user_led3"," {: M2 C3 H$ P n5 ~- {
.default_trigger = "default-on",7 x0 }7 z: N9 S5 t9 P0 L
},
( e: I3 N, S0 i1 b: I7 @/ S};
( [* q& H; d h2 q* B! u9 J u [8 H/ O d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 Q9 y1 Z1 E" J) {( x) q2 ~
.leds = da850_evm_tl_leds,* Y, c% `( h* l! w" [- y4 r( I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 l, V0 J% f. D* d: h};
# D5 W0 Z8 Y4 U6 r2 n# g
$ ?6 Z! C+ ?# i/ ^' p6 y8 B3 Dstatic void led_dev_release(struct device *dev)* W7 M2 o, g0 U; T+ t3 I5 J
{
6 ^6 l9 K: ~$ j& i, T' D8 q};
* C* p6 g: e% m( v" O/ w% t1 C1 t5 a& M D+ C% d1 G
static struct platform_device da850_evm_tl_leds_device = {% m! A& J+ i" d! |* }2 \! D+ @4 x
.name = "leds-gpio",* w z' }0 y' p$ K$ h5 i
.id = 1," s$ B: ?1 l* W" g& f( r6 V7 ?$ L
.dev = {
* d/ o. _. F! }* \. a# j .platform_data = &da850_evm_tl_leds_pdata,
$ t/ A9 F' ]* s v0 Y; P .release = led_dev_release,
4 g! T& ]0 W& J7 H5 H( j }* w" ]9 K4 t2 `+ c% w8 w! E
};$ ]4 H$ H; x4 s
) K! C7 _- W8 ^static int __init led_platform_init(void)! `7 Y% Z7 ^* b! z
{6 \+ W- A! [0 x, Z
int ret;
. K% `& S) k+ n7 W2 T#if 0" o! u3 `8 O/ l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' E! O- p. |; P if (ret)
$ z# B3 ^' V- r' B0 c# @3 u" L S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 O& N( y+ ?- k! ]( j' k9 | "%d\n", ret);6 Z) m8 E A& [1 a
#endif8 |/ z, P- [- b5 M* t: }( }- r
ret = platform_device_register(&da850_evm_tl_leds_device);
# h7 F; J( v9 X. s; _ if (ret)
1 n" _& V! ^# l4 G m- {) \9 R pr_warning("Could not register som GPIO expander LEDS"); A, R3 Z+ L0 m& q
else% u7 }0 U! e4 W" g# _- g
printk(KERN_INFO "LED register sucessful!\n");
: g& }0 O: f9 A
1 K- o: q1 b7 X8 g4 |" V2 Q return ret;# G3 ~+ d5 e8 ]1 a/ \
}$ c7 ]0 E$ g, {3 h3 H5 x! P& c
, D6 s J% {. h$ ^7 s0 g; r hstatic void __exit led_platform_exit(void): n. |# z3 O! ~- D7 x% A( ~: R* ?, L; [
{
9 Q. l8 t3 u+ R platform_device_unregister(&da850_evm_tl_leds_device);: n X* X* ~: `5 ~# m& W7 G
` `6 q- D, ] f* [
printk(KERN_INFO "LED unregister!\n");
7 z; ?+ B$ N: T4 v' P. x}' x: W2 o- f. a
) X% x7 p" S: M8 \0 e' \module_init(led_platform_init);* L- N' g' y6 V. a. k! K ^& U
module_exit(led_platform_exit);
! F& i, r$ P3 X7 h7 A
8 j2 D* k1 {+ v; ~5 V# L! MMODULE_DESCRIPTION("Led platform driver");
0 p9 F6 A3 u N8 Z% y- i7 Z4 t: MMODULE_AUTHOR("Tronlong");+ {4 T& L2 _0 ]2 K
MODULE_LICENSE("GPL");" T$ o _# z, g2 O# m
' v0 u. M9 j# ]' L `4 n6 | |
|