|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 _( { c4 d! R b! c/ [4 `#include <linux/init.h>1 d- d& g. l( V
#include <linux/module.h>0 G% i" _- F3 u$ M. c
#include <linux/kernel.h>2 ^) d# ]3 T( N0 J& g, p. a# r
#include <linux/types.h>) `6 j7 Y$ c$ p3 S& B2 U. [2 w; o
#include <linux/gpio.h>4 l6 Z% ], j/ ]8 D
#include <linux/leds.h>
7 ^% M& K, W9 W. z6 b#include <linux/platform_device.h>
% K+ L2 e; ]8 h9 I, d/ r! v ~
* @" g, D8 t/ d' g" {0 s3 A5 z#include <asm/mach-types.h>
2 Y5 t# y& S) _#include <asm/mach/arch.h>5 ^% N9 m/ O; x& O% i8 O9 u8 n
#include <mach/da8xx.h>. h# `4 v2 `' Q
#include <mach/mux.h>5 ^' S' L/ I4 U# T d
7 n; I% I4 h$ N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( T- l# |' e3 m# C3 B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: |4 n# c: k. ?$ T/ f$ s#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- P+ b+ l) L# j4 g
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* V' J5 J* F1 H& Y& \
1 N6 B9 a* V+ c, A/* assign the tl som board LED-GPIOs*/1 A' I2 A6 f @& G/ ]9 u
static const short da850_evm_tl_user_led_pins[] = {
5 j$ }* s) `6 ?% c# ]) O! ~ /* These pins are definition at <mach/mux.h> file */% w2 O2 s" c2 S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# n& d2 i! f0 V; R -10 @+ |5 I/ C& d: K1 _
};
% F" b, z( s' u2 p$ R( o- k. J' f- _3 r7 R! f
static struct gpio_led da850_evm_tl_leds[] = {& y: S' ~% \8 J# ~
{
' K8 J4 b. k: V+ B8 [ .active_low = 0,
6 t+ h' i( x0 X; w' u9 S .gpio = DA850_USER_LED0,8 q& a( `$ u6 e1 w$ v6 N" S
.name = "user_led0",
h3 }$ k* T$ x( C! a' \& b .default_trigger = "default-on",- u9 x" ^% }& j, P
},
# D1 H& |2 i& K- k0 }3 B6 ~/ j( b {
5 f" ^, _ Z6 X/ L8 @8 D .active_low = 0,
* F# G& e3 J5 h4 z .gpio = DA850_USER_LED1,+ l8 Z F9 \* t7 L: G
.name = "user_led1",, C8 Y& M% ~$ B) i* w- i
.default_trigger = "default-on",1 l& O) @2 O9 m& K3 G4 ]: I
},
! E3 M" ~& D" R" U- C$ v8 ? {' @. W2 @& S& L" V4 Z
.active_low = 0,
* B! K/ e8 i! B .gpio = DA850_USER_LED2,! g! Y" n% z/ R$ v" R2 H! x
.name = "user_led2"," v: L. ^; g1 U% P6 L& B: T
.default_trigger = "default-on",
" Q% Z! ^2 s, ]0 v },
M: I# q' \5 |2 p7 h; \ {1 x p8 `7 X; E5 c+ v, O
.active_low = 0,; p" [& S L0 n1 I" M
.gpio = DA850_USER_LED3,3 ]/ ?6 p) o, d! O0 O
.name = "user_led3",
6 s( L- d+ d. p; i* ^ .default_trigger = "default-on",6 `6 L, e( f/ U. E8 \8 O
},
N& g0 l2 W: t% L" @};, x9 g/ u; s1 o
7 H9 \3 H/ P8 ]8 q: S% u! T0 Z+ N! j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 \; x1 a" Z7 C2 {1 `1 T
.leds = da850_evm_tl_leds,# j8 f8 O+ T4 ?7 X; ?$ }$ R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 W/ Q8 P, b5 P5 J2 S" h
};
- J; s1 K8 ~# @, Y; k6 e# ]; p
R9 k4 h6 J- ]static void led_dev_release(struct device *dev)* W0 _4 t+ {. |: p
{
2 C5 N+ D+ W5 e" b ], N1 p};
1 M( x n4 _; M( m$ v, r6 _7 ~2 ^" {9 X0 e. d! ?; V
static struct platform_device da850_evm_tl_leds_device = {2 J- h/ ?& Y/ N, c
.name = "leds-gpio",
+ l+ n% L1 K5 \: X .id = 1,0 R2 p3 a5 c% b1 o) S
.dev = {0 {$ i' s3 k0 Z! O0 {* R. P4 o
.platform_data = &da850_evm_tl_leds_pdata,
1 I$ }% X0 J) R) R+ u% q* Y .release = led_dev_release," c% n5 i8 u: x4 k! [. T
}- n# w5 N! r t/ U! I6 e# v8 P4 M
};
+ Z8 D) d) {4 a
: {% _3 y# \9 o# ~- Fstatic int __init led_platform_init(void)
, @1 j( a4 [! E) Y( L, n! M{
- W ~/ g6 D4 P0 v/ }0 @8 N" S int ret;7 y7 k1 P. Q8 ]2 x9 O N% t0 I
#if 0' s6 V, @( S0 X& C8 U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 v4 x. O. o, @3 P6 y' s6 p8 X
if (ret)
% o! Z. F6 J$ e( I. Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ p9 N4 U+ d5 H- {$ U "%d\n", ret);
$ s9 E$ m$ C8 Y1 e% G4 i#endif
. s5 Y! ~7 l: |/ F- N* B( s3 E% s ret = platform_device_register(&da850_evm_tl_leds_device);
1 H* A! D5 K9 j3 s1 R if (ret)
' F! b$ M) j$ W- B& h pr_warning("Could not register som GPIO expander LEDS");
# h% ]$ W: |# C% ?6 c$ k0 r else
& L) i* Y- s5 _3 v printk(KERN_INFO "LED register sucessful!\n");
- c1 z+ K- \# q, M5 z3 F# M0 F' f' o+ X0 X; h3 X5 Q
return ret;
9 w5 A. h" ?! z# q}
& ~0 c U" Z* t( | d
+ o# p2 D/ A2 m. s; { n2 lstatic void __exit led_platform_exit(void)
; ?& u5 |. y3 F. N) b! E{
6 W7 I3 B* _; u) m, p platform_device_unregister(&da850_evm_tl_leds_device);) l' [. y- e1 J# S# h' z
( H7 M, p5 z, x( C3 R9 r printk(KERN_INFO "LED unregister!\n");$ @ j+ t7 a! f7 G$ U+ d2 c" M% m
}
. D0 b- P1 v, _0 g9 r0 N6 `% \1 P* h: X I8 `
module_init(led_platform_init);* B2 y; K1 T3 W6 m+ e& @- K
module_exit(led_platform_exit);
9 Q$ W0 y9 J/ E) |
- V( x6 ^- _5 e: N$ t, d2 `MODULE_DESCRIPTION("Led platform driver");
5 X) y, A: T2 z# ^MODULE_AUTHOR("Tronlong");
) S- A) Z$ q0 w7 eMODULE_LICENSE("GPL");, K* s$ b# A; [; R8 M' H
# `3 I; O' d! L4 y) f: _0 X5 b: a
|
|