|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" D' q& V9 o3 S#include <linux/init.h>
! d/ P) o w% w! {9 Z( ~#include <linux/module.h>
; W$ v* q1 q/ B: ^# h: f#include <linux/kernel.h>
$ @6 a, J5 |: h3 d# S#include <linux/types.h>) c* d# q) E" ?4 ~- C! M' u/ \
#include <linux/gpio.h>& X+ g8 g1 D1 N% x) _2 q& }+ W: [
#include <linux/leds.h>
1 Y, O7 [$ o0 i( z' {+ |( T#include <linux/platform_device.h>
% R5 _! r4 x1 p- r0 W, I
* ~$ G9 x! [3 h# |' u8 J% [9 [#include <asm/mach-types.h>! l0 c& `7 Q7 c( B0 \; J4 }
#include <asm/mach/arch.h>) r* z0 S8 K2 D* K4 d; v
#include <mach/da8xx.h>- x2 e/ Q' m) I, h
#include <mach/mux.h>5 F3 z+ O1 J7 [- w
1 F- f- n: S5 ]5 H
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 H- I1 A$ O* R! x5 I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# O4 u& a! Y. K3 Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 d- i" U' |/ P: j) B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) R( R# p" j4 w$ x4 W/ u# r! X6 ?8 v3 i& k
/* assign the tl som board LED-GPIOs*/
8 a# b2 ^: M3 d& q# d2 h' d* istatic const short da850_evm_tl_user_led_pins[] = {
* E( x+ ~: n7 h, d4 T( B% _# X4 J; Z /* These pins are definition at <mach/mux.h> file */
8 Y2 v* c: H$ m0 ]* f, f: @$ J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- W/ {/ _ f. {4 o5 u -1
) e/ [4 U* B0 ~1 E8 M! ^1 @};
& b0 E' j% W2 g S7 q/ e9 T
) c& c% B: K6 H1 i$ zstatic struct gpio_led da850_evm_tl_leds[] = {
: j+ ~. X6 {- R' O2 O% a {$ s" n! b0 }9 ~
.active_low = 0,
+ p- S4 V3 Y9 } .gpio = DA850_USER_LED0,4 g9 D' k7 r Z: a7 k
.name = "user_led0",
6 v% g& P" `( i6 M n .default_trigger = "default-on",
+ I$ b- e8 P$ G- n- N; T9 H },5 k. D. v; P3 Z
{
3 X8 D1 \, n( S. { | a ] .active_low = 0,
& C( Z# p) B$ O6 u0 h r# H: K .gpio = DA850_USER_LED1,7 ]% b" ?0 B; x2 f- |3 v
.name = "user_led1",
6 r. D( c+ P/ p! w" V .default_trigger = "default-on",
6 [1 C& E T/ A: T. M! N- O! C },6 m5 s, }$ f+ g, Z9 Y
{
0 x' ?2 z7 `& s9 Q .active_low = 0,9 `9 `) B, q" g0 ?2 E+ t+ ^
.gpio = DA850_USER_LED2,
: v2 R5 u/ v: o* e0 d .name = "user_led2",5 N( b7 y9 t1 z* q/ b7 q
.default_trigger = "default-on",1 g1 G K" d1 E2 r" J
}, u+ u+ ?+ Q0 W% k) Q
{2 l8 W) v% z" X" j5 z% q
.active_low = 0,
8 y% e8 B, c& G .gpio = DA850_USER_LED3, C- J/ Z& O# U
.name = "user_led3",: X. t- B& V( O7 y$ b
.default_trigger = "default-on",
+ O) V o$ n" N6 ]- z1 F2 S. o$ c+ N },
! p+ ~5 X" {# A' F1 j};
- j$ v4 t$ y: ?9 m2 Y2 B2 y- D
9 n6 J) z8 [6 y* B" _" j% _" ~' P J9 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 T( [- @' G. b; a
.leds = da850_evm_tl_leds,
+ E8 L; l6 B7 i' N8 X: g" p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ Y1 M" }6 ~. d! k+ }, C& s};
" ]- d3 T" ?" N# W$ _" u) |! _& v3 ]
, Z% w+ n1 I5 ]) U, Cstatic void led_dev_release(struct device *dev)
- x, U5 f3 F1 @1 Y# C{5 a1 r7 f0 ^) X9 `' W+ [8 \! y" ~
};
5 Z2 q) Q0 B5 e }9 h( ^# j: O4 D5 L# L; h1 T9 L+ ~
static struct platform_device da850_evm_tl_leds_device = {
/ O& _% F+ {" a/ _4 ~ .name = "leds-gpio",5 y5 `1 d5 U- b% N
.id = 1,. x% A# `/ K- @% E) N
.dev = { ?$ B4 E P; L$ M" p w
.platform_data = &da850_evm_tl_leds_pdata,
) P7 V( F' V' z+ p/ ]' a .release = led_dev_release,
5 m2 O! ]8 C1 T9 R }
! o, [2 n. g3 P W};
6 m: @% c/ A6 |( J6 m& s6 [+ @3 o( N
static int __init led_platform_init(void)
( R R; n8 I5 H4 Y* q {4 e{' X/ M% J, K' V n7 U' V
int ret; O8 y4 v/ R9 N- v& U
#if 0$ ~( v. t8 K" G% Y4 { ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ C9 L m x( r$ ]5 l
if (ret)- s: ^; V1 T) L$ Z9 H2 X
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) f- o. ^, m# P" r- D "%d\n", ret);7 P: E) z& j4 B c
#endif
7 u' U* B) U5 H5 } ret = platform_device_register(&da850_evm_tl_leds_device);2 a- @8 ?9 Z/ t+ i# H" e' f; h
if (ret)
0 D2 x. Q. M" D& n% ~ pr_warning("Could not register som GPIO expander LEDS");8 q* p$ X% P. q& O- r
else
! x& W1 s/ X6 K printk(KERN_INFO "LED register sucessful!\n");
) u, H8 V/ F" E$ ]
( u" q6 ~+ K2 w0 H% T9 k8 X return ret;
/ t/ H; x: I E}8 y. L' ~% x. _" X
7 B4 k( f' Y% X7 E, g6 j0 ]static void __exit led_platform_exit(void)
; ?6 a; j, h9 U t/ ~# P( D{4 _2 M# ~8 j2 \) |
platform_device_unregister(&da850_evm_tl_leds_device);, y3 Q/ Q3 C% A% r |1 [& v
7 y9 ]' q9 n" d5 c: l3 Y printk(KERN_INFO "LED unregister!\n");* J; y! S0 _: Q0 v* {5 u l1 m) @
}8 Y% Z+ H9 I( T8 V/ a' v% ?% o
# m5 d# Z, ^" V. omodule_init(led_platform_init);) X# J% Q1 H0 K% ]
module_exit(led_platform_exit);
# I! s5 B% {0 L1 W. L" G7 b" J0 F# }2 B! w7 A9 j0 t
MODULE_DESCRIPTION("Led platform driver");% }/ e' {( K- f/ M+ L5 I/ p2 t( n
MODULE_AUTHOR("Tronlong");# p! t5 h& M" z+ O, a7 q4 D
MODULE_LICENSE("GPL");" b7 C; ]! G+ p) U7 ^
. _8 p+ A% |7 ? |
|