|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& m# o" |) o5 H* J: y& |/ B
#include <linux/init.h>
H: X( d/ V% x- {#include <linux/module.h>3 E% H( z/ \8 _+ Y4 H" ?
#include <linux/kernel.h>+ f) P/ N1 S6 T8 z9 g& D
#include <linux/types.h>: S& {. H; r% y5 \/ M/ R% V z
#include <linux/gpio.h>
5 @) c ]5 o9 {1 k* _6 F#include <linux/leds.h>$ ~% O2 x- i! u" I q
#include <linux/platform_device.h>. o) Z# F$ c/ _4 F. p
* N9 Y j1 Q v. w; s
#include <asm/mach-types.h>
3 b4 o, j, \4 ~3 A7 {3 d#include <asm/mach/arch.h>, X# {. c+ V& q( G
#include <mach/da8xx.h>
6 I# [3 b- a* q& O#include <mach/mux.h>
( g2 Z5 \' h, T3 I. V/ A, w1 d8 `( u" r1 u6 P/ Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ r4 [3 f3 E) s4 g3 s @2 a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" y7 @. ~+ K5 U% g' q1 d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 E# t5 Q9 v/ K, U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, t; k, s* T# ?. k# E( \4 t a
6 ]2 H. Y6 N' m/* assign the tl som board LED-GPIOs*/
0 e5 x" w5 q- l5 {* Cstatic const short da850_evm_tl_user_led_pins[] = {8 a, b' T% N/ e8 c% v( t( B
/* These pins are definition at <mach/mux.h> file */ ?3 d. ~, e0 d+ W+ R! q+ R7 L) H; o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( r2 `& D: @# P1 T9 [- M -18 Y. i' m, p* o2 N c
};- o" E, v$ h* v
# Q# j/ n- n8 [* c9 I* Y% Sstatic struct gpio_led da850_evm_tl_leds[] = {
: F" ^: M' Y2 z {
2 J0 J$ w0 P( N .active_low = 0,/ Q5 V9 U, H! J* `4 _3 N
.gpio = DA850_USER_LED0," D8 l8 n7 k+ _5 v: \
.name = "user_led0",: t# {) b3 R' F7 [1 O( O9 h
.default_trigger = "default-on",8 ]. T0 {& ]: u
},3 i6 x5 s$ ?9 m. B/ Y# i# D
{
; s& N5 ~6 f1 q" ` .active_low = 0,
9 D% c6 ^$ a* g ~% i d! A .gpio = DA850_USER_LED1,; C& ?! j0 D3 k8 g' q# R
.name = "user_led1",
, Y8 N7 N/ Q+ T0 G .default_trigger = "default-on",
: Q4 t7 O: z2 |* q7 R# n0 c },
% j1 P8 j ^9 \ {
2 O8 a8 [2 p6 v6 _( f2 v' v+ c! c .active_low = 0,
* d/ g: E& S" h2 `; o. `0 h! G .gpio = DA850_USER_LED2,
1 v9 {5 C$ }+ V .name = "user_led2",
3 p. z- }5 u$ G# U( K4 D9 {/ {, R .default_trigger = "default-on",7 l. L" t W# U3 {* p* @+ a
},& E" ?/ N% \$ Q
{' I6 \+ p5 M4 @. S! f
.active_low = 0,2 {' R3 \4 `6 X( b& \
.gpio = DA850_USER_LED3,
2 ~' A7 g& ?/ e .name = "user_led3",
4 H6 d/ S0 i0 H: g .default_trigger = "default-on",
2 ]# {% E- A* [- ` },! y& u: b. }2 F5 t7 P4 n
};* E, P6 B1 \+ s$ |( J
; V8 M) e5 P/ H* I$ E9 Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" M; z* q- s4 } P, `% H T3 M .leds = da850_evm_tl_leds,( |6 v3 N0 K+ F- B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& N) r' l* }5 d};! z/ T' ^( N3 C# e
! y1 P8 D. ?- @. Xstatic void led_dev_release(struct device *dev)
7 H/ K' q& f6 b" d& l4 f{# S6 B1 J: v$ x7 p' f) r) n
};
; {) U+ z9 S! J1 r3 ^8 T% i; W+ s6 n1 ]4 {# y/ T& k! {: b( F
static struct platform_device da850_evm_tl_leds_device = {
. _ [# [ _. x$ W { .name = "leds-gpio",2 b4 }$ g) T! p
.id = 1,
7 J( J S7 G: X, m2 m8 f .dev = {3 M; J4 N% ?; y" x5 ~& V
.platform_data = &da850_evm_tl_leds_pdata,* M, g% j+ P2 `$ ~ K
.release = led_dev_release,
& B* O- h) F }- d }
9 Y6 K9 g3 i& v( M};
$ A8 w8 ^/ v0 X: T: Z) b$ J5 L3 W- C- d% n
static int __init led_platform_init(void)
t' U1 P. `, a h# N{
" N2 y5 _5 e+ F int ret;
4 S- i" u) @! T9 B6 P6 o2 J#if 0
6 L& t* l W: t/ M' V' { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: @9 O- V4 s1 v0 U% p, R
if (ret)
2 e5 {: P4 h/ Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 p5 [( w( z1 r) l+ _1 } "%d\n", ret);
3 a, T' o/ v z. N$ T5 f% @4 u#endif
) |# J& k' A2 n ret = platform_device_register(&da850_evm_tl_leds_device);/ X8 W/ w( ^* s# `* R
if (ret)
6 J+ R8 L/ H' S. i pr_warning("Could not register som GPIO expander LEDS");
; F# b% z, e4 i+ P. @# R) b else5 a! S7 ?8 n, H( e9 b
printk(KERN_INFO "LED register sucessful!\n");
# l, @1 V/ H6 T0 Q$ z+ v G3 c) I
8 w& e# a! f& @) a5 E& {5 ^ return ret;
+ ?5 X0 C: [: e6 A; A s1 v}
6 @8 {, i {) o7 R7 L' B" }. x6 d( m( Z9 s: x3 u4 V
static void __exit led_platform_exit(void)0 t9 m! I l, Y1 g: N- R. }
{
6 Y- j5 `! P) f/ j& U$ Q platform_device_unregister(&da850_evm_tl_leds_device);, L5 n/ _" S1 E& @ B2 E
# z% N* O1 F: @2 H5 x( Z3 P9 o printk(KERN_INFO "LED unregister!\n");
9 s" U ^0 F( ?6 T" v: l4 O6 j}* R! v2 P# a& }. a! u8 S
0 f3 X& Q' o5 r, i. tmodule_init(led_platform_init);: p9 `6 A, L2 P% d& G: A
module_exit(led_platform_exit);8 j4 j+ t8 V7 h" Z$ M9 v0 N
, R2 y4 c+ e/ H/ M7 C7 I4 {! x1 @
MODULE_DESCRIPTION("Led platform driver");6 Z% @7 u6 X8 V5 w/ h
MODULE_AUTHOR("Tronlong");& T5 R- Z1 X5 H8 W
MODULE_LICENSE("GPL");4 i0 K+ M3 d, G& M% {, C) A0 `
% e& ?- v% d% H |
|