|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ V7 F0 Q/ |7 Y% d1 A. u, l#include <linux/init.h>5 g/ K# y3 ~+ g9 x
#include <linux/module.h>
" @4 i/ D0 A& s5 b7 w#include <linux/kernel.h>
' k& R, B; E {* _: y6 _#include <linux/types.h>6 C! }( a- K7 u5 L7 f( m5 p' B
#include <linux/gpio.h>9 F1 a( \6 \8 Y- T, d0 P" y" u
#include <linux/leds.h>0 V& K# \$ _- g% }; n
#include <linux/platform_device.h>
- x' h# @1 y+ H/ l
* J' f5 g: O. [+ T& E/ ?/ o2 B: G#include <asm/mach-types.h>
2 f" {( r' \% J/ c/ D' [#include <asm/mach/arch.h>
9 j* M) r: j& v; `. N) z# `#include <mach/da8xx.h>; p% r, {2 }6 | ~
#include <mach/mux.h>
) t5 t; g: x- d: o
$ J2 P9 m) I( t/ B+ [. P$ L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 m5 n, P$ c. q1 U#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 E6 I) M1 e5 f. U; Y6 H& S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% z% v$ w" |. W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" e6 \5 x* x/ `
7 a1 g5 M. j5 T+ ?/* assign the tl som board LED-GPIOs*/
5 n% _$ N- m Q+ g/ k- G, bstatic const short da850_evm_tl_user_led_pins[] = {9 t+ h: _. m4 y) {( ?) I
/* These pins are definition at <mach/mux.h> file */3 d; o G [4 j' j3 Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! n- b# g( D5 {1 s
-14 l0 n# t+ X, L. H1 G% o: |; i
};0 J: U! {3 X, \- Y4 q
$ V7 Q3 E8 e$ C6 K8 D! Pstatic struct gpio_led da850_evm_tl_leds[] = {
. e, Q! y9 _ L8 Y' a2 @; @8 {' T {7 T" r) ]8 A1 [5 N: [/ Q" Y
.active_low = 0,
0 z2 u8 @# \0 b0 S) K. T .gpio = DA850_USER_LED0,. a3 w2 x" N5 c2 _9 T' Q* f' J8 v
.name = "user_led0",# l) v+ h1 a" Q. s
.default_trigger = "default-on",
/ u, Y: ]; e# p0 n; o },
) V! f% P9 a9 }8 ?/ Q {) Z- X& M l% p: j: C' ^ o
.active_low = 0,
# @0 E8 K+ u9 d. f .gpio = DA850_USER_LED1,# `% C/ c' C* q
.name = "user_led1",
0 {' t/ I& u! o3 N% }; R3 u .default_trigger = "default-on",
7 r( p N$ p# n4 f },
2 @8 D6 z9 w9 z {
- y. s6 N, ]9 x .active_low = 0,
8 T# K, i4 J4 a( Z [3 | .gpio = DA850_USER_LED2,, x4 [# A1 m: Z; d) P" H: f6 S
.name = "user_led2",
. }- B8 G: m5 F+ d1 d, q: w .default_trigger = "default-on",7 Z5 @! a4 @0 F$ \3 Q; l% j
},5 n3 k1 n( h& d$ L' _! ?) e
{, W+ L7 {1 V6 G3 M
.active_low = 0,
* r0 ~6 P# P/ B8 _ .gpio = DA850_USER_LED3,, O/ ^5 N0 [# c2 x
.name = "user_led3",
5 r" |7 X& h! W @& m3 h .default_trigger = "default-on",0 ?# R7 P2 Q2 a* V' Z6 M: k
}," @* r* n" S% x3 l& p+ X
};$ |$ h0 Y/ j5 t8 F7 Q3 z! j
3 r- u' Z) i0 g% j. ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# h+ g; C0 Z$ W4 W$ ~8 h
.leds = da850_evm_tl_leds," ^0 v+ B: o7 }4 ~% |9 _: N- E6 P2 k
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; J2 S$ s, S3 i9 p$ V. x};/ B3 r4 v; E+ o# G
. W( i9 s! H |+ ~" [
static void led_dev_release(struct device *dev)
: `5 s. L3 K5 D. C{& x& y4 |5 W2 [8 T( t' c8 m+ O
};
9 x* c$ @! J9 m
5 ^. e4 T9 Y9 }) l+ o& Jstatic struct platform_device da850_evm_tl_leds_device = {
9 i7 Y( S9 T- q, c. G3 m" g( f .name = "leds-gpio", F f' O* z, s" {' O
.id = 1,
+ X# @0 h( q8 z. Q7 f .dev = {. {! D2 k3 p6 Y9 I' ~' |* S# H
.platform_data = &da850_evm_tl_leds_pdata,3 U5 L6 n0 l5 _' u+ G
.release = led_dev_release,
; v. p' F( b- v% f; |- l }# Y( o- g3 c, |4 p9 w0 o
};, ~. p' p& k; W8 u: r
% T0 K, j8 Y, t) u4 V
static int __init led_platform_init(void)8 N" F0 y# f. O' Y
{
+ S! E- s$ O" ]4 }1 L int ret;2 S5 M2 ^* H: K/ a
#if 07 ]- E4 V$ N, L4 \: Q; L3 o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ H# A& r( @8 T# W& B if (ret)# ]* }, U4 g9 m) q* Y! w
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" d1 m3 Q: ?7 d' G' Q- ~! w "%d\n", ret);
5 t- S) C3 }* A" h) v, V0 B8 Z#endif( y. N* S; G/ d9 z {3 a9 D Q
ret = platform_device_register(&da850_evm_tl_leds_device);9 @( r( i( o! y. }" e( [' s( X, @7 G
if (ret)
5 b4 Q! a" S! t4 E2 r( i) t pr_warning("Could not register som GPIO expander LEDS");
) h; W+ z3 V1 p |: W/ D. a b else) P3 G$ M" E% [2 y5 Y6 d0 c
printk(KERN_INFO "LED register sucessful!\n");
J1 a b; J; }( t- v9 F% v# L% @5 ^3 ]' a2 D
return ret;6 }$ J e" t, s: l
}
" H' [% Y2 \9 k/ ~0 }
/ g$ O# x* M t0 q% Wstatic void __exit led_platform_exit(void)8 y0 F+ A7 L* A7 D2 I6 I; s
{
# W1 p/ @$ i1 q9 v! i1 [ platform_device_unregister(&da850_evm_tl_leds_device);
$ C" R! C9 Z2 h3 E3 ?
( P! a1 x( o* y, } printk(KERN_INFO "LED unregister!\n");
# {+ E: R |: U* T}% c. H. p: h5 j# d/ S) F; Q
& G& Z8 T" K: {) @0 mmodule_init(led_platform_init);
: F+ L3 L, F1 q0 bmodule_exit(led_platform_exit);
8 O, N4 K0 F! |8 |6 E& d ?; q7 w2 z9 ~1 t# t1 O, U+ [
MODULE_DESCRIPTION("Led platform driver");
$ N% C' j# j- P! [MODULE_AUTHOR("Tronlong");( L; ^8 J4 {; z0 q, W9 X8 u& d
MODULE_LICENSE("GPL");
3 u1 }5 _( p& r
# v3 P- o) v2 `$ W; z, D& w |
|