|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# t0 p4 x2 Y7 c#include <linux/init.h>% x) r7 Q$ p; ~. E$ y* X0 C! a, Q
#include <linux/module.h>
5 }8 c; d1 o1 m! k; d#include <linux/kernel.h>
; u6 f1 F }1 ~8 C#include <linux/types.h>5 @. w/ F; k. W# X* G, @* W
#include <linux/gpio.h>9 X: ?6 j* ~4 ?% C
#include <linux/leds.h>
( e& e' Z) ?/ c- x! n u#include <linux/platform_device.h>1 ]) E( c- m% i
$ S- ~! w" B+ ^: S/ H
#include <asm/mach-types.h>7 b/ j9 X V9 K& O1 B
#include <asm/mach/arch.h>
; u/ v1 w! e: y4 T z#include <mach/da8xx.h>5 y3 K$ C# n3 C: z
#include <mach/mux.h>3 ]" i6 b! j5 u+ l
2 _9 f6 r" W, k+ P0 {+ _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" [4 h. y# f# C r+ B) ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 J! F% F5 Y( `6 Q& P$ V#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! X# X8 x, V0 Y7 D* J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 s1 D8 @0 H5 }& U! B Z
9 C K( O8 U* R; T6 d" j
/* assign the tl som board LED-GPIOs*/
- m2 G {# ^! h6 |6 a% _/ kstatic const short da850_evm_tl_user_led_pins[] = {3 H0 R7 l* X0 O |
/* These pins are definition at <mach/mux.h> file */! A9 v+ j- E% \: B9 K: a% o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 ^1 P1 _% L3 f5 g0 n% k, n
-1- s g( F. O/ Z7 q0 K
};* \ [. d, |& I- ^3 O! e
$ q7 M3 n$ n( wstatic struct gpio_led da850_evm_tl_leds[] = {3 o+ u G6 e9 E- @
{0 U; u5 v0 Z: [9 e1 [
.active_low = 0,- Q5 _ p; \5 A3 L3 M) c8 r
.gpio = DA850_USER_LED0,
8 U* k* ^+ D$ y2 O7 _, s .name = "user_led0",
" V9 a; {& [8 K/ ?* @$ O+ R8 ^) h( w .default_trigger = "default-on",2 e, _, b" T! @" o: I% w I) G3 E( G a
},# F* {. e% q* h! n ]3 N
{
+ z( X" n# [7 [( Z" B .active_low = 0,
; c: T/ H1 z) q2 S. g8 r .gpio = DA850_USER_LED1,( s2 N0 l2 S5 x5 `2 J2 R9 z
.name = "user_led1",
$ q' P% ?6 b% U& O P% I .default_trigger = "default-on",
" ~) G: g- K2 G. \5 D4 r- s$ b8 F },
9 T8 n' y+ O& T$ a) j {
2 i0 g9 u' q7 [$ \ .active_low = 0,7 J& D7 F8 ^' L& U& _; \: h
.gpio = DA850_USER_LED2,- |( j- Y/ z- X0 _
.name = "user_led2",
' _- J1 D) l1 Y, T8 D- _& J .default_trigger = "default-on", m+ F/ t+ N/ ?; o0 D- b
},- M- Z8 Q0 v) J
{
4 u3 P3 I# h- |# g8 w7 d .active_low = 0,
. D& ]3 z" @7 N .gpio = DA850_USER_LED3,
/ M* p" ?3 m+ T .name = "user_led3",
% L. {8 G8 J. M# E* g .default_trigger = "default-on",
8 z: E/ R l# u" j1 w6 L( T },5 D# p* T! I8 i4 n: V
};/ _: v9 t# _" I0 K6 y
t% u' M8 Q7 T1 W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 `3 Y0 s2 l- T) n
.leds = da850_evm_tl_leds,
. U! J ?2 h9 t. @- [4 u .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- g' c- S1 P$ ~% o8 e* |
};% q4 e. A; t2 F0 U4 w4 r
& `4 Y {: r% X* }5 U6 `* Bstatic void led_dev_release(struct device *dev)
/ O' a, C. v% Y2 {9 _" B7 `8 U{
! P5 s' g# O9 D# t3 S6 Z* x};
6 X' m+ U7 I% R0 R, U" h/ V/ L' |' d8 U/ Y+ b- {
static struct platform_device da850_evm_tl_leds_device = {
8 M: A' m' k/ B- O .name = "leds-gpio",8 n, r* n# q5 W# {% f4 E$ s2 S. M# K
.id = 1,9 d1 u1 I4 F: O/ Q1 U6 p( L
.dev = {
& s0 _8 c3 o9 k: }# c% M, } .platform_data = &da850_evm_tl_leds_pdata,
, b. t# [. |3 u; J .release = led_dev_release,
# A$ z+ E: K( e; R }
) O6 @+ \+ ~, y# W% x7 k6 {};
1 {% R6 C0 r# _! z
0 s! Q I8 A: d. k3 Z( |& x" _static int __init led_platform_init(void)
5 h# q7 D; H3 M: K/ P. M- G{! W9 {) q- d7 z( Q# `* _9 t9 }
int ret;
+ m6 @/ L- v+ Z7 P#if 0
& E5 n# l" s" H5 N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ n% _8 h9 u9 l: g4 Y0 q! g
if (ret)
9 p1 |, C( N! o) F; y: R n5 E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 g9 ]% S6 {* g; k4 R1 z "%d\n", ret);* D2 D0 r8 n( N1 `3 X/ c
#endif
3 \0 C) `8 A& } d! p ret = platform_device_register(&da850_evm_tl_leds_device);
, u% w/ C2 E9 A9 ?3 t% Y if (ret): ]& b6 x8 C/ y6 C
pr_warning("Could not register som GPIO expander LEDS");
0 x' V2 y5 c# U) A/ a' A" `3 ] else/ U# }5 Y7 C8 U @6 t
printk(KERN_INFO "LED register sucessful!\n");
3 Y5 a! h1 }2 v4 Q# D# l5 K& h9 P8 o5 x! J, I, ?
return ret;" |8 ^' u1 B+ h' G
}
" b- a( O$ i0 X9 Y/ l0 S
' g1 v) @4 W$ s# K$ O3 y$ B# ~$ hstatic void __exit led_platform_exit(void)3 d0 T( o2 G# Q1 i0 g" y
{0 f6 G5 Q* Q, ^0 t$ h
platform_device_unregister(&da850_evm_tl_leds_device);; Q+ `. O! y3 b5 H
& S$ ^8 v; ~. a5 j' f
printk(KERN_INFO "LED unregister!\n");# [, V+ V! E2 P5 Y, o
}4 t& x2 ]3 G. p* u/ c, ]# D `7 ?2 A
: Z% Y) G h3 p- F6 {& M0 ]5 |% Y
module_init(led_platform_init);
! T' | x/ g4 Wmodule_exit(led_platform_exit);% R3 |/ X( Q ~1 w7 C; k5 o8 Z; o
1 @! R2 X/ h \4 o7 @
MODULE_DESCRIPTION("Led platform driver");
Z! C$ b: g; A( O, gMODULE_AUTHOR("Tronlong");; a$ x3 X4 W" E# k9 v4 z$ G
MODULE_LICENSE("GPL");
0 P, O3 i* h8 Z/ b
% w3 _7 K+ _0 D6 e |
|