|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( r3 }" \5 e) s4 ?& R' q7 c" j#include <linux/init.h>
9 R, U+ ^# g0 G' ~- q4 F$ v7 s#include <linux/module.h>
: G i W3 z) x2 Q) G+ O) ]/ J#include <linux/kernel.h>
; l. Y6 g8 j# V) q#include <linux/types.h>
& |& }& `5 ^% I#include <linux/gpio.h>, d1 d) m) l' }4 }0 T
#include <linux/leds.h>
% g' ~% r% [ b- V( i) A$ j5 L% Q#include <linux/platform_device.h>) {' N4 B: w, R! {8 y
8 H* k: ]: `! {' Y, ^+ G) E, a#include <asm/mach-types.h>: f- I9 ^% ^3 ^8 u) P3 Q/ r
#include <asm/mach/arch.h>7 m9 F2 p9 n s- n/ s# C
#include <mach/da8xx.h>, V% }& Q7 h( l- X2 `( D. u
#include <mach/mux.h>* n, n; q3 w7 g* a1 A: v( I
, `, L& o2 J* Z7 q0 t4 A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) x# U1 V! @+ n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# ^' @) q7 C$ n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 C n3 z! N& e3 w: C: r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 h$ T, D/ Y& @4 C& L
! d8 F) ^5 F9 T8 \$ O/* assign the tl som board LED-GPIOs*/: Z: b1 | y3 N" d& {
static const short da850_evm_tl_user_led_pins[] = {4 A0 L g* ]# e8 \
/* These pins are definition at <mach/mux.h> file */
2 b% U# I4 Q, N% m* a. z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 c& h8 D* j1 p8 y% x
-16 U" f' ?' z7 P: m2 Q; j
};
+ B* a0 k5 p M1 z; p0 Q" D9 U+ c( a' U g
static struct gpio_led da850_evm_tl_leds[] = {: J6 U" ~: f) S7 `5 C$ G6 a
{1 u5 [- }* ?; n1 `9 c1 ^
.active_low = 0,
5 }9 \, L# O x% N' G .gpio = DA850_USER_LED0,# a5 }2 [3 I& O5 b. X
.name = "user_led0",
0 d, ^; H5 x" n6 k .default_trigger = "default-on",
6 G: c d; B/ b },
, y4 D/ l' A1 O6 z+ _ {
) a- ^3 N* m# K$ e, o .active_low = 0,, ~4 c+ N. v4 B9 U6 f, d
.gpio = DA850_USER_LED1,
# v9 S" Y! V) @ .name = "user_led1",
% i, Q* Q+ w, L* k# \2 e' z0 ?/ i, a .default_trigger = "default-on",
+ o. F/ g, ]9 ]$ x* x9 a/ O4 f },3 P- q- P. L. ^
{
7 A' ]: m- y0 Q$ U& x .active_low = 0,' R* ]" g* E# K* ~, B8 l1 \6 g+ ?. f, [
.gpio = DA850_USER_LED2,
5 o' I0 R* v1 i6 g .name = "user_led2",% o5 A, H- c: Z" R/ _' {) I2 _
.default_trigger = "default-on",/ L) }: Y$ s0 G* k$ @ x$ x7 `& B3 H5 _
},: s0 z6 v' F( t. [
{
$ W% S. H6 ?) Z4 b; j .active_low = 0,
: J2 {# z( Y/ J: u! O .gpio = DA850_USER_LED3,
9 s- Z# o' b( V4 j. D8 w( K. ]0 h .name = "user_led3",
- N2 P$ _" i* `: h .default_trigger = "default-on",
; s9 @6 Z6 p1 | },
" ]0 V5 Z% Z+ t! t};0 |' ?3 s+ p" Z8 \) _$ e7 u
5 J* i$ b8 G" _! O3 p& H- ?7 [0 J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) q; v% N- k c' y/ J
.leds = da850_evm_tl_leds,
# T/ W1 X! u# z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 m& V' O7 B& ^2 |1 O' t2 Y y};
2 }, C, l* v, n$ L. g4 V$ N0 U% \ e: l: s
' A# T. r5 P, j& l& M, z- a8 w0 L5 b9 kstatic void led_dev_release(struct device *dev)
* G9 q& H0 y0 }% I. m7 t6 d{
7 G9 ?3 c- g/ f- ]4 \5 e- U};
! M e# _ c/ y- L3 u
+ a7 n: d- p+ J1 \* `static struct platform_device da850_evm_tl_leds_device = {
7 f) H' S" @5 w4 u3 t _$ e .name = "leds-gpio",. R9 |3 f% R9 L) c9 {9 I
.id = 1,
( @ d4 y2 y& _1 s( B7 C .dev = {
- ~ ~- X* c" i. T7 q8 w; t .platform_data = &da850_evm_tl_leds_pdata,2 X) B, c# A5 j8 ~
.release = led_dev_release,
^! j6 y$ Y6 s1 z' e }0 A# H7 C% y5 M# Q: i# O
};
& F* [1 l; R# [4 V( P" H$ f1 ?& d
static int __init led_platform_init(void). z, \& d" t0 ~; A
{
b8 a5 W# U S int ret;+ t# ?+ s0 r& b' F' F' p( ?" u* h! m5 C
#if 0
! `; H7 `: n9 P% r2 w q9 x ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 l, K7 _$ |& X: V if (ret)
. e0 f& g. O6 R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 p' V0 T" T3 F
"%d\n", ret);3 n) L! s. ^+ D- K
#endif
" N5 Q1 B7 n5 @( ? ret = platform_device_register(&da850_evm_tl_leds_device);! f/ r( S7 A) }! j* f! T/ z
if (ret), p, d" P: |3 f# g* x% b+ h# t
pr_warning("Could not register som GPIO expander LEDS");1 s% p% O g) |! J, u8 B
else
. r7 o' N5 J" D printk(KERN_INFO "LED register sucessful!\n");7 G" C7 A! }" v- H' K6 x
, x4 I; C) c5 j# J/ v return ret;2 j# l3 x% L7 Q/ g, N
}
/ \( J z$ d) m" F% P) d
9 h( @ m$ Y3 m1 v; E- q- Astatic void __exit led_platform_exit(void)9 n& S( G# r) V4 l) z2 X8 v
{; r" W1 g( l( W0 \
platform_device_unregister(&da850_evm_tl_leds_device);
8 @" X( X5 G, \; R" h7 X1 T
6 l. U& u4 k7 d4 i1 ` printk(KERN_INFO "LED unregister!\n");
" s, O1 q) C1 T1 D}- [% b( v, R7 P, F# S" G
/ r! t. N0 h$ h \
module_init(led_platform_init);
5 a9 E0 ?" Q( f9 Z- g% t- F' Z( Lmodule_exit(led_platform_exit);( ]' @, ?) I2 d, i4 E$ P5 i
/ S( c8 N4 L6 P; V; m3 T) tMODULE_DESCRIPTION("Led platform driver");
) Q& d! {; M+ z. D" OMODULE_AUTHOR("Tronlong");' Q, e8 d( ^! y7 i9 t- @
MODULE_LICENSE("GPL");
- b% h X. I: j% C. t4 j0 F- r K9 z
|
|