|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 a8 P0 s; U9 n$ b" y( ]6 Z* T% }' ]
#include <linux/init.h>
2 R9 b7 A# D& z1 W+ l& E$ E7 G% M#include <linux/module.h>. x8 p7 h1 Q6 N; h6 e/ D
#include <linux/kernel.h>8 J. X% |3 q$ `" W. P
#include <linux/types.h>; f$ w: j" y4 N- J( `
#include <linux/gpio.h>* A& Q, i2 C. K0 D
#include <linux/leds.h>
2 q2 n9 O4 C% y0 y f; s#include <linux/platform_device.h>2 j) M* g' I4 C) |; `& K" l M8 c
& c' N. m7 l0 G$ F& A1 |# x#include <asm/mach-types.h>* A4 U! Z. I+ L! x- K
#include <asm/mach/arch.h>" |; p% L. R- e* d% H% ?
#include <mach/da8xx.h>* y/ k* L% h5 `" i/ G3 t
#include <mach/mux.h>
( b4 b' P, x) d$ t
p9 e [) `$ Z) U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! z# |; Y' t2 L R8 V. A3 N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 O# { Q. ~9 ?3 E: h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 B; h; @, N$ B7 ~( G. V- j#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! S6 ^% {6 P8 i' L# T+ ^# h
# ^% l$ D- @5 N# T3 P/* assign the tl som board LED-GPIOs*/
" R8 C" y& J$ A3 [static const short da850_evm_tl_user_led_pins[] = {
0 i- Y6 t7 q) ? /* These pins are definition at <mach/mux.h> file */
& A; q2 h) z: j* g! y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 ]! y/ J ~/ O
-1
; n8 B0 q5 X0 ^5 s};
7 k( g- L/ s5 R& X* T! v
' O4 H$ v% E2 q" }% _! K' Wstatic struct gpio_led da850_evm_tl_leds[] = {
F% Y* [' ]* \8 Z! Z {
8 m6 n) e7 U/ e. C: u: F( J) e .active_low = 0,- S2 k8 c6 R% e
.gpio = DA850_USER_LED0,1 M( P1 s( S; N5 r8 A7 L
.name = "user_led0",
! a7 f; f# K' c1 Z% C I .default_trigger = "default-on",
2 F0 s: h6 V# }3 B- _8 m },
; o9 U3 g) L( `- E {: V- {0 @' b5 h- d" p; v
.active_low = 0,
, E6 N$ G- O Q/ k7 B; t .gpio = DA850_USER_LED1,
% j M' e& Z# _ .name = "user_led1",* v2 j6 T! j* Z; A, [: ~
.default_trigger = "default-on",# h E# z! ^: K& ` A- N
},
6 x+ x. [" S+ m( ^ {7 e( T- ]5 l' M5 P
.active_low = 0,
$ [1 s. W6 I7 C .gpio = DA850_USER_LED2,
+ V( y7 m" G% m) F5 T .name = "user_led2",
1 A6 |8 H! S" ?( m/ Q+ G .default_trigger = "default-on",
. ?: a! O* A1 f. b) Q },) F: ?2 A+ B2 p; M$ `0 t1 e% C
{
5 \. Y0 J4 X8 J/ L3 Z7 s .active_low = 0,+ J1 x% Q" A# K( }) X2 [
.gpio = DA850_USER_LED3,* i% Q+ X& t6 {& Y6 Z
.name = "user_led3",$ M: F& t8 k' d% Z q( j
.default_trigger = "default-on",
0 K" v4 v4 q; ^% A- Q },
$ m( C5 S) C" K; b( m( [* h};
6 m7 V8 g" F/ ~) h/ k: M; m1 Z+ J I) e$ U# {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! h8 ^, ]4 j! O. r7 J+ R+ G
.leds = da850_evm_tl_leds,7 Z( Z& P* _) b, y0 X& m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 C1 J! N5 R/ H, b8 i};
2 J' u9 P2 g. ^- ~' K1 M6 k
9 d# A$ G* t9 u7 M0 r' U2 y+ s4 ~/ Fstatic void led_dev_release(struct device *dev)7 `4 }0 Y+ F, @9 c0 `8 Y$ [
{
' j. g4 \ G8 t$ r; b( D' c};
1 a0 G, T1 J; q, k4 {* O$ n+ E, w! j @9 x+ P
static struct platform_device da850_evm_tl_leds_device = {
& `' n) e' q$ m3 H; v' l .name = "leds-gpio",) O1 o" v' _' C0 v% r0 A
.id = 1,
# y& }9 Q' `: n2 Z0 r$ j .dev = {
$ s8 [; \# ^9 [. q8 A( ] .platform_data = &da850_evm_tl_leds_pdata," P, ]' V; }* q: A& N- i
.release = led_dev_release,5 H; R5 n) G0 r% |/ }3 i
}
9 T# ~! d: y9 Z0 j! i};
+ t5 L7 f! x* }& M i, ?
/ g* h7 l: q, t ~" Zstatic int __init led_platform_init(void)
% b7 R& U9 |9 B. e9 ~{
, K! b$ c) v. U$ K* P7 { int ret;2 t1 W. g) O/ I
#if 0
3 G0 H& w! G5 V6 K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: J7 R/ o* t+ T6 r# [/ o if (ret)+ i, ]# \6 F* p' u* A9 F2 n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 ^( W2 g5 d) x4 b "%d\n", ret);
# t' j ]8 V5 w7 O# D#endif O$ ~) t/ v' n. H6 B
ret = platform_device_register(&da850_evm_tl_leds_device);
v, O4 X+ W% T) o) M! q if (ret)
r# q9 s- o6 S" f pr_warning("Could not register som GPIO expander LEDS");
& s, q1 n+ ]' ^7 s else, g- [. |( m( q
printk(KERN_INFO "LED register sucessful!\n");' t# d- ]0 v$ ]9 T* d
) E' v2 A% w, `% p. i return ret;
( g" t) ^+ p" @# B. C}5 k3 X! e/ {: a, i: I" ^
) z2 e. o- M) b; ` c
static void __exit led_platform_exit(void)$ }9 D- L9 u$ j3 ^
{
1 H# c& J; F1 m( { platform_device_unregister(&da850_evm_tl_leds_device);& h* L/ A1 e K7 y: c$ ]# ^, W
{% ^9 f# }/ d/ U3 ]( G
printk(KERN_INFO "LED unregister!\n");8 f* S# b7 z; }) T$ x- X( k
}
e" _4 n8 W; _. _9 x0 q N0 @& C7 Z" v3 z( `1 s2 {
module_init(led_platform_init);; S8 j+ x# w7 F" r7 c
module_exit(led_platform_exit);
$ l, o8 j9 J5 c/ @7 W) P3 I9 X# y% ^7 f, A% `) z
MODULE_DESCRIPTION("Led platform driver");
; F. q/ B- ~' V# m- GMODULE_AUTHOR("Tronlong");
K+ b+ B. R( P9 z: K+ Z' c- \MODULE_LICENSE("GPL");
5 T0 L2 n" z' N" x9 r8 A% g- S' j" f B; J6 ]( ~
|
|