|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! z; Q, B, ~0 d5 F: I' ~#include <linux/init.h>6 A( q) U7 Q p1 v6 E
#include <linux/module.h>" U) P( V9 n& l# \: x
#include <linux/kernel.h>. U% r0 |* H/ \9 I2 T; V# M
#include <linux/types.h>
6 j* z6 M9 A" m/ q" b#include <linux/gpio.h>
% ^6 U1 b9 h: L$ l#include <linux/leds.h>' S+ ~: X5 e" `$ }
#include <linux/platform_device.h>
2 q1 k0 B+ N" R5 j0 w" I) f8 n& Z7 ]7 M/ e1 z- Z# ]+ \
#include <asm/mach-types.h>- ?8 ]" D9 p% Z8 s1 g
#include <asm/mach/arch.h>: n, v" N O3 ]' { o3 z
#include <mach/da8xx.h>
# r: {# j' |# j8 l, P#include <mach/mux.h>
, L l n; C. b1 B# B8 ~' W X( B/ e6 }9 {# C2 _5 Q9 n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* }* J9 L, G3 f: X- |% C; n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: v; h+ U& Q7 |7 l; h& H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% N/ W8 K6 \; h, K5 _1 m0 F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# S9 ~) X2 ] X$ u6 s3 V) e' J, d! l. |& Q. o2 ^
/* assign the tl som board LED-GPIOs*/
. t" x z3 \0 C. Estatic const short da850_evm_tl_user_led_pins[] = {
! P9 k" e2 n& U2 k6 o5 o /* These pins are definition at <mach/mux.h> file */
* n' S8 `- l. o+ u2 T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) M3 }0 Z9 i( X; g$ _! v -1
" G' n$ ^ ]. |( n4 f};/ V9 F- ~4 [8 u w( O( B
4 q; Z5 F: V+ |" d# X
static struct gpio_led da850_evm_tl_leds[] = {
* R& E* I( _" |3 a8 E4 X" K {
, E* |! a o* { .active_low = 0,' Y3 ?8 Z3 i. U
.gpio = DA850_USER_LED0," W2 f7 K) Y+ Z1 v0 s3 Y2 t
.name = "user_led0",
$ p9 [5 \3 M, d8 H .default_trigger = "default-on",
9 N7 g) `$ ?$ j; m2 C7 [7 } },: Y# r; X& J0 X0 K3 I. O9 @
{ q0 M8 K3 K, c. f, _; `
.active_low = 0,( I2 Z1 P' _# Y9 J$ h& `6 {
.gpio = DA850_USER_LED1,4 M$ ~ |$ S9 n+ J
.name = "user_led1",5 u8 n; \( W# }) @: S* a2 h, m, D9 k
.default_trigger = "default-on",; s+ w$ }& [4 F8 M- k
},, F# `% j" _* ~$ |2 [) F' D
{$ s3 `/ r9 g7 s6 K& t
.active_low = 0,: w) T5 O7 E: o) u
.gpio = DA850_USER_LED2,
- n% `) Z1 R+ g9 l* G. M .name = "user_led2",% s0 @8 \& m* w) {: c: _
.default_trigger = "default-on",
4 w; r- k7 _, z, c' u# v' S7 J1 { },
: \& Z6 w5 I. w# J {
* q8 I, J. o1 V& _ .active_low = 0,* d) @: w. f8 Q. W2 d8 R' Z
.gpio = DA850_USER_LED3,
. V4 J) R2 U) ~5 k5 R. L .name = "user_led3"," C" m; N+ j" h
.default_trigger = "default-on",
, ], i0 K' f5 s* u6 [9 O$ k5 B: S },
4 n; }4 ], P$ _! W" @};: k& ?# P# K7 _5 _" [1 |6 m
& p7 D' l, V" F9 I' Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 Q: u6 [3 e4 [8 j/ h- D6 {, { .leds = da850_evm_tl_leds,. \0 _) {4 M5 U# k% z, m( J& q6 r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, [' g) z- Z& N% M2 n2 U" E};
# Y9 }0 H, E: I7 L- r( b4 g
1 t% l9 C0 R6 M3 E1 kstatic void led_dev_release(struct device *dev)
) K0 ] b5 U: Y# E% V4 b, v7 T3 e{; a9 ^7 _0 b+ P5 v, \
};& o* u4 P; f1 x- u/ S: b
; l% B* j+ h% A# u8 z$ t/ A9 ^static struct platform_device da850_evm_tl_leds_device = {6 n2 S0 Y; \) t4 u
.name = "leds-gpio",+ x- I; X8 C& E
.id = 1,: N0 x+ p4 o+ k8 N3 X* w
.dev = {
. v$ V% @. G# F0 y( w2 C: d7 d8 C .platform_data = &da850_evm_tl_leds_pdata,9 q7 E+ [# H0 @9 ^8 W
.release = led_dev_release,3 p( L {: ^1 h5 z( @4 I. B* |
}
{, @' x8 D/ ]$ v2 Y* x};
' p: _; q* [9 @) N$ c$ n5 s
" r) I; j0 [9 P$ W9 `2 ^& C$ E$ b- estatic int __init led_platform_init(void)6 W, @! d2 H7 O# d4 n. R# z
{3 l& s7 x- m: R2 T4 b% T: v5 [
int ret;
$ ~7 t, Z1 M1 e#if 0. S- r! f: r. V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' h0 F3 n, W! k5 a$ V8 X# z- h8 l
if (ret)
$ J- p U2 k% y4 A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' l' _# H4 j9 o
"%d\n", ret);
0 x! l: @( T5 h4 U, t#endif
# `' _6 v: |/ ]# A: @: S ret = platform_device_register(&da850_evm_tl_leds_device);$ {/ w* c$ j8 w8 N* Z
if (ret): ^2 r9 j2 t' P
pr_warning("Could not register som GPIO expander LEDS");
' F( Y" a% T. n' g else
5 l1 w- Y: H7 T% { printk(KERN_INFO "LED register sucessful!\n");
) V: |% J- I; a) o. I- ^5 Q. Q$ d5 V5 j7 O$ j' |
return ret;
! P. v# f0 Q5 K) D3 R: R" [}- M; }/ @) B; l9 @. w% i. A
# @0 _) i! }" U& nstatic void __exit led_platform_exit(void)
- u/ B$ c( V5 B- c' d5 W{1 b5 n! c: x1 q) G
platform_device_unregister(&da850_evm_tl_leds_device);% D- T0 f2 |' K0 C- d: r8 m; j6 e
0 h4 @& b* E& F# b& Z printk(KERN_INFO "LED unregister!\n");
: y. B: m9 y0 Z l}
8 w/ P) @. d2 c" S' G
3 m" ^% }4 T7 ^9 D% Ymodule_init(led_platform_init);
/ A0 ]% }& B( s0 cmodule_exit(led_platform_exit);
# w2 }, J& M4 B/ V+ c3 ]
6 c, W8 ]% U0 l _ }* l, VMODULE_DESCRIPTION("Led platform driver");; t% s5 X4 [7 n ?# A( m$ ^9 _! y
MODULE_AUTHOR("Tronlong");, N+ N, O3 `9 y% P& M$ h3 B! w
MODULE_LICENSE("GPL");
; X0 y& y- G5 [
3 p7 U. i2 k/ N( Q9 D |
|