|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ ~3 Y D# q1 d9 a#include <linux/init.h>$ ^& C8 X# m) ?. \# a# ~
#include <linux/module.h>
/ R1 b/ T. l- h5 t9 k1 J; i#include <linux/kernel.h>
, O' W0 P. I( Q1 ~5 w1 B8 T8 o#include <linux/types.h>
! y: G5 P, W; @/ u% K0 M# _% D#include <linux/gpio.h>8 `- e5 U# c' f
#include <linux/leds.h>8 k: M$ k/ J* K* @
#include <linux/platform_device.h>: O! x/ U) Z; Y, B
8 c/ \$ _3 v& g& O; U. Y" ~9 `#include <asm/mach-types.h>4 G! g5 t8 M- X4 B
#include <asm/mach/arch.h>
' M, V$ p7 ]. m0 M3 U/ n! n#include <mach/da8xx.h>" d; W% l6 ~% O: ?; a, N
#include <mach/mux.h>2 r" G& N5 m y; ?! _3 m2 }) h
: a" A% ^9 |% J" k7 [, x6 m! {! c
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). a9 G5 |/ h2 U$ W4 t& n+ {/ m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 I- g7 v' N& x1 @. q" H1 v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! I" P- D" G, g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 A) q( {1 R* J
- k7 G' Z$ r; U: d* ?* i. G, H/* assign the tl som board LED-GPIOs*/
1 z. l; I# J b, W8 {% } k% `( Estatic const short da850_evm_tl_user_led_pins[] = {
/ l6 ]& [4 I2 z5 ^" w /* These pins are definition at <mach/mux.h> file */
" i5 |0 p2 Y# A$ o! p, ~2 V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) W0 c2 N2 ]/ D! u/ y" @: K -1
* E0 m, d+ I* n! s};
" @5 K5 n# S6 r% h2 c
5 b6 a& A* @! K2 j; _1 zstatic struct gpio_led da850_evm_tl_leds[] = {9 s; {: p4 O6 B4 i; R' P9 F
{
' e% Z- Y* c) q0 J, u" C9 I .active_low = 0,
x2 q) [/ B/ t. N .gpio = DA850_USER_LED0,
4 ~+ @ y5 N7 ?% \2 u* m0 }) I* p( ] .name = "user_led0",6 y3 r0 G) r4 H% @. n9 p3 R
.default_trigger = "default-on",
) ?% a7 ~* S8 r6 Q/ x0 ] },
2 j. F$ o- E- q* P {
9 v$ a) G* S; `0 F$ V) i8 U' h .active_low = 0,# _8 w- l' x/ K
.gpio = DA850_USER_LED1,$ L2 H( t+ w9 j" [9 y
.name = "user_led1",
2 d/ U6 i T1 e4 ^( Q3 {# W% S .default_trigger = "default-on",- T9 ~$ u& r1 ~9 U
},
) F, `/ c4 m3 n7 ]% m4 a9 M0 y4 T {+ N, K- Z$ P' P7 s' V, ?
.active_low = 0,( |) x# A. R! r, m% I. b
.gpio = DA850_USER_LED2,
8 M+ r: i) T, U' V* ^* T .name = "user_led2",5 _2 Z/ f6 V; ~+ u3 C
.default_trigger = "default-on",
1 B) W, d7 r! k% A1 W },- I- t) a: c* g9 t7 e) h, _. D
{
9 S5 x! y9 V; M$ d/ k4 _( Y) N; Q .active_low = 0,
?/ a3 i7 ~! v5 P9 E; |) O .gpio = DA850_USER_LED3,
# I. o9 O8 F+ R" \' R5 n9 j .name = "user_led3",1 }9 T2 E0 q# e Y' F1 n$ K9 W
.default_trigger = "default-on",
2 l+ D( b2 N9 a4 w. P2 Z! N },3 o. w$ S2 Q. i7 d+ {
};' V% d+ t+ R7 I7 Q# R: k
I! T8 h: R& E* `% i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% y7 _9 C6 n/ x
.leds = da850_evm_tl_leds,
) f" C: J. ^+ M5 H- ^% o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ [- z% _* c6 k9 U* s( F9 D
};* Q, {* Z M& D* z' @$ w6 A
: V4 H* z. C4 m% F, y) ]9 W" a
static void led_dev_release(struct device *dev)2 `/ I. w4 g }! ^! r2 g6 _. }, \9 M' z
{
* _+ [# \/ _+ m. G# _) r# k};
, G" T# R2 B9 Z, a/ R, Y
2 o7 Z) Z# K7 m9 e9 K6 Y8 `! Estatic struct platform_device da850_evm_tl_leds_device = {
# P- A4 M) h/ b' m! M .name = "leds-gpio",! o0 }* X1 J8 d$ C( ?0 ]+ Z# G
.id = 1,
a. N/ _" e5 d4 G+ ~; b4 f+ s# [ .dev = {
& u. q* c' j! k n' W- q# H .platform_data = &da850_evm_tl_leds_pdata,
) f7 V5 G- L- }8 J; O .release = led_dev_release,$ l( q9 f( m4 U# P- ~. @. d
}
; U+ K# }1 w1 U8 K* G0 S& N. R};
/ [9 b( E+ u J5 x% m/ z: M, [. W
8 g- ^0 M8 G, s( Nstatic int __init led_platform_init(void): k. g# P6 \/ y" I4 \8 C
{( j5 {: ?4 n" r# G; W8 {
int ret;; T3 ^) o, H: F9 C, Y% E3 V, P9 Z
#if 0: F( X* L5 x/ K! x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 H j# ^4 h D' U0 ]. c3 A if (ret)
( ]$ p0 t- d( q) {% i: T& f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 m' m. F. L% V0 C7 E% w "%d\n", ret);2 Q* x8 V1 ^5 I: Y
#endif) l- n# c6 b {* o5 i! ]$ {& T
ret = platform_device_register(&da850_evm_tl_leds_device);
. Q& k* T) B* T! O1 i0 T* o if (ret)
1 i4 y- A7 a& D s9 y0 ? pr_warning("Could not register som GPIO expander LEDS");" }& c, B" A5 S; G& ~* S
else {; m; H/ M5 L6 @( g8 E) o
printk(KERN_INFO "LED register sucessful!\n");
$ u9 n* B5 z# y. O% B0 n4 A. q9 {5 `2 f
return ret;
" e0 }0 J6 o( h, @( h" _}
- H& z8 u1 A* I8 g! N# V' @4 ^- V6 ^! n9 w) G2 i$ L% M" |5 P% M( @
static void __exit led_platform_exit(void)
. B+ E- ]# ]- |- r e2 m: \. ~{9 Q- V/ } G! l, Q# ~
platform_device_unregister(&da850_evm_tl_leds_device);+ C3 `6 E, P' \5 o2 \5 n
" y4 q& n l5 I6 y5 x
printk(KERN_INFO "LED unregister!\n");# E' X, |2 \& E" \
}- Z/ y a3 H1 x% a6 |5 G/ f
$ R( a: z) i, l
module_init(led_platform_init);
0 C+ e0 c- x/ }, S3 ?$ W; [" amodule_exit(led_platform_exit);
V8 V% s. K, `5 k# n4 D- n1 F" r, U, e
MODULE_DESCRIPTION("Led platform driver");
- y( ^# k7 s2 P8 d( l9 Z) a3 EMODULE_AUTHOR("Tronlong"); \& v! p* `/ E; e6 \, [& O5 I0 M0 R
MODULE_LICENSE("GPL");6 [ r# m; ]$ z& n- G/ i
& g& P7 O) k# J, T
|
|