|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# p1 ~0 N+ v1 t2 i5 k6 S$ T#include <linux/init.h> E9 X) W: K( o5 s; }/ s, U
#include <linux/module.h>
: Z, d+ l7 s, \) @4 D1 v#include <linux/kernel.h>
) d# H; s5 x% d#include <linux/types.h>
: t; }' d% l$ T( l% Z#include <linux/gpio.h>/ P; b7 [" c+ b2 W, w$ \% E
#include <linux/leds.h>
* V+ ]+ c# T0 H5 x _#include <linux/platform_device.h>
H2 y1 Q/ V6 j# V
9 ~' f. ^" f( ]6 w+ L( K#include <asm/mach-types.h> Y& f: P1 P0 U8 D
#include <asm/mach/arch.h>
, H1 a% Z2 N. N& P+ }) m y#include <mach/da8xx.h>) O* K. k) ?8 ~" \
#include <mach/mux.h>
& @6 L% o0 c# u; s: Q; Z( R; D0 m; j5 ~4 g, A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' [% w1 n+ H! O& L: S( ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* q6 p! H8 c ]- V8 ~4 Y3 `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 V M( w) H, p% M# q. c# ?) K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ h% o9 v. @4 G6 Q. l7 w. ~
& o# z, g/ [+ K& E% a- Q! L7 }/* assign the tl som board LED-GPIOs*/4 H. J$ ]& O0 U2 t# G% x9 H
static const short da850_evm_tl_user_led_pins[] = {
+ k" r1 W& x9 A8 x7 J- ]" ]' y /* These pins are definition at <mach/mux.h> file */
7 a% O7 q U/ Y$ f, V& D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 i' y) Z7 N; F! _) o -1# D7 K& g! }8 o
};
" z" p- C- `8 j L+ x' q. k0 x5 K/ Q. k$ J
static struct gpio_led da850_evm_tl_leds[] = {
. U4 O- k) V r {
9 R& A% N1 o7 p. p6 C9 s2 ~/ B .active_low = 0,
: A( p6 |! g6 J .gpio = DA850_USER_LED0,0 ?0 b/ d4 M% a }! n8 E% h
.name = "user_led0",' F& L8 a4 F4 Y5 z# L! V
.default_trigger = "default-on",
: m* {- R; ~3 p$ D. @ A },
) F$ \) ?$ ?8 c8 p+ m" i {5 R0 J1 m& M( b) T; x Q6 B0 b. q
.active_low = 0,4 Y6 ?( J5 i- s [7 w
.gpio = DA850_USER_LED1,
1 k3 Z& t2 z+ j! t v .name = "user_led1",
3 K) e( _+ V! ]6 t4 z; l# ` .default_trigger = "default-on",
W9 T* n' d1 D/ `/ }: W$ s },
- ^( |6 e( ?" K X {
0 T- @# `! W4 D+ K: p5 a .active_low = 0,1 M$ P8 t8 r% X& d
.gpio = DA850_USER_LED2,+ o/ d4 q8 H* q0 S8 n+ U
.name = "user_led2",
9 r$ C7 `3 D5 K- H+ f .default_trigger = "default-on",
4 E0 U8 ?5 E v/ c% y$ E( q },. S' U: V9 {+ E z, }* i# u9 e! |
{3 M: S$ [9 c) c1 `( H1 c5 K" T% C
.active_low = 0,
+ L0 P3 k; g8 p .gpio = DA850_USER_LED3,- ~6 I1 s# F5 L9 Z8 ^
.name = "user_led3",
$ M6 m- A" q B .default_trigger = "default-on",' ^7 k. x7 o) @( ~$ f" Y8 p
},$ h& ]# @1 H2 C% `' L
};
i+ U6 c- ?3 y4 e V! M3 W$ M9 B8 b. z3 Y" X) ^$ z5 A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 F1 A) d& ]# @( v8 E
.leds = da850_evm_tl_leds,' t" U% ~9 C, i3 x! N
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 U4 f: S: h) X( N" p3 W};9 z* M) R2 r& u8 `2 Q5 E1 n
6 r f+ \/ [/ q. q+ W3 ^3 astatic void led_dev_release(struct device *dev)
& g" Y% Z7 C2 r$ ?1 s! D3 o1 N{
& f C, S6 u; M) J5 g};- ~% D$ a* f" c# J5 B
" P6 {7 f0 L% d% N2 J3 ]9 g
static struct platform_device da850_evm_tl_leds_device = {
: t n; O/ y9 F" Y" [+ S7 g .name = "leds-gpio",
" U, I3 u. B0 P .id = 1,
, `7 ^( g; X* Z7 p h .dev = {$ B+ a; d6 ^. q" o
.platform_data = &da850_evm_tl_leds_pdata,
$ g. Y/ F' U( }4 U .release = led_dev_release,
9 r C7 @: K7 I$ g* F }
. h0 I# M, m: e, H0 x2 X; L b( L5 ?};
+ _6 P+ t6 W6 J5 _8 `, g2 ~' I5 U' o
static int __init led_platform_init(void)% K9 D$ C# h% O# V; R8 X
{
- A8 e/ C/ R. [$ [0 q8 l int ret;, {# [! Y2 Y* Z0 o+ P6 S7 x" A: {
#if 07 X. v3 z. K$ r! r$ L3 D8 x5 y9 ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% D& V2 B9 ~! P if (ret)
% b& T% v" f* c+ ^/ m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 Q1 A4 \4 U U7 f8 o1 f8 R ~ "%d\n", ret);
% r' f, ]0 Y* P* x" O% P#endif* i/ i {7 d$ X# ]
ret = platform_device_register(&da850_evm_tl_leds_device);
% ?9 H r, t4 ^/ j if (ret)
o0 S# X3 B5 d5 e pr_warning("Could not register som GPIO expander LEDS");
( J& B5 H! K4 q- x: P else; z% a# y; O) ?7 U T+ T' R* l/ ?
printk(KERN_INFO "LED register sucessful!\n");+ }9 h6 s9 U8 t3 P4 b
; k& \% i; o) P7 {2 j! I
return ret;
- \+ ~1 S# @: X% x* o& ]& a}* |7 k8 b' i$ ?/ c, T
; F* I% c" W1 Q1 J" }2 `+ T
static void __exit led_platform_exit(void)
% [, A* g x3 Y: u( c{
1 J8 W; j6 m1 b platform_device_unregister(&da850_evm_tl_leds_device);: E; h I/ h/ @* W9 [9 ~. I
: U' K. U) T( @" N% b
printk(KERN_INFO "LED unregister!\n");
& K1 s7 T! l* c7 D}, e+ c, F. m: R3 x/ N
, u7 l5 U, {/ z1 C. s& `- N
module_init(led_platform_init);: C3 v5 h, \* {, N- a; u" M4 u5 l
module_exit(led_platform_exit);
: L' v* X: B: B9 t4 x( Z. B. [
- ?: K3 g: v. E; M6 XMODULE_DESCRIPTION("Led platform driver"); S a0 ]8 e4 ?5 `5 G8 d( w
MODULE_AUTHOR("Tronlong");1 i% p" z* C _, \; n
MODULE_LICENSE("GPL");) Z4 j$ u* X( D& m
% m h/ a6 Y& J# r/ x
|
|