|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) ?" d% h/ K* D
#include <linux/init.h>! i. Y2 m0 h! I0 k: y/ h6 a: K
#include <linux/module.h>
2 [. I3 a! C$ J) _7 t4 h. a3 t3 f#include <linux/kernel.h>6 t" d8 k4 z+ b& y& W8 [
#include <linux/types.h> i8 Z( ?4 O) y9 h4 P! f4 ]
#include <linux/gpio.h>
d& f% E. X8 @: w% D/ q#include <linux/leds.h>% D) ~; h" q4 j) u
#include <linux/platform_device.h> [! G# v9 s; x0 c2 K+ b6 C
7 |0 p7 |1 B! |; Z
#include <asm/mach-types.h>
) L! T0 D5 S# X, |- B' y1 l5 O#include <asm/mach/arch.h>
0 }8 b- r+ g1 m( i) O9 W- O#include <mach/da8xx.h>
( j$ T6 R" W/ F. [( @, @3 I#include <mach/mux.h>7 R6 i1 X+ `; G
, {* J0 w" r% D& c0 ]: B$ G( N! Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& W. Y% e* z& w! `: V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 s5 v/ z1 t- t$ Q- d- j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ J5 }# c5 [& G) A3 D/ D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 b$ t6 Y$ ^& z7 l9 G# ^
9 A& q5 I1 Q; K) V/* assign the tl som board LED-GPIOs*/
7 d; ?! E- ^8 `( V) e, V# zstatic const short da850_evm_tl_user_led_pins[] = {% C' P" h% j" m
/* These pins are definition at <mach/mux.h> file *// `+ N* [6 M- f4 W: D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- @0 A& K& s; i |4 X -1* \( d% ~" ?1 g P$ F. {8 Y
};
7 b' d3 ^$ `1 F$ F, a# Q) W
: _6 ]& l* X" S) N" f$ wstatic struct gpio_led da850_evm_tl_leds[] = {
: R3 m1 y5 _9 l3 m. J {2 `. V2 Q# L; Q
.active_low = 0,
4 V- }- I- B" s& a0 O& O8 V .gpio = DA850_USER_LED0,
' D, {5 h/ T) q' }9 Z .name = "user_led0",
( U5 w5 u) p9 S# ^6 J' t .default_trigger = "default-on", \1 C% B+ W2 S/ s/ ?. r
},
: U/ _$ `6 Z) | \) c1 w( y {
4 H( b0 }4 R8 @' { .active_low = 0,
& q/ I: R: D6 q/ C" { .gpio = DA850_USER_LED1,/ _* G* e9 A0 L% L
.name = "user_led1",
8 W$ F- w5 h& V .default_trigger = "default-on",
7 D( O' g4 E9 c) Z' g, L },
3 ^ [ U$ @# `+ s/ { {2 S* r5 y; y) H; w1 A
.active_low = 0,' K7 h4 a# P- g& s
.gpio = DA850_USER_LED2,
1 {; c' @$ f: y% G. E .name = "user_led2",
1 E/ C6 [, h# n. }! s' w .default_trigger = "default-on",
% Y% y% S% J$ f }, F- @ W- u. v6 F" S
{: }/ Y; G9 ~1 y: [5 w# T
.active_low = 0,
; f4 C' w* E5 a .gpio = DA850_USER_LED3,' l4 t& @# T2 D# j, @$ w. D: C
.name = "user_led3",2 D8 V) }5 I4 O$ j2 g
.default_trigger = "default-on",
4 y* L0 n- i) T# R: y2 U: r1 F },
( ]& @: h( }7 v/ \5 A# S4 a( M) _};5 D% G$ J1 O t( A, B& X0 Y
" p; H. n; L# C: x( |' Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 m8 I1 k$ q r; [" x! d0 @) Q
.leds = da850_evm_tl_leds,
b1 C. v" g3 U& ^9 d! U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ x2 U3 ^& T; g1 I; ]7 J
};
8 m! x, B# w1 c; t
$ ?2 I9 u: L( P! a0 h& c$ Tstatic void led_dev_release(struct device *dev)1 i' }( ^5 o; F0 T: p3 v% O! X1 F- @) }
{+ e$ I4 A9 Q t2 J/ S
};) P$ ]4 {' c' g" x/ i( z; C) `6 X! m
+ [4 l) L9 F; J8 X V( N- n
static struct platform_device da850_evm_tl_leds_device = {5 L5 G' z8 `& p
.name = "leds-gpio",
/ E: e/ h& `2 D5 e" S2 |# s .id = 1,: x# p j1 I: ~
.dev = {1 M- M; N1 x+ I. _1 N
.platform_data = &da850_evm_tl_leds_pdata,2 S+ Y1 `% R" X+ b. a# d$ E
.release = led_dev_release,; F T- G) l9 |' W: P0 ?: j
}
* V3 z* ~7 O/ n6 C};# h/ ~/ q$ e; k( M4 o3 f9 K
7 I* ]& r6 t* P# Xstatic int __init led_platform_init(void)
2 e1 q" M) l9 g, K8 J5 ~{
( U' A' F8 W, m% I, ^4 ~# U int ret;
# k: y- {; x6 M2 E#if 0
9 A7 y# D& H2 F7 b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: g8 V- M- v& N+ j
if (ret) w8 G: U- w$ ?! ]4 f
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 Q7 \% Y5 A- x! M2 K2 z. X: b
"%d\n", ret);
* u* F( N2 H/ [1 p- |#endif
. I) K7 H/ V5 h! L+ o ret = platform_device_register(&da850_evm_tl_leds_device);0 _4 t- j* f- A8 L* L) Q0 y
if (ret)
) m/ C/ y F, b7 y4 P$ v pr_warning("Could not register som GPIO expander LEDS");
- i3 Y) O u8 _& s2 f! E( A else) ?+ p! m1 A- U- G% e7 J7 D
printk(KERN_INFO "LED register sucessful!\n");
+ [% y+ A$ M5 E ~, [2 A# n2 d# K8 p2 u# O2 S) d( N6 e# {5 K) @9 O' F
return ret;) V) K: g% D* \4 [& D' d! K
}
1 V8 Y9 v3 _7 ?' v; P7 n3 N. I5 W+ }1 {& V4 z1 m
static void __exit led_platform_exit(void)+ |8 }# }$ i5 b
{; O8 \/ m( i1 `2 V; l
platform_device_unregister(&da850_evm_tl_leds_device);
' M) p4 h9 q- c1 Y; O; Y% u U
' w! g/ C- }* b$ ~# o& q- L printk(KERN_INFO "LED unregister!\n");
) C8 D8 J5 o0 B0 l4 Z" A# W}6 Q8 V0 A% G6 D$ R2 F! m% _% b& `
( L4 O Y8 i$ k4 N( E0 jmodule_init(led_platform_init);
2 L9 b0 E; H [ R% dmodule_exit(led_platform_exit);
* v% M5 p- E: @. |
# @3 B1 x: m" {! uMODULE_DESCRIPTION("Led platform driver");
; z, ^3 t% s6 m w; QMODULE_AUTHOR("Tronlong");: n8 a( g+ y. |
MODULE_LICENSE("GPL");
0 S7 D4 L; Y; N, I8 U+ O+ j8 G( U! V8 l8 W$ |
|
|