|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& H. u) ~. E- ]8 ?7 `6 p6 n
#include <linux/init.h>5 }" T" T# W4 q4 Z
#include <linux/module.h>
+ ]; Y" q' h8 K0 D: l9 m#include <linux/kernel.h>
! u5 J+ a8 G( ~" w/ U9 j" |#include <linux/types.h>
, [% P! L. ]0 o#include <linux/gpio.h>
+ f$ ~( B; V2 G#include <linux/leds.h>
$ r0 {" p; u* ?& F2 j7 m7 b9 ~& Z5 Z#include <linux/platform_device.h>
4 f. B4 A& P0 q. p+ Y; W. U7 t4 r) b* R8 s* z) ]; m
#include <asm/mach-types.h>
) d. _! f) ?; p- N: x+ x! O7 o#include <asm/mach/arch.h>
; b& a+ D- z- X1 o0 a#include <mach/da8xx.h>
( V- x6 |7 `5 X" v. Q* p1 r#include <mach/mux.h>
1 w( D2 V2 T; z0 D4 w
# K5 C( s$ x1 \1 h, w8 D7 A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 D; _3 o# S4 J( D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% Q- B. R! ]5 v2 Z/ r/ ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 j' I. [9 _+ L
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 ?& p" X; {' H5 {& j
9 W4 V! I1 v" R6 Y: i/* assign the tl som board LED-GPIOs*/
0 e5 s9 W! y9 v( h- O: p3 ostatic const short da850_evm_tl_user_led_pins[] = {8 S$ J. `: T7 o
/* These pins are definition at <mach/mux.h> file */2 ^: x, v' u2 H) o. w0 @( F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- X* O9 z( m/ O/ C
-1* G. Q4 i: | j5 v. u3 p
};
+ _( X6 r8 \; |7 a, n
' L; `' [% {8 R0 }+ astatic struct gpio_led da850_evm_tl_leds[] = {! }( K4 H6 O$ r5 A9 H' d( l1 g
{& W9 O( I5 f9 y$ d
.active_low = 0,/ o& p9 m9 D8 T
.gpio = DA850_USER_LED0,
# V( @: L$ L2 h; R8 V .name = "user_led0",$ y% o" Q( }: r! ~
.default_trigger = "default-on",: w/ k$ b- c: Q! W: A0 `4 l' S
},
& O: @! R# K! w {: n6 s/ v9 N3 z! v! q8 |4 h
.active_low = 0,/ e* r2 ^4 X$ ~! E
.gpio = DA850_USER_LED1,5 t' E# t, Z# p" ~" H! g
.name = "user_led1",* g/ W0 ~9 k- t
.default_trigger = "default-on",2 ?& O- E L6 g$ C) B5 J* _8 x
},5 Y8 f: ?6 X0 p0 C
{
9 A$ e7 z5 p) K5 S2 R .active_low = 0,
0 C. P: @. k0 H9 o .gpio = DA850_USER_LED2,
) I6 }6 L% I' F .name = "user_led2",
0 T* ~9 H' _( Q% \1 d6 N: p .default_trigger = "default-on",+ w+ E1 O2 R$ X# J$ M/ U
},
/ q4 |2 w2 O! v {* x9 e; [5 b3 Y$ f! r
.active_low = 0,) X7 x2 z( N* U
.gpio = DA850_USER_LED3,
3 \3 v& W3 S" y* ? ] .name = "user_led3",
# ?1 p Q; |4 { .default_trigger = "default-on",
4 _1 M9 |6 J. w3 B* e- {6 z },
( o' K A# B; y$ q% f, C};' c3 t* U7 V* @& ?
2 M( B" q1 G4 h$ G3 X+ Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 |2 x& {8 V' X6 U7 Y0 P& z4 I
.leds = da850_evm_tl_leds,
; H ~+ Y$ z2 n2 s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! [ D5 }5 e1 G0 i
};. a( b/ s" o5 {' D+ t4 l- K2 i: \+ r
, j( c7 V$ N* X" ^2 pstatic void led_dev_release(struct device *dev)
4 U' `. a! @% U' O" Z @% e{4 D o) y# n0 L
};9 t& m7 R) I# M: O% E7 b- [
) T2 `! X/ z. Z9 b1 B- S' X
static struct platform_device da850_evm_tl_leds_device = { I1 O3 y6 ]& t: x, Y" M7 {
.name = "leds-gpio",. r- h5 C7 T4 m+ O j9 D
.id = 1,
2 T8 n6 x& a7 O( h0 S: L .dev = {
. |3 Z% ^+ {8 p6 B .platform_data = &da850_evm_tl_leds_pdata,
' b. C: w; K6 Z. {5 H .release = led_dev_release,
% W/ ?' M" K) g }7 u8 J# d$ ?. ~7 G4 t. v; F
};
0 J- w4 P9 O5 N" \
3 U3 E( P- ^0 c2 F1 p. ]static int __init led_platform_init(void)% r g6 I% Q* n9 a4 H2 \/ ]
{
" |7 s* e( B x( O7 Z int ret;+ G3 G V9 @% c) H5 v
#if 0
0 b* O, C- o# D! H8 O1 J+ L5 z/ _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( m! |8 C3 O* r3 I( l- z4 q. q
if (ret)
, s. P9 J9 h, V; V! {5 | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 b, ]/ A8 a" A% r6 `$ J0 P) y
"%d\n", ret);
( W& L+ E( C8 R+ p1 i$ X#endif
1 o6 c. v3 W& \ ret = platform_device_register(&da850_evm_tl_leds_device);+ g, ~$ S$ @# t
if (ret)
5 x( {0 n8 j% R; A9 u, |4 ` pr_warning("Could not register som GPIO expander LEDS");
! |, v7 m5 \6 g# k else& D& U/ r- }! O3 ~7 @
printk(KERN_INFO "LED register sucessful!\n");
; J" X; Y1 M1 \4 m3 u# R4 Y) i9 n0 O* P% u! _3 g) I
return ret;, f: }" i8 Q8 c+ k
}
_5 I9 k! t+ }" \/ w2 E% j, a ~) c( U5 k: c K8 }
static void __exit led_platform_exit(void)
1 P; t4 @0 h' l8 B; k* C{
( ]4 [# x) Z! G j/ z platform_device_unregister(&da850_evm_tl_leds_device);8 D; W) w8 z0 Q$ l6 G
. P8 _5 ^6 |1 n$ w0 ?* O) s4 c% P5 P printk(KERN_INFO "LED unregister!\n");
' P! q. `+ K7 i6 z% ~}
2 T" H! w7 ^8 q; G2 B5 m% D9 j$ s, s. T# N& s
module_init(led_platform_init);
7 c. j1 U ]- ~6 ]. b% m# b' B) Pmodule_exit(led_platform_exit);4 C7 t6 X# F/ m: |$ T. B$ Z
; n4 M% H6 ] z; D, W, e
MODULE_DESCRIPTION("Led platform driver");
% S% B3 S. Y# K- W m. B' Y2 V$ ]MODULE_AUTHOR("Tronlong");) I, f3 G/ e" j ^/ o" G3 ?
MODULE_LICENSE("GPL");
1 S6 v1 N2 S& a
7 f1 m% b" E+ I: @0 x4 I6 m( H; Q% h |
|