|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) w% w1 b9 o: F' E#include <linux/init.h>
1 i1 G5 |/ p: Q4 }! S, R#include <linux/module.h>9 q9 V6 X. |9 x6 `$ F
#include <linux/kernel.h>4 E6 m1 n( U) }7 g2 B3 K
#include <linux/types.h>: f/ ?! D! z$ x
#include <linux/gpio.h>* J" [4 |# S1 f% J
#include <linux/leds.h>
1 [7 ~4 n: l% x7 R3 R* x" F#include <linux/platform_device.h>1 O8 g7 t" u* Z9 d8 q' w
* q" W7 ?, B3 r% x" J0 S$ M5 _#include <asm/mach-types.h>3 ?0 `$ E" O/ r4 K
#include <asm/mach/arch.h>/ X+ x; F+ b3 {4 u. y1 Z! F
#include <mach/da8xx.h>
0 _( A V p- Q$ d#include <mach/mux.h>+ I2 l1 t; i: X$ K
. w) z! G% _3 D+ @! \4 T8 _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 u& Q( X* P- g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; x$ L, M6 N) h% J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ i1 Q: h3 d2 x: {% U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 z6 L0 H. g W/ C( A) ^9 n! @
$ U; M4 z- c# [) o- Z/* assign the tl som board LED-GPIOs*/& z2 O; ]3 z3 X6 b! ]/ {& @
static const short da850_evm_tl_user_led_pins[] = { x- j/ t( q2 y+ B6 o) h4 u
/* These pins are definition at <mach/mux.h> file */
. m7 v1 ?2 y8 B3 a. T# K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ L' w M% @) C5 t# j -1; d' ~/ u. Q) H) q
};
5 r M( o! ?3 L- @6 c u _, ?% N% i( J8 ^: T) U& P4 I
static struct gpio_led da850_evm_tl_leds[] = {+ I X. V: c4 @
{
8 L5 }; _8 G) G" q- P- Z4 q .active_low = 0,9 I k' a0 w; p" P5 A v
.gpio = DA850_USER_LED0,, R- ~% }. g/ d2 R+ I
.name = "user_led0",
8 U" u: b; m- r! [1 e2 K0 d .default_trigger = "default-on",
' K2 g' t+ W, i5 u$ b },
: g, s( H- p: l {
; l- D3 i8 G' Z& E .active_low = 0,
& C, y+ ~8 K3 Y- X7 t/ w .gpio = DA850_USER_LED1,: h1 R" {1 f% z$ [; ~9 `
.name = "user_led1",: k' Z# n% H0 K" V- K
.default_trigger = "default-on",9 v/ y: i' f {2 s1 Z
},. U) {* q" k" w
{
5 {' r; [% y) J, \9 _* b& q .active_low = 0,( {$ J6 r1 ]( n5 s6 K) g$ Z
.gpio = DA850_USER_LED2,. O7 Z k6 p/ N
.name = "user_led2",
. W4 Z- W- W1 E .default_trigger = "default-on",
, F% d! @: Q- [ },
( a0 }( I4 W8 P, B+ h {
7 ^7 e5 Q# P- R1 N8 d# k7 g .active_low = 0,
/ A' D* r" p3 F+ L .gpio = DA850_USER_LED3,
+ l6 b2 x( X+ C( d, K8 a% u .name = "user_led3",/ K7 \, e0 R6 r0 j( y8 d% w! c
.default_trigger = "default-on",3 q7 Q# t8 h3 r8 r: U9 ^2 T% b q5 b
},
3 b3 f5 I- D H+ }4 E! |};- R" q+ Q& C( e `5 V8 S% {
0 ~6 m7 Y' _5 w$ N- _! N0 {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# _( `* y+ G5 v4 W6 z I
.leds = da850_evm_tl_leds,7 ^# D: ]- F- R9 y' A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
W( f- \4 G R: S1 Z; z- B8 C; w};; t: F6 t$ g0 T
- b1 s6 R/ {6 h; @
static void led_dev_release(struct device *dev)
6 [7 S ]% P8 v8 t7 v0 r. o9 J{/ @+ E* F9 I: a- K/ n
};1 _2 g3 E5 O1 P, c
4 O4 r3 A( u3 p D7 Kstatic struct platform_device da850_evm_tl_leds_device = {
% s5 `! H% h2 x3 ~8 ? .name = "leds-gpio",( u; p8 l* B" E' ^0 _6 s
.id = 1,
) d% u: P/ Y( h' a! |; ` .dev = {6 k5 S4 |% ~3 P% \! t
.platform_data = &da850_evm_tl_leds_pdata,+ ^, W& O \) o2 U7 m. D; `
.release = led_dev_release,
8 }7 i# r1 v- _3 l }
; A! ?% H+ i0 u9 U k. _};) X/ Y' s# \9 O% ~# y% F& k% t. ?
% g: u D' w+ s# C
static int __init led_platform_init(void)- c9 M5 i7 u; U3 @: H
{
7 l, F/ E+ L f/ P" ^) r2 i) P int ret;$ y" s+ r* U9 c2 W% J
#if 0: C/ f5 `: G/ i3 Z5 c( y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! A3 D& g) g, @
if (ret): t. V- Q$ F: F8 e7 {+ B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 u/ e* V! q5 M2 f9 f! D
"%d\n", ret);
8 q! a' t/ E1 b9 U5 N& v2 p8 C#endif
! |+ z2 o v0 [$ t ret = platform_device_register(&da850_evm_tl_leds_device);
; t" k9 {$ [8 ]4 d, Y if (ret)* O- b9 C$ I3 |
pr_warning("Could not register som GPIO expander LEDS");) g2 {$ O) i4 h c4 Z) I% P
else
( o6 J- ~1 n" F x! T& r6 _ printk(KERN_INFO "LED register sucessful!\n");
) N$ ~: [+ j1 M Q
_$ e2 `! I- S2 L return ret;
4 ]- I9 N3 u3 g+ s5 b2 m' E}
3 E/ p; }/ T7 I6 N% k7 _! n4 H) [; H. ~! ?( d
static void __exit led_platform_exit(void) X0 g8 a! s- m2 z7 I
{
3 h( q, J6 L! g9 Y/ |& n platform_device_unregister(&da850_evm_tl_leds_device);
' \1 s$ V* S! f! V
+ c( ?' z; B! y9 q, P printk(KERN_INFO "LED unregister!\n");% @" `& J$ s2 j. [
}: C d( m9 N) g$ i
5 q& z& K. l2 t8 H. I* M
module_init(led_platform_init);
2 ?0 L; D* p$ E omodule_exit(led_platform_exit);
, p$ K6 e) N4 `' J- u3 D |1 X" \& q Z% G
MODULE_DESCRIPTION("Led platform driver");4 V' Q2 ^- u" c+ H
MODULE_AUTHOR("Tronlong");, |. |0 `( I+ l2 l8 O0 M8 ~2 n
MODULE_LICENSE("GPL");
1 E$ p9 h5 D3 L: z8 S; `6 O" k/ t+ F/ T+ c, I" N$ X) v
|
|