|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& {- v! J# L! ?4 X4 B; n) R#include <linux/init.h>
& C- o! ^7 z& d' o% M4 J#include <linux/module.h>
- W1 r. c! @* ~- {: M7 ^% H" K#include <linux/kernel.h> m/ _& V# N( V2 m3 H6 T1 w: J
#include <linux/types.h>
# R5 I+ w, O) u: i8 @( |$ E; U; L8 e% ?#include <linux/gpio.h>& w# u0 C! T- R$ u9 T
#include <linux/leds.h>
. {; W% M) P# Y9 `* [% s% E) I* f$ t#include <linux/platform_device.h>/ J; z# u/ u: n+ l3 ]6 n6 A* X
, }9 K# N" d: ]7 q0 }
#include <asm/mach-types.h>4 ~2 ?5 M9 u/ I3 G3 b: G' d) p
#include <asm/mach/arch.h>
. i/ `" w5 D; l( R1 D#include <mach/da8xx.h>3 N2 K: |4 ~; V3 d+ c: I3 g
#include <mach/mux.h>, v# k! {6 U8 k( `7 x9 t8 u
9 {" R( ~" c8 f" j2 ?
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 G. u) i9 H# A$ F4 X
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' L4 S' N) z$ |8 t, x w5 K( R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) y* c& N5 N4 c+ P, J% R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% W; P6 C$ X$ p$ J1 O. t5 m
1 B# A* ?5 X% ^/ }9 l/ Y/* assign the tl som board LED-GPIOs*/
! u# Q f' l" U/ K9 sstatic const short da850_evm_tl_user_led_pins[] = {+ Y- A( q1 [' t
/* These pins are definition at <mach/mux.h> file */! `$ u( M5 r4 ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" R3 `- u* O" M3 ^2 A1 l -1* a& O. S. M8 W9 A z
};
* R" n' P; J% [% j' p
) z8 ~: u& ]5 \1 |; I/ P. m/ J2 Tstatic struct gpio_led da850_evm_tl_leds[] = {# Q' O: a: _3 M/ q
{5 a/ A" i, x) g9 [' y
.active_low = 0,' h2 B: x: L) z- v* U
.gpio = DA850_USER_LED0,
* e$ {& G- F* {& \ .name = "user_led0",
* j5 ?$ I) c. c( \9 v& w5 F* I. M: q .default_trigger = "default-on",' Y) k+ F6 X) u4 k( ]/ O0 b" e
},
" Q/ {' G1 K3 ?# B7 A {
' _* q$ y" q1 s' G# m$ L: f8 e .active_low = 0,
& w2 Q/ h6 k }/ T, x# {+ \; w .gpio = DA850_USER_LED1,
( L }8 d3 G' F; R& G .name = "user_led1",' h2 V$ c* l/ b# M7 Z* J3 z
.default_trigger = "default-on",! ?* o# t# Z" B
},
! I& a+ d7 k9 w$ [" Q {# r! ~' P* E, W% o
.active_low = 0,
6 @! ]- y) u1 Z& r# L: l .gpio = DA850_USER_LED2,
+ }/ m' I" x. e# D1 p# G .name = "user_led2",, `( N0 W8 o) Q" P
.default_trigger = "default-on",
! b# e. `# d$ F( p. ? },
, X1 N, {/ H9 O5 W' K {& m/ [3 O$ e, T
.active_low = 0,
6 u b6 b" \! Z .gpio = DA850_USER_LED3,0 m: |+ K/ ~3 f
.name = "user_led3",$ }% K S$ X- C# P. V, l- L0 q, `- z
.default_trigger = "default-on",
8 t3 c( B& P' ^, c },! v2 ` a2 R1 O" l. T
};
; U1 j6 X" a3 u0 {8 r+ |4 \/ F/ X. P0 m2 l! v- M7 l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- J/ k* p, X' m7 \" w; z. h% a .leds = da850_evm_tl_leds,
* S: u9 {2 M& U3 w/ {# R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 |% V' ]$ } P/ {
};. n; E- T% @5 T) P) [
" a$ @: j1 }+ `3 [0 `static void led_dev_release(struct device *dev)
0 I3 g- D P4 @9 d; Z{3 F) P+ D/ D& C: ^9 A
};; {5 v" W7 A( E+ s3 D" g
* y. O0 `+ v! o6 n$ b8 wstatic struct platform_device da850_evm_tl_leds_device = {' m' s% K, b4 j# [
.name = "leds-gpio",7 o- I: T/ a$ ~* F
.id = 1,4 g1 C# E, w* r+ a& U6 w' [9 z
.dev = {
* y Q, e, h, W; O+ l0 G .platform_data = &da850_evm_tl_leds_pdata,
; A9 r( A! p% q% z5 V9 R9 Z5 e .release = led_dev_release,/ B" @3 Y( g) f) X, |# C1 r/ c
}* Y0 m; Y7 \. m+ ^% a
};
* A$ j+ \2 A3 s+ [
7 [- g; r+ H4 r3 K& p" M* ?static int __init led_platform_init(void)
* b; w+ _" z7 B/ H{
) M! @( W- s; D) w9 I int ret;
4 @3 n" @0 s) L#if 0
" L4 H4 }9 _/ `) ~5 ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- p u; R; H7 }. `3 L
if (ret)
1 n0 A2 F$ d" I" G. `. x5 w pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! H$ u h9 K1 r% ?! F1 D
"%d\n", ret);
! H% ^& h5 H; ?8 w& p$ O: {#endif
0 S$ c/ |( ^/ s4 ~9 y7 J$ a# ] ret = platform_device_register(&da850_evm_tl_leds_device);
6 P6 F. v2 X, i( d, r* b. W if (ret)
1 _7 W3 D5 T: _- [ pr_warning("Could not register som GPIO expander LEDS");6 w9 d4 T: N( q" R# c
else
: }# T; o) c& o: L& O' T printk(KERN_INFO "LED register sucessful!\n");
/ |! c4 M$ }7 A1 Q( A6 ~. Z6 c. d7 N w- |
return ret;
, c0 i: Q& ]; F6 `' h}
3 R/ v! U( O- l5 ~3 f
& q! o. X, X3 {* D5 qstatic void __exit led_platform_exit(void)
- D4 a4 |& B3 x# S0 W{- c! P2 j5 k6 _, W f; }
platform_device_unregister(&da850_evm_tl_leds_device);
/ C" s- D+ z0 S3 R4 k& u% A: M. E' l" [ r- N4 x% l: v! f9 B
printk(KERN_INFO "LED unregister!\n");
! S2 F5 I5 B3 z( @: O}6 C/ i# }4 r9 t6 C/ d4 u# {
/ Q- S0 {" x9 }% |) `/ q3 L
module_init(led_platform_init);! { b% d0 L: f# h1 i3 T
module_exit(led_platform_exit);+ W8 q9 y3 J' z0 i Y1 u6 D# J
/ D9 d' j: q- D' R& }) R
MODULE_DESCRIPTION("Led platform driver");
7 E3 z8 w# m- X5 d1 e" w8 d* LMODULE_AUTHOR("Tronlong");
. S* w; L7 W" N& V& C: C! z6 a9 }8 aMODULE_LICENSE("GPL");: t4 j4 p- g" ^' B
' {$ Q; Q$ }+ D |
|