|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 `/ c4 I1 T4 Z) G( l% B
#include <linux/init.h>
" s" k2 l; K" \! g J# @#include <linux/module.h>
9 u/ h1 i& n9 \#include <linux/kernel.h>; Y3 Q& D( h: W$ i: G4 b1 \* V. ^
#include <linux/types.h>9 N: C3 G- y" r3 V2 p, n4 t) |
#include <linux/gpio.h>; R6 o8 {9 i) B' ~' G' w8 B H: Q/ d
#include <linux/leds.h>/ _- L2 l& Z c! ~. _4 u" B( W
#include <linux/platform_device.h>5 h+ w: l' n5 o/ S5 a7 s' u
' M5 M3 u8 e% E; Y2 [% ~
#include <asm/mach-types.h>% g, q) {0 W: t8 L
#include <asm/mach/arch.h>$ f" M7 I9 b2 k" {2 P! U: G" D
#include <mach/da8xx.h>
3 C5 ^+ w# t. H+ a! D" n( Q2 `#include <mach/mux.h>- }. W a: Y4 M- Z" V
! S+ [ b) g$ K+ V
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 p' k8 w+ \' L' ]$ n6 X/ \2 i x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). L. R- @. }! o1 h5 n \. e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" o4 J. a6 |0 {% u& F! [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# t) X- } {# i6 ~) v
* r1 i5 U6 d3 M/* assign the tl som board LED-GPIOs*/( X) f3 v& c7 J( D) k+ R' {
static const short da850_evm_tl_user_led_pins[] = {
2 K. r( V6 F, y3 z& L: s2 V5 Q /* These pins are definition at <mach/mux.h> file */" n" h; a% S. Y# C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: a+ w7 L9 Y# Z% g) P) r3 `- u8 k/ ^ -14 E# r+ e4 h/ u: {7 v
};
) Y" D* Q8 L' [* {- \/ h8 {
( g$ O& u5 |) lstatic struct gpio_led da850_evm_tl_leds[] = {
& C0 z; F4 e% q4 K/ ^! T( b7 d {
/ q5 v4 M- r& {& h* D. Y! R1 I .active_low = 0,
% C/ _" K& W, @ .gpio = DA850_USER_LED0,- l3 f% [4 L2 u2 b
.name = "user_led0",; Y) P2 a4 p7 _8 p' a4 ^+ ~, d
.default_trigger = "default-on",
/ k+ A) A# j$ R8 k$ Z4 e6 D" a: k },& I9 [3 \& [( K' ~$ [
{! k6 j% J' R. x" \
.active_low = 0,& s" o( i6 L& m* Y+ X6 E- H0 ^2 U
.gpio = DA850_USER_LED1,
: u8 j- ]) @" S' g .name = "user_led1",( G+ q j7 f& k% ` ^, x' i
.default_trigger = "default-on",
5 q0 e# M. d! X+ M/ w },4 @$ R+ r( E- P2 l, a
{( V! d3 u1 P3 B! p; J4 N- i8 B0 u* B
.active_low = 0,
6 j: `% x: w: @% [8 I. ` .gpio = DA850_USER_LED2,9 M9 c4 {! o7 B7 R& \
.name = "user_led2",
$ c" y2 M; T9 I' @* ]- I, a, m .default_trigger = "default-on",
% ?' R) Z: F) f) s1 k },
: k) i/ ]; _. H$ [% X3 J C# ^ {
& g0 q5 {' u/ N9 M: G, V .active_low = 0,$ e& u- I* [! o* n
.gpio = DA850_USER_LED3,
) a" ?: D9 c8 [ t% _# A! R .name = "user_led3",
3 ~- `' K |4 @3 j .default_trigger = "default-on",
9 S2 {7 X2 C6 }2 x4 E7 l6 y b }," {5 X: L0 a4 y- m, D5 j
};/ Y) ]$ D. J; D1 o7 G# s0 F
6 g, B. x4 U3 H- p7 h) gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 O/ _# A* Y# U `7 |. w( ~- A .leds = da850_evm_tl_leds,
, `1 A. f# l. U; w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* `: t" k2 [% S};2 ~* K- ?6 n3 X8 Y) V* {
1 E3 v! q* w' Bstatic void led_dev_release(struct device *dev)2 e& Y* Y e* |
{% ?2 v0 s% ^; H7 _2 s
};( j5 l3 I0 W' r+ v( Y
+ h% g; \9 `& e8 f+ g. tstatic struct platform_device da850_evm_tl_leds_device = {8 v: T5 o! `+ i9 {9 i
.name = "leds-gpio",
; U+ u3 q( J) c( @ .id = 1,
; [: d. \3 e( K u. Z2 g3 B .dev = {# _! l: k3 g7 c( L2 P
.platform_data = &da850_evm_tl_leds_pdata,7 y6 o# G6 Y; D& g3 P6 O Q/ @' |( M
.release = led_dev_release,
4 m8 U1 I3 M7 B/ ~' q6 x& O }8 B b2 B1 H5 N0 m" O* r, X) M0 O1 t
};
1 x& `5 E; h, V# l% C
) S0 z+ ~6 ~( y8 i" dstatic int __init led_platform_init(void)
s( F$ ~& r, M( Z& r- @2 l& u{: F7 q& @ @; z
int ret;
. ]+ ]3 w: P; ?. e0 c6 b3 k#if 0
( u# K6 d/ J& \! D* V" ?1 K$ y* [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& T! I7 K8 `% G8 r
if (ret)
" ]; o4 ~7 w9 d; u( K) g4 I9 U* Y! k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ S$ |6 U7 _- j1 w; _! }7 U8 _
"%d\n", ret);3 ]5 Q8 p3 B0 A( j4 C( i8 \
#endif; b _ p) m/ q" b$ g8 s
ret = platform_device_register(&da850_evm_tl_leds_device);
& ?6 o, Q& |0 F" \' M, D if (ret)
2 X# Y- }# s8 `3 M pr_warning("Could not register som GPIO expander LEDS");6 Q/ V3 W+ [5 H) a/ }0 K" n/ s
else
* R3 X! `) `9 Z8 Q printk(KERN_INFO "LED register sucessful!\n");/ E% x* S6 J* K# Y2 u2 r1 d; i
, H3 Y; Z: Z( h/ y6 h3 x
return ret;
' I D. Y0 p: E# Q9 E}
q) x1 d2 }! V" k$ k
% o8 @& c' @8 d5 G2 Pstatic void __exit led_platform_exit(void)8 g- q l: G$ ]( g0 D
{" J9 I; U+ y$ Q& q
platform_device_unregister(&da850_evm_tl_leds_device);3 ?. Z2 t7 {2 p, Q& X x
" A+ k( ^5 ]% k5 U" A8 p printk(KERN_INFO "LED unregister!\n");
0 t" v" ^1 q/ M6 K1 B}2 y4 Y& A- m+ W- b- r6 L/ {6 k, l
3 j( C) V1 u5 V) f) j% q ?
module_init(led_platform_init);
' V9 b E3 O5 m7 X/ fmodule_exit(led_platform_exit);: i# z* x& X! ?! r- B& p
$ W* V }6 K# Z: m" O# Z2 s H
MODULE_DESCRIPTION("Led platform driver");$ d, f7 e8 n# Y$ E& l$ w# Z
MODULE_AUTHOR("Tronlong");
# a# J/ z3 Q2 R$ Z% @6 m) z( z4 G+ uMODULE_LICENSE("GPL");
. A$ R0 m1 [: \& d% M) ?( R5 e: b: j( U, h* s' a
|
|