|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* U/ O+ _" [( d8 L
#include <linux/init.h>. g4 v9 R0 k0 B2 |, e- t( S) p
#include <linux/module.h>
# F; t; x3 F/ k R#include <linux/kernel.h>4 f# Z+ W: p1 D( X* [; B1 \
#include <linux/types.h>
# f! o6 N/ e t#include <linux/gpio.h>; Y7 d; D! _/ W8 t0 a3 ~2 b
#include <linux/leds.h>/ `1 y7 E& B% E' Z/ u+ Y
#include <linux/platform_device.h>$ U3 @0 X) c4 d) i* a) b6 U) |
' z( B% c: I0 V. |: W1 }! D#include <asm/mach-types.h>9 W% O, _- i7 ?$ i1 h- n1 p+ F# `" G
#include <asm/mach/arch.h>" c8 ^! v6 ]: P
#include <mach/da8xx.h>
; q4 S" N+ u9 B- H# b) ~#include <mach/mux.h># S0 ?# h9 d" f2 z" ]! e
` Y6 l# j5 }9 M- [2 S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ m* R$ V Z% y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, M% y# l# [; Z) W; W/ U1 c, ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* A; S5 G, }7 H" _: y5 P: i0 t#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 Z7 l% Y& [6 c+ b7 U3 X3 W
0 |" L( y& E9 C5 n/* assign the tl som board LED-GPIOs*/6 b7 \) e8 c( x; g1 L
static const short da850_evm_tl_user_led_pins[] = {3 [0 W- h2 |; V9 [! R t/ b
/* These pins are definition at <mach/mux.h> file */2 h% n2 C4 v" [( V! l* g* ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
r% F; h$ X6 @' U/ N+ k* Z( b+ E -19 D$ ?3 ]; H ?3 Q% u8 r% W! S
};+ y8 n4 w$ B. {
5 q0 [. D- r4 X& `) q T
static struct gpio_led da850_evm_tl_leds[] = {" D9 {5 p: S1 Y8 i% f2 S8 g
{# x& H& R, [+ L0 E% F: Q; k
.active_low = 0,% a9 V! J( b+ X' `6 D9 D/ n
.gpio = DA850_USER_LED0,
- y9 v: ^ a0 ~! L1 B8 Z .name = "user_led0",. y5 V9 d2 f( X$ i
.default_trigger = "default-on",) a0 ?8 c# H k0 y6 L' x
},
) X, v' z8 E0 I' ]$ }* g8 p0 J, l {$ Y: y0 I. |3 X( w6 r) ]
.active_low = 0,( e& I5 Z& v* m4 S* J6 o0 ~
.gpio = DA850_USER_LED1,
( N* V0 B8 t/ c9 a& J .name = "user_led1",3 P" s3 l# z ?. V- d
.default_trigger = "default-on",7 s+ z( d- }# w( C
},
% U5 G3 G% J9 ]9 o" y' { {+ z- I7 K& H4 n4 Q& Z4 Y4 |/ r
.active_low = 0,3 r3 f& `; ~8 z! u8 M1 V
.gpio = DA850_USER_LED2,
, v; n7 }! _4 N6 J0 J/ ?. m/ P .name = "user_led2",
6 @) A3 D- A8 a. ~ .default_trigger = "default-on",
2 p4 M6 t( {' m9 Y }," @" T! E! x: k- ~7 J+ G% @ ?
{% L2 O8 d4 X5 g; f- \ Q% Q& i0 m
.active_low = 0,0 Z2 L) {* j' i8 x
.gpio = DA850_USER_LED3,
4 ~$ H# e; \0 x( O6 O .name = "user_led3",
$ J5 b8 B/ i( X$ _- m7 k2 x .default_trigger = "default-on"," q8 n- y, z5 j& L/ e
},
1 D- ]7 [" A# N% ` |! V" H$ p};
& q/ e/ T3 ^- Z
, w2 D' G0 A# B; B5 V, ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& K: i1 H& n3 B8 B2 Y* @
.leds = da850_evm_tl_leds,6 n* V- U% B" T0 D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. a+ v; R" [0 Q/ z6 m- K: h8 b};6 }! K# n: K$ D z
2 y) O3 y) D; \* Zstatic void led_dev_release(struct device *dev)- R8 k/ N( q4 A3 _% W
{
0 w. X8 Z7 D8 u- A$ e* z% m};6 \, F( C. C; K- z
$ _. J. F) v3 ^: Y
static struct platform_device da850_evm_tl_leds_device = {
/ }4 a$ p7 b) t F2 K4 y .name = "leds-gpio",
" o3 L$ T5 w: t/ {5 N6 \ .id = 1,, B& i7 o. l, D) l0 i0 X9 p* O
.dev = {
/ C1 d: R- @2 _* c, ? .platform_data = &da850_evm_tl_leds_pdata,( G# ?( p; O2 ^" _3 S
.release = led_dev_release,* P5 a) p# V' K! `; D
}( j( L& k9 i# B0 [' V3 M
}; U' c4 H) C# t! n4 R
I% J% X2 w+ k% }8 Jstatic int __init led_platform_init(void)8 ^$ O( s' s- j& P( g
{- A/ P. L' U# _, r6 u6 M4 V
int ret;& S, U% Z: {6 e9 L& K5 l4 l
#if 0, c: x5 ]- N0 g, ^" s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 }' p' ~+ z2 h" X! w if (ret)
% y3 ]7 F0 F2 W1 I% t X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 }$ J# ~' A% ^+ O) G1 h "%d\n", ret);
4 }; A! s0 |# m. f2 J#endif
) {: ]% y5 Z: t1 T1 n( u ret = platform_device_register(&da850_evm_tl_leds_device);
9 R, v" S6 o. r if (ret)
; f9 G$ O4 F/ H pr_warning("Could not register som GPIO expander LEDS");
3 b0 x- V7 _6 X9 h3 w& z, T! A; e else
, u5 u4 D. a7 \! f printk(KERN_INFO "LED register sucessful!\n");5 K9 O5 a$ u( Q4 d5 y, |
* Y2 V& a' r6 V, i" f return ret;: @" @4 y/ V j) p
}3 \* z* M( c+ z2 ]; q1 z6 o
) ~# ?2 V8 q8 _1 `% X8 t$ U5 T- cstatic void __exit led_platform_exit(void)
1 q- C# x4 ~5 n' y' w: n{
$ R9 \: v9 E' w. L: n; E9 R platform_device_unregister(&da850_evm_tl_leds_device);
9 |5 }/ ~4 U- ^. G; O0 L# @9 E. H9 A$ R# H9 l1 Q
printk(KERN_INFO "LED unregister!\n");5 t' R- U$ ^! K8 o$ m5 V
}. T& F! i6 \" X$ O; m, j. I
+ t5 k. ?9 t0 t4 n9 k1 m( \
module_init(led_platform_init);0 B* `; | A r1 [/ e! `) G6 u
module_exit(led_platform_exit);
% c- e5 x) z3 a. J1 S- t9 ?* f+ ]0 i
MODULE_DESCRIPTION("Led platform driver");
' v& e5 e+ w4 X! l% ^9 x9 zMODULE_AUTHOR("Tronlong");
D; t( B* K& n5 C U; ^MODULE_LICENSE("GPL");
a2 Y* I5 l* Y, t( t5 v1 \* F" M) w$ Z" D, [8 Q7 |
|
|