|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 J3 Q! Z2 T, E' P/ A- H& m#include <linux/init.h>
; h: P8 v) o5 C/ M#include <linux/module.h>
9 |; p& ]7 v: R4 r$ e#include <linux/kernel.h>- M, R; _; Y# n/ w: D
#include <linux/types.h>' {( u' Q: v) |+ a
#include <linux/gpio.h>5 I8 [9 `1 u7 \% B
#include <linux/leds.h>
$ o6 c9 q! c& q# E7 e& ?#include <linux/platform_device.h>1 n2 ]8 z6 R2 b$ L {
5 L; u; N1 w: [! y. F& l# |* t#include <asm/mach-types.h>& V6 Q$ `# s4 u% i/ ~
#include <asm/mach/arch.h>
5 u" d$ |5 I" @" ^, j) U; M#include <mach/da8xx.h>0 p/ j( N D0 c, W( D
#include <mach/mux.h>% B6 ~* g9 k- K+ O5 H$ I
) e5 c+ f2 _* e* {
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' N5 r9 ?( J$ f4 g* U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): Z! u6 @0 s/ b# \' [# o+ |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ ?) `! n0 M8 ?1 [7 v o#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 f- m8 b- Q6 W( U) A7 Q" o7 x
7 X0 n! |- j' ?; }& }# @
/* assign the tl som board LED-GPIOs*/) n3 F* \9 a8 T" }: o, F% a
static const short da850_evm_tl_user_led_pins[] = {
5 K: j- e- t# U2 M. b, Q /* These pins are definition at <mach/mux.h> file */
6 c$ l7 T& H% `4 d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 M, m a, o% m4 \* f1 p; i
-1
% u: X; u2 j4 t};
2 J( q( c2 J6 o3 k) m
+ B7 h( `& m6 N8 l3 L5 zstatic struct gpio_led da850_evm_tl_leds[] = {
- Q% S) ?1 s6 u: y8 M2 f {
) a1 [/ M8 i6 S/ G: V7 U. S .active_low = 0,
6 h, \& Y7 L, n) K9 e% D .gpio = DA850_USER_LED0,
$ m7 J/ J3 f- N+ N6 o i5 \ .name = "user_led0",* q, T: g' Z4 x7 j$ Z$ l6 V. B8 p
.default_trigger = "default-on",* z4 c4 A. q) S
},
- x/ }1 B; w* w! ~2 Q. p {
0 a: p% x* j% P9 n4 j+ Y2 G r .active_low = 0,& E' A# Y: b: x# s! e$ e; s
.gpio = DA850_USER_LED1,9 {6 E3 T$ i: r; z0 ~& ^6 y
.name = "user_led1",
0 D: S* e7 r$ i W .default_trigger = "default-on",
U" z0 q) T: f J },
' v5 O! N5 {/ h# `5 [3 o. U' m {
# }) y* |9 m; S9 z9 l4 F$ l) { .active_low = 0,
6 C7 [5 z" n5 g% [0 I .gpio = DA850_USER_LED2,
- \& q. k7 h" s$ f5 ~ j .name = "user_led2",
& V0 D& ?* e$ @. d# r' u .default_trigger = "default-on",
# u9 F' |: k" L* w, z2 R" H },
) Q( s C$ A& U$ X' A {
& D7 |: n$ m; ~0 h1 Y% M .active_low = 0,( ~7 r, O L" r
.gpio = DA850_USER_LED3,
3 `5 ]7 r# \6 v! x .name = "user_led3",& t. L9 e3 j, O h
.default_trigger = "default-on",: p! s5 N6 N1 C: r8 l) h& P" B T/ j
},
7 q2 I& Y: h9 ]( i8 a};, Q+ h: v1 [" t7 }, f% V
3 D4 u# N# a( h# R% Y0 I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) l- i! d4 Y0 n8 J; s7 p7 N8 P7 G .leds = da850_evm_tl_leds,
& {" q$ \0 S4 U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 \5 `& ~) @' |2 ]+ q" M
};
7 I. \! \7 k4 q2 L4 U
: `$ Q1 M6 S/ t& o) v% c& ]static void led_dev_release(struct device *dev); S7 O- i/ `# [. g2 _& p8 Q# D7 [/ Y, O
{, _# ~6 Z" u6 R* J2 V% w# ], ~
};
- v; R5 q" x6 J' S, n8 T: t; ?1 S5 ?7 l( `
static struct platform_device da850_evm_tl_leds_device = {, Z7 M7 ~2 n! W/ R. U2 V/ ^# O
.name = "leds-gpio",
* F- i( R& C# Z: A/ K) | .id = 1,
! A6 E9 v4 U( f+ K2 g .dev = {
5 [6 M- Q& A1 Y( y+ u' D. F, n .platform_data = &da850_evm_tl_leds_pdata,1 O1 y$ T9 e1 b* l5 m) L
.release = led_dev_release,
+ J( {9 H/ C) T }
8 l; a' F+ P8 m0 _3 Y};
2 ?2 v7 g4 ~9 m
1 Q8 h0 W+ g. I2 l( y7 l5 \static int __init led_platform_init(void)
( W- q8 J3 C% h3 j{
* n+ [& D" v' P: ]( @ int ret;
% u+ g: f; i4 N3 w* e6 B; R, Q& N! T#if 0
0 D& R. R& n5 O9 l; T, @ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 g5 W% l/ e) r$ N" ^' A/ @) ^2 G if (ret)
, g: u5 N4 y' O% O* X) r9 v% I; K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& N) y" V# H* l# O5 T
"%d\n", ret);
. w' [, H6 w! V4 R#endif
3 q* [0 P' |8 U: h( O! k' y ret = platform_device_register(&da850_evm_tl_leds_device);. ?0 z6 r' F7 q1 P9 |; g* A+ M
if (ret)0 a. X0 d- t/ C# G' [! Q. B
pr_warning("Could not register som GPIO expander LEDS");
4 I& `. W: _* I; ^7 \ else+ B- Y$ N' M: K) y
printk(KERN_INFO "LED register sucessful!\n");
1 G5 c9 e/ W }6 K" @) { V' w9 i, D: M) ~9 R; z/ h9 M! V& \. _
return ret;# z3 |1 a9 M: W/ p
}
+ r; k: p/ A1 i$ R; i- v S, [ Y5 X H* n7 V
static void __exit led_platform_exit(void)
2 k" L) s, y, ?& }, F# s{
0 Q+ _( `; ]! q7 G platform_device_unregister(&da850_evm_tl_leds_device);
0 C8 |# f$ _" J3 D+ p C% Q& u
3 D5 F3 T5 L" }7 k5 g) v' K printk(KERN_INFO "LED unregister!\n");
: T8 i7 @9 ~, t( H5 d0 f/ ^}; j' I* H; T; z9 @
; b h, ^, T" B& T. Y6 @module_init(led_platform_init);
: V- g, w: G) q; _- `& wmodule_exit(led_platform_exit);- n4 J( C( L5 h* O! Z5 e9 m
+ v8 w0 K. m0 l q4 wMODULE_DESCRIPTION("Led platform driver");
+ H, Z9 r; M0 e$ zMODULE_AUTHOR("Tronlong");2 Y4 t& L: K8 \- B& m
MODULE_LICENSE("GPL");% D0 c5 U; k/ K( s
! O3 x: s! h, Z$ ^ |
|