|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% w i/ c0 w8 u8 B+ W#include <linux/init.h>, O) \( j) `9 B
#include <linux/module.h>
: L [, F6 r! r, K- p7 g5 n1 t#include <linux/kernel.h>
' P2 c- g( m& f# n! Z K; d( a" H# E#include <linux/types.h>% x+ P# ~8 f3 A) V& G; t: v
#include <linux/gpio.h>' n7 v) {, u3 F
#include <linux/leds.h>" [$ A1 P' F4 S
#include <linux/platform_device.h>
1 p1 S. R# T* l3 Q4 q# y9 J5 X) r3 r$ R. p/ l3 i. Y6 y6 C
#include <asm/mach-types.h>8 @8 Q3 h2 m" x7 p
#include <asm/mach/arch.h>
?# w! i+ N+ a, u0 F5 e' B% Z#include <mach/da8xx.h>" V1 r: V" l7 o7 D1 b5 \+ _
#include <mach/mux.h>: H: f1 b) |# ?# c# E
+ z* u6 p3 {- [" t4 y) D#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), i& s E8 e$ a# \- @+ T8 O; v, w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ B9 F: Q' X0 s3 Q P' \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: K+ W7 U# q, g+ o! M! j#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ ~1 h: n" G; T" b& l# H
: H" P0 E% S8 Y$ V' F
/* assign the tl som board LED-GPIOs*/
+ c7 N8 P& Z- M4 d3 \1 |static const short da850_evm_tl_user_led_pins[] = {
* m: u! v7 Z } /* These pins are definition at <mach/mux.h> file */
. D; ]' f, T' {* L! K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
P; A+ ^9 Z" U2 A) f' h" _$ ] -14 s+ h; h# G P( V5 k8 K% c% S
};& {( M8 J& p' m4 s7 ~* B6 C
8 f) m. ?4 n k0 K7 U/ Y" istatic struct gpio_led da850_evm_tl_leds[] = {
5 v, e* R* A) }: S1 }- H' k {" @/ h: T/ c! O/ U
.active_low = 0,* e4 g% Y% p# v0 y
.gpio = DA850_USER_LED0,
/ \! T- ~/ i2 U7 B" W& X; C j$ Y .name = "user_led0",
- s; _* I5 T$ w9 ^& u .default_trigger = "default-on",
1 P a* c6 |2 W! q# o },; t8 Q: ~6 N7 z. q. P0 z9 r
{
! C, i3 M; L3 N# ]5 [3 A { .active_low = 0,
) i9 z4 \0 t. i! v. d, ` .gpio = DA850_USER_LED1,+ O( ~* e8 Y; _! ?$ N+ U+ }+ `. U2 t
.name = "user_led1",
. g" _' M( ? C" i) Q; d0 u .default_trigger = "default-on",
A; X: f, V$ u) p; e: E* y6 a8 Z },
& M2 y) l4 D7 ]6 M/ N) Q) T3 @ {8 {$ e( K1 @1 _, N6 p
.active_low = 0,
' x% d7 E# m4 v& j2 @) f; y( r .gpio = DA850_USER_LED2,% }) p+ e8 `2 \! h
.name = "user_led2", Q& V" j7 ~9 |( A
.default_trigger = "default-on",
: P( M' a& Z# w. g7 ` },
7 Q4 _" S. R# B$ y4 E% `6 r" t$ F {6 n0 Y5 M( S$ [# |$ |) ~. Y3 F$ o
.active_low = 0,2 t3 t7 }8 I% r# @% V
.gpio = DA850_USER_LED3,; w( n! \% J' N" L9 G X2 x
.name = "user_led3",; T* N& ^+ o3 j7 C* O1 ?7 N
.default_trigger = "default-on",
# P; |, i/ z$ W },5 v6 \! R' U# U' D
};
2 c, }2 x. ^. C; W5 D
4 [# f& C) L. Q0 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 n0 `) m, L5 J6 C- b$ M) |' q, R/ K
.leds = da850_evm_tl_leds,% m/ D5 w) n% D- ?+ }$ b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 M; ^ _2 |; F+ d# h, S$ W3 A
};
; r R5 R2 j( Y0 t
5 r% X5 W8 x& H8 }6 [, ystatic void led_dev_release(struct device *dev)
2 h" k9 w; W/ b4 p& i- Q{
6 K. e, A: o9 A; w3 ^/ q};
& s2 U8 ~+ b: n+ c* K' o# d: U e" p. ]3 }
static struct platform_device da850_evm_tl_leds_device = {0 d8 \* R* t; I* F- Z
.name = "leds-gpio",
2 D Q0 m; ~+ U3 F .id = 1,
" y1 w6 O- Q9 c .dev = {
8 i1 {4 w& S# R0 C1 |8 I8 X+ t, H .platform_data = &da850_evm_tl_leds_pdata,
; c& N0 P1 o ? .release = led_dev_release,
r+ l" Q! f7 @/ h* x8 w1 O7 t' n3 q7 k }
" \% i$ A) n& i% y};8 z' U6 V9 U6 N3 P3 z4 C
0 W# u k8 u% R+ T% Tstatic int __init led_platform_init(void)
6 i ?& S8 m" W# ]{7 O. j" w4 ~: @5 |: r
int ret;, {- b$ y# U& q; c p8 Z
#if 0" L4 [8 P% i4 q) c/ U- J
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ s8 k4 @% N: t C+ v, T- h
if (ret)$ e$ d# t( o* w! {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") K4 j% Q& p; Z5 S* S8 {
"%d\n", ret);! R* O* J; _: T$ J4 J* ^; M
#endif$ S0 ~; Q7 I8 q3 k; u
ret = platform_device_register(&da850_evm_tl_leds_device);% K- Y# Q z; n' E
if (ret)& m! `* l2 k7 L; h2 c
pr_warning("Could not register som GPIO expander LEDS");
) y/ y/ X2 t9 P" B6 o r. p else
9 E* r+ l$ _( y# i printk(KERN_INFO "LED register sucessful!\n");3 O6 |3 [ u. w; Q8 c1 {" L1 a
% O* \+ x* V6 i$ g1 G! p return ret;
; I1 {5 D. B* X}/ l; k' S+ ]. l( u; g
6 W$ q* o! @0 Y% D5 p" Mstatic void __exit led_platform_exit(void)1 B1 Q1 W. f/ M8 _' V% O
{+ y5 h" f& T3 g, K% T. x% p1 ]
platform_device_unregister(&da850_evm_tl_leds_device);
+ l: M: [ m4 a$ i$ r+ I' z7 W) w1 G) d4 ]% g7 N( h: j5 w+ E
printk(KERN_INFO "LED unregister!\n");
% m- S/ J8 @# ^: N& X- Y- \}) J; y# h( x6 N# A! c
, |% K$ B! R" G" Q& Y0 N6 `module_init(led_platform_init);
: X" U, k" E1 Z* lmodule_exit(led_platform_exit);
1 t; K, S& k1 m
. Z Q% @8 w, p" Y+ t: _. xMODULE_DESCRIPTION("Led platform driver");
8 X- X% R7 J7 N/ @) B" AMODULE_AUTHOR("Tronlong");
! D5 \( j% v! P5 V& H. vMODULE_LICENSE("GPL");5 |7 c. @# F9 F+ `
1 t' J& V6 ?5 [+ L' F( n! Z |
|