|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 K, R: T# V) j#include <linux/init.h>
, T2 L# P/ d/ }3 T. @#include <linux/module.h>2 s+ S7 O1 K3 O2 w* j# I% _
#include <linux/kernel.h>
; _" t& _/ U# F3 L, J' I#include <linux/types.h>
* v) F+ a" u- L" t#include <linux/gpio.h>) F) ? A( W7 A: _
#include <linux/leds.h>: K; [0 z) y3 a. w q: Z5 C
#include <linux/platform_device.h>
4 I- k& J3 L7 r2 V( |* J' z+ m; r' E6 H% Z1 a$ t
#include <asm/mach-types.h>
W5 ^1 O1 W% R: f#include <asm/mach/arch.h>
2 }& H7 ]' }1 o' v#include <mach/da8xx.h>$ q- W+ v3 F1 q6 h/ r5 P1 Y. q
#include <mach/mux.h>! g+ t& M4 P; ~# T4 J
+ M9 j* V$ u3 F3 s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& A: r: `, n% y* ~, A/ z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, U+ Z8 T& \/ E* r/ ~" Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* G- L% W" A8 p
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& m9 g' m. f, T# {' i1 `: E% T
" [& o" b) Z* A
/* assign the tl som board LED-GPIOs*/4 H8 C8 W+ s2 i0 Z1 {; H3 `
static const short da850_evm_tl_user_led_pins[] = {
" R4 G0 h$ ?4 i) ?1 a- y /* These pins are definition at <mach/mux.h> file */
- w2 L2 x( S8 I2 Y) | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! \8 q" c- M; _& `2 v0 h; f& b -1
6 T( o( H& x1 \7 x* X# x3 E};# K6 A# h) S5 J `3 F% c6 E }
1 D* e% L0 G4 z5 q0 l3 _) Tstatic struct gpio_led da850_evm_tl_leds[] = {
1 D3 W4 X4 a. s- Q! z+ A7 O& [" K {
6 b/ V7 w/ j5 f! |1 N7 h7 ~* } .active_low = 0,
/ O# Y9 v9 j$ P .gpio = DA850_USER_LED0,
5 d( A4 ^5 T2 T; T4 N' q .name = "user_led0",
# I9 L- y9 }7 ?. N B9 K; d1 `; H+ f .default_trigger = "default-on", y0 W! I2 `$ E0 @) T
},1 y/ m. ]" N# r& ^2 m9 F5 P
{* ]( Q" }0 p, q
.active_low = 0,; g8 l3 F6 I5 K
.gpio = DA850_USER_LED1,
% Q9 m9 ^6 W7 x& ~: m3 H3 R .name = "user_led1",4 F5 l8 h' E( G
.default_trigger = "default-on",
- A. Z; q9 y0 o( ` },
1 o* Z# |9 l( S {
5 w- M) J' C) H X# b( i0 ~9 p .active_low = 0,
8 \* X6 K2 ~0 `$ l .gpio = DA850_USER_LED2,( M( m! f. E; z
.name = "user_led2",
+ I3 U# P/ H( v; E7 w% X .default_trigger = "default-on",
& \1 s# [; K9 m: x* U! i7 w( X },* P( g% o' Y4 V- r2 t; ^- U0 S
{/ B$ J# m8 L: o, Z/ ^
.active_low = 0,- L6 T3 L0 \8 }" D L6 \- Q
.gpio = DA850_USER_LED3,, p- W% S+ e2 V4 S) W- ?' o; h
.name = "user_led3",
4 Z8 R5 T: \$ z, l8 a" |" v/ \ .default_trigger = "default-on",+ F C M7 e" f, k1 x1 z
},
5 B# p& h! z, z- C$ c9 F};
9 K* Z9 g' z) y4 f+ ]" h, F5 B- |3 T1 }) W( d$ y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 ~8 f: K1 F# D2 \! F3 S
.leds = da850_evm_tl_leds,
! B& Y; E, C! S, A .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," \9 P& e T$ ~. E9 s
};! [$ y) g- K4 E0 [ t
# U) ]3 R- _6 T* s) B8 N% W
static void led_dev_release(struct device *dev). G6 A3 T" H6 n D" ^2 V
{, v% |" R) y" _* J e
};
7 P" H6 X! L$ f% M2 X0 t8 _ `: {3 Q! B+ `
static struct platform_device da850_evm_tl_leds_device = {0 d; J7 h, [# Y
.name = "leds-gpio",
; b/ ~* g% i- l/ V& F9 x .id = 1,
* s! H; n% h( i* S( }) Q .dev = {& _5 A- E& A( ?6 Y. J: r6 @
.platform_data = &da850_evm_tl_leds_pdata,/ H# @3 e0 i5 \& J& @- A
.release = led_dev_release,2 H9 U, n$ x/ ~* c
}1 s) ^7 U( Q" N+ J) e* g
};
1 `7 h, Q/ d* h. \- @/ {8 I. n/ m* e, d' H+ [
static int __init led_platform_init(void)
7 ?: E5 w. n F8 X( o{
, u3 E) l# s$ q& s8 x! ^/ C int ret;
9 m9 h' d( G5 t5 h8 `, V9 k#if 0, A l4 G, l# d+ q" c2 F6 ~" ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ x- `( q) v" s6 a% x
if (ret), ~% @4 v( i% T* m( f
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& q% R7 F+ \( N% B" `! X' Y
"%d\n", ret);
0 k" g8 f4 n# ~9 t6 {1 P#endif
$ `* c8 F' ~3 L1 Y: o! | ret = platform_device_register(&da850_evm_tl_leds_device);% B5 r* ^% z1 ]. s: ]% `# g
if (ret) U- K. v) q: a: t: H' D; z
pr_warning("Could not register som GPIO expander LEDS");/ Y) M7 Y3 @0 r* c# n% [: G
else
3 s6 B" B1 D. B+ m: w n S printk(KERN_INFO "LED register sucessful!\n");' b' c, U' E( ]3 p! o3 ?
! w0 M* I0 F4 W6 M6 V1 l
return ret;
. {/ B9 l! ^5 S/ E7 w}
1 h+ y3 M! \% A) H0 y9 M- P5 P7 O$ A C5 n' T1 [
static void __exit led_platform_exit(void)3 f) S4 d% I8 m0 v" R
{" D B; \ E' `9 {* U" W$ d2 ^- V
platform_device_unregister(&da850_evm_tl_leds_device);; _2 x j% d4 v# ^5 q0 k+ T9 f
2 l' I& c9 t2 ]; ^: S printk(KERN_INFO "LED unregister!\n");4 d6 @: A0 b3 h0 |. y
}/ C& B0 z6 N+ @2 X$ c
* P7 ?7 e, C, \4 t q$ `! [module_init(led_platform_init);
) [0 {- ` ?; l+ ~module_exit(led_platform_exit);
. i8 z v" E7 C" f- e2 b2 O2 q0 l' G* n1 S
MODULE_DESCRIPTION("Led platform driver");: H- V; T5 J/ O- s
MODULE_AUTHOR("Tronlong");$ D( ^& m: |+ {4 x
MODULE_LICENSE("GPL");, K: n1 G" B; m4 M
( Y; T) g% o2 g9 O x
|
|