|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& T2 V% V& J( T, K- `#include <linux/init.h>: {8 n) F7 X0 b7 x
#include <linux/module.h> z% f% }2 ^2 T d( P. v
#include <linux/kernel.h>
; t1 [, A/ F( b( J/ k9 d#include <linux/types.h>
0 _( l* {" K/ a. ]#include <linux/gpio.h>
, x. t5 a$ K$ i4 l2 \" q#include <linux/leds.h>
6 @6 ?9 ^! v( I$ E; I#include <linux/platform_device.h>
( g4 G3 t# O! D6 X
; ]6 ~0 y G/ J8 n7 |#include <asm/mach-types.h>
% n* Q+ \4 V" c: _2 a#include <asm/mach/arch.h>: L3 [/ t' ]! V
#include <mach/da8xx.h>
7 P! C, I, x+ ?. |0 l#include <mach/mux.h>0 a& S6 S9 I; V3 S$ O' r# t8 h
0 x( `! k! M6 _2 ]
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
F8 X F7 ?0 a- E, L; A' C. \1 F#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% P# W9 p2 \( `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 ?0 S6 @. H2 L5 s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 `4 @, x" n: {8 n \/ [3 ~* I+ w; S# }6 _" J; x% O8 @# s9 c \+ t
/* assign the tl som board LED-GPIOs*/
/ O5 c8 w R8 E4 A, ~; \static const short da850_evm_tl_user_led_pins[] = {
+ N& ?5 `4 t, p& w /* These pins are definition at <mach/mux.h> file */
+ J3 r+ v& _7 P8 [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: v! O$ o0 x" b6 W- A: J' s& i -1
# K1 X. d/ V9 ^8 {# y% @$ `};" K* S8 @5 [1 \) f7 c
3 L' o& }. ?- w G2 d0 n$ V/ O( Q% pstatic struct gpio_led da850_evm_tl_leds[] = {- h! o! P, c, Z0 P6 k3 d
{( H( W5 a+ ]6 P5 @' T0 t- P; M
.active_low = 0,
7 I5 d2 v. H* d .gpio = DA850_USER_LED0,- Q, J. ~, c: z: B# M+ t, m. S
.name = "user_led0",
' h# ?7 Z' p. U( ~, T! q+ B! `/ Y- I .default_trigger = "default-on",
% P$ |8 U1 T' n; ^3 ^. r },
) b Q8 z; k9 F0 _9 b1 x# U2 s- D5 Z {
! p" Z. k: F4 D( S .active_low = 0," n: Z6 h. c5 s5 j% Q* m4 |! t, i
.gpio = DA850_USER_LED1,2 T6 x. D9 P) D1 h; B
.name = "user_led1",
& X5 F1 Q9 d) `9 A0 `0 r+ e% Q .default_trigger = "default-on",5 q5 L6 M5 Z: Q: h Z& W) c
},
3 q5 t! j! E3 i, v: d) F$ p {8 b5 Z/ P+ `2 U, d* { \
.active_low = 0,: l- z( q. M4 x
.gpio = DA850_USER_LED2,2 m' o- }- A6 X
.name = "user_led2",- {1 X4 S8 q" q* n3 g0 E
.default_trigger = "default-on",5 {, k( N9 _1 ^, P% R) W
},: C2 Y7 t, Q) G
{3 P! a" e$ N! X: y& I2 x n: t1 v
.active_low = 0,% V: o" @& L8 s5 a) J; N$ s, X/ b
.gpio = DA850_USER_LED3, K+ h4 x( I \
.name = "user_led3",% ~5 N, I! `8 H' S6 z6 z% i
.default_trigger = "default-on"," R; b; _1 x% h3 n! k/ A1 y3 D# @# t+ I# B4 F
},! I; b# u4 a" V5 ~0 u5 q
};
! `& \. S* @% L. j- [0 W( Y9 E
! U8 T5 t! W0 V. K) ?# [static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( f8 C) A* ^$ @1 Y# J .leds = da850_evm_tl_leds,
) D' H, x6 W& j .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% S! F9 S/ N( D5 A; g
};
* Y7 k$ x7 L" ^+ ^1 g6 |8 T% z# v8 [) U
; v# [/ Q6 m7 Pstatic void led_dev_release(struct device *dev)
7 e0 H9 J3 P" G1 N6 Y6 J. [( B: N{
( Z& V! i* J2 A* B};
) i3 f" m% f# f) H
# c; P' M3 t7 \2 A& W3 {9 ~2 astatic struct platform_device da850_evm_tl_leds_device = {
$ P0 z8 ]" L+ n2 f4 U# r# Z3 R .name = "leds-gpio",
. Q1 K" ~6 d9 M9 T) |; X$ x .id = 1,0 I+ U' J% F' f1 W
.dev = {" J+ R! Z4 D% e+ G2 d
.platform_data = &da850_evm_tl_leds_pdata,
) P9 p0 z) N2 N$ f .release = led_dev_release,( u( S1 j, d$ `8 G2 Q0 M
}, ?* l6 b8 E/ }) F+ L) i
};
# D& Y# O" v7 c; y1 I4 p2 ?/ f' `( u# H. c6 \5 F
static int __init led_platform_init(void)
) e7 _9 V4 S; k: T0 g5 B{5 ?( ~! d$ ^2 z+ ~
int ret;
% \9 p6 C/ H& W: i#if 0
$ X0 H" j" }. g; O0 Y4 b1 Q7 j, Q( H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" |8 Z' k+ D+ q( |+ W9 {1 d if (ret)
. x; `; A; p6 _1 F4 H) Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' U; A1 x2 E% A1 A3 h "%d\n", ret);, [7 W0 g% B( c' u; J
#endif
9 a8 E% ^$ E( b w1 V; _7 T ret = platform_device_register(&da850_evm_tl_leds_device);
2 }0 Z7 x1 m' i1 R- M if (ret)
- ~# V8 [' `4 i& J Q pr_warning("Could not register som GPIO expander LEDS");
5 q6 v+ A6 [' Y' m: y8 n+ I: d else( ?$ e; z" r% t+ q# V
printk(KERN_INFO "LED register sucessful!\n");1 M3 {0 Z% X. }9 v
9 ~2 p6 G% [. d. c" y& ~+ e
return ret;
/ K& U4 e. ]0 _0 ?! e* }}! n5 D( d T: |9 R2 f) B
& @* C1 }) u+ E# f
static void __exit led_platform_exit(void)
% j8 D+ `+ G+ t' [6 I4 Z{
4 g2 ]: t; P: ~- b: ] platform_device_unregister(&da850_evm_tl_leds_device);% [6 C. B% r' Z: ?) W) o! F
. Q$ Q/ ?* i2 P( A2 ]8 D! d8 C
printk(KERN_INFO "LED unregister!\n");
, _2 p* n- d* a+ I6 b j}
! K( S+ w$ M0 m
0 \! k, D: A6 @. y/ Rmodule_init(led_platform_init);! n4 r$ P- p$ x0 f4 K
module_exit(led_platform_exit);. j5 o& H1 j. M
! M* A2 ]+ Y4 Z4 g2 y I8 U" B+ }MODULE_DESCRIPTION("Led platform driver");. i! ?& e, c! @; H7 |* S4 s' h1 o
MODULE_AUTHOR("Tronlong");- C1 g @2 F! D W8 L. f
MODULE_LICENSE("GPL");
) A4 _3 q7 I2 _6 v6 k, ~
) D- n2 s, d( ?% c& T0 X |
|