|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# v! V7 m* y- I; Y0 V#include <linux/init.h>
% R1 f8 S# [ [. A#include <linux/module.h>8 X+ d1 I1 g! i6 O+ S5 H& c4 f
#include <linux/kernel.h>
& @: M9 a% S9 }+ U9 T+ U- F" ^& Q% d#include <linux/types.h>
: f) R& Z1 b: v" W; e+ r- V, f$ v9 G5 {#include <linux/gpio.h>+ s! ~" J7 A3 s# n( a% j- T
#include <linux/leds.h>
2 ?6 S. v9 h/ _( n) S! C#include <linux/platform_device.h>7 [0 }- G# c; G
8 X k' Y+ `- @
#include <asm/mach-types.h>
4 t+ o1 \2 w' ?0 K3 g4 n* _#include <asm/mach/arch.h>4 _, }. W- }8 S) O4 B
#include <mach/da8xx.h>
! X7 h/ a8 {3 E: t3 c#include <mach/mux.h>
4 |% K/ U6 R5 O2 l& W2 i' ^
- ~/ A. @$ ]( n% {' L! D) w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% \5 ]3 O- T% f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ i7 x6 i+ y1 k* {# W" a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* z- l. |! }8 s& F$ y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ w* G1 f, w% P& ~! s# k+ I/ @8 P
+ U$ B0 W d( `& O' C4 x& z3 k
/* assign the tl som board LED-GPIOs*/
4 w0 n2 k! z4 E/ A8 l' a; Cstatic const short da850_evm_tl_user_led_pins[] = {
# a4 Y. Q) V' ~+ k, G' c* t /* These pins are definition at <mach/mux.h> file */
$ W4 z: q, l" K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* @2 p# `5 t5 l+ d/ V* v2 v
-1) Q4 k0 H2 K; |3 T& W. K2 `
};
0 A2 S5 r' H7 W% H( { D
- m: }- }" P0 M- }. Ostatic struct gpio_led da850_evm_tl_leds[] = {, b! l) k' ^8 F% T
{2 G' {: j3 D8 `/ q" t1 I& k, z( g
.active_low = 0,
% Q% A7 x! v5 k* w .gpio = DA850_USER_LED0,* J) G4 f3 I. G9 X3 A! N6 W1 M' G
.name = "user_led0",9 ?: R7 a6 q% |8 n
.default_trigger = "default-on",# K( _+ l2 \9 _* s9 y4 T
},
1 x- `$ q: k" \9 Q& u+ d* G {
, i+ @$ } c/ ]0 q .active_low = 0,3 q( |' n5 D0 _8 w$ o
.gpio = DA850_USER_LED1,6 ~. U. x: X6 I) f# T" s& D
.name = "user_led1",1 n9 X& S1 f! w8 ~% J" ]$ i% s
.default_trigger = "default-on",
7 I$ y, J- W/ B( w8 C },
y0 u4 R0 j: i! Q6 Z6 D0 I& v {
0 ?/ A9 ]3 k$ M5 o! @- g2 ~' k .active_low = 0,
" x: Y/ C* B- x, ]' ]# a+ \ .gpio = DA850_USER_LED2,
9 p5 f: k* l% {5 ?% a7 B .name = "user_led2",
3 X N5 M6 W1 Z/ r; T; T" n .default_trigger = "default-on",
9 B( ]/ |1 M3 ^ x },( Z f" B+ V: _! ?) k8 C) K
{
/ f# O) |5 e! S5 j" F3 y# ^ .active_low = 0,
! S) n7 E/ d% m. T1 P2 ` .gpio = DA850_USER_LED3,
* A1 u3 D; z& p' Y .name = "user_led3",
) M; ~' `) l: Q1 Z: F/ {+ F2 E .default_trigger = "default-on",) m9 W9 c5 T, A- W
},& {! \# Q. q+ Q6 T2 [, A+ x
};
# O" B, o; C; C% w9 q, e7 _+ `) J- R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 \) L3 D" I9 l0 Z9 V. f# z2 g .leds = da850_evm_tl_leds,
+ c+ r' ~" @* U' M, K" p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) I6 o+ j4 w i# `/ P8 d, q" J
};
8 g9 P- e C w$ B% ~4 c2 ]- X3 o9 _
0 m& X/ K# l" a M. Qstatic void led_dev_release(struct device *dev)
! Z: {1 V2 l3 v6 W ^ k0 T8 L{
& G& o( ^8 \0 p};( ] g& b9 i5 e0 E% u
0 n: z+ ?( c& W2 |- y
static struct platform_device da850_evm_tl_leds_device = {3 n4 ~$ ]) Y& ^- I4 s) I+ f6 X) S
.name = "leds-gpio",
# x' I; F: e/ c' k* i( t+ y/ I9 t .id = 1,! C* q: ` C; {: H1 d5 ^& M- X
.dev = {
, V. H1 P. O6 r; G .platform_data = &da850_evm_tl_leds_pdata,
8 p$ E6 v) ~$ w .release = led_dev_release,! v ]6 I% _' d
}
% ^, P, V. S/ d};8 c+ R7 {/ A2 A2 c$ C7 u$ s( K
/ b6 _5 D- V- v1 J
static int __init led_platform_init(void)4 p7 y7 Y! @/ d9 r, O7 o; m$ J
{) |; I/ Y9 I Q2 z' l9 _/ r+ j
int ret;
" S% }, Y( W6 J9 k1 A% H#if 0% [2 h, g+ H' P1 Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' u* E- v2 M6 \/ N r" Z
if (ret)$ T# C3 |, l) L# m& @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" M" t& ^/ h e- I7 W
"%d\n", ret);! e' V$ i" X5 A7 c' t9 E2 f* a
#endif
* f1 }/ _" K# U' |( q* |- h1 { ret = platform_device_register(&da850_evm_tl_leds_device);
( b! N n% X3 L2 ^* f if (ret)
. p; W1 q1 _; p" V8 P$ B pr_warning("Could not register som GPIO expander LEDS");
- s2 L" J3 k D4 Y" z# | else f2 e6 }$ ?% x. W; ?2 l' ^0 A1 ^
printk(KERN_INFO "LED register sucessful!\n");: r, D8 C6 K* `* U- T
& r. P. a+ N6 e9 M7 P# Z1 t return ret;# v- X: B( A8 T7 w
}% U& h1 Q% W% o( ?. a' f
( h) ~# F/ X2 Q6 {9 lstatic void __exit led_platform_exit(void), H/ h3 u% Q; d+ K! y
{6 z2 J4 ^. Q* [( k4 o! ?
platform_device_unregister(&da850_evm_tl_leds_device);
) t: b* t8 C' R0 M2 t4 n% x' i) J8 d. p! T3 s, W1 w
printk(KERN_INFO "LED unregister!\n");
" f6 v4 I) s. |6 f}
( ]( t5 f$ u, M
, L8 V8 \ J. ~( p. ^, `& n8 m7 Imodule_init(led_platform_init);
. q- d1 J2 e3 umodule_exit(led_platform_exit);8 |: O' w8 S" e! e% i
3 ]9 f# V9 F! X( X8 C& |) U
MODULE_DESCRIPTION("Led platform driver");" b3 s# } x. l9 r+ {% e
MODULE_AUTHOR("Tronlong");+ L) M" @( B: e2 E- m$ y$ f- l
MODULE_LICENSE("GPL");, G! n# v$ V: k( k
* X/ H4 ?. d, e |
|