|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ R' Z! D& e8 m& E1 w& {/ S3 `#include <linux/init.h>2 ^9 v# N& d; K* w* J
#include <linux/module.h>0 D& W1 G- h! M; Z4 [
#include <linux/kernel.h>
8 A; y5 W6 h- s( x7 j#include <linux/types.h>
7 G: x8 I& L5 B#include <linux/gpio.h>" l5 [. m) r7 N" @
#include <linux/leds.h>
. q0 {3 A' e& B( S# J8 q5 M' r: O% c#include <linux/platform_device.h>% l9 O5 \9 n" o+ j
# Z: ], P, j( p) H1 q0 S#include <asm/mach-types.h>4 k! c: q6 |. `# z5 @# ^0 m
#include <asm/mach/arch.h>
$ l t& j' c6 f. ]+ _#include <mach/da8xx.h>0 }# a: e) i3 D3 o
#include <mach/mux.h>
4 y4 a& Y; R! _
. Q2 X l5 y# `1 E, n& `. q5 @- R+ x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% {$ O; {* ^( n8 x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! Q6 ]) Q" B& P' a& Q2 ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( g2 f, b1 i+ A b5 x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): G, ~- o" {+ j
' c3 T m- q5 o6 |) r/ Q
/* assign the tl som board LED-GPIOs*/: @$ b: V7 I1 M/ i4 T0 T+ U2 }
static const short da850_evm_tl_user_led_pins[] = {, o& R0 x; L& B* `9 Z9 F
/* These pins are definition at <mach/mux.h> file */
: j+ t. h/ j V4 ], a \$ X {2 c2 z5 ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 C+ d3 M- v8 N -1
+ x% ~ J+ c, u$ v. j/ R7 b};
, c% x1 K5 d+ a# E" [6 q+ j1 s& @* M0 \" N: M6 E2 ]( w( N
static struct gpio_led da850_evm_tl_leds[] = {/ w* ^( b* w* Q' Q7 y
{1 B1 a, L+ }9 w
.active_low = 0,; [6 @8 E5 t) A1 i2 r
.gpio = DA850_USER_LED0,
; a" S$ h: c$ E5 t! @/ S3 m; [ .name = "user_led0",% F& a* S q& e; d( x
.default_trigger = "default-on",
2 M' m( X8 j) }8 x5 @6 k },
) a3 ~' I9 _, y+ ?4 h" ^ {
: i; Z' E) k: f# _8 g1 V& h .active_low = 0,, \5 D* {% t2 G: v; t, f
.gpio = DA850_USER_LED1,( B6 S T; s' a3 ]0 R: i+ n9 z" V
.name = "user_led1",
; ]! o' ?7 i. S) n4 N6 \ .default_trigger = "default-on",
* e% F' [! v; y: `. o: F },) K. z M0 ]2 K) K
{
: B: q* c+ h1 o$ W .active_low = 0,6 l: v- P4 o% c6 }* k6 j0 z
.gpio = DA850_USER_LED2,
: _: W X5 c3 g .name = "user_led2",
( c* f; W9 u" i( i3 ` .default_trigger = "default-on",
9 C" }0 m8 _* c& d3 A9 L3 w },5 f# _% Y" \) }6 O4 d- f; m
{4 y2 e w: s( c' I
.active_low = 0,
& Z. O# Z# `7 k& [6 y9 D9 `, A .gpio = DA850_USER_LED3,& o1 _3 j3 i) p$ o% d+ ^& i: [
.name = "user_led3",1 c2 a( |" @2 a+ C" z
.default_trigger = "default-on",5 l7 f0 w1 H, I+ z' T
},
& L6 f5 E7 k! V8 r};+ O) N7 ~( o6 _
' g4 w4 V& Y$ o: p0 h% ^$ k" d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' I6 h e) j# e! ~/ H .leds = da850_evm_tl_leds,7 S4 {2 C& A- F" k8 N
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! q* d! U/ Q2 n};' n. L( Q6 m% F0 G4 R
( e, R+ K6 o+ w1 g! V" o
static void led_dev_release(struct device *dev)0 b7 r r& v) c
{& {, Q- Z/ z; ^
};9 s) u+ L$ U, u F+ ]6 Z
5 L0 ]2 v# G, U; {
static struct platform_device da850_evm_tl_leds_device = {: Y9 u9 l; o; Z3 r- s
.name = "leds-gpio",
. Z4 \; A" ?6 s4 f .id = 1,
' A, M8 [# @, {2 i2 ` .dev = {
/ s t8 D2 i0 Q( b: G, D! P .platform_data = &da850_evm_tl_leds_pdata,/ Y, H4 @1 C, E) K( g+ v$ m
.release = led_dev_release,3 ^0 G0 w% Q* W, O. R, s; ]
}' l* @4 V S {8 Q: F* g2 H* i
};5 A( |1 r0 E6 `$ ~- I1 q# k
% _& Z2 P. R% E" `# b8 Q- q
static int __init led_platform_init(void)" Q) G+ W6 e2 i4 O# J& B
{
: ~3 p- t; o- a& L& L8 v8 g+ R S int ret;* B6 n: J3 E) a1 Q4 I7 A2 c& W" g2 D
#if 0- C" `5 N$ X# N0 I
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ o3 O n/ s8 A0 E: X if (ret)/ ]' n! X o; m8 o9 Q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" l; S# S: f4 U I& H
"%d\n", ret);
. W$ q9 V# b' T5 X% T+ P! g" Z {8 T#endif
" T' K3 e# B; a5 M( R ret = platform_device_register(&da850_evm_tl_leds_device);. B+ L$ ^) d& {# L0 V
if (ret)
$ Z8 m J- j7 } pr_warning("Could not register som GPIO expander LEDS");
# Y/ j# ]1 I9 P) }1 k else [" U1 a' D* a, q* A l
printk(KERN_INFO "LED register sucessful!\n");
; B; z1 ^+ i2 _9 i& p
5 b0 L6 n, u8 i1 h8 z return ret;- [5 `5 F E N& [1 j6 y+ R1 t/ D1 ]- E
}
9 p6 H- h/ Q+ B5 p& G* k. T7 z- I
static void __exit led_platform_exit(void). I; Q8 w1 M+ R9 `9 q* [
{7 F1 s1 S# @* P6 ?3 C
platform_device_unregister(&da850_evm_tl_leds_device);
: s/ r( F1 G4 \2 w A" q$ f! [( O$ A3 I" o/ G* Z. L- O6 k' f
printk(KERN_INFO "LED unregister!\n");
( a5 l0 l2 w: }! k1 o6 N}
% ]$ J9 Q; u' p& C. B0 }( i# O( I( a2 e! i/ l; S
module_init(led_platform_init); {$ m4 K% Y1 L* [# o/ b. M* F6 Z
module_exit(led_platform_exit);' {& R' ^) L. i, N6 }% |( b+ h
w7 A/ a! }: ~) xMODULE_DESCRIPTION("Led platform driver");; P$ @" T& s# ]) ?
MODULE_AUTHOR("Tronlong");
- `9 r$ u2 R2 E! h, U$ p( f/ eMODULE_LICENSE("GPL");
/ Q/ a% X. x3 y9 D. ?0 ~# V" M, r
|
|