|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, N+ r& Q' }/ x8 @/ I: ?
#include <linux/init.h>
6 |, I; y; [6 k7 ~3 j#include <linux/module.h>" K0 J( g! T+ n1 j0 {! f8 P& p
#include <linux/kernel.h>
& i1 s5 T/ W/ x! c#include <linux/types.h>
* b" l- y$ x" N* O" h7 }5 t( j#include <linux/gpio.h>" c: C$ c/ J) r" h
#include <linux/leds.h>
# r* s& @) I6 ?#include <linux/platform_device.h>4 e) \1 u) }# f' U5 h* q8 Y2 t# @
* |3 A- E; y$ l
#include <asm/mach-types.h>: r1 c4 ~& O9 ^6 O- W1 o
#include <asm/mach/arch.h>
: r8 E% ~* R6 o) c#include <mach/da8xx.h>
9 C: W& n! A* }+ \! f+ Y; ]#include <mach/mux.h>4 z' T) @) `" B5 H
) ~% N5 Y$ v6 p9 u" E/ B% m6 k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 c* f7 q' X2 n9 }. B* e9 i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 y- X1 \! v" V- B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- O! ~1 r! V' H5 |( O: ^- h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 a9 c% ]4 L3 M1 H+ S
9 m, \. |4 [! q4 O% N! ~% P+ U/* assign the tl som board LED-GPIOs*/$ U1 z" k" y. E% C
static const short da850_evm_tl_user_led_pins[] = {( A7 ~ c7 O5 n7 u
/* These pins are definition at <mach/mux.h> file */8 A/ `9 U: X6 p9 F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 ]' t1 B2 `7 v6 O& {1 J/ K- Y$ o
-1
2 V$ Q$ O! w* ^/ |};
" u, c% q% W: E' x
& [2 D e! F" ]static struct gpio_led da850_evm_tl_leds[] = {* c; n4 ?* C }5 C4 x& Q. }4 o/ o& E
{* P; j2 C" o! S
.active_low = 0,8 I2 ]" ~# V; \# {, L
.gpio = DA850_USER_LED0,
+ s Q/ y! P: F( z& Q/ f/ A .name = "user_led0",0 W" c0 C9 Q! ~5 @! Q8 v
.default_trigger = "default-on",% ?# l+ ^* A- ?& ?( [
},
% Z5 c) S' U' u- c {" ~! ^& {& t' z
.active_low = 0,
@- t; z* A4 C/ R .gpio = DA850_USER_LED1,
7 R1 `9 P) U: Y- _# c .name = "user_led1",# p3 Q& Z6 v, F) L! v5 |
.default_trigger = "default-on",4 }7 @) j- r1 o' y; D+ X& G
},8 l$ d6 u9 ^8 S- d
{: e$ u9 }5 y+ |6 n9 _
.active_low = 0,
; @. X# Y- F: ]! U .gpio = DA850_USER_LED2,
K3 }3 s% k4 q7 `6 h .name = "user_led2",: m1 L" Y9 ~+ ?
.default_trigger = "default-on",6 }% x, X7 x% _' y
}, M( w- k9 x0 v% ~2 v% F" { ]
{
# H+ x- b2 V+ i2 B( n& T .active_low = 0,( z: d5 c* F0 h. Y8 _
.gpio = DA850_USER_LED3,
2 }' A5 l4 v; R- P& v7 q+ B .name = "user_led3",
; M4 A, o' M9 h" f8 b7 Q: {& n( v .default_trigger = "default-on",
- e: Y7 k. U! P) ^9 H5 O7 @ },7 h9 S2 A7 g* |& b
};" u8 V7 _9 g- I
, ^( x7 P8 N3 w- I U, t' lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 P1 n' S- l, K4 [" c+ j6 N .leds = da850_evm_tl_leds,
. C/ z' V- a2 i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# ~* M# ~" d+ Y% v* Q# m
};
: K* ?0 W7 K s6 |2 Y* o$ V
6 H3 M: g& o6 ~static void led_dev_release(struct device *dev)" l& D# D) H" u
{
6 B$ Z1 c, k! k$ i: L+ H T};9 f0 W0 |" w+ N! T1 h% v. F* Y( \
2 u& h7 T& `) V. A1 F6 E J. |* {% Gstatic struct platform_device da850_evm_tl_leds_device = {
4 T5 n5 L1 E% A. b1 M .name = "leds-gpio",
8 ]1 o0 e. F3 R- @; }. k o; W .id = 1,1 f7 @: }- K; m/ [$ {* @
.dev = {
$ x7 l G3 o Z& b3 f0 x .platform_data = &da850_evm_tl_leds_pdata,
5 V$ ~" n& S& @* ^: }+ F6 C .release = led_dev_release,
9 V ?) w$ x: Z }4 J/ d" q' T' n v" T$ s
};+ G" K% d$ v2 d& A
7 a. Q. Q6 i6 g+ I( p; { P, Q; Sstatic int __init led_platform_init(void)
! p6 K8 D& S2 \9 ~8 k- l{
! [$ `2 p9 U0 F) z5 ? int ret;& R6 U! U, G+ _ t
#if 03 g) p2 v$ a! c4 w R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ Z5 S, G/ T, G6 e if (ret)
0 \/ v8 R, ~* @& r" Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ K3 B8 Z) v# f
"%d\n", ret);
) b: z# j( J6 ^6 T#endif" F0 i' Y+ q. Y8 N
ret = platform_device_register(&da850_evm_tl_leds_device);5 D3 L+ W4 z. |7 ^: ~0 P( q8 W3 u4 K
if (ret)# x0 z' W; e* {5 H9 e8 L
pr_warning("Could not register som GPIO expander LEDS");5 y9 j" [% f& D8 i, u
else
/ K e5 o* h, F printk(KERN_INFO "LED register sucessful!\n");4 e' ]3 v6 H& f8 M
/ W6 S- K# }5 ~: m5 r
return ret;
* l0 x7 a5 ^& k. D! v$ R} E+ R1 K3 X, i7 A: M$ U
- E( i* n2 j5 y2 f/ kstatic void __exit led_platform_exit(void)
& h# n1 k5 [6 M. b5 C# _+ V( [{$ l) P! x( h$ M) ^. K
platform_device_unregister(&da850_evm_tl_leds_device);
: n7 y- B3 v( x- p& H: E6 b! D$ B# C
printk(KERN_INFO "LED unregister!\n");0 r: p4 b% N3 q& n7 O
}5 D8 S" h* o8 a( f# R9 W+ s
9 e" M4 A( r; s: } }5 D# v% C
module_init(led_platform_init);" A! p7 K, y0 h" d% n
module_exit(led_platform_exit);% _' f5 I4 u/ |
8 c e1 L% l; m$ J' j: MMODULE_DESCRIPTION("Led platform driver");
) x+ E+ O5 w) T& Z. D: wMODULE_AUTHOR("Tronlong");
$ d* _+ M" g4 S9 |& ZMODULE_LICENSE("GPL");3 p1 h- @7 d% u/ V
+ r( u$ D, ~2 _( j+ D: Q( S
|
|