|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! w3 T( r$ }" v#include <linux/init.h>) a+ s/ q. |9 s' Q8 ?6 @
#include <linux/module.h>
$ |+ C& i% S: F, H2 |/ O#include <linux/kernel.h>
$ P& o; h+ e5 J9 \" N4 r( V#include <linux/types.h>
* i+ \, D- B7 q* A+ ]* M0 H# T#include <linux/gpio.h>
6 m \: E6 P: ], W; C. _#include <linux/leds.h>
' \8 Q$ i! g; |: x; h/ ~#include <linux/platform_device.h>
3 J/ T, k- h3 b5 a( y) p- `& I+ F7 I5 Y. r ~& w
#include <asm/mach-types.h>* g/ s% Z4 q( y! M
#include <asm/mach/arch.h>
$ A% |1 _1 q- x0 T2 ^& o* P#include <mach/da8xx.h>' z6 O5 B8 C" T6 F) l# \
#include <mach/mux.h>' y1 z& s Y/ s/ s3 `5 Y0 c( S" t
. X4 `0 R9 k3 K, N8 ~# l0 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 Z' s/ c9 F. i% W/ n, g% S8 D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 _' H2 i4 [# @ M) }+ b t7 q& B5 `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) z+ R$ U" u2 `, ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. J2 J/ t* b6 t1 D7 x- A7 {1 E0 U" R! F% n& n
/* assign the tl som board LED-GPIOs*/
6 [$ A, \* s% K% _: w; _static const short da850_evm_tl_user_led_pins[] = {
4 Q: _* b. ?; m' S /* These pins are definition at <mach/mux.h> file */" Q& B4 U- |! Z& {! p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, W$ ?5 O- Z/ @9 u
-1/ z- _3 V1 o: e5 I. c; a2 C
};
: a1 _+ E) y) Y" i: Y$ A. k, _7 P# P) C0 w7 M) P6 i# o
static struct gpio_led da850_evm_tl_leds[] = {
- b) l( L5 c( [* n: Z {" e# i! J1 g5 a
.active_low = 0,- N% K+ E5 }7 R: p% A' H
.gpio = DA850_USER_LED0,% j9 O$ Q) \2 b; C
.name = "user_led0",
$ c$ J) R( B# e A5 D/ y1 I x" K .default_trigger = "default-on",
* D3 ?2 {' V: l% s: j4 C( c, r/ u },+ f$ |2 q5 D* l# a! X
{
3 E, T5 `5 }( o0 y, z .active_low = 0,
4 ]5 w5 N! n, }* Z .gpio = DA850_USER_LED1,
4 B1 S" R" ]6 g7 v .name = "user_led1",
4 ]! D! S, ^. h1 ? .default_trigger = "default-on",
+ q! u* }$ v9 Y; @9 n' K6 @ },; h$ K5 R0 B6 ?+ O
{" g* |( a$ |2 K; }1 q" D5 O
.active_low = 0,
# g) J' E6 R4 M1 a3 h+ P! T .gpio = DA850_USER_LED2,# J1 r3 K6 n* `7 q4 I: L
.name = "user_led2",
X( y/ T7 q0 a. b .default_trigger = "default-on",
: F0 h+ n* a: p U" ~$ i+ A% C },
9 F; {9 b( S. m6 t7 U \ {. C. {1 ~* V* ]- x l
.active_low = 0,
. }8 B/ |* |; n, w0 q .gpio = DA850_USER_LED3,
# P3 e7 q& a# e" v: Z .name = "user_led3",
* f- C& [' C) { .default_trigger = "default-on",
2 \- ]1 O" m( i },
( y. \- X: C7 G' O};; R% c8 N, f; y; F
/ B. d$ m. m. K7 m! sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: { G- @) e/ K7 ?, Z .leds = da850_evm_tl_leds,6 d2 |9 Z. i( v" ?6 R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! D6 o" \ i* b/ u3 H, m};
6 u& i. p' p# E* F9 d5 z) G" v8 `/ E5 ?9 J
static void led_dev_release(struct device *dev)
- `7 U) Z; w: ~/ X1 @- R{. r$ I& u" p9 m: I, A( Z- H0 a+ x
};6 O w$ c, h. \: j+ |! W8 Y- Z) z
j7 p" E3 N+ z t% P+ }* `1 q
static struct platform_device da850_evm_tl_leds_device = {7 r% H, k* D7 V+ c9 F7 L
.name = "leds-gpio",
7 q9 o# ^6 V" K- ~. }# Y .id = 1,
- G0 Q v1 i, ?! e .dev = {
' a+ Y& S& X c# C- |9 F .platform_data = &da850_evm_tl_leds_pdata,
9 ^6 w, o8 _" s7 S( N& |0 ` .release = led_dev_release,& ? X6 |; `5 T( a, i
}8 y; [$ u ?+ E; Y1 O: U) Q, C7 a
};
6 v6 h" D2 ]7 G4 }2 v' t- `% D8 E: v, j1 p- l; U% P! T6 d+ v* g& [$ b
static int __init led_platform_init(void)
) X: Z5 g) f/ p$ E8 q/ y; u1 U{
. o: \, w( V( e1 q int ret;
% e! C+ L: X& D$ [: d# i$ u& B. }#if 0
; L1 M5 M# L. h+ i# n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# ?7 h! G8 {3 ~6 k% h- l$ a# r
if (ret)$ e7 m$ x. j) C/ @( ?9 I8 |9 o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" A p) Q9 S7 e Y "%d\n", ret);
8 `6 Y5 J0 N6 h) m0 @8 i9 \#endif; t5 @0 K) j% d! Z. c
ret = platform_device_register(&da850_evm_tl_leds_device);
& K, }4 ~+ ] u p: I if (ret)$ y. H0 [' F4 z7 J8 t. \ E
pr_warning("Could not register som GPIO expander LEDS");( m4 P9 @3 k! I0 J' h- \% G. e- b- m
else
2 e9 |0 N f4 l# L1 A printk(KERN_INFO "LED register sucessful!\n");7 L; n9 R; r; K# J2 C
- M1 d2 s9 @4 Y
return ret;2 D" _& j% J f) q# l
}
; V1 z1 w- A( Y# X5 s9 s% v6 g$ _( m- I; @9 d3 v# }! X
static void __exit led_platform_exit(void)- r- I) u) `3 R& [) R$ X, h
{
6 x2 g, ?0 T# [) J8 N platform_device_unregister(&da850_evm_tl_leds_device);
6 @9 | w+ ?* [$ Y, m @/ p' J' D8 R* ]; I }: B/ @) D* ` w% e
printk(KERN_INFO "LED unregister!\n");
) H4 k: b# {) M# B}
9 b# u( p5 ]9 c% ?1 t
" E: n' Z' M$ h. | Cmodule_init(led_platform_init);
8 h# M I1 m5 }& i [module_exit(led_platform_exit);
& S# g# P) J5 a( x$ m: c0 O. R6 a t9 g
MODULE_DESCRIPTION("Led platform driver");
% C$ ~0 S- b# d4 }4 \MODULE_AUTHOR("Tronlong");
. p" ^" X( o9 p' z5 \0 ~4 [: gMODULE_LICENSE("GPL");
7 {% Q( y( i, i [: q* O" Q2 ~& L) \/ S C
|
|