|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! ~$ e: Q- W. ]% i5 b2 m#include <linux/init.h>
1 s! l( m/ d' ]! M6 `" |#include <linux/module.h>$ U' j3 B; c: h
#include <linux/kernel.h>. I" ]; U P$ x3 K
#include <linux/types.h>
, n$ i! P7 v- C) t, x#include <linux/gpio.h>4 b. B6 {+ e$ h0 ]
#include <linux/leds.h>; J0 H* X5 e/ i: ^; U" R/ i& K
#include <linux/platform_device.h>
( f0 q4 S4 D) u# P# }
* w% H$ a( Y+ x7 f, Z) P#include <asm/mach-types.h>, q0 c" z/ t; U) M9 h, v
#include <asm/mach/arch.h>0 @- K% r0 I8 Y8 R
#include <mach/da8xx.h>
1 R3 h, G0 M4 z. |( b#include <mach/mux.h>
5 j: E7 ]4 Z3 A! ]; i0 I* {
, H3 W2 ^, A/ L$ _# e4 A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; {/ N: S) o4 U3 ?3 w3 m7 D) O7 W#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) {0 @* Q: C4 l) J7 m: Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. C3 y s& R3 h8 {5 ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ S. [+ x7 d% p) ]. G; `
# F! s! ]/ N, r3 S- d1 A
/* assign the tl som board LED-GPIOs*/
( e- g7 f2 @: qstatic const short da850_evm_tl_user_led_pins[] = {
Q) Y6 y3 U' _/ K /* These pins are definition at <mach/mux.h> file */1 X8 W; `) ]6 L/ B% [: y0 f% T. c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- m0 f+ x$ x$ e) r, Y3 ?5 d6 b
-1
G! x5 E8 d- P9 ], p3 l" |* C( o Z! e};" F0 m. T; v! C) t; `! R0 V9 \8 t% K
( x) Y; S+ n- r& J: ]
static struct gpio_led da850_evm_tl_leds[] = {! p* c# O- V% G: B2 X" B
{! q# V$ G8 v7 z. D
.active_low = 0,
& ?2 v* F* F+ i. ~4 } .gpio = DA850_USER_LED0,
8 A$ M. n b8 p .name = "user_led0",
4 A: [$ ~! a/ W4 ]. M1 @5 N .default_trigger = "default-on",
4 j% U5 Q6 G# n! S& O },
5 a: K* ~4 O) K" x+ y$ m- L* D {2 \6 T% r( U4 H/ S2 i
.active_low = 0,9 s( U3 i7 h9 Q/ x. E) i5 A
.gpio = DA850_USER_LED1,
, c; W6 ^. }) h) k4 H3 d .name = "user_led1",
3 y/ }+ N% Z" n .default_trigger = "default-on",
8 I, B, a d* f6 F8 ~: l },
( b8 X0 n+ M) z$ Q3 N" [/ c8 c {
5 A7 \- A4 e* B- ` .active_low = 0,
' L# Y4 h7 H$ w .gpio = DA850_USER_LED2,( j- n; B. Q* S0 h7 ]" ?
.name = "user_led2",: ?0 w0 j/ @/ x$ a
.default_trigger = "default-on",
# p! N; R. ]+ R },3 a4 c' l+ H5 Q' }$ D
{& g/ F9 J1 A2 D# S9 T; g) x, p
.active_low = 0,
/ P6 f' K8 z0 o6 ~! |6 ` .gpio = DA850_USER_LED3,
, q y0 r' C; x' W .name = "user_led3",+ f5 g9 p" V6 Y3 Y2 Q. F) T
.default_trigger = "default-on",
+ {. Q/ f- j' u& w5 _ },+ o+ v% O7 V" m( ^0 [" b
};9 W( ^" H0 y" O
: {( v7 v/ Q6 {# {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( Z/ _" t, U+ ?1 J/ Q% I& |
.leds = da850_evm_tl_leds,
- B4 T7 l* R5 ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 C3 G% A' ^* f
};$ n5 n7 h5 w. W$ u8 r
- C7 R. \" g3 Z- Z; X/ astatic void led_dev_release(struct device *dev)
/ P0 z6 }2 S+ n& b4 O# ^2 _4 \{
0 S( p f/ K/ {};
% I: z W6 h3 o- S
( P" p7 a9 _6 X# B; e% w: h5 mstatic struct platform_device da850_evm_tl_leds_device = {5 H& r7 t+ \5 m8 v' y
.name = "leds-gpio",
5 d& _# K+ g4 i9 h; {5 K9 M, A .id = 1,0 U0 u8 u) c, ^2 E1 }$ n& u
.dev = {
, w2 c' u# Y" I .platform_data = &da850_evm_tl_leds_pdata,
8 a T8 a+ V* W; Q .release = led_dev_release,5 n: g8 _4 k6 H5 J, J
}
5 A+ s8 A, V# f1 H3 I+ l};# g& J6 E o3 v2 x x0 u
5 O- @ [$ V1 B2 s2 pstatic int __init led_platform_init(void)! \' l0 n& q; L3 L2 T. i! b
{% B- y, S B3 A
int ret;8 @& f5 F4 l M6 z( b: h9 l% [
#if 0
: k7 h+ R' y. {% T2 ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 M+ c4 r: K$ L0 v( s
if (ret)5 ] E7 G: |, K' S- J; |# L! W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") D3 K5 I& O5 b5 }$ ~7 k6 k7 | x
"%d\n", ret);3 D1 [ F4 b6 F$ m0 U) n
#endif
. p3 J* \/ a* Q ret = platform_device_register(&da850_evm_tl_leds_device);. i2 L7 B* K2 x/ W/ z$ ^8 S
if (ret)1 Z8 T) n1 D; I' D* a
pr_warning("Could not register som GPIO expander LEDS"); C$ ~2 i8 n, E& S) c1 X
else
9 ]2 {2 `" ?; W3 F9 B. ^# T2 z k, B printk(KERN_INFO "LED register sucessful!\n"); X9 m5 X6 U; c- T# T! F3 Q
( P$ h' k$ I6 R* A return ret;+ p) {. M; ^" r
}
* z/ V. x2 [) W x
( p0 S0 P# ]) A1 |static void __exit led_platform_exit(void)
& |7 e3 ^0 x+ D, Q{/ H/ Z9 J/ c2 N% Z4 b
platform_device_unregister(&da850_evm_tl_leds_device);9 A- I, t1 i+ {! X. p! A
6 c8 k: y0 C- N8 Y
printk(KERN_INFO "LED unregister!\n");$ A# _; ?/ F( k! W
}
" g7 c2 b1 u7 E) f
7 I3 [; @$ d6 m0 R( kmodule_init(led_platform_init);
1 I0 }( M+ p: l' c* Amodule_exit(led_platform_exit);3 V+ Z1 h. x; G% n+ }5 Z N
- Y" i1 K0 ?8 V" b# d- f, IMODULE_DESCRIPTION("Led platform driver");
' e2 s0 V0 [* m0 T' W$ EMODULE_AUTHOR("Tronlong");
( M7 R( ~7 z; F! s* g0 |MODULE_LICENSE("GPL");
/ c* f8 I- |+ H$ t" I1 B1 X" E4 E" h. ^ ?1 {! u- b8 H( J
|
|