|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 D- K( r7 x9 f5 A% g
#include <linux/init.h>7 J, ~! @& m/ k$ U2 A9 w" t- i6 ?
#include <linux/module.h>: x/ i0 n" m- n& ]4 e
#include <linux/kernel.h>
, D7 t& p: g1 l& H$ Q1 e. V- o2 C#include <linux/types.h>
# U4 R3 C& J9 Z" ]0 d#include <linux/gpio.h>
9 K. i7 l1 J& Z+ f+ L& ]7 D& N5 }#include <linux/leds.h>
# a8 J6 q( N8 H8 A4 e#include <linux/platform_device.h>
( x, I; ]/ Z! ]! U5 i8 Z
) d2 L/ H7 D* \#include <asm/mach-types.h>2 b( T g2 k1 s7 m# P5 O* N. _
#include <asm/mach/arch.h>& d8 W1 E2 K0 s Q' L6 z$ T, H
#include <mach/da8xx.h>
* I2 ^1 N. X0 t/ E% a#include <mach/mux.h>; b- z/ b' |1 G6 v. |9 k
$ F( V5 E# l, H7 A7 f; g* w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% Y6 O, S9 j' t, m/ ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* ? F( [3 x" m) m# n" `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 c ?4 Y& y9 J#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 w7 |2 m% |) i* ^! A ]% d% `5 f. M7 o8 ?0 C- q8 T
/* assign the tl som board LED-GPIOs*/6 n! r+ O9 @# L: ]
static const short da850_evm_tl_user_led_pins[] = {6 @8 Q8 b7 o& {
/* These pins are definition at <mach/mux.h> file */
O$ Z# o# x: J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ h" Y, Q! N6 u { -1
L8 T4 ~9 n! Q$ M};
; n U; c1 ^( H8 `; e
2 i% c8 A( x+ E* f; ~static struct gpio_led da850_evm_tl_leds[] = {! T. ^ d" M9 l& \
{
0 _- { y: W4 n, O2 O k0 E+ f; p" f .active_low = 0,6 Q8 ]& b7 s2 Q T6 ^7 S4 b6 n1 I# G
.gpio = DA850_USER_LED0,
c$ T8 m" b5 c7 D* o .name = "user_led0",/ a6 H8 q( w5 D3 F) P- k0 |
.default_trigger = "default-on",
$ w2 }* z5 h" L6 f },4 k2 R3 w. n' G
{
& u& j9 Y; X; @ P .active_low = 0,
! g6 ]5 C9 o% `- ]1 h .gpio = DA850_USER_LED1,0 H5 L: j, V$ m4 s# }7 S, M: L
.name = "user_led1",
2 g/ K6 @0 D& t6 f- v1 I .default_trigger = "default-on",: W. r* o' g" h# t8 }" A/ m1 u
},
: J6 ]- W; Z3 @" r$ x {
, f$ s* d# l( \1 H# u .active_low = 0," j* B$ R5 c {! ~: k! L
.gpio = DA850_USER_LED2,
U6 j4 n# S8 |% A; G6 G& f2 Q! Z .name = "user_led2",
% u( k$ [4 G5 M1 l7 x. c i) N .default_trigger = "default-on",
2 a1 L" [4 X0 S$ Y. U4 {2 F },8 k7 L- r- }+ N2 g
{& C6 s4 z3 X, a
.active_low = 0,% O! O L+ }8 P7 X) V& _% j
.gpio = DA850_USER_LED3,# Y7 L* e3 m% M7 ]! y8 N
.name = "user_led3",9 ^2 Z Q" C# i/ i' e9 Y" @
.default_trigger = "default-on",
% Y4 {% }) Q0 Q7 a2 a },
3 s) d2 k: i7 T) d0 u, D9 |9 X};1 ^0 G% [2 [, }2 {
8 m7 L* k T/ m* b( W! Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 l2 v) S- W; P- _: L .leds = da850_evm_tl_leds,
. h& ~: D0 T" C- M8 z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. |/ B/ A+ N" |4 K- `/ y% _9 o8 E6 C};$ \1 P* P @7 s. F
# K8 x5 }, y4 i9 f9 \, [# t7 l5 O
static void led_dev_release(struct device *dev): g4 k4 D }" ~% K/ n
{
4 r/ w( e9 ?# y, G8 {( K6 X' C};6 z; } f2 X! p! \. e
; P; `) j% F1 Y. Q: Q9 m; ^0 p6 F
static struct platform_device da850_evm_tl_leds_device = {
1 w4 w8 g* X2 c; Q4 v .name = "leds-gpio",. Q- Y$ [9 S) n. a; L
.id = 1,
j$ j5 g) U4 H .dev = {
- N& D [3 B/ a8 v+ @6 U% s .platform_data = &da850_evm_tl_leds_pdata,$ H* |) z3 `# P5 w- T! E: S
.release = led_dev_release,
3 p! n+ @$ t- x8 Q+ N. o# l# d }
. q% g, M' r. u+ c* l/ I};% C, E% K5 m5 U" F
# m- C& `/ }' R* k' K9 Z% H
static int __init led_platform_init(void)1 ~) k# }: N! k7 {4 g* w
{
; K7 y2 N5 ^/ \2 M5 R h int ret;$ E% E* f2 ^3 P) d8 u- a2 B/ j
#if 0: Z- L$ Y3 L1 f* s' z5 F
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( {7 d& O" K8 L& t* u6 B4 n, n if (ret)
2 r1 i# }# u- B5 m9 g0 _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 P) o1 }5 d8 t* [
"%d\n", ret);0 Z8 Q; t# ]* v; q7 f4 `
#endif
! E, E0 E( h7 [: r7 m! M9 f# V ret = platform_device_register(&da850_evm_tl_leds_device);
2 M0 O6 C2 ], ?$ } if (ret)6 d" v9 X2 U/ C+ ?7 R
pr_warning("Could not register som GPIO expander LEDS");" C, ^0 o& N' x! w y
else# i+ L2 R$ T3 M1 g7 I( V# r* [# ]
printk(KERN_INFO "LED register sucessful!\n");
9 A x+ w' r) I; x4 T& P) R+ _. Z% S/ a, k1 A: X, s
return ret;
: |0 ]% \3 y0 M! D; |}
( |. a# t9 ]3 w* d$ K1 l( ]# i: V4 q* {
- P1 z, X2 R1 I3 ]2 x* d) E" Jstatic void __exit led_platform_exit(void)
5 D9 ^; J- \" R; J4 m% i{
9 z+ H1 k' C" X8 W( F+ W platform_device_unregister(&da850_evm_tl_leds_device);
# ?5 i5 F1 r2 Y' j* e }+ w. C. [! ^" e2 `5 x5 m
printk(KERN_INFO "LED unregister!\n");
3 F9 L8 j& H. g- v8 U& O}. i5 ?, ~+ R. U2 x- s! K( h/ G' ~
. O/ Q! _4 L# F& G# h6 xmodule_init(led_platform_init);
# h" E' a) V. P/ c6 Tmodule_exit(led_platform_exit);! r K( e$ I2 F+ g
8 i- _: N8 ^1 S2 m5 Z% F/ W! WMODULE_DESCRIPTION("Led platform driver");
& y/ D- H5 Z% j4 a- zMODULE_AUTHOR("Tronlong");
A3 p' f- {+ b3 _& t1 y: RMODULE_LICENSE("GPL");
# f* B$ q7 K0 Y7 L6 A4 w0 p8 n. G
! b: n/ w0 \" w, E) J; f' C* D# n |
|