|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 Q( g2 K" k* s/ V3 l
#include <linux/init.h>; j K+ h8 D5 V5 H$ u
#include <linux/module.h> v& n( b- _( R- n& N
#include <linux/kernel.h>
8 Q7 ?/ H1 l3 [#include <linux/types.h>
" s6 }; Q. f p/ }5 S& ^4 [" r#include <linux/gpio.h>
3 P3 K+ f4 p$ i! p. Q) a [#include <linux/leds.h>3 I* ]8 J9 I# Y$ n* Z+ t
#include <linux/platform_device.h>$ |- n$ k/ n% s. a ?
2 {0 ~6 d# c+ f& d9 h: \#include <asm/mach-types.h>* {+ S* ~+ @9 ~& s7 M
#include <asm/mach/arch.h>
; C% q' h: m- V6 d: `: u& |9 J#include <mach/da8xx.h>
3 ^9 T3 w5 O! W2 c#include <mach/mux.h>* f( J# ~! O" {0 z
9 f, J$ M* b5 m B8 Y' S; T, W# ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 g2 q- s/ ~1 S. f2 j1 F/ |#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 j# c; ]4 A; c+ m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 \9 w2 u( M# b! w' v! M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' m% h& f& r9 a" E R0 I; x/ e1 ~8 D% D) M O5 ~, Y1 w
/* assign the tl som board LED-GPIOs*/6 U& U1 p- C. D3 ]
static const short da850_evm_tl_user_led_pins[] = {- [% `( G3 P2 }/ X6 Z$ `
/* These pins are definition at <mach/mux.h> file */
. d8 ~" _. }; s" ?4 \/ f( f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# Y9 w* b9 B- O; | -1
. h# O$ r$ \. M7 F4 d+ r4 A# I};
9 n/ L7 \6 i( {1 n/ r: |- K2 n3 {: G9 ?" L" y* O
static struct gpio_led da850_evm_tl_leds[] = {, A7 f. C7 O' m& H) ~( }
{
5 @( M3 R p" t: d4 ~' s .active_low = 0,+ l) S0 X! V) D1 A+ A% K
.gpio = DA850_USER_LED0,
' @! | q; s* d* ~: R+ F* J .name = "user_led0",+ v2 Z; B" \6 w5 E/ N" r* e
.default_trigger = "default-on",8 X' _: O" h% v" T7 K! A
},' X# u: K) \ R$ n5 o; l1 J7 K
{
- w3 ~1 ~( ?/ Q3 x, ^ .active_low = 0,
0 K' G0 o: s3 _. J .gpio = DA850_USER_LED1,
3 W0 I0 P" M4 a .name = "user_led1",. Y; A5 u; J% R' l0 M/ u
.default_trigger = "default-on",. A* |9 P% V1 X' f' z0 [* F
},, L3 h q" G# W6 H. E
{. [) J# u# V$ f) g" x$ u# g; }4 W
.active_low = 0,0 c3 V' g* e' I
.gpio = DA850_USER_LED2,9 A& }$ S& a% ?
.name = "user_led2",7 x5 L$ X% Z6 F, ~5 C# h( g
.default_trigger = "default-on",
. P( v* {5 d7 Y2 \4 |- h: V },0 Z3 c: l/ [" }/ _. O
{
; j, N1 g2 I f1 R3 D N, a) q! Z .active_low = 0,2 Z* W1 e4 z& x& `
.gpio = DA850_USER_LED3,
4 @9 Y* y4 X2 q r4 X# ?4 ` .name = "user_led3",
. u! W) P! r( P8 p .default_trigger = "default-on",
# G: O+ S! L3 g% Y4 q. P },$ t. O3 H2 v; Q" f
};
. _: X) r- C3 a- H/ {9 X3 Q
: }% P( {& E# O: k4 T `1 s$ Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 e S5 a7 B5 I" h2 H- Y& v2 u
.leds = da850_evm_tl_leds,( q% u* i; p9 L- p$ d5 G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 t5 R3 T& q. S, |% s ^};! S6 B: F, o/ A& r) ?8 P# _
% e0 f+ Y' z: o6 Y: p
static void led_dev_release(struct device *dev). A6 a/ R9 J% p- y/ J
{
) q) _0 V: Y% X7 a& x};! C- q) `1 ^. r* o" a0 i/ l
* j& I# _2 |& d/ M: ~, C* f
static struct platform_device da850_evm_tl_leds_device = {
: R9 c9 J% E! ~& _# n `. d .name = "leds-gpio",
- g- J/ e+ G8 a3 }; k! X .id = 1,2 v" P, `8 }8 E: {
.dev = {
8 T! q% h" u6 { .platform_data = &da850_evm_tl_leds_pdata,, z2 S6 Z5 {$ D- j0 a
.release = led_dev_release,3 C2 Q( {! P: ?3 {9 Y/ M
}8 i! X' A9 F9 [6 V
};
! h4 z4 \. u5 \+ I( [- [2 L7 {% z+ [+ c4 g# n% P1 W- Q* A1 m
static int __init led_platform_init(void)
/ ?3 ?' Y9 ~% L @# i: T$ C{( N6 i9 ^* w' m/ U; V0 k% c* E. @
int ret;
: j. o7 b$ M! M* |#if 0* n$ _& Q* B: |* q B
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 C- I3 c: b( P3 L0 D
if (ret)
' _# a/ H8 f L/ }' i- x/ _% n4 Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 l2 P- x' {; [+ w6 U. \ "%d\n", ret);. E8 c( g. l/ E- E3 h0 k6 k
#endif, b/ Y- M3 E3 i$ E- \( U/ w. J
ret = platform_device_register(&da850_evm_tl_leds_device);# m, W. @. d, D' W( g. }
if (ret)0 `. `) z0 ^( [9 z4 Z, H y( T
pr_warning("Could not register som GPIO expander LEDS");
& X6 H* G" `' R0 ?3 J else
! k5 ~, C, I3 M9 s! c% d printk(KERN_INFO "LED register sucessful!\n");5 k! s# H r3 r5 U0 b' U
/ D5 @1 \ K6 V. ?/ f return ret;& H( ^4 j: b2 a
}9 N; e1 I. ~+ S
1 c; `' u: M$ z9 W" ^8 w" qstatic void __exit led_platform_exit(void)
0 o( A @* i2 p5 X- Y _$ [& x{
' F2 C6 Y/ y* A1 P; E platform_device_unregister(&da850_evm_tl_leds_device);" i$ q! ?3 o' i2 o: S. h9 y
4 n% K0 s) ~- R& ]8 Z% C printk(KERN_INFO "LED unregister!\n");# b4 k0 T& A" @5 M
}
/ c; x% {" ]8 L1 C* D# H* q' V3 g6 p6 N0 |
module_init(led_platform_init);
6 C* o! }% b+ I: ]! W$ zmodule_exit(led_platform_exit);
" m. K1 j( z7 H0 X4 N% A& x( \
; t; M" p' G: u- z( DMODULE_DESCRIPTION("Led platform driver");" V' Q2 [. `$ c. R
MODULE_AUTHOR("Tronlong");
$ ~# ?$ H: ]: [/ CMODULE_LICENSE("GPL");
; F; x, C' j4 d1 m# @& a# j S! |
* J2 K7 i$ k; {& T7 _ |
|