|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 O& j0 x' F* D#include <linux/init.h> w+ i2 e) k; M& q, x2 ^
#include <linux/module.h>
W. \5 O: ~$ @5 k7 g3 v! u#include <linux/kernel.h>
* O5 p0 G$ {% n. x. `#include <linux/types.h>
5 A3 d: z$ [$ F$ R6 V#include <linux/gpio.h>' ^/ R8 z8 Q; c$ H
#include <linux/leds.h> b. `- t! \8 {+ ^/ T& L
#include <linux/platform_device.h>7 w( q9 r4 Q4 L0 z
7 D2 a1 Y9 R$ K( x+ d2 F" ]8 u2 A#include <asm/mach-types.h>
/ `+ b! \1 S4 ?1 j5 F1 M#include <asm/mach/arch.h>
/ V; g2 e2 y- d" @$ C2 |#include <mach/da8xx.h>
& r: Y4 `9 x* h6 b+ f#include <mach/mux.h>4 ~7 {" q& H. [0 M0 P& h2 u
) \% G4 z; n; T: g/ ?. g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ R, ?5 a3 e+ `) k# Z+ h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! p& f: O, \; a5 C
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% N8 ^ V1 N' P4 S# d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ Z( u, q1 ?) H/ p g5 E
" U _' M; y) H0 l/* assign the tl som board LED-GPIOs*/7 O6 b- L) P+ w2 S- g
static const short da850_evm_tl_user_led_pins[] = {
6 {( q" {: j L7 P; r /* These pins are definition at <mach/mux.h> file */2 n. e4 E* f7 j1 I) R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, W: Z$ _* }6 A# N -1
: g9 U- G; M! A' h2 @" ]; f};
$ H$ f# G4 Z+ l! l( k# H
+ ?; `* J8 m/ p7 i4 Cstatic struct gpio_led da850_evm_tl_leds[] = {
1 j9 Y+ b9 Z. v {
% I; a1 P& s( C' u0 D% {) Q .active_low = 0,
! w3 s/ N, q/ p .gpio = DA850_USER_LED0,* g" L0 D' }& K" d q4 Q6 e
.name = "user_led0",
# N% m K9 T; k3 O1 k .default_trigger = "default-on",
, w2 q, s: \: G2 Q% q. s) D },7 s( P& v8 O4 _5 p, A- H& Y$ K
{
) B( Q6 b0 o W& O* [ .active_low = 0,, E. H; X! g9 N& P
.gpio = DA850_USER_LED1,
- E' q! J4 P9 Q" D: L .name = "user_led1",
# n4 j2 I) J) B( o) f& h% U .default_trigger = "default-on",* i, H$ U6 ]. T8 u0 H0 x' Z7 Q9 q
},+ a: B# v: ~& u1 R1 t+ y
{4 I1 ~9 a+ T$ ~+ c' o' E; q/ ~
.active_low = 0,8 d3 m5 B4 ^, c/ M3 {
.gpio = DA850_USER_LED2,
- \" P: U9 S* M l2 q* f .name = "user_led2",
`) m6 E, v2 I% y, Y .default_trigger = "default-on",) L* a4 y* V9 t3 o
},: S% S$ |0 V5 N0 _, f! B
{& N8 J0 l5 X% P7 R2 w- \6 W
.active_low = 0,
H+ J. a* J! Q. T! i. Q# Y2 _ .gpio = DA850_USER_LED3,
- Q6 K7 L) f* i0 ]8 q$ o/ J& r .name = "user_led3",
% k- Q- w8 [) Y v9 [+ V+ M& ~ .default_trigger = "default-on",: D( j- C9 W0 ] T4 H
},
/ `7 q3 H# H1 \, T6 B};
# ]5 \3 S' U( X4 Z3 J2 W1 n* i4 D0 B* M" U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 R7 n" l" e" s* z .leds = da850_evm_tl_leds,7 s) u! w4 l7 t, M2 T" S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 z; a3 G7 B$ \" m! ^5 a0 o1 I};! x7 K. ~' h8 W5 B; B8 d/ S
% P \7 R; N! Q# I% Kstatic void led_dev_release(struct device *dev)
" c% y3 a: C+ L{2 Z7 I4 V" ]1 v3 u! g* y: P' I+ `
};
2 n" F6 q9 ]% n& E- P2 c8 L9 n8 v9 O+ X/ f! W5 |. s. V
static struct platform_device da850_evm_tl_leds_device = {0 d' \6 Q; n* ^3 W: [( Z
.name = "leds-gpio",
2 L6 {+ w; c5 O' d .id = 1,
7 L+ w2 y- g) j7 l3 C .dev = {, R2 ~: }- h. s8 D
.platform_data = &da850_evm_tl_leds_pdata,4 Q# o9 ~8 g5 S' z2 |; s: m# z
.release = led_dev_release,7 {, {4 w. R1 x) s" @
}$ C- }" [: t( `5 m# X3 J/ u; q$ V
};& ~8 ?4 o+ s) P* j l! S- q }
[& ?: |/ d+ m, U% \8 Y! X
static int __init led_platform_init(void)- J. u) h8 ^( o& [1 \
{
" r: C' @1 X; @' v6 t* v int ret;) k, ?2 p( K' c! \
#if 0
2 X: r1 Q2 v( k9 A; o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; U7 e5 _ c7 Y! _9 P+ J
if (ret)" l7 f( f4 U$ y& a7 J* m- C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% P0 I( M4 J! s, o; X, V; |1 b
"%d\n", ret);
" }9 N$ a4 v- V# C# o) }% \#endif6 G5 j' t6 k. G; |, H7 W# D1 e5 @
ret = platform_device_register(&da850_evm_tl_leds_device);
+ h) w r- Z4 B# f if (ret)
' b, F) U% U- o1 ~+ a pr_warning("Could not register som GPIO expander LEDS");0 q3 q I* x9 s" T* ]
else
4 y6 i% F5 D P$ m$ R! Z+ ^3 L( v printk(KERN_INFO "LED register sucessful!\n");/ s. Y8 m8 X6 O
( c5 `3 m$ G) p: C
return ret;1 P* Z! l3 z" x4 R* h
}/ `/ k7 M8 J$ ~& X
& i. b( G9 i }2 R8 {
static void __exit led_platform_exit(void)& R* i" H. ?' \7 X# {1 ?
{
* {$ I3 C: Y; ?% E; l platform_device_unregister(&da850_evm_tl_leds_device);) [$ ^2 a- \, l+ \! E( j5 a. X
- C* a7 g ?6 v8 _! r9 q5 d0 f4 d
printk(KERN_INFO "LED unregister!\n");7 W( g, z& b& [
}; i5 N! d$ n0 Y8 c4 ^2 {
" l) B0 U# X3 y& b4 G, ~1 z0 F9 q. rmodule_init(led_platform_init);5 W! F* x% Q2 M6 I
module_exit(led_platform_exit);% N+ ^; i. e9 i. R m- }
- m' K7 D1 u- j" E ~, j* A: `MODULE_DESCRIPTION("Led platform driver");
. M1 M6 _# {6 |' tMODULE_AUTHOR("Tronlong");+ O4 z+ h g, k/ ?1 C) p$ E
MODULE_LICENSE("GPL");
( N3 U- w8 F! }+ J) ~3 W. U# P0 @8 N- h& _0 m) {- L3 B/ Z
|
|