|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, Q) C1 M! u. `#include <linux/init.h>
! ~7 }8 E/ K' s0 G( J#include <linux/module.h># f8 }. a' ~; m+ y& S
#include <linux/kernel.h>) c9 Q# h1 @1 R) u" K. l: g8 v
#include <linux/types.h>$ x; z' ?/ @# Z9 o G2 e
#include <linux/gpio.h>& ?3 q1 E( l# C7 y1 m
#include <linux/leds.h>7 ~( t; [8 A9 E
#include <linux/platform_device.h> q' ^" ^/ a' l3 {
, Y8 x; k9 U+ }1 X4 ~# s
#include <asm/mach-types.h>$ q" s" Z/ G3 y# T) I: i0 V% w
#include <asm/mach/arch.h>2 t/ a# `4 O: H* d
#include <mach/da8xx.h>
: E, x( E# e5 [' u7 d& T/ v5 w3 M#include <mach/mux.h>% l& x( ^ {3 ]# n2 ^
' L0 M/ r; K1 i, i' b9 ^/ `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) [% }; D$ C" \! G5 L \, N G
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( K1 \8 P! g' @4 k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* x8 D' {8 X* f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ P: T1 A# i' p2 D, W3 U$ l! J7 m, a$ Q Z! s7 S
/* assign the tl som board LED-GPIOs*/5 W* k/ w6 H& W9 t# {' U* y! c
static const short da850_evm_tl_user_led_pins[] = {
2 e9 h1 S. T) X7 y7 |6 U, ?/ B. E /* These pins are definition at <mach/mux.h> file */
3 D7 ~& |; K& G) g3 m4 e0 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% p/ ^* n) ^( @7 k3 s- a U H
-1
5 c# R- T8 S6 y! `}; `% h! O0 B+ W8 M5 J, h& H
" G# y7 U/ X; u( F' L, j0 o8 m/ F% ~static struct gpio_led da850_evm_tl_leds[] = {
0 A$ G: L' u7 G {- r4 r- }" E: Q% s& I
.active_low = 0,% z( n8 ]. h" o# k8 u; v9 H7 A# }
.gpio = DA850_USER_LED0,; F- ?$ F/ z3 Y7 O: T" N
.name = "user_led0",
' U9 Z, q" ?/ u9 V J: I. q .default_trigger = "default-on",% p( S5 e( c" G3 f
},
+ t3 e/ i; e# \9 m$ A% ?+ e3 ? {
1 n5 @, B2 U" t6 W: S! i- W4 b( j .active_low = 0," f% X! C9 y% U) C6 `+ P% e" Z
.gpio = DA850_USER_LED1," Z6 M/ X- O1 s0 j, Q" [
.name = "user_led1",8 F$ |+ u: u) q8 J1 G& a( \: h! _+ q
.default_trigger = "default-on",2 k- V3 |9 n9 ?
},
0 p2 G* R u8 }. T# g: H {5 |9 e; s9 a4 U0 B2 B* r& V
.active_low = 0,: z. I; m* h$ y( K& C y, u, ?% u
.gpio = DA850_USER_LED2," l- @1 N) h9 u0 b; A
.name = "user_led2",: U6 l. I: e3 A' s9 z
.default_trigger = "default-on",
. \" k) E7 O H9 \2 u: m9 M },
) s4 `* V% p ~# ~ { f' R5 T; I# p
.active_low = 0,
( |/ Z4 r; F* T0 u5 a O .gpio = DA850_USER_LED3,
( v( u6 J1 R: B: X8 {3 | .name = "user_led3",
7 A ?4 N/ `( U; g .default_trigger = "default-on",1 i: A) c6 N H/ t4 M# ^
},$ o8 ?# s. y* ~9 q- H* Q
};
4 T2 Q# Y# I/ p a
0 m. W# @; K) S, @5 E2 ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 ]- V8 @3 o ? ]- x- H
.leds = da850_evm_tl_leds,
# R5 u* |: U, z* v& s b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 @4 X: N' o$ u' x% J& r};
+ T5 \2 g, A4 I% b' X$ i. `0 l0 i
static void led_dev_release(struct device *dev)
4 @+ M% K. [& O5 F# L{; q/ l$ Z5 b- m
};) C% n+ |: n ]2 N, H# y5 N
S8 Z/ F2 E3 ]3 W. t% D$ ~static struct platform_device da850_evm_tl_leds_device = {+ f0 u" r. Z& f
.name = "leds-gpio",
: |% _2 S$ m. D$ q .id = 1,
* i$ y6 _; W W' o .dev = {
7 V" Z( A9 [1 ^2 f( W0 r .platform_data = &da850_evm_tl_leds_pdata,
# A C# q- @" \9 ~& r .release = led_dev_release,
" U* U, ?( H: O7 u+ c9 n$ P }7 J' x) ]* `/ Q; t
};
* \# T @$ F. l! m, b, I% \, M
static int __init led_platform_init(void)5 n5 ?' h9 @' ]3 d2 J; x3 P
{3 f" ^& d, i8 A' m
int ret;
6 `- t$ J {9 Q, ~ g#if 0' W* P+ H' H# C2 Z& x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; L& @3 a. K7 ~% E+ a. n6 S if (ret)- N: m1 e W3 g' D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". T W: l" h& P$ X2 Q# f; S
"%d\n", ret);
5 T. H, v& h/ Z1 W3 a3 n#endif" _+ |! Q" v+ }# J6 W* V. ~( v
ret = platform_device_register(&da850_evm_tl_leds_device);+ N8 h4 f0 b. H* @4 \ p% I
if (ret)
; P, {$ w; ]" c$ Q' w e# [! {- Y pr_warning("Could not register som GPIO expander LEDS");
0 P% ?( J6 b9 ` else
' I7 m5 Q6 m* R' c printk(KERN_INFO "LED register sucessful!\n");8 M8 R" {& \2 k& l- j4 U
9 u0 ]1 s: R! N/ ] return ret;
3 G" b! H: c) @8 P) K& U G+ b}
6 \! J! d5 n+ ]1 w8 u
+ G$ E6 ] H$ X- o2 k% q; kstatic void __exit led_platform_exit(void)
7 W' Q, O/ t1 x3 t% h' @{6 z9 v5 `% u- d6 `% Q5 K1 I
platform_device_unregister(&da850_evm_tl_leds_device);3 i" h1 z& X- x1 B1 X9 \
1 z& G! R- [6 o# b/ B- \$ |
printk(KERN_INFO "LED unregister!\n");
$ j" z6 }# [" h( u5 Q& d6 f}
7 k: m A! ~$ Z& ?( y+ u/ K4 D+ g. b) a
module_init(led_platform_init);
, z% n+ v$ ~' B( [) Bmodule_exit(led_platform_exit);, ]- d' f* k8 @3 o6 Y4 Q, w
5 j' R5 _; s6 t4 Z% g/ Z" o9 `MODULE_DESCRIPTION("Led platform driver");* @3 B# e: [/ Z5 J! w# r( @
MODULE_AUTHOR("Tronlong");/ b: s- w/ Y3 J+ x* h
MODULE_LICENSE("GPL");
: C! V% b, F& I6 { |+ O( `& w/ u' W& a2 E
|
|