|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 _1 {( C9 a" X5 ~$ b2 `- S! p
#include <linux/init.h>
8 U: a/ s: |, c#include <linux/module.h>
8 L- r. o3 u9 N) ~- ~2 Z3 j#include <linux/kernel.h>$ h+ S! L% K) d: A, J" x
#include <linux/types.h>4 K, ^( i7 q( K" v
#include <linux/gpio.h>
! V2 Y2 I1 W8 a; L% f. u#include <linux/leds.h>" A, Z5 ?4 w. | z. k' J
#include <linux/platform_device.h>
1 V, C' w6 P& Z' j/ {, Q+ P
- m# e' g5 ~- i" d; [" k#include <asm/mach-types.h>8 b: E1 l% c( }7 J2 N+ d; g1 y9 @
#include <asm/mach/arch.h>
8 q7 F5 R: P' T3 L, s8 p. g4 q#include <mach/da8xx.h>
' P9 y$ g$ c, n3 ^& n9 {8 m#include <mach/mux.h>9 K6 r/ x( F( E+ n, k5 n0 N
7 T% d: a2 X, t$ w5 J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): N$ [* Y$ i' `- o9 k; I9 T- V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 a# I" u1 `. o6 Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" U3 Q/ _, e: @8 b4 A1 @- A; k5 b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% x5 i& w" K" G* z; l* U8 E
7 B R& ~ ~$ l6 o2 r
/* assign the tl som board LED-GPIOs*/* f% s* D9 R' ?
static const short da850_evm_tl_user_led_pins[] = {
+ n, C* `$ I0 L2 y; T /* These pins are definition at <mach/mux.h> file */2 X; N" r9 k1 M5 v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' u6 H( Y% q% V8 v4 d# Y -1
. U$ c& ~1 r+ a6 E, x6 [ [};
9 p3 ^% C( V! B7 Y* u2 b) U" U
. a9 X6 R) {3 r7 ^static struct gpio_led da850_evm_tl_leds[] = {: j6 q2 ?2 z6 n, H
{/ q* a# B8 ?, J7 q* ^9 Y5 I6 U5 M
.active_low = 0,
$ U Y% W4 Z4 O2 Z6 q# K: t* }( z .gpio = DA850_USER_LED0,9 e. C; y1 ~' P3 D& K, h1 ]
.name = "user_led0",. t- U. Q& u# U7 z- A- g5 E# v
.default_trigger = "default-on",4 q# a9 h1 L6 B" N! B8 ^% w$ {
},
! c$ F5 ^2 D4 A1 w2 N2 f9 \ {
6 z( u0 @( Q% i( M q/ l2 N6 q .active_low = 0,
7 ~4 J( }( y) d' ^8 n .gpio = DA850_USER_LED1,
/ b+ V Y, }# y# a+ E) n .name = "user_led1",
$ Q# {% ]: W& d .default_trigger = "default-on",( I2 X; O6 f& _% z$ S! t
},
" [" Y) W9 ?/ ?& p- S6 {9 K {; n. d9 m- d: G2 h9 c# t
.active_low = 0,
, a% S# }9 J" G% b7 C c+ ` .gpio = DA850_USER_LED2,6 |2 |2 l1 N2 Q+ F! |- S0 F
.name = "user_led2",
2 \6 k' l4 P6 R" s .default_trigger = "default-on",6 p* W: D5 f% ~3 P5 ~/ _
},
% I: H& t# [4 ?# s {
" Q+ U! [! d6 I4 m. E/ m7 f .active_low = 0,! P. k! Z- p* l H( | J: r! T
.gpio = DA850_USER_LED3,
3 m4 e) D6 F4 u( P0 u .name = "user_led3",2 L' w4 {" s( h; ~0 ?- f
.default_trigger = "default-on",6 H3 t: O, [( d
},+ O* n) v: Y- j
};5 m$ N1 v$ t$ c- i; K+ M/ c
/ C5 H( m6 ^8 K) s8 @0 P0 s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 ^- r2 p$ `( w( t* \0 i/ X
.leds = da850_evm_tl_leds,; W* |2 B7 F9 ~0 _: A4 m2 h, N- v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 P% E' w, ^3 S};" s% h& A, D$ ^9 }* Q/ W1 V
8 i: c/ V; g) v! e) F, B
static void led_dev_release(struct device *dev)
% R& Q- y' A) U+ V/ `{
@8 F% J* k- D+ a# ]) J};) c$ x. \7 M9 J! a# h; a. O
8 C. O& ^1 O: h; P. K& W3 ^
static struct platform_device da850_evm_tl_leds_device = { E. q- M, }1 _
.name = "leds-gpio",
) y% E$ `# \ | .id = 1,
8 D1 A# h, d7 a! }' K0 R# c. Y .dev = {
5 z& b" ]% W1 S. E3 E" Y .platform_data = &da850_evm_tl_leds_pdata,
4 j3 C- d& [, H/ |7 v .release = led_dev_release,
( T; ~, o3 `% H4 f }" D( }; W+ D+ D1 Z* g
};
8 q. D6 I) I+ a' r! M- ~/ V% P( {( ~7 V @+ b) L$ G/ @* h4 R
static int __init led_platform_init(void)
8 o3 D. S8 I+ C- H: a{
; x6 i- T* h/ i1 i1 z int ret;
8 k5 x! R' ^ M% x4 x* G7 v$ l#if 0
! e6 O7 p3 j! G# x0 ^$ s( C) e# Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! }& _, k+ b2 R& G& u. f* K if (ret)
! X; l2 V( B0 ~# G- ~8 _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 ~ e( z7 ~7 z "%d\n", ret);
: E2 a% w9 T0 y/ ?) M V#endif0 ]- v- S& j7 }8 a w. |# Y- l
ret = platform_device_register(&da850_evm_tl_leds_device);3 { u; Q7 y' Q& p( N6 }
if (ret)9 r8 N( O, h# _% l# W0 G
pr_warning("Could not register som GPIO expander LEDS");/ }- H* ^: u- z3 u) y
else$ P3 b" A3 i- v, l8 y: Q
printk(KERN_INFO "LED register sucessful!\n");
; E' f( _4 F, C$ x+ S- I' \, c8 `0 E* t4 G
return ret;5 l7 j4 \; t+ G2 y# e
}
. t- L% P4 @4 f5 v/ I' d0 d5 V& W# ~' |5 o, F3 l
static void __exit led_platform_exit(void)
8 v4 Z C* ]3 H) _# o{
: t9 V+ ?. k. ]5 A N X- x5 Z# j platform_device_unregister(&da850_evm_tl_leds_device);* i$ U. J# p" }$ O' V' x
' D0 X% j' ^! g8 ?0 w% A& C printk(KERN_INFO "LED unregister!\n");& i2 j( _% s8 l: X$ ]
}& X3 v% A2 w/ I- A4 W
$ f. M: S/ L* amodule_init(led_platform_init);8 }8 \) S$ g& g- ^
module_exit(led_platform_exit);
& g5 Z W. U* Z2 m2 _( } }/ X2 h: }
MODULE_DESCRIPTION("Led platform driver");
' l9 ~2 i# B" P; v! x, nMODULE_AUTHOR("Tronlong");
3 Y* q. g0 }0 T1 wMODULE_LICENSE("GPL");
2 i. v" Z1 {+ f3 F5 N& a& M5 R1 X* b2 c5 C1 u% H: Y
|
|