|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 t& i. q# V0 l$ j- T
#include <linux/init.h>3 Z3 k7 y. b' @5 @1 U* k7 @
#include <linux/module.h>
* s" m, V" G, t/ A+ R#include <linux/kernel.h>
( A0 K+ y1 M6 N! N, S#include <linux/types.h>% A V4 c8 w7 I+ m
#include <linux/gpio.h>4 s/ N" C! X, K! D
#include <linux/leds.h>
" i. D8 N9 E& J, J4 P2 T9 A#include <linux/platform_device.h>% l+ D# ?$ N+ w+ v& a% U/ ~
2 i- U+ u5 |3 R5 x8 d9 n
#include <asm/mach-types.h>
; n5 r$ x8 u b$ O" l& B& X, J' J#include <asm/mach/arch.h>& F5 w- q, Z" _8 _0 z3 m$ `
#include <mach/da8xx.h>
: b7 ^5 h* C1 B5 D#include <mach/mux.h>( R/ |: e8 Y! u% l! p
3 T6 I% t! g8 Y. ? Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# g0 C% i* o; n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ S; v) _# V- _: Y8 p! y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* ]0 u% n7 `% d$ j5 G F; l) I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 M3 Z2 l3 [2 d+ H- }
# [* ~- z- G8 t3 i' x" d5 I+ n9 B/* assign the tl som board LED-GPIOs*/
. S: l& a) y$ x! tstatic const short da850_evm_tl_user_led_pins[] = {
( B, l* Q4 Z7 X* S- W" E9 i8 R. e /* These pins are definition at <mach/mux.h> file */, k- c' q* C, K6 ]- A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) b- z m! d2 B) q: j$ ]+ g
-17 C: c/ R0 z& f0 y
};
) Q- T9 w7 }- v+ \
, } T9 ]8 x: astatic struct gpio_led da850_evm_tl_leds[] = {
- ? _4 T2 m. ~5 ~* u, b$ U# Z% D6 y, o7 ~ {
: P0 U6 l4 k; \ .active_low = 0,6 F5 O9 r* v1 N) w% S/ v
.gpio = DA850_USER_LED0,
) Q2 \2 l* t' n .name = "user_led0",3 p, R1 |+ W/ Y; G+ p3 t
.default_trigger = "default-on",
8 t/ v4 d: }6 p/ s S5 L. \7 L },% i3 G3 `% E( z. B' b. H
{5 x" G, o1 C( ?
.active_low = 0,- w0 r( p; d( K/ r
.gpio = DA850_USER_LED1,+ N. o, W; E8 @4 O8 D
.name = "user_led1",; c$ I( j' b# f! |# i' M0 R( f
.default_trigger = "default-on",
2 x- B! T+ m- S D, T% f, G },
# c# v8 x7 ?6 e# J# c+ b {; i% ]: ?5 S4 h5 j& Z; n7 L
.active_low = 0,: [; X) @ O3 \0 F! [# @
.gpio = DA850_USER_LED2,2 `8 m2 L. J+ C# \$ q& k& ?- w9 |
.name = "user_led2",
: P" a* k& \' O2 _ C Y3 f .default_trigger = "default-on",
2 x- ]" \- h/ G, H% ?5 e },- m$ r' {* L. l! S
{
I" d9 N/ t0 G0 D .active_low = 0,+ [6 h- @( B# v* e& c2 A
.gpio = DA850_USER_LED3,
0 f$ P3 L; }& _% ~, f6 v .name = "user_led3",
! q$ Q( M$ O s& E4 M: S8 E .default_trigger = "default-on",# D* D2 E5 [% e' B' l* @4 x
},. B' E `% q4 O" Q& k0 n4 \7 ~
};" q6 G9 g+ b- G/ ?
$ b5 W* O8 B- X$ {: P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 s G( @8 v6 @% w8 | .leds = da850_evm_tl_leds, K: y2 ]+ K3 z' i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 V3 }1 A. K! ]7 J# M
};
& [3 [& k D& |/ n! m+ O& ?0 C' f
static void led_dev_release(struct device *dev)8 s- S/ g1 _. V3 J _( d$ x
{
& H, o( v+ t6 m( S# w# U};
, z2 S2 P6 i" F. o1 D1 K! M) B
0 Q) K/ s* p4 y" @: g" }static struct platform_device da850_evm_tl_leds_device = {
5 _9 r }- A- X .name = "leds-gpio",+ h& c n9 X6 b. U
.id = 1,
% G/ @, S- F/ H. K .dev = {
( P; E* Q# ^" Y3 \; M* x& N .platform_data = &da850_evm_tl_leds_pdata,4 J) J2 e7 ]9 j0 I
.release = led_dev_release,
9 x) s% d" E) s7 Z$ N" J% w% p }% ]* ?' ~9 \) W. a
};6 l# `/ z5 u2 k. } U5 A
5 W6 ]" s* u& f2 V5 x; |5 h7 P/ \7 Jstatic int __init led_platform_init(void)
! \2 h2 z; _4 C0 d, ~" t8 r{' g- T$ e: i* F/ b
int ret;7 r+ L' i8 ]. ]
#if 0
4 J0 h: e. _: ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& j1 M/ ^2 p: `7 O
if (ret)
4 Q3 O3 S6 S! e) s0 \9 Z( K( W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ r1 k! Y: L6 A "%d\n", ret);
& G6 d0 e+ w# \- i3 ~#endif
0 U, G' F `! m. _" D ret = platform_device_register(&da850_evm_tl_leds_device);
& v! U. T# v6 y. c. o0 P% ^ if (ret)
; e. K" R1 x5 K6 C" z pr_warning("Could not register som GPIO expander LEDS");+ Y5 C, b% h9 W' \
else6 F4 M$ D3 T+ \! L3 `. I+ S+ V' V
printk(KERN_INFO "LED register sucessful!\n");
: G M2 }, _, s( ?9 w! k
* |( |$ |' k) t, j' ]0 N: e return ret;
% Z; W) N* }* g5 f4 r4 q1 r: N+ `1 b}
% a+ z; |2 i/ ^4 f. R* x4 k0 W$ Z0 g
! f, d: e' U( f3 H- M# t8 ]: ystatic void __exit led_platform_exit(void)
* F, U* f3 S( m& _{
5 K" p' P1 `4 ?" E+ U platform_device_unregister(&da850_evm_tl_leds_device);2 @0 B2 s+ Q- H7 z& Y6 G/ Q
7 Z2 P1 x$ o* n% F
printk(KERN_INFO "LED unregister!\n");
) c9 |/ G! } h4 E _9 i}
( o- }; I: _6 m
( _1 Q5 d% |6 _; |7 Nmodule_init(led_platform_init);
+ q+ @1 v) [ T1 q) _4 [* {module_exit(led_platform_exit);
8 V" v: r& {7 h; W7 o2 U0 `
e4 D z5 P% L. C! u! E: ?MODULE_DESCRIPTION("Led platform driver");( n3 y6 @9 a( c; P6 D6 c" y
MODULE_AUTHOR("Tronlong");* e8 ?. C. B& |/ X: y( F3 e
MODULE_LICENSE("GPL");
1 D. V# O5 z) A0 {% ~
. S7 z. W8 _1 |( x+ p A( l V/ E |
|