|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' i+ H# b+ d5 i0 O( s#include <linux/init.h>7 N8 ?. x9 P# E
#include <linux/module.h>
; l- \+ ~: J2 j) e' g/ b& P3 A3 ^#include <linux/kernel.h>1 U5 c: x- i" K' y8 ?
#include <linux/types.h>
+ ^. a$ a& @- o2 l#include <linux/gpio.h>
3 c. }4 u$ q0 G9 X- x t#include <linux/leds.h>! @, J0 D* O i6 n+ D
#include <linux/platform_device.h>
7 Y- [/ n( z$ B7 Y1 X% B0 p# w0 y, ^9 f% z8 b4 e
#include <asm/mach-types.h>5 v- i' j! f) |
#include <asm/mach/arch.h>7 f" W: @% X) ]& W$ D E
#include <mach/da8xx.h>: Q; J9 ~- W+ s* S
#include <mach/mux.h>% e8 k, u3 l& l) w8 K& H
# r$ y! n) @* g: @, |- g( O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 X$ o/ y- p# {, A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ |- y5 j, H( x. E" x4 p7 P' {5 F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" A/ h+ Q9 F# e# X0 P/ e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# L9 @9 z$ L+ S4 d
$ i# S, |( x$ A/* assign the tl som board LED-GPIOs*/) {) Y! G! A8 I+ e* x
static const short da850_evm_tl_user_led_pins[] = {
$ m( U9 h' G5 }+ W F /* These pins are definition at <mach/mux.h> file */
; ]3 f+ b- M* M! y l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: R) W, ^& M- P4 s3 H
-18 x f4 A. m0 h( A' J J& w7 @2 y
};, ^- x% R; f2 X6 X8 |* M+ I, D' i
2 M; e% q. L$ C5 r% }- ?( R
static struct gpio_led da850_evm_tl_leds[] = {
( v/ y+ ~8 I) g' j {
6 C0 W/ z5 T7 S; v! U" A% r9 G' g .active_low = 0,7 r8 k: ?9 Y% W+ ]( j$ o
.gpio = DA850_USER_LED0,
' r9 Q! [4 ^8 O7 d# u! I .name = "user_led0",6 \3 F! |2 Z: U- k6 Y
.default_trigger = "default-on",* l4 r7 S; i' j& I
},& x& K( @) l+ ]6 r# d" ~* i6 Y4 E
{
3 n1 f+ E3 ^. N9 h& L3 y5 c7 l .active_low = 0," c, z' a( ]- P& z& M0 r
.gpio = DA850_USER_LED1,8 D* O, l h5 K9 ]' x4 e) L
.name = "user_led1",
6 y2 L. P; ^, D .default_trigger = "default-on",: n2 E2 w; E8 \/ I" ^
},
5 A- L. O! F4 s4 o, W8 f- _8 W {8 T6 y" c2 r: f7 V. o3 e" i
.active_low = 0,( J( l- u! i6 h" B
.gpio = DA850_USER_LED2,
( B* I) O+ L& D .name = "user_led2",! X: R. ~( C4 w9 a( L, t
.default_trigger = "default-on",( |* U. _! w3 r* @0 _0 i
},
+ [; i8 b) I6 Z- K4 Q, C2 n! a {
5 Y% Y9 y+ f3 s; d .active_low = 0,
5 p6 k4 G `- k# H8 ~5 w+ s" i1 F .gpio = DA850_USER_LED3,6 m. M/ S3 W1 B1 ?" ]
.name = "user_led3",
+ e, {' h. f( x .default_trigger = "default-on",, {5 s3 n- e6 v
},5 y7 L: W. Q1 f4 h. x7 _
};0 l; e d! i- H
$ G- d$ m* w9 z( M) `1 rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- L! r+ S& D: j" Q \" }
.leds = da850_evm_tl_leds,& k: P& ?. B2 D _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: [) l W0 V" L};
. W B% Z# ~- Z9 ]$ S2 `9 V$ m2 o4 z. H9 W: |
static void led_dev_release(struct device *dev)* Y3 B. ]6 s6 Y$ l% O2 P
{
& U: |- ]/ o4 G2 z7 S' [ \( E+ O0 L};
2 y! k. P' m* x# H) B( M6 }% u* N8 {
static struct platform_device da850_evm_tl_leds_device = {/ y& J& x# S% Q& j" L. s
.name = "leds-gpio",6 e5 c" x" L: V. n* \
.id = 1,
& E" l+ ?; c+ x; i6 n7 n( ` .dev = {9 F) S+ g7 ^! Q a. I6 X
.platform_data = &da850_evm_tl_leds_pdata,
+ K5 g7 x9 {9 z- f .release = led_dev_release,6 p4 S3 e0 n, I8 C4 j
}
. |5 {/ C6 A5 M6 U U# F};
& W& _1 ]: m8 A2 j) V+ J; J* G5 @* Q: Z( ~# a
static int __init led_platform_init(void) B! X* |, o0 c* { r5 z
{
: {- v* x/ } k! z1 v- e int ret;
! f) K0 V" S* c% o* @2 R#if 0% p' ?- [5 A; ]& D4 h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' U4 j% c" V+ E, n if (ret)
) e1 `' G% u$ v! ~: u( l) F/ h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* q6 U* h. [! h; j2 E% ?$ s "%d\n", ret);
/ g4 M- S# T( K; {/ d1 {#endif
; K! O1 ]# `9 E) K D ret = platform_device_register(&da850_evm_tl_leds_device);& @) }4 \6 }7 w7 z/ \/ X4 R# ^+ n9 k
if (ret)7 G+ E) \8 X$ d
pr_warning("Could not register som GPIO expander LEDS");
1 R X! z( A7 k: h/ {- h else
7 h! J# x b" o ?' ?1 j | printk(KERN_INFO "LED register sucessful!\n");4 w3 e5 S8 E; i7 `% F8 s
" K- [" q' x* G- w0 t return ret;
8 ~4 ]5 F0 y1 O( M1 O}
+ d' e$ p; W5 g r- m
' M8 q0 R u$ P: `3 e$ Jstatic void __exit led_platform_exit(void)
3 N& S) J6 }; ^# F7 \/ h{% b! a2 d* L- `/ }( u; _, G
platform_device_unregister(&da850_evm_tl_leds_device);
7 y, d8 x: f- Q/ w) \- {) y
% ^ B! J! b- T1 e) A printk(KERN_INFO "LED unregister!\n");
/ z3 n& w: E7 \5 f' l/ u}5 s% K1 H& I; c; ?! o! t
9 A2 t2 e) f$ J0 O4 Q
module_init(led_platform_init);
& C) S3 s' J; d+ |! i; d5 v, G/ e) Nmodule_exit(led_platform_exit);; a1 w. ]" ^( a& [
, _/ e/ E9 R" i7 n5 K4 q
MODULE_DESCRIPTION("Led platform driver");
- I# m7 l& ^3 bMODULE_AUTHOR("Tronlong");- z# z; D/ j3 v0 Y$ b
MODULE_LICENSE("GPL");
, L+ G/ U" P7 Y' I* V. ]# t0 P: J) @0 K1 S. ]5 @5 X) b
|
|