|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ e5 e2 G8 {$ d5 |1 ?% @+ ^
#include <linux/init.h>' r3 V- `* P. }& a& z
#include <linux/module.h>: d4 s! I- }1 S6 ?" a7 ]4 O h
#include <linux/kernel.h> L# D6 D5 t# a+ l1 U
#include <linux/types.h>* U% t7 C3 g' M
#include <linux/gpio.h>: Z8 G: t/ f6 Z( D8 D
#include <linux/leds.h>9 g1 `: R" u% l+ q
#include <linux/platform_device.h>
8 g" @; P" L2 \* L; S! f& O9 s$ u, c6 s: G5 e
#include <asm/mach-types.h>2 H4 `& w0 m) h) w: Q
#include <asm/mach/arch.h>
7 @6 A* ?$ l7 P+ u1 C#include <mach/da8xx.h>
6 @$ c$ X: E+ z#include <mach/mux.h>5 ~4 c" y. B0 @+ k' J) x
/ ^3 N6 g( R9 m4 o; l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& \7 a% h( h3 p! B* v* b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# g0 N& j5 J1 L5 A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); @* x. R( U% s- }, R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- E' \& `0 D2 C# e
O0 ]( T5 ?# t/ O
/* assign the tl som board LED-GPIOs*/
! x! N+ L) D" w+ qstatic const short da850_evm_tl_user_led_pins[] = {
2 I/ c/ m9 x! v/ P' W3 y /* These pins are definition at <mach/mux.h> file */: _5 l+ f: ~0 d+ h9 {% V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( f* d/ _2 K5 c' {- y- Q -1
2 D) q- _" r/ k. a- s};
c8 y% \) v- S: t
1 A; M: G8 [# _# A! Kstatic struct gpio_led da850_evm_tl_leds[] = {8 q: a! ~* o, i
{
+ M2 w) y, C4 V% ?' ^/ y$ y .active_low = 0,* \1 f' v9 W+ O! N* T
.gpio = DA850_USER_LED0," i+ h: s' T" ^. d
.name = "user_led0",
$ T) `5 U7 G( Y. Y! i7 T .default_trigger = "default-on",
: R& }8 l& }* s8 R" m },
1 ~& R$ K- d& x1 e {4 }1 o8 p) O( i0 u8 { K5 F# K1 }8 K
.active_low = 0," n6 X. ~+ l9 i3 l
.gpio = DA850_USER_LED1,
/ L3 O* f# ~9 f; R2 A .name = "user_led1",$ ]0 O9 \0 L7 K4 B
.default_trigger = "default-on",8 T, k8 e3 I/ f) y' B
},
3 X1 M1 l4 L) x# B {: p, ]6 \+ D% M
.active_low = 0,4 f$ t+ Y1 i" D3 g3 G- x& B
.gpio = DA850_USER_LED2,6 X3 e6 O j, |2 |2 o
.name = "user_led2",2 o2 `* U& |! ^1 c7 |) D3 `' `* l
.default_trigger = "default-on",/ e3 t. l+ L' M4 d+ m* B, A, t% e. z
},$ c1 Q/ T$ @% b. l9 b" ~& C
{
7 d& }& m4 K+ U, l( c8 w .active_low = 0,
5 x3 j' B! T# J* l' f$ L .gpio = DA850_USER_LED3,% ^# o2 B7 U) }& a9 H/ w
.name = "user_led3",
( n: Q7 w/ H+ k( i/ j .default_trigger = "default-on",
* V4 C% e6 G5 | },
4 z4 f! M, z6 k# R) n};
0 M) K h* _/ K; q/ n& L. }/ m% ~0 H" I/ t4 A! Y4 Q6 k: ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 M- P6 b" H& r$ m! A0 E. S
.leds = da850_evm_tl_leds,3 s$ I8 E7 f7 ?" K9 O0 `! c1 S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ d# N* O* B& m% d+ \9 |# ~};
# n( Z3 D4 p" U9 o& b& e8 D. y, u. A$ w7 i
static void led_dev_release(struct device *dev)
7 M3 q; y5 t2 T. y$ ^) y{3 i* w& ?/ O' H z8 A( p
};1 }. I; e* t# _1 t
& h* @ H# H5 ostatic struct platform_device da850_evm_tl_leds_device = {" ]& G' B* ~1 J9 ?: \: w
.name = "leds-gpio",5 @" o' f1 [3 p4 E3 r5 ~
.id = 1,. v* j0 D! ]; J. R2 j, ~4 }: j
.dev = {
0 x, G% v9 n( [4 ]1 o# u6 k( ^' c .platform_data = &da850_evm_tl_leds_pdata,
4 S6 M+ u4 Y. M- ?7 P. \- H8 p .release = led_dev_release,8 ?1 P7 b6 C/ W2 B: U, T
}
7 _" x: W) L! `# z1 ^( Z; J' x) Q0 j};& A: j7 r* Z2 H6 z" B
/ v8 d& c7 F, S5 ?+ I# e6 Y
static int __init led_platform_init(void)9 R' k1 `. E: f' \0 I8 T
{
}" a4 \3 S1 U4 a% e& k int ret;+ H* \ a5 F, D3 u! \: Q6 N+ H
#if 09 O9 m* S& g# J/ A1 W3 w$ Q( q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ Y. M/ ?% k1 S; f- X" w
if (ret)5 _, N+ i) I5 Z4 J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' y4 u) A+ T$ g* y "%d\n", ret);
$ p, K+ H1 \5 ]! E& c* ^- w5 v#endif# A1 i" J2 V# o! W( R/ w' @
ret = platform_device_register(&da850_evm_tl_leds_device);
, L% e* R: T$ ^2 G: } if (ret): S6 Z9 ]# P7 a/ D- j
pr_warning("Could not register som GPIO expander LEDS");& w5 O, m4 D6 w% V2 w$ z0 P# ?# A
else8 H% ^$ L" {/ W
printk(KERN_INFO "LED register sucessful!\n");
+ {1 Y- R3 M0 t; C: K4 O |* B# }% K3 X! c" N1 e* W9 S
return ret;- [9 i3 L+ {# o ^6 T
}0 S' x2 d, G: r% q( ]+ O
. y/ Z- _/ g' p: x
static void __exit led_platform_exit(void) T J' f$ q4 y4 L( ~
{
. P F8 q4 ^# {" Y platform_device_unregister(&da850_evm_tl_leds_device);
6 F! p6 P& x' K# B* [- W4 E" M+ u9 c" }1 |/ Y
printk(KERN_INFO "LED unregister!\n");
9 C2 j# z G" E5 b}
# p7 A4 u1 F% _1 l! p" G
: ?0 W7 \9 h# z' V! T1 u7 q8 t0 R4 kmodule_init(led_platform_init);3 |2 f0 H) A ]5 ^' R& R+ Z
module_exit(led_platform_exit);
6 B2 |1 d% S" x0 N! w8 g3 i* ] n* l0 @: d$ A2 m% Q
MODULE_DESCRIPTION("Led platform driver");
* m# ~: |3 w$ x Q1 p6 }: t( RMODULE_AUTHOR("Tronlong");3 j: Z/ T/ c6 h7 _4 G
MODULE_LICENSE("GPL");2 m! `4 p' ?- X% W I! r$ ?- w
$ S9 e8 L: E# ^3 G: t- O' x |
|