|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% Q" ]% }2 D$ h1 A#include <linux/init.h>" |5 M3 E2 F5 i1 v7 ~. i$ C( `
#include <linux/module.h>4 A$ i. }6 x* U3 h4 ^. M
#include <linux/kernel.h>8 h( o# q8 x3 |, p; d
#include <linux/types.h>) k& X, ]" u/ ]! h) w% d
#include <linux/gpio.h>
4 s3 ]! i* t& P#include <linux/leds.h>
# b: ^1 b8 F" B/ k: R/ h9 f1 j, \#include <linux/platform_device.h>
" M; }. W, n+ ]
. s& M. I( j3 P: a#include <asm/mach-types.h>
" f( B" `) ]5 I. `; m" @#include <asm/mach/arch.h>
/ {9 a D) ]; s1 u) k0 O: X#include <mach/da8xx.h>
* v. h8 g8 q' q+ _#include <mach/mux.h>
/ }. ?, I% ^% ?# f
4 r b: m6 R1 z7 N7 ]. H0 a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 W5 N: W! u- T) ?. D: b0 l#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 g: F; J- e. @' |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* ^1 R. X/ s7 X5 s2 H! L E) l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& t7 @7 ^5 P1 n. l6 @7 f- y' [+ [& G. }& ]1 b
/* assign the tl som board LED-GPIOs*/
& M) ^ H& j9 cstatic const short da850_evm_tl_user_led_pins[] = {; Z6 T) W; q0 ]& d! e: i
/* These pins are definition at <mach/mux.h> file */
; Z: C/ A7 q' M4 h; c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! b- V1 {% N7 K! j3 [5 l1 u
-1
j0 Y3 `1 `" c' Q};
L+ ~8 `: f V) F. z+ Z" }1 g6 |+ l. `6 O# l3 H
static struct gpio_led da850_evm_tl_leds[] = {" J" g- t( V5 N: H3 l+ r
{
; L2 ~8 J" g6 Z/ R; O: Y- y8 s .active_low = 0,* E' c* ~2 o& E' L: k9 c" }
.gpio = DA850_USER_LED0,. f8 @; i' ]# u1 R; T' |* Y& q
.name = "user_led0",
; Y; k# h4 j3 q$ y# U7 ^' K9 D! Q .default_trigger = "default-on",; `( ]- V1 c4 F/ S# W& c6 h% U
},
- {3 F. s+ H8 F& o, P: o {: o! O/ A* I; b5 i" |0 a4 V
.active_low = 0,
+ M1 A! s4 O; v" D. J .gpio = DA850_USER_LED1,
0 C9 D+ ]+ M5 @- k7 x7 w .name = "user_led1",
. }0 A/ {, |5 q! P( [ .default_trigger = "default-on",
m5 [3 y8 v9 S6 _: G },
6 h+ p6 p5 Z& G! y: v9 \& r {. k7 f$ w9 F$ D8 o, m
.active_low = 0,1 ]6 p f2 x% L* K
.gpio = DA850_USER_LED2,
) H7 [6 r: Q: |/ X. i( K& s .name = "user_led2",
2 C+ Y* E) q& f Q" s( m9 Z .default_trigger = "default-on",
+ H4 T' r) Q8 _7 u- [# F1 r# d2 a },
0 {! D$ e) e* o5 H {8 E$ t7 u7 [; ?- |, @, ]
.active_low = 0,
$ Y4 }+ Z) c- `( ?! x4 V .gpio = DA850_USER_LED3,
" q) Q+ p- x2 }$ g% F .name = "user_led3",
' g: n" a! p! K* a" J3 X0 ]8 B .default_trigger = "default-on",
- M u% b& W1 }4 z6 I4 T- G },8 P4 B2 P8 v) G7 b3 Y- G! A' a$ ?
};
! a. p7 s% s1 {5 h- R5 o) A
$ E* \0 G7 D. }' vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. |- l! R3 }; w# n0 y& w1 I .leds = da850_evm_tl_leds,
" d* ^8 O* t: s8 b) g .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" J9 L. B# G( r1 V};9 O" t. P* q* O! d& V. l+ y
" [! Q# d; }6 f/ I$ }, Q
static void led_dev_release(struct device *dev)7 O9 `! u/ Z% S3 Z) E
{; t1 {0 k V" F. S6 ~
};: O( g8 a4 n5 H3 X, `
+ G E- X e5 B
static struct platform_device da850_evm_tl_leds_device = {
$ l0 A" Q* q# q' a; m: _, a4 j .name = "leds-gpio",
6 N1 W. {; v2 E .id = 1,: b, i: _9 C$ ]4 l
.dev = {
9 C# l2 K8 J4 X; T! @( a* Q .platform_data = &da850_evm_tl_leds_pdata,
) ^/ [1 @7 {5 r/ K5 X* j' N* Y .release = led_dev_release,
- |" `! G2 d" S+ d$ n! J }
: M2 f$ @& s* ^7 d};/ |9 k! s: Q4 D( l. o/ r
. \8 Z. N3 B6 k0 Q, Q% rstatic int __init led_platform_init(void)
e* R& @3 L- h+ P! P. M; q{
; m" w& e% s, y% I int ret;
) c9 B2 ~& g8 w; n, i0 e#if 06 v; @* U, s6 b2 _" p( @7 z* z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: b8 V8 x; X l1 O8 N) v2 S if (ret)) x% ` @3 |! o" J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 e/ \% y" P7 r* G# w "%d\n", ret); b7 F) o+ p1 D9 t8 L: h
#endif$ G! A5 ?& m8 y C: _: s
ret = platform_device_register(&da850_evm_tl_leds_device);3 Q$ f$ T2 N% s* x3 S
if (ret); z0 J% m% `1 l! C$ ^# y b/ o
pr_warning("Could not register som GPIO expander LEDS"); Z+ y1 Y( k, r' ?
else2 ~1 r( y) `4 D) R( T$ M
printk(KERN_INFO "LED register sucessful!\n");
0 ~3 J9 Z0 E+ Q1 v: }! `$ M2 Z$ b/ g0 n& @
return ret;
$ J% S9 q6 R8 b- c& W}
5 |# f. ~5 T) c; R& B2 g8 }1 }% a9 s( q- L, N
static void __exit led_platform_exit(void)
. W; P6 |8 }* l1 e# Z# y{) B" [$ s6 T4 E5 o* O
platform_device_unregister(&da850_evm_tl_leds_device);
* Q8 C/ m8 }$ H; Z* o
1 J3 z$ d' v7 ~; V- O2 Y# T; J0 c printk(KERN_INFO "LED unregister!\n");
. c& I8 ?. @7 [}
$ l" s* {0 E. v2 [" P* w5 m* c" l& C8 _, R( `; ]
module_init(led_platform_init);) Y) }0 M/ g+ S- u1 Z* S: C1 w5 v
module_exit(led_platform_exit);
8 \$ K- n. ?8 A$ G6 U
4 u% Y3 y/ s' y! w2 _3 fMODULE_DESCRIPTION("Led platform driver");
: D% @- x! T/ N2 k. s' CMODULE_AUTHOR("Tronlong");
/ F: ?7 }( u6 B* K6 t; q4 xMODULE_LICENSE("GPL");0 E2 i) K9 J3 S+ K7 q! m: ?
y3 y$ T5 D; M i6 R3 W/ F |
|