|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 X1 |* U9 K# K* E
#include <linux/init.h>: b) I6 j1 D+ k
#include <linux/module.h>1 X7 J" ^! f) c/ f% `
#include <linux/kernel.h># ~; b: U( v/ v/ o- H
#include <linux/types.h> L" ~2 c; `0 ^" c+ I q1 M
#include <linux/gpio.h>4 y3 G6 w" J; c. Z. h
#include <linux/leds.h>
! }- i7 p0 x/ j" p2 }#include <linux/platform_device.h>
, L& G5 s& q; S- v; ?) g' T8 t! @1 W9 n: e6 \
#include <asm/mach-types.h>) m3 y/ g, N( |
#include <asm/mach/arch.h>) ], U+ f( @2 V/ j' o$ T: y' ]
#include <mach/da8xx.h>, [& v1 I6 Z& j
#include <mach/mux.h>
; Z) f( Z4 I2 J, }2 G% J: [4 N' F/ H1 s+ G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 r) b' d& i. T/ O& \9 o/ d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): S: f! q5 F" v7 K- |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ g {1 L6 ~ F& |- }4 x( V3 }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). ? ] T/ o7 M- H+ D% W
8 z' T, L6 S: j' o$ d) J/* assign the tl som board LED-GPIOs*/8 O$ S$ r2 N) M( R2 O1 f. x8 \3 ?
static const short da850_evm_tl_user_led_pins[] = {
& p& e+ V5 e& J% Z/ X /* These pins are definition at <mach/mux.h> file */- ^9 s- l) c# w4 y8 a, ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, \( R$ \5 s- s -1! v$ c0 c0 Z3 E
};
+ Z$ g- W+ H9 Q5 c0 N0 J* { l+ K, n1 O5 y9 o8 y) T% k4 F% Q# c
static struct gpio_led da850_evm_tl_leds[] = {
1 D$ Q4 s* a" l, k: t, R; C7 | {
" n# j f. |5 H$ ?) U .active_low = 0,6 n$ C( t5 Q: [8 f3 s2 Y0 @2 E; M
.gpio = DA850_USER_LED0,
1 S7 T; S! I+ h2 Y .name = "user_led0",3 x) s( i3 c! ?( T$ M
.default_trigger = "default-on",: ^# U5 r/ l# ?& z, Z4 Z- P
},
" L6 E P7 g8 K4 M9 u- P {
; b' u1 {$ F+ N2 x0 ~, ^ .active_low = 0,
# }( y. U$ R" K4 S2 E, } .gpio = DA850_USER_LED1,& O6 I, B, I0 J$ r1 L
.name = "user_led1",
1 K1 A% L7 f: C7 ~9 h$ ? .default_trigger = "default-on",# Z! g4 H9 [/ D! L0 j
},
8 q" v8 R. U- F, u" f# P3 p# {$ q {6 ?9 h& A, t' X Z$ F2 L z
.active_low = 0,! i$ Q" B' ]& r
.gpio = DA850_USER_LED2,( M: R- L( C1 U' G4 V, f9 l
.name = "user_led2",
$ ^' J/ I1 u9 `2 M1 v8 X .default_trigger = "default-on",4 d4 ?5 r+ Z0 |6 W; G+ u
},
6 v, v; N! Y" p- _ j# d; ]% L" ] {
; j9 @- g4 T4 {+ J0 J; G .active_low = 0,
9 w, h) N# i, b$ P9 m .gpio = DA850_USER_LED3,- h/ F5 i' b' h
.name = "user_led3",8 G6 T$ b3 y7 M# u% ?
.default_trigger = "default-on",3 B% i& e( a8 ], o( G7 {, B
},
% S; T) `: U' Y/ ? F8 T8 D};
6 r" A6 v9 N5 p8 W2 p
1 j* C$ l) T' b$ d8 Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% Q# i/ W. _9 t" b2 [( L
.leds = da850_evm_tl_leds,$ F' A9 Z* m8 t0 J; B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), p# I' h: g8 j* @* S
};
8 x1 H, _4 L9 h7 P! P' e4 X, l7 x! u
static void led_dev_release(struct device *dev)
; U @* M2 T k9 R# @{
5 b7 @+ x* b+ [};
8 ^$ p, c+ Q: ]1 r1 Q3 J P2 u
! }4 C+ T' ~3 d6 Wstatic struct platform_device da850_evm_tl_leds_device = {/ H# g& }- i# e, m; v; R- P$ F
.name = "leds-gpio",& V& P* b# V) x! A
.id = 1,& _& f" F7 [* r1 b u( |' H& D
.dev = {% ~) }2 [+ i+ P+ V& q/ b3 z
.platform_data = &da850_evm_tl_leds_pdata,( M' d' l$ M7 M% v3 @4 l
.release = led_dev_release,
- J ]. u7 l2 c3 p) X' b2 L }8 d: W$ x; Z, I2 }- I: Y F. k' x
};
' G+ t5 q2 G+ M4 A9 X. {" P. q/ u& q5 G, A) V' u$ s
static int __init led_platform_init(void)
. Y7 p% b& b$ t2 o, R5 ]6 Q$ g{
9 B+ q& C# f) k2 s int ret;
& y8 ?' {" U# ~#if 08 ?5 d9 ?. B# v6 P3 c9 j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; @6 M5 y9 l, k* S
if (ret): g9 L; |+ D8 Y, k5 Q7 Y7 [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
g+ b5 N- T& u "%d\n", ret);
' q) y& M7 z8 _4 g$ P#endif
* D0 ?, g: {" k4 ^8 `, r/ w ret = platform_device_register(&da850_evm_tl_leds_device);
' `# J0 N& b7 ^ I) K2 p# V if (ret)
b, w' n# Q7 L/ d6 r9 ] pr_warning("Could not register som GPIO expander LEDS");# Z4 M% E2 |9 D4 G
else
, P8 u# b. s4 i' H6 M printk(KERN_INFO "LED register sucessful!\n");
+ x, Q7 Z% F7 E/ k
* ~& N' _2 H. S1 m/ {' O return ret;; k0 W0 ^. U# ?0 E
}
+ ^6 D# L8 a9 K2 l4 ^# J( `0 ?9 E' L' F f
static void __exit led_platform_exit(void)
& x- Q5 l/ a$ a3 b{
4 T0 d" F. f- J7 g platform_device_unregister(&da850_evm_tl_leds_device);
& ~; i7 b! ?0 R3 _/ w
" o* F9 g& H+ d0 p T printk(KERN_INFO "LED unregister!\n");1 v: o* q8 H# h( y
}
+ x; k) z S/ n4 X- B' j6 U! ^! V3 _0 f- s" q, N' |3 Q
module_init(led_platform_init);
! ^" g/ Q R& @9 m% emodule_exit(led_platform_exit);6 \3 S: h4 s0 u# F* q* L# N
8 L7 y# `! i7 M8 ?( r( l
MODULE_DESCRIPTION("Led platform driver");: F- Z' d* J& z
MODULE_AUTHOR("Tronlong");, V) V) @5 L/ N; O
MODULE_LICENSE("GPL");) ^0 @& F$ L4 d. h6 K
. ]0 _6 J1 K0 f- W
|
|