|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( ~0 I. j2 e3 H6 a& x#include <linux/init.h>- x ~' ~5 Y) Y$ k
#include <linux/module.h>* y! G2 s1 Z" k: v
#include <linux/kernel.h>
2 A, ~! w9 ?1 \- _5 M. V9 a#include <linux/types.h>
8 \% G$ l$ ^' x9 [! w7 k/ p0 [#include <linux/gpio.h>' V9 _$ w( V O) n9 p7 A
#include <linux/leds.h>
7 W% o/ s8 Y2 `: N#include <linux/platform_device.h>
( z9 T4 B& z" L# i
0 D5 ~, G6 J& Q/ y5 t) E#include <asm/mach-types.h>
1 Q, S* M) S; e- M# Z; @: `, D#include <asm/mach/arch.h>
( G: G5 j9 ~' B- B#include <mach/da8xx.h>
5 m' e( v, G" P- `8 T#include <mach/mux.h>
- M6 |* c% b4 d8 T2 x; O- X6 W: d; `$ K7 K% {7 M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* f8 f$ c0 j# W0 D- p/ \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% h. |4 n! j5 |; L0 c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* K- P! G7 r2 o( N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) Y' C& L9 Q& d+ ]- h" p
/ \. R1 J3 S2 ^) t7 o+ y3 S6 ~1 f/* assign the tl som board LED-GPIOs*/
7 o1 a; G; o; p+ `static const short da850_evm_tl_user_led_pins[] = {
" K; A% i, C" T$ J$ E" d! e3 s5 { /* These pins are definition at <mach/mux.h> file */9 L' d# j) x5 l, Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 ^' l1 S% I; M6 p, O% T -1
" s7 H6 b7 O9 H9 E0 j};
( H6 E! `0 i8 m
$ {* a+ S2 L+ n3 M% ~6 ]static struct gpio_led da850_evm_tl_leds[] = {2 t6 I5 S2 ]; H( s* f# Y
{
. K0 b% k& l2 d1 q, D: w .active_low = 0,6 S, ? \$ C2 _, s4 K
.gpio = DA850_USER_LED0,
3 w: p) p5 t6 S .name = "user_led0",
( d9 a v/ q, T j3 w .default_trigger = "default-on",: B8 n) s, a" t- j; o% ~. M- _
},( ^- \" L3 l: G/ A. k4 E2 ?& d. r- O) a
{
) u8 r O9 F7 p' m$ B3 @" V3 [8 w .active_low = 0,; H+ }8 C% j/ |: f' G
.gpio = DA850_USER_LED1,$ X# D) v" M$ a
.name = "user_led1",
R9 o% q# S' u/ B: Z0 \8 t; v .default_trigger = "default-on",4 y+ v5 b; X0 H& X! Q8 I) ^
},
7 d+ I8 \+ }( i! n: \ {
l6 c5 x* l+ O2 G8 c .active_low = 0,
! j0 Q; g- G0 p# C/ \4 L4 L( G .gpio = DA850_USER_LED2,
$ ]1 t* Y7 O0 ]+ C' G t4 I .name = "user_led2",
! k5 I; f! G, ? p! S .default_trigger = "default-on",$ C+ i6 [5 y# ~1 s" n
},
2 b! f n9 O- x' g( H; e- D {1 w/ Q4 l0 \- {! v
.active_low = 0,
4 u. T) l& m. m& ~' f .gpio = DA850_USER_LED3, Q/ p! S& l X$ [ U! S$ E
.name = "user_led3",
0 ^! c; B5 H5 H* R9 W .default_trigger = "default-on", i/ K, A* [) h& p
},
' E: c5 W O* R# q2 s, }& Z) C};' G, H' j9 V; b# q" I! k9 _
2 o6 k6 i! ^2 P* astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { E: B8 d1 t6 C+ p
.leds = da850_evm_tl_leds,0 U. w9 E- }3 M& f" \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 T* F4 S; }6 M: u& H/ F};
( P/ Z( `9 N2 a3 y* C3 f/ V+ T: w( Y" B r4 f! a" m3 T( D) h
static void led_dev_release(struct device *dev)3 j. M# H( g3 L" {& h
{' Y9 W8 |' R4 d. a* d
};' \: s* n* y# J
: F% v; ]$ @5 G5 ^/ d& _! {
static struct platform_device da850_evm_tl_leds_device = {+ b! w9 I8 P& V% j3 ?* o
.name = "leds-gpio",& Y# r$ S5 L! o5 a$ t0 g# F
.id = 1,5 q: Y! w2 \+ q8 m7 `9 J9 g
.dev = {% r0 h1 ?3 r$ e) L0 \
.platform_data = &da850_evm_tl_leds_pdata,; I0 D1 t: d* z) f8 j. y
.release = led_dev_release,
2 h, x+ a, r4 O* v- X+ r" k }+ h5 \0 E, B2 H" T$ X
};
# U3 K+ H- {* X# [. M
. r8 Y) J8 k! Hstatic int __init led_platform_init(void)
+ b4 P$ m& X' Z, N% O4 O, u{
; G( O' f$ M6 G& J% m3 g int ret;3 V; @. X+ Q2 g* M2 d |
#if 02 n7 @4 v% i, I$ `. H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 z5 v x/ ?% E5 `' @0 l
if (ret) u6 @1 G8 Z# a& q8 A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 [& Q3 t- J2 d, G b! L# D7 c "%d\n", ret);
2 M. \! H* R* u#endif7 ^* S! [% O/ ?) k' m3 T# Q
ret = platform_device_register(&da850_evm_tl_leds_device);: {# v( i( w6 q0 j" J. e/ f
if (ret)
- Q7 E' ^; H- N- ? pr_warning("Could not register som GPIO expander LEDS");
; b0 Q9 t! m D3 c2 m else
, j2 Z U! s a7 P printk(KERN_INFO "LED register sucessful!\n");1 ^9 M1 }: s9 U* G1 d. d
0 @% G- c" D# i$ @2 l1 _
return ret;/ \4 W2 t9 d- F# b6 r- f+ ?
}. ?+ h& o. H( @1 {8 _4 Q; O' R
$ h2 N2 g! L+ ]5 U* k" ]
static void __exit led_platform_exit(void)
# x; v7 `, Y& s s2 w{, W* n; [1 a8 H6 o" d4 D/ E
platform_device_unregister(&da850_evm_tl_leds_device);
% E% x; r! b" z2 q/ ]
2 O9 O j' ^# g% Q8 ?2 d) k [ printk(KERN_INFO "LED unregister!\n");7 S3 ? W, }2 g1 n
}0 K8 E" h: M' Q$ j7 N) v. r
- ^& x. x: l" r! Y% V d' Emodule_init(led_platform_init);+ }4 ]0 `, M" H" @
module_exit(led_platform_exit);: \' R7 N- O/ O$ _4 H6 W K; h
. ]/ H: X5 B( AMODULE_DESCRIPTION("Led platform driver");6 O' O" p% p9 ^2 y8 X+ K: c9 x$ d
MODULE_AUTHOR("Tronlong");
9 ^. k! X1 _) ?( T8 P6 @3 iMODULE_LICENSE("GPL");
9 e W/ z; Z1 R5 x" B/ l0 E( @- t, {8 [
|
|