|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 T8 S% d1 I2 V$ z
#include <linux/init.h>* k+ l6 `. t' @6 y! W% i
#include <linux/module.h>' x; w- |) N) I1 L' O
#include <linux/kernel.h>
6 R: F/ F9 I3 q0 m#include <linux/types.h>
" G1 J/ L8 e1 O ]#include <linux/gpio.h>0 v& _% I5 f( j+ j; b
#include <linux/leds.h>7 u2 A3 r0 Z4 J5 o+ y* O, f2 P7 N
#include <linux/platform_device.h>
; Z5 ?) d( \* f
* `" D8 u |, w" \) J4 I#include <asm/mach-types.h>
( z, Q+ O$ s5 r% X2 }#include <asm/mach/arch.h>
* ~1 X8 B6 A3 I2 e. D( R% A#include <mach/da8xx.h>
# H6 a9 {& N8 a# f, j#include <mach/mux.h>" i) q; y8 _/ U, t: V! i
, b `& m% j1 h: U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ I p8 O! X8 t# L' c! d) d d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- ~$ V$ Z1 [6 C# @: V#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
B% _% i9 T1 r4 V- s8 D( B# k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 ^& A0 A7 }8 ~! k6 t) i
! V. Q! o; ]( m, l; ~5 ^* ~/* assign the tl som board LED-GPIOs*/* _& r1 ~# j4 Q/ x, L' U
static const short da850_evm_tl_user_led_pins[] = {
0 [+ m" X1 e# }5 }. U /* These pins are definition at <mach/mux.h> file */2 t+ x8 D+ V, s9 x5 w; ?3 H6 W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 Y5 p% k9 \6 ?% r* l- A
-1
- m/ A, ]% s6 c};
1 d) F8 E% A1 t! }/ `; o' ?7 m) L/ a
static struct gpio_led da850_evm_tl_leds[] = {1 f7 i% i; g8 L" E
{6 g2 Q0 b9 h/ H5 v2 Q
.active_low = 0,' r# S7 F& D8 ^& @2 z
.gpio = DA850_USER_LED0,4 _$ h4 f' B4 t1 b$ i5 i t
.name = "user_led0",6 i: \ _" v: `5 z0 }5 D
.default_trigger = "default-on",
! R5 B" m/ `) m! N7 y },
7 O* v4 Z6 @$ e9 A! [, B {
( M( r5 a/ V6 O .active_low = 0,
3 O5 \- A8 X" q6 ^7 d. s; [+ H7 S" T .gpio = DA850_USER_LED1," \$ @$ D1 R/ y7 \) D
.name = "user_led1",
' Q1 d# B/ t# }% `* L .default_trigger = "default-on",2 b5 R3 a. j' _- x7 p, z5 J. T
},
+ p* s& ^% J: H% w0 u5 N {
& ]+ I/ l. A5 {/ N: r! D: Y& A .active_low = 0, K. ]0 f X6 j& N( x' q! m: i
.gpio = DA850_USER_LED2,
3 }. @3 a) s" C1 N7 S+ k .name = "user_led2",1 R* A4 J: c e5 m; |* u) Z/ G
.default_trigger = "default-on",
+ {9 G$ D% H S {$ b1 | },- Y. `' i4 O o8 a7 y6 I& E
{3 B! W6 _' c4 j) w
.active_low = 0,
$ n+ x2 @4 T5 n W .gpio = DA850_USER_LED3,
4 ~+ ^) P) @0 E+ h5 } .name = "user_led3",
6 e! g; V' H3 P' e; ^! U* H .default_trigger = "default-on",
8 o! Z* u) k. B2 X! X6 @, B },
, |: }! y5 Y9 Y, {};
% z, M. M. v: Z
8 [: S; f7 {0 {* @. |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) ?% w9 _- Y: B .leds = da850_evm_tl_leds,2 G& i E' k( q% E/ M6 u7 m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! Q$ e' k; _* d};
& T% r- W# \/ i4 T% [/ L9 q7 j
2 F, m3 V; D/ g& J' }! {static void led_dev_release(struct device *dev)
: u: _0 j6 K, M* Y' G6 N2 n{
: [) W8 i( c# G" T# N};
! z* B7 l4 x9 Y6 D( y9 T6 D& J; ^- V5 v9 S9 M8 P# \. ~; o
static struct platform_device da850_evm_tl_leds_device = {5 g$ W( z5 N. \! T0 s( B" {
.name = "leds-gpio",) N3 c- F; N! {8 ^
.id = 1,$ L. P2 T( N8 b
.dev = {% w+ e' m7 o. L4 p3 l
.platform_data = &da850_evm_tl_leds_pdata,, b0 l" W' W/ V$ B. z4 s
.release = led_dev_release,
5 m2 t) M/ k$ R) I' t" \3 Y }/ K+ e% v1 v/ D% ]2 _
};7 y3 U+ |3 g' J( q! [/ W; O M
) N |% B' |/ ~" o
static int __init led_platform_init(void). h' o6 h1 L' p5 O$ E
{
. P& P, E$ C) j5 }% R( J8 k int ret;
; D* t7 v/ ]- D( h% q, [#if 0" J! [/ h1 X! b5 h/ ^ S9 k8 F
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- l4 a/ P% a0 E if (ret); m4 T8 T* w# A/ N( P) ?* i1 V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 W, B8 |$ T6 h6 `% l1 F
"%d\n", ret);6 r! o d; g6 z+ j* @5 Q
#endif
3 d' E& C B. h {* f* p, w% k% q ret = platform_device_register(&da850_evm_tl_leds_device);3 L0 m; X' V# g3 D- y
if (ret)6 R# |# ?( l. s4 }1 f: _
pr_warning("Could not register som GPIO expander LEDS");
7 e/ ]! ?* ]. G. f2 T else. C" Q, ~3 @ J) W* E4 h4 b
printk(KERN_INFO "LED register sucessful!\n");
9 x2 y0 [2 j1 R. f6 O- I- U+ |5 u4 q1 u4 M% M9 G
return ret;
( i7 b0 C5 b! g9 o) x( Z}
4 Q$ F$ x% c- g7 Q6 y7 ?; E1 A
7 }9 ?% }$ M' Y- ?5 l0 r" A/ Estatic void __exit led_platform_exit(void)% r5 |: H' X1 c' q# Z( Z
{
4 j7 X$ a$ T3 e platform_device_unregister(&da850_evm_tl_leds_device);+ _+ C1 {2 C$ [
5 }( B1 s' G8 s! e2 J printk(KERN_INFO "LED unregister!\n");
$ f; z& ]/ i0 {. k$ a}/ U, R: {# Y6 f/ `: L$ \% h
1 V. d7 p0 e& m/ }$ H+ P0 ~% X/ Mmodule_init(led_platform_init);, U' _1 w1 n. C( d
module_exit(led_platform_exit);/ H9 ]9 [- ?+ X# Z
7 {$ P! p: X$ W; `" YMODULE_DESCRIPTION("Led platform driver");
: `! ~: x: E/ y$ IMODULE_AUTHOR("Tronlong");
2 q4 L0 u5 u; T+ u# Z* j) gMODULE_LICENSE("GPL");
9 H) }! N) ], ]$ V4 j2 I6 j
% V$ M M& g2 s( J |
|