|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 ~" V5 P$ F/ A5 y
#include <linux/init.h>
6 M' D5 z. D' t+ ]#include <linux/module.h>4 G U* C) _# f1 T
#include <linux/kernel.h>; Q, O b+ c/ E- P' t
#include <linux/types.h>0 F; L* w6 X! h4 y1 x' D# B
#include <linux/gpio.h>
" D' C% q2 Z8 O#include <linux/leds.h>
9 c/ m o2 G3 d3 ]) M# `#include <linux/platform_device.h>% r o; v0 d+ S3 R8 {
& o7 X( [; d) E7 O; d
#include <asm/mach-types.h>8 I- U9 r9 b0 U1 e3 W: L k
#include <asm/mach/arch.h>+ `8 Y" q7 }- X8 ]. {* d
#include <mach/da8xx.h>* H3 x+ K ~0 M; M' n1 q5 `$ t
#include <mach/mux.h>( e& x4 G, ]& z/ Z" `4 F
3 f. B- u ` C6 L% V8 [. w/ q: X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ o" Q2 {7 d% j4 c+ M6 X
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) T7 H8 c5 m9 e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% n1 h2 p6 W" v m( i
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' i3 U. i: |2 t D$ G5 V, |' r1 B
/* assign the tl som board LED-GPIOs*/
0 c( N% j* i' I6 o; k) k1 W! Sstatic const short da850_evm_tl_user_led_pins[] = {8 O( J( J r' P% J
/* These pins are definition at <mach/mux.h> file */
; |+ E2 ~: q9 u7 ^+ @; r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) j# ~& ~7 U6 E; r9 H2 ?* |
-1% q# V7 j( y% ?; v+ @
};
2 B3 N m8 _+ R" U6 Q
# a* H0 f8 u5 i2 wstatic struct gpio_led da850_evm_tl_leds[] = {7 B T8 M# R" V, ?
{1 `- _$ k0 U% [7 \8 ?3 i. n9 ?
.active_low = 0,
0 R4 c0 K2 N( H .gpio = DA850_USER_LED0,9 v% @2 }! {3 i+ U
.name = "user_led0",
9 V k7 G* O& ^3 |3 J' J .default_trigger = "default-on",4 a: `% m( o; D9 K
},
0 y) P; l- [* U1 N+ ?1 G0 Z7 ?2 d {% a8 l3 k- X8 b- x( Y! t7 ]
.active_low = 0,/ R5 O0 B/ x, P m' i9 p+ V8 l
.gpio = DA850_USER_LED1,
! E0 ~" a5 ]. E' G, c# T& k .name = "user_led1",
6 e( ~2 S q' { .default_trigger = "default-on",
* J! V( S0 v0 z0 K1 ~* F },& g! l4 ?+ p% V! d/ F* X" _, u
{/ H7 B% _5 m2 e; F) i, S7 _4 \- ^
.active_low = 0,( y9 N3 S* N6 k: B( y
.gpio = DA850_USER_LED2,) J7 R0 A2 T9 D t2 N. I# W J
.name = "user_led2",
/ d w! }! T( }0 K2 H+ F" N: Q .default_trigger = "default-on",
0 ?% B( C& v4 P9 x2 g* l$ R, T& Y6 D6 r },
) u5 B/ u4 ]0 X! G3 i' e {: d$ N* i) @; s
.active_low = 0,, t" N! Y8 U3 h
.gpio = DA850_USER_LED3,0 e; g9 K. C' \& Y
.name = "user_led3",; z% h ~5 M9 P8 E. V
.default_trigger = "default-on",- D9 H3 {: V/ a! g! R
},
" u+ X4 ^( |: I7 j$ O% x! B @};
- L2 i( }1 w' |6 E- n! D$ `' h' k
6 I3 P) Y$ a0 jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 W: \& u1 s* J3 V! b! j- a .leds = da850_evm_tl_leds,6 d6 V4 r- l0 l: D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) Y0 q" i" g, n5 b: a
};
! g- i A% F0 x' J1 Q) @1 u
7 r a/ \' A, N5 a4 s8 Pstatic void led_dev_release(struct device *dev)
" H! m( y- S( X( }{
* h" I* ^" n) {5 t' n};
v# K) f' n: b. d" X. x( p* E% \: K$ V f, Q
static struct platform_device da850_evm_tl_leds_device = {8 J7 ]; P+ R9 W C
.name = "leds-gpio",6 P$ \: g3 K" R, |5 a9 [4 H
.id = 1,% b& {- Z* Z( h% x) G4 c
.dev = {( x9 Y4 q, W0 J! ~. q
.platform_data = &da850_evm_tl_leds_pdata,' d# g0 C2 k0 v
.release = led_dev_release,0 I7 |0 z# i1 u( R5 C8 E9 h4 {$ O
}
# i6 |- O4 R! Y# V7 V4 |6 D# ^};
. v" c% @5 x* p' N
1 u; M& { ]# E2 A8 b9 W$ o, vstatic int __init led_platform_init(void): }0 A+ F5 F2 _6 u- F
{1 n% _' v9 ?" A$ n, ?3 D
int ret;
, o0 k7 t: e2 w) H0 u#if 0& e6 P, o$ W: o' |/ e4 Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ ?2 d. ~/ ~ U3 P1 E6 w if (ret)
+ [. q2 e. ]' L- R* D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 U3 e- F* W( E5 f( u
"%d\n", ret);* j( }3 l% ~# R7 Y
#endif4 t- d! J! U, @% L9 Y: U# y1 k
ret = platform_device_register(&da850_evm_tl_leds_device);- H- Q0 C% W* A( e' j3 d' d
if (ret)
5 M& D+ `0 A7 m0 l1 {& B pr_warning("Could not register som GPIO expander LEDS");
' u/ Q% T i: K* l0 B# n else; E' R0 Z* y2 P- d5 W. n9 u* M
printk(KERN_INFO "LED register sucessful!\n");! u2 s8 z: d: d- L# P+ L# U# c
5 u) W/ t, R3 ?! t7 m( M
return ret;
, c5 ]3 U( d: N( ?5 k8 f% F+ r}
, G1 b: @6 R$ V! }) B5 U" J1 T8 O) N& p$ Q5 z5 a) I: D& R$ T
static void __exit led_platform_exit(void); _3 V9 s& }5 @3 D$ m! }
{
1 h1 j' a5 v: ?2 `( [- k platform_device_unregister(&da850_evm_tl_leds_device);
/ B; R }0 d) o$ O$ }1 s1 W3 }. |, ^
printk(KERN_INFO "LED unregister!\n");1 V) J- p5 N2 m( V/ W: I% ]
}
7 T9 n. C. s# S
) c6 T. n3 }. |* Fmodule_init(led_platform_init);, B7 P$ m0 x4 \
module_exit(led_platform_exit);
0 C5 _- X7 X l) Y: R
6 `3 Q$ F6 |: ?9 w5 p! A; ]4 M iMODULE_DESCRIPTION("Led platform driver");! x, F ?8 W# j, `
MODULE_AUTHOR("Tronlong");
% i s$ g9 z- e- T9 m! \MODULE_LICENSE("GPL");
6 L1 X4 i, K* Z6 u x: I, E
' d3 U& n! V! e |
|