|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, S3 L9 X! P A
#include <linux/init.h>9 S& u( s) H- r7 L' S
#include <linux/module.h> X/ N% n, E) Y4 I* z
#include <linux/kernel.h>; S4 s& s# N# {( o ?: Z( {
#include <linux/types.h>
" n9 s+ v* a4 k9 s# Z. P9 X% {#include <linux/gpio.h>
# C# f; Z. Y4 \( ~3 [% j9 E#include <linux/leds.h>8 S- T, F/ O1 }$ m- y# ]
#include <linux/platform_device.h>
+ v- _/ \: Z4 c; S; c5 g+ `) m x/ J n' V( r
#include <asm/mach-types.h>" Z0 |+ m* S$ Q
#include <asm/mach/arch.h>* E# P$ m9 Z5 w, T
#include <mach/da8xx.h>/ V' f% U. ~% U* z& |+ f
#include <mach/mux.h>8 t* Q7 J! b' p$ N# o
' ~6 b2 E5 M1 D) ]) r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# N# J* O4 O3 V% {, s" o3 a# o$ p' w#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ f2 t7 U% s" u$ N9 @4 |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) h1 N4 _ {! s- E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 [3 k5 M* E* R" f4 z7 J% E: p
% p0 i1 ?2 z/ ~8 v/ P
/* assign the tl som board LED-GPIOs*/- L) `& W3 d3 H9 `
static const short da850_evm_tl_user_led_pins[] = {
~8 G( k7 Q# i) A6 a6 F% o3 s# [ /* These pins are definition at <mach/mux.h> file */2 @7 e$ u0 T9 P# q% ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( v2 _4 N5 n' V: }+ @1 Q7 o
-1, v$ E, \( [1 t8 R8 ~$ y% f
};
- K( J0 u; I6 A0 z- \! T+ g( s$ i" p, M$ N
static struct gpio_led da850_evm_tl_leds[] = {2 a& A: a& [6 q7 H h; u% O& P% E
{1 c# ?. D3 P2 e, N6 r
.active_low = 0,3 b% ?! M0 G9 y& K3 S( B; C
.gpio = DA850_USER_LED0,( X, Z$ l; P9 Y4 _. g. m9 @
.name = "user_led0",; c# x7 S1 T i' j0 i
.default_trigger = "default-on",
3 d7 k3 k N% G2 c- i },1 l0 Q# u% d5 K- g9 W9 s
{. ^0 Y$ U7 C+ B2 I- ?5 W
.active_low = 0,% I1 c S2 `( k) t
.gpio = DA850_USER_LED1,& M( ?2 }+ [5 ?
.name = "user_led1",3 M' Y0 A. u, W4 C2 s* k
.default_trigger = "default-on",
8 h, R8 v, _! v4 ? },
7 _$ G- e% Y6 z+ S& F% s- E# s {
. h2 A* x5 H8 r3 g- j .active_low = 0,
* e. f/ G3 r: Y: a .gpio = DA850_USER_LED2,
3 Z" U G9 z: G* u0 }; c/ i! R5 | .name = "user_led2",
8 |, {. D. M1 m6 [ .default_trigger = "default-on",
) Y4 {+ W& n) s- P- N! W: K& p% F },; M+ q5 K4 S% n% b4 D& g
{7 K; v4 u9 M% P, l4 u
.active_low = 0,
0 C! g p# ]5 V' [: B .gpio = DA850_USER_LED3,
9 y& y. D% [" c% {* f" P5 U .name = "user_led3"," r6 n& i0 I6 C6 C
.default_trigger = "default-on",
% y, |5 S8 n& K$ R },
' g' }. Z- M$ x @};
5 _# W, I7 E: T* ?0 L! g! u4 Z, z3 R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! l6 l( r& j; Y6 F, ~
.leds = da850_evm_tl_leds,
1 O2 J" @7 \; q/ k9 G. { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" R4 } K9 \* ?};( w# w5 E' z8 U% ~; I; ?2 P
8 J" Q, F8 H: t4 S6 v
static void led_dev_release(struct device *dev)
4 B2 b* |3 B8 U$ J, g; l{0 |) ?1 w5 A! s. V2 W# {
};
/ c* ?. J0 ~& z6 @+ F# ^+ w1 P3 f# H$ Y8 M- Z
static struct platform_device da850_evm_tl_leds_device = {
% z+ x9 h! T- i( |0 w' h: A9 V .name = "leds-gpio",2 {* f: s* ?3 t1 A( r; }
.id = 1,7 d' ~5 L8 Q9 ]$ T/ v& l* c
.dev = {
7 O# Q4 Z" p8 ^) e .platform_data = &da850_evm_tl_leds_pdata,
" A9 o3 Z/ Z5 U" j% K* }: L2 W .release = led_dev_release,
0 x# @. E% ^ t }
$ A" U, @# L j, G};
# T& W, D$ R3 E2 ^+ \' w2 a4 x0 \5 R# Z$ g
static int __init led_platform_init(void)
/ t' h: E: @% U. M{
% l! Y3 K( H$ L% y2 x int ret;
! ^2 x; I& T6 a#if 09 ^3 T4 h7 h# v9 p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ x9 P) R0 E0 p0 g, b if (ret)5 n( w' J% w8 n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# h; k& y- l$ |1 L "%d\n", ret);$ b. S% w' C" P+ |4 v& y
#endif
2 z9 L$ X M0 |% g' M ret = platform_device_register(&da850_evm_tl_leds_device); B- p" J6 u3 K7 m: m- n. X( B
if (ret)
' x3 ~0 C% Q9 P" m8 D) V, _! h pr_warning("Could not register som GPIO expander LEDS");/ E# ~1 b! }0 g8 i2 R0 p
else
: t8 w: n/ P5 L printk(KERN_INFO "LED register sucessful!\n");
+ A4 m6 ^3 } O' f
4 n+ [8 F1 _7 M, H, e1 ` return ret;
7 j7 v4 L9 H/ }+ s; G}
; h* I+ v6 N v+ t% x
8 ~) @ [1 B: H" D, w/ mstatic void __exit led_platform_exit(void) r l" O* i+ ?# Z( ~
{
# u: n, X* \3 m platform_device_unregister(&da850_evm_tl_leds_device);
$ m& o* o' K2 `5 H; E( g3 W5 j- N$ E0 }
printk(KERN_INFO "LED unregister!\n");1 y- D F/ u6 \+ L# Z8 D+ S
}
- W6 k( t" w# \% i* g* Y, p; w9 P- w* }* c a
module_init(led_platform_init);+ w+ x' ?' J7 c& O& P' S
module_exit(led_platform_exit);6 b( S3 l3 u& n4 _
% M1 @; `, g6 I, }
MODULE_DESCRIPTION("Led platform driver");. g/ V; e: L' Y
MODULE_AUTHOR("Tronlong");3 ?; `3 P \( _0 Q7 [
MODULE_LICENSE("GPL");
V9 {4 \' x% N+ G: Z4 Q6 `% Q- D5 Y7 F( ~
|
|