|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 X: _' k+ e( G7 ]6 C#include <linux/init.h>
8 a) Z/ h; V: A* l% ] S a8 o#include <linux/module.h>2 I B+ R2 L* ]1 c( d3 B( \
#include <linux/kernel.h>
" N. T8 W3 r, c8 M1 I#include <linux/types.h>4 S; p. F- G6 v
#include <linux/gpio.h>2 g6 B5 C5 B# [# ~0 X0 \8 {
#include <linux/leds.h>$ v5 e3 u$ F* W, ?' i3 ^
#include <linux/platform_device.h>
- r) p( p; X: C7 ]. e0 l
. ]# s/ i1 z0 Z#include <asm/mach-types.h>( |7 I, r, a2 k
#include <asm/mach/arch.h>2 l# K: [2 l. O) m
#include <mach/da8xx.h>
# C$ W/ ~& I$ y' w( e: P#include <mach/mux.h>
1 x5 J, i7 K) G2 t9 u
: A" w; N; q, O( ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 p: v. {) i# y: y1 [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ p6 J1 f @, f# _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* N( f( U# X9 l0 T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* E4 \" P% i4 K9 _
' ?, ]/ [$ R; \/* assign the tl som board LED-GPIOs*/" u" {* o$ ~" j& r
static const short da850_evm_tl_user_led_pins[] = { P! ?/ w' w) p# B
/* These pins are definition at <mach/mux.h> file */+ e6 ^: M/ J3 F, [& m0 ]
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 d- P' W7 t! q$ u8 j -1- E ~( ?: i0 Y* X
};
& d' D' I+ M) K) F! |2 `! i" q1 U7 E* G- N/ v+ }
static struct gpio_led da850_evm_tl_leds[] = {
" C0 p! v. X3 B" s {
5 _, a k; X: E: i .active_low = 0,- `$ J7 D5 T# X
.gpio = DA850_USER_LED0,- F$ Z% @& ]8 O u: e, l4 R
.name = "user_led0",/ u' ?& F% {5 o" G4 i' ?
.default_trigger = "default-on",+ l* p3 u2 n* I# C% G
},9 G' y. D. ]! w' g( j
{
$ m# T/ [6 \, b# s* M .active_low = 0,& H5 M0 j4 F9 e0 w
.gpio = DA850_USER_LED1,
# n6 i" c: v; ? .name = "user_led1",
Q; d, {5 Z' y1 p: v$ X+ }" R9 g .default_trigger = "default-on",
/ K5 P! D v1 } },4 ~7 D, O! \! l7 L; C" N# b
{
8 C: O# X/ t/ V) g .active_low = 0,
# g( m" z x' w, t6 `/ p$ A4 D) A( x$ d .gpio = DA850_USER_LED2,- x4 b$ [' m, w7 E+ f
.name = "user_led2",
( r( p, a) `: E. Q( f* R .default_trigger = "default-on",8 Y3 T1 c; ~% _8 x: |6 e% |9 V
},
$ C# v; N, l# v# u/ r" p {3 n0 N* h2 s+ S1 N. }* n
.active_low = 0,
; d3 x, U' F5 b* V# h .gpio = DA850_USER_LED3,, n2 {% v8 k( j" v2 m$ @
.name = "user_led3",
& f9 q% D( ^3 _% I8 G .default_trigger = "default-on",0 D3 X- C( D5 p
},
7 V4 |( _4 T; i: R! o! h};
# Z( U* V! l: s M- j8 w' B0 l* |
. z% n; ~" w, z' H9 h6 R, ]6 cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 Z# c2 ^& u) m# V9 T
.leds = da850_evm_tl_leds,! R. C* G4 X7 P2 @$ l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 l2 N( U( }- n};
Q% S. X' c' U% s$ ^% `
: `* Z: w# N8 v* E' _7 Xstatic void led_dev_release(struct device *dev)* P3 e" H" r3 n* v0 X1 D- L
{$ s. n7 i' P% ?$ C; j; o5 o
};
- B9 L# a( s+ U0 {) D- }
' {: `, w6 c Z& l5 d4 Jstatic struct platform_device da850_evm_tl_leds_device = {
/ i5 i$ x6 W5 M6 I( C .name = "leds-gpio",5 O+ o! Z/ O& G6 s$ w2 B# g6 ]2 D
.id = 1,
z: `; Z* j' d4 w4 ~2 A: r( O .dev = {) L7 g/ m1 F- v0 {1 l, n+ L
.platform_data = &da850_evm_tl_leds_pdata,' Z# C+ h" v. r" p3 b
.release = led_dev_release,; s- Z' \* h; w3 Z! B3 R
}9 _ |% K4 p s$ [- p# R Z
};( U! [/ m' X8 E) H; d5 i3 n; @
6 S# _ j, z8 Y1 U, pstatic int __init led_platform_init(void)2 Y& ^0 O! e- s# v. T: W
{
8 Q7 V: v O0 n9 B- ~, P int ret;) }3 S# o& s h7 J5 u. j0 f
#if 0
7 }, A" V! H% z- M* S9 i: a6 W& B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 ~$ F# O4 o r if (ret) z( I6 q0 n8 ?* m6 p) ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 a7 F1 \% c/ J: [6 \$ H q1 u8 S/ M "%d\n", ret);0 w7 R& S+ C I+ W2 k
#endif# n1 U- o. l% Z* Z% T# i
ret = platform_device_register(&da850_evm_tl_leds_device);. b" A/ H* w, j/ x2 N' A
if (ret)
9 j4 H" E. ?4 B pr_warning("Could not register som GPIO expander LEDS");7 O3 Q% [0 ~/ `4 p ~: N n
else* C" j0 a' u: X3 y1 Y
printk(KERN_INFO "LED register sucessful!\n");
1 O% E& C% c/ J! z/ O- \/ U
: O8 |% r0 ~- l$ c return ret;" W- I5 X& G$ p( i
}1 G9 ~& U5 g' |/ E. h \
; Q# F3 h: T4 O) }0 c' gstatic void __exit led_platform_exit(void)
\- {9 Z# [& Z+ o' V7 L/ u4 h, _{- n$ F" W5 N, E. i2 b
platform_device_unregister(&da850_evm_tl_leds_device);
, @$ C$ }/ y) o" t! @2 R! ]+ h- ]* J
printk(KERN_INFO "LED unregister!\n");
; t" i0 z2 @/ r* `6 s5 [. r) i}) R x: V9 u) ]6 a- f& ^
r% V6 u- O5 T' ?/ j9 t/ m3 vmodule_init(led_platform_init);
5 ^/ @4 m' P/ @& p5 E/ G2 wmodule_exit(led_platform_exit); g& |9 O4 W! l2 o8 ]* w4 w
( v2 F* |# I+ l9 t. ]# G! q
MODULE_DESCRIPTION("Led platform driver"); z) ]: c6 o$ N: b3 S
MODULE_AUTHOR("Tronlong");4 m8 d6 p# Q6 E5 L
MODULE_LICENSE("GPL");3 u4 ~; E5 i+ N: M* q0 J; R. g) l
, j# f% w3 f$ b1 r- N7 Q
|
|