|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ \+ i' i) t4 I2 g8 X#include <linux/init.h>
" ?6 V5 j" z5 x0 s9 [#include <linux/module.h>1 _, B0 h3 A7 u- W6 I0 `2 J+ S
#include <linux/kernel.h>
) Q8 o( z6 c: f0 F+ O1 J#include <linux/types.h>( H V+ R+ V0 Z+ X% p" \ ^
#include <linux/gpio.h>, x" w( b& v1 m- }9 s9 ]) q* l
#include <linux/leds.h>. j, x H% }8 D
#include <linux/platform_device.h>& u$ r+ G! a5 S, I4 k# H# h
- k0 o1 S9 Z" V# j) m#include <asm/mach-types.h>
6 R$ k0 w" \* c#include <asm/mach/arch.h>
+ F X" ]6 U$ R8 o- H#include <mach/da8xx.h>$ l( e/ w2 ]6 ?: V
#include <mach/mux.h>% @! H6 {, C: N! g1 u7 S
5 M: E* b6 l! K; ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: N" p }% m! \0 |) ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- f' V0 I& k2 w1 P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 R. l$ w) W3 @% C4 h9 A e* z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( }% G# M* k( q
: z. i$ n! ~" T/* assign the tl som board LED-GPIOs*/5 n2 ~( a" t E( n
static const short da850_evm_tl_user_led_pins[] = {' Q$ s& w% E2 c) z
/* These pins are definition at <mach/mux.h> file */
5 k z$ J5 r5 q9 F( Y. {! l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- E6 Z8 H9 r% N; l. x9 l) w3 J _ -1- s5 z$ Y3 l: f
};
2 p& C. b8 o7 B+ r7 c! X3 v6 o: N6 Y* `( z# F+ x& p
static struct gpio_led da850_evm_tl_leds[] = {, W) H `. m0 ~( l$ e
{1 B) V: Z6 c O2 `; ~1 S7 c
.active_low = 0,
5 B: |' t( A9 @. [* } .gpio = DA850_USER_LED0,
% X6 X# @4 T! {! G. a( F1 [% X; p .name = "user_led0",/ U5 D$ ?/ W: b
.default_trigger = "default-on",
7 s. K( W* N( Y) w3 X" t2 W },8 k3 L& C2 \3 n4 D
{
9 `) P) E1 f8 I4 _/ V .active_low = 0,. m5 c7 _. @" o6 ~! m
.gpio = DA850_USER_LED1,5 ^8 R( i+ `' A3 A8 S B
.name = "user_led1",
) Y) V' m4 ^" v* h; j/ X .default_trigger = "default-on",$ a9 w4 |0 n5 ^& S
},8 Z4 j5 g0 R6 f3 B! c* B/ N7 ^0 n H
{ y' c6 Z% f, G9 v; f/ K8 y: u
.active_low = 0,# N( d# y: f+ p4 P0 t
.gpio = DA850_USER_LED2,3 b5 C0 L" h; u. m' k3 [4 z2 Y
.name = "user_led2",
& K' P7 c0 Y0 p .default_trigger = "default-on",& ]2 w& g: `9 U( O! r$ f6 o; D
},
: ^% W5 P! D8 a/ V {
% S! q3 }2 U% u& o% J/ m .active_low = 0,' F# k* R- i* J: O
.gpio = DA850_USER_LED3,* g: K- C3 H% y: k' H5 i% d
.name = "user_led3", N! j+ T( K; H, ^8 t* N1 S! p
.default_trigger = "default-on",9 r2 d" r. X- w/ O, c- R
},, Z- ?9 i L& ]( a
};
+ I3 Z2 N2 G* M3 R6 ~; R" @7 T' }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) M6 C! A2 p4 x3 w, d/ K .leds = da850_evm_tl_leds,
' P9 {+ [7 O& L3 k7 {: [) C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 ]) x+ i' ?7 K; i. C& s
};( |$ ~; @- V( {) U; d; S
0 e5 A5 @/ m# q2 ]; x+ y/ W
static void led_dev_release(struct device *dev)9 f' Z; _; O% x& z
{
; Z% M% w( c; @" A) G, X};
' ^8 Z& d& q/ |$ t9 L( G" w1 q) u; y2 Y" h
7 G. l# _. B' l% f1 q3 G. Ystatic struct platform_device da850_evm_tl_leds_device = {
4 v/ g/ f- h) P8 ~. _' z .name = "leds-gpio"," Q3 A7 }" l* S! f/ v8 L4 I
.id = 1,
1 b5 \" H) ]# N& ?3 L; x' i .dev = {
$ E( t) y& r3 y. u s' ~5 h1 t: H .platform_data = &da850_evm_tl_leds_pdata,# o# i5 G: Z4 |: c' d; x
.release = led_dev_release,. ~& r0 M, |- b5 m2 Z7 `8 e0 y
}* S" e6 V$ g/ z1 K
};# t& D9 o7 g7 T; x
1 w7 l2 Y2 e* i9 Y
static int __init led_platform_init(void)" H0 S. @% i; A
{
3 X. v; Q- I& W4 X+ T; q int ret;2 m5 t# C- p& @1 }
#if 0
: [, F: C3 e* A3 Z2 z1 h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 H! C6 f/ d0 f# F
if (ret)
% Z0 v% Z! I% X2 _2 }4 R+ S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ P8 q( O" i+ E" c) I: z "%d\n", ret);& z" C6 c) N# I
#endif, Z9 x$ P9 z P" r
ret = platform_device_register(&da850_evm_tl_leds_device);
! I7 l! M# d5 U! ~# o% S if (ret)
3 a& F: C" Y3 A: A: [. W! N3 T pr_warning("Could not register som GPIO expander LEDS");4 T6 C* R) I) }- m3 D
else
, J3 B3 w0 Y* F2 w- M: o printk(KERN_INFO "LED register sucessful!\n");
- f2 Y2 x: D. `! I
% Q- j; b1 L" N E return ret;
% d$ r! `# H; q% I# k6 U}
1 B# g, ?9 L! }) [1 Y: P- A8 h R6 K. k6 s2 ]3 L
static void __exit led_platform_exit(void)
9 Q: d- V: U; l/ L( O/ w! k" w$ C{* o2 O1 g7 B% n5 _" @) V& [
platform_device_unregister(&da850_evm_tl_leds_device);0 n2 q0 H" ^0 D# a/ e
1 ~# W1 q' _) [7 w. S% \ printk(KERN_INFO "LED unregister!\n");6 n/ X# p% D. D. g; k, `
}
) y$ q, D r6 \5 V
, M* k" @! m7 M' ]! `, _; Omodule_init(led_platform_init);& @1 K0 a( Z' V7 G3 I
module_exit(led_platform_exit);
" [% z/ m1 U4 ~% z; ~7 ~6 _6 c* v
MODULE_DESCRIPTION("Led platform driver");/ T1 G* D, b0 y4 _: I
MODULE_AUTHOR("Tronlong");
- b; i- w e' A0 IMODULE_LICENSE("GPL");6 B E$ A m& \: c d' G2 @
; t3 I% B% J- I# M
|
|