|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% n: j) w, o' v' ^#include <linux/init.h>, [( R0 x( S* o! Z
#include <linux/module.h>
9 E& o% h. h9 B @#include <linux/kernel.h>. V' B4 [. B7 {" `/ G
#include <linux/types.h>
3 `/ ?; d' H* Z+ [* a#include <linux/gpio.h>8 {( T5 f6 I1 y/ {) T, \. i
#include <linux/leds.h>
& ]* j! a. }; p& @. Q3 D+ }& x" f2 s#include <linux/platform_device.h>6 m* d: H( p3 ]! G; i
) G/ u& h6 L4 X0 [/ S( Y
#include <asm/mach-types.h>
* ~& @' k; z- U7 [5 `: _#include <asm/mach/arch.h>
* n1 R8 d& }7 a( C: B# i3 v#include <mach/da8xx.h>
5 s, [6 \. v+ L# B: ~' |5 q$ x#include <mach/mux.h>
* L7 h- p) v% E: G3 x& r) z0 f) }3 e/ k" v, u3 F3 x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% p6 Q- I# k# g0 ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* _5 N" }, p2 g, `* h3 ~2 S- D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' j e6 N( E0 C- u" O( _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% g' g$ `; C; X" u1 _5 W* S' D
1 q( E0 `$ \$ `/ j
/* assign the tl som board LED-GPIOs*/( X& E( m4 N' k6 @6 q) ?. t
static const short da850_evm_tl_user_led_pins[] = {, g) }' t. v$ a9 s. _: I
/* These pins are definition at <mach/mux.h> file */
q: l ]) s: t. m: L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 n/ D0 m1 Q d" V, K1 X -1
9 u& H. w. n2 T0 ^$ x" a};; r4 R( i p2 ~9 e9 [* ]0 A' A8 u
. _4 L7 D( h' d$ @static struct gpio_led da850_evm_tl_leds[] = {
) i( d/ K/ s8 O6 W! {+ h6 S {
* [4 |+ a; u5 W5 R* c: e .active_low = 0,
F, p# n6 r' V' p1 O) N( ^: u .gpio = DA850_USER_LED0,
; ~' y& `/ ~( Q' w .name = "user_led0",
2 z: h4 M9 u# {! {8 z1 u# J! P& t .default_trigger = "default-on",
8 \' w4 K. J$ ]2 R4 `4 i1 o8 ] },' a- p6 X6 q5 d4 K
{7 {' q' o6 K( ]5 _" n9 ]/ ~
.active_low = 0,2 x4 f# P8 z$ i
.gpio = DA850_USER_LED1,
3 [- h0 h7 C2 B" J) ` .name = "user_led1",
) t) \: Q8 v" R5 v# U .default_trigger = "default-on",
1 e, o- M) J& R },( k! s% X# T5 K' g8 p; N. x# }: S
{4 B7 x; T$ {; _# v1 |4 @
.active_low = 0,- ~" _. j/ }7 |
.gpio = DA850_USER_LED2,
6 C% t8 O8 C0 ~$ T8 c* T; u .name = "user_led2",
0 A2 s, P2 K' W/ i .default_trigger = "default-on",
- J9 w5 k) `% L- i5 q },9 `( Z2 O* [! i2 D+ X
{7 I4 U( i3 \1 x& v+ ]
.active_low = 0,7 C! {! e: r/ c# n( F
.gpio = DA850_USER_LED3,
! D" e/ p! s; X# J0 z% h .name = "user_led3",
7 M2 u: V6 g$ T) ]6 Y# Y# d .default_trigger = "default-on",/ q5 K+ Q2 I/ x
},6 ~0 s" I) `) K L
};
# s( }4 |" {' S" e6 O9 S! A
' l9 F) N+ S- v# O# a1 tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 @" ]7 F. U. I
.leds = da850_evm_tl_leds,
: F1 Y: f2 p* @7 u# G9 X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' `8 |6 c( A. M) \" B
};
1 O# Y, x, q1 @( I; B, {) ^+ x# E: D0 | \* x* Z
static void led_dev_release(struct device *dev)
8 B0 w1 r/ ?% D% V{0 c* W/ ?+ L- q3 ~. N$ i$ o
};
9 T ~; ]% ^0 J3 i
/ ]( ^4 o6 p# s. b7 Xstatic struct platform_device da850_evm_tl_leds_device = {6 z; u! @& L' _
.name = "leds-gpio",# y# z8 D; j V, q; j" e
.id = 1,/ ?/ W% Y! ?! h) k- T) V. @
.dev = {
: k2 R% ~7 E8 [9 @3 H- L4 a .platform_data = &da850_evm_tl_leds_pdata,5 N2 q; c9 m, D; l: m r: d
.release = led_dev_release,/ a/ K& N6 P, l1 b
}
* h' h% \2 N# x s) G4 E};8 a X' L# C$ L: _$ R) r8 ], l
) }5 L- Q/ S s/ b0 Mstatic int __init led_platform_init(void). w* L5 W$ n4 W# b: p0 G
{
4 o$ }* U$ l9 t9 g int ret;1 z2 u4 c4 T& l* \: ?; A3 b
#if 0
1 ?6 O+ a& K, o( A" [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. y/ Y, r, i. S' z+ x9 c2 e- Z
if (ret)8 T$ i# A. c6 x( `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 M' d( p% b5 o. i "%d\n", ret);$ V) J; ]& a i. G1 P- q1 R
#endif
5 ]' o" o) z/ w6 Z ret = platform_device_register(&da850_evm_tl_leds_device);7 T+ X: z) \* @' N# {* a6 I
if (ret)
# J; l4 d# M( x; @ pr_warning("Could not register som GPIO expander LEDS");
* H5 V5 h P' u2 { else
* ~8 o9 O7 A2 b7 U8 N printk(KERN_INFO "LED register sucessful!\n");4 D) R/ W; S$ B/ E7 ?
% l S/ Q& B* a- B" M return ret;- s# c/ T" U2 l7 q) Y
}- d j( c2 R- H+ l" z& K
& a% u M" \3 E" Y$ u, i0 E. u# W
static void __exit led_platform_exit(void)' H. l; N" p n1 u, e
{) p: E" T' C$ H
platform_device_unregister(&da850_evm_tl_leds_device);
& h$ E& N/ P$ z, d, O4 X" m2 h- ]% a1 E: b
printk(KERN_INFO "LED unregister!\n");
/ q) e# h/ j" o: S: g}
5 x8 z# m g) K9 k" }3 U: n. H7 U" O) `+ z. ]2 U
module_init(led_platform_init);
. Y- p9 d9 V% E$ P3 `+ Fmodule_exit(led_platform_exit);
7 O1 B. P5 L2 s$ Q9 z7 W/ V
c( O7 Q/ H4 fMODULE_DESCRIPTION("Led platform driver");
! S( ^- N& @3 u8 |5 z. k" `MODULE_AUTHOR("Tronlong");- D1 S5 c, H4 d. U! u
MODULE_LICENSE("GPL");, i( E4 r6 O E
6 Q3 I1 |/ [8 L: \; c
|
|