|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
`8 e- s- G$ ?2 c#include <linux/init.h>
# U* e$ f9 c$ @2 c8 `; R! t#include <linux/module.h>/ ^" A, A% r. B
#include <linux/kernel.h>
1 m% ]8 z7 b z7 E( S#include <linux/types.h>
1 e3 J R/ R& Q8 \6 Z9 M#include <linux/gpio.h>, c2 L- k# i! ]
#include <linux/leds.h>4 X8 v/ } U3 L3 k1 l+ _# K
#include <linux/platform_device.h>
! `, Q7 D; y5 {: u! k# \# `' ~' ^" \2 u4 F
#include <asm/mach-types.h>! T" n4 P. i( \6 i5 K8 p$ V
#include <asm/mach/arch.h>
p" y9 L: k5 U9 G4 h" i3 Z5 F#include <mach/da8xx.h>
5 S! G. G1 z# P+ S( h$ ^#include <mach/mux.h>
$ X3 \0 P- ]# U5 S- k! L# ?! g: I3 ^
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 [9 W$ W) E) T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 [6 `# a+ E J$ w- ?6 W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# D( B, H/ ^ j; M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 E, M' l7 \% W0 z
( c; z4 G9 a7 K' w3 b6 _, U: k. T
/* assign the tl som board LED-GPIOs*/
* s# R* Z2 @1 _1 Nstatic const short da850_evm_tl_user_led_pins[] = {4 O3 S Y4 U2 Q* b, t0 Z
/* These pins are definition at <mach/mux.h> file */+ ` I: G1 L7 {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: ?* v* s) H0 O" j+ j n -1' K: Z$ T- A2 W4 {. T. y) l4 y
};# P: T2 Z& |: ]0 z4 ]8 l, ?
" ^; J, o/ f5 W V) Vstatic struct gpio_led da850_evm_tl_leds[] = {
# }3 L' C# Z3 Q0 I {% C; d3 ], ]6 I6 c% q" T2 b
.active_low = 0,
& p: b9 g- a3 \ .gpio = DA850_USER_LED0,
7 X/ Z) g' j6 M) J2 V2 p8 n3 u .name = "user_led0",
( I w% s7 G/ E7 f, c- ] .default_trigger = "default-on",
9 y9 f% W" Z0 x },. T/ u: |3 ]. P* N6 k+ {5 Y5 L
{4 u4 f/ |2 b, |5 g
.active_low = 0,& P* U: y+ _' J
.gpio = DA850_USER_LED1,
, S0 ^; ~2 ^+ U2 L1 m" u .name = "user_led1",0 f7 V7 S! J! d/ g8 M6 Y
.default_trigger = "default-on",
4 Q: b( Q, S" H; [' ~; _" B },9 D; E/ } n1 \% K9 O/ M
{
1 w# S" p7 [ K# E6 { .active_low = 0,1 X- ]3 ^" k7 X* [" e9 M
.gpio = DA850_USER_LED2,; D; C& s$ s' f3 G+ A5 z
.name = "user_led2",
" L4 v5 e( P' c: ~; n .default_trigger = "default-on",* b X2 @5 v7 s) n
},8 D; e3 @9 U: Q J* Y3 U* E
{
. l+ ?* x* l& H8 h6 h- N/ [+ p .active_low = 0,3 R% v* C4 e7 C% M s( T
.gpio = DA850_USER_LED3,0 E4 W. J7 {5 f3 ^
.name = "user_led3",+ a$ N, g# T$ q9 N
.default_trigger = "default-on",: g8 J4 F% S5 q/ a( ~# S) a
},& X* F8 |6 L1 P' J
};6 H1 [$ _& Y/ z! H4 w
4 J/ a M2 W& @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* `6 y% @: \" F( s4 u. M: e
.leds = da850_evm_tl_leds,& x- T* a" c7 C. U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' V& W& J. w$ I+ L3 F% A9 }
};
7 T$ a2 o& \& y, s7 T
2 _; r3 J7 R" K' H( h( H. estatic void led_dev_release(struct device *dev)' J7 U( E$ a4 P. j
{
0 [2 F5 n* p0 `% |2 Q7 ^};
5 ]+ m) c# B P7 [. d! x
* o$ u! i& B5 Sstatic struct platform_device da850_evm_tl_leds_device = {
$ g- j$ w% k; G+ W8 W2 n5 D; Q .name = "leds-gpio",8 s7 r: n; [# m- z3 }
.id = 1,
2 Y- K0 z8 `9 m9 s, n+ u .dev = {
4 ?) G' q: c6 h; k .platform_data = &da850_evm_tl_leds_pdata,1 T$ P- }" e6 {) G% b6 w
.release = led_dev_release,6 F; U; C2 s' V
}3 ~8 H9 k: o. U% O* M0 F
};
+ W R8 G7 c: J1 j* F$ I; O$ ^+ A2 d4 X' Y
static int __init led_platform_init(void)
0 z# d; }7 E2 t{
9 q3 @! K7 k5 U' D6 Y- C2 ? int ret;5 V3 d, K2 _7 f6 ?$ `) H# K) }
#if 0
' R$ m1 o& b4 _, i) C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- b& o( _; s( a: K' N
if (ret)5 b' R! `8 f& A4 @: G8 S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 d& @ e3 |2 a' A! M9 L( F' w# G "%d\n", ret);
0 ]6 B) l: Q9 R( z6 M$ h7 u#endif
9 [) d! M6 n1 v' { Y: {$ }& w ret = platform_device_register(&da850_evm_tl_leds_device);
) k% \- i2 {. A I' E& h if (ret)0 @: \2 R: P, r4 \/ [
pr_warning("Could not register som GPIO expander LEDS");
* e5 j& {" `# h# H else
/ [# S0 a1 P- b, @) b/ m# K printk(KERN_INFO "LED register sucessful!\n");
* a4 ], r/ j9 a, D- u+ R6 @7 L
! r: ]% N# Z/ Y5 |$ z return ret;
' G+ T9 `8 X) p) X$ V' t$ Q}
, d, ~2 v# [9 G- A5 e" ^8 v, K1 j
2 v( r$ b/ Y% Vstatic void __exit led_platform_exit(void)3 ~$ y( p. T' E9 o4 |# v$ z
{
- F7 ` j% ^) S" n& W2 \" z3 @ platform_device_unregister(&da850_evm_tl_leds_device);
& I3 l& w( x' l& @) b! B6 B( y: M: N T
/ y5 G; m& A$ v" G printk(KERN_INFO "LED unregister!\n");
1 o. M% K2 Z8 u z4 S}
$ U7 B& a; K! [6 O* ?' a' }4 d9 D9 i& r$ R- W. n
module_init(led_platform_init);' P+ r# D8 f" I3 u8 ~) I
module_exit(led_platform_exit);
/ \0 }7 z2 n4 O! u- {$ P
) H) S& l, k3 pMODULE_DESCRIPTION("Led platform driver");
! B1 m' G) N3 \4 UMODULE_AUTHOR("Tronlong");
* c. M# z8 D9 QMODULE_LICENSE("GPL");9 g' z) w9 S+ Z
$ h5 V7 k v& n6 U
|
|