|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& F+ ^& s, \" e# o#include <linux/init.h>
# l9 u9 C1 _/ S! _#include <linux/module.h>* u" l# O0 l. D2 H, g! R
#include <linux/kernel.h>
3 \7 t1 `6 @: d/ N ?#include <linux/types.h>
, b, q$ l, G0 Q1 c: X& v2 k#include <linux/gpio.h>, ]3 `% t; x, X' ]) Q. n
#include <linux/leds.h>
4 p7 C- A* A4 O$ {#include <linux/platform_device.h>4 ^; Z, F) N7 F. T: c
( R+ V- A( q" b9 R2 j
#include <asm/mach-types.h>- ]7 q& P6 l* X. I; x( V
#include <asm/mach/arch.h>9 \/ E1 O9 t% a" `0 u
#include <mach/da8xx.h>
( p# j& G" X# F( S& T2 a) r: z#include <mach/mux.h>
9 r4 }" A$ M+ g% v
e" m6 t0 P3 n O. I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" S( ^' o0 ]0 ~2 C4 Y3 j8 z: r#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( C3 [" u8 c1 Y s; S6 G5 w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 z" c* C. B" C, \. e( }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 I( r3 L* G" I
9 E0 J& f- C% F3 s! `/ ]) |* ~
/* assign the tl som board LED-GPIOs*/, [3 i6 K; ~! L" @: o! \$ d% s
static const short da850_evm_tl_user_led_pins[] = {
: B' h, M$ _; H /* These pins are definition at <mach/mux.h> file */
' y0 T% W+ L/ O/ p: p5 q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 p8 M7 L2 Q2 P; @% H -1, b1 t3 }; O3 y! r" S
};
5 A" r2 z2 R, q- H: V% f5 X) U" M( G5 A9 Q2 f# G
static struct gpio_led da850_evm_tl_leds[] = {
: R- t% t9 j- G$ c% d! ^7 m: h {4 E' A, o* q, k$ x- G
.active_low = 0,. O/ v6 k/ C6 A
.gpio = DA850_USER_LED0,
o) t& L, {% o .name = "user_led0",
, v0 S7 f H# P9 k4 q9 t .default_trigger = "default-on",0 D, G# |. z" h/ X/ M: `/ a
},; N/ o2 n+ |( G0 \6 m) l
{
. P+ s5 x8 ]: | .active_low = 0,
& X4 A3 u( M+ Q" l1 y8 ~ .gpio = DA850_USER_LED1,
0 n" G9 `1 n# `; `3 ?+ J .name = "user_led1",& \% W" Y3 |* T: ?
.default_trigger = "default-on",
* C" x, p5 i/ e M7 t! _+ M },
" z T# v" t. P1 S, g {
+ u; W# o7 w' N* n/ N# j' u .active_low = 0,
( e( U$ ~1 d1 m. H .gpio = DA850_USER_LED2,
i9 F& Z3 t/ f' G .name = "user_led2",
3 L+ t2 ~1 D( z5 h9 I) c .default_trigger = "default-on",& s7 ^0 _5 F7 w2 [( X- g- h( f/ h
},( c- `# ^7 C$ x5 ?% O1 n% j8 c" K1 ?
{7 ~2 p- }+ i7 V% Q% H% o; G
.active_low = 0,
9 P7 W- D* n0 k) j5 n0 Y2 k) H .gpio = DA850_USER_LED3,
- J7 o% m3 F s$ l7 H .name = "user_led3",! r- P+ ?' B) x Y
.default_trigger = "default-on",
8 S, y q5 O6 i$ _$ n* C! A },
4 h: D4 y. V! q4 b) _};
( V" G3 ?2 [. B- m7 O0 s: C' |( R# A/ f& \. _$ G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- _5 q7 K4 r/ I3 G2 S6 u' N .leds = da850_evm_tl_leds,: F7 j! q2 G# p! A6 E: {0 o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ u8 Z: `' f: s( j# p$ Q
};
" z% l A* R# P. \( p* Y
- L8 s" L Z: m( x, P |3 ostatic void led_dev_release(struct device *dev)
" C* c/ k3 ?+ s' h{. G4 X% H3 _; O" l O- _3 P3 f9 H
};* B; k V7 y% y- q. b( ]
7 a; j: ], D+ r$ Z* L. e
static struct platform_device da850_evm_tl_leds_device = {
( R0 U' }* K$ y# _9 L .name = "leds-gpio",
9 a% ]* U! ]2 f. V; e" u .id = 1,, V2 A$ [% |( z& f2 e& [4 H
.dev = {6 S% h2 Y0 _+ K
.platform_data = &da850_evm_tl_leds_pdata,
& b+ J) @' ^2 D' }% }5 y( s9 e' ~ .release = led_dev_release,
$ t4 X: F$ v$ { ]) X }) Y( S6 U. @9 q9 K% R2 [8 n
};! n6 U( w# S) g
! ~5 a" w. S4 b9 l+ k" @# ostatic int __init led_platform_init(void)+ \# J, x' g. z) I& A! m4 C/ R9 n
{) N; P: S% ]9 U6 h
int ret;
& i, I' ]0 I' e, X5 y#if 0
$ c: ]- i( V* ?5 F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: }$ _7 G( j" C" y
if (ret)4 l' w' [ Y' V5 C+ w( G+ ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 J6 o$ ~6 G8 A- J2 V; w "%d\n", ret);# c z9 w) a# y
#endif
3 |5 m+ s8 I, q. s; _! v ret = platform_device_register(&da850_evm_tl_leds_device);
. w! I0 b6 A/ o% L0 R' @ if (ret)
: W. A/ E8 J9 }- o0 ~7 w [ pr_warning("Could not register som GPIO expander LEDS");
: R0 X' ^. B) ?! n& e, D3 I8 [ else
) T- a/ L6 ?* m- J: B printk(KERN_INFO "LED register sucessful!\n");" w6 {0 ]2 p4 e# u m- d
/ B% ~! M' q4 K! Y( F) Z' ~3 Z- k return ret;& Z! L7 v W$ ]8 a7 k' t7 V4 A
}, }$ ^- j; l2 a, H
( ~9 l5 G/ J, T4 M* z% Z
static void __exit led_platform_exit(void)
( I, Q. L/ T& j+ j/ E{
$ Z3 k6 c& W- o" W3 \ platform_device_unregister(&da850_evm_tl_leds_device);
- n0 @# h, E& @
6 [* q: P6 V1 o& O+ ~& ~% ^ printk(KERN_INFO "LED unregister!\n");
8 M0 q* [4 J9 I6 j8 h) {}
2 ~8 x5 z8 E3 B) }+ A1 c
% y! i2 e- O: Z# bmodule_init(led_platform_init);
" k; c& G! L3 ]" L% Hmodule_exit(led_platform_exit);
2 e7 e( f) K( d. i* r# {( Z j/ I( W1 Y2 J" B, ]
MODULE_DESCRIPTION("Led platform driver");0 p4 e8 B8 H! g6 ]6 [, d( T
MODULE_AUTHOR("Tronlong");/ \7 K% l& G2 f( B, f* w
MODULE_LICENSE("GPL");3 | c+ Y4 C; s6 O# y% U
1 `6 p+ u. [5 M3 z4 |9 J- v9 c |
|