|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: s+ V( `# p1 j1 s) S#include <linux/init.h>" w7 ]8 T$ i4 g: ~
#include <linux/module.h>
7 H( P- F# ?# u3 a3 p- v#include <linux/kernel.h>1 j. Q. f1 g& |) G6 m
#include <linux/types.h>
% g! g. ?, a+ o6 |( G# T#include <linux/gpio.h>/ ^% [* [- u1 G' d
#include <linux/leds.h>
2 W4 j7 a/ \$ e: N#include <linux/platform_device.h>
% b- n. ~+ V" m. V2 j9 d, I7 A+ B8 K- H+ ?0 Z6 }! P, \9 \/ Q
#include <asm/mach-types.h>& T- l& _! B& k6 r' Y" ?. R- M# n) q
#include <asm/mach/arch.h>" s1 O$ h+ G4 p. i9 V
#include <mach/da8xx.h>) @0 \ z& R8 g
#include <mach/mux.h>* r, E: y! |) d& c8 ^
: n. L1 C3 U. U* b- m6 m6 f4 j6 q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 J0 O/ `- l% k' @& D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 |( O) N1 Y7 R. w. ^* C/ R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
t3 F" C) B$ E# m#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: Y$ o5 } v+ e: g
* D( Q" h$ Y7 Y/* assign the tl som board LED-GPIOs*/1 D6 T, I) w: `" u% k
static const short da850_evm_tl_user_led_pins[] = {/ w' d q+ F! Y B4 F) E! `( y; y4 I; \' ?
/* These pins are definition at <mach/mux.h> file */
' W/ _ _+ E. V6 E ]" l$ K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* I) C0 }$ n5 F" O3 {7 s
-1
5 I4 X% X- z6 S% H2 O' {};( }; Z: v6 _+ l8 I" q
1 a6 C( F2 f- y" c! a: P7 j6 \static struct gpio_led da850_evm_tl_leds[] = {
7 |' B! J) q- L; C' L3 A+ i: m {1 ]. C, _) Z* O# a' T
.active_low = 0,
( T( M0 I. X+ ^ .gpio = DA850_USER_LED0,
Q6 U+ a& u8 H4 |6 } .name = "user_led0",
( ^8 o8 r! g$ U* u' c .default_trigger = "default-on",
5 F& _" y# R' y5 k; N },9 e, S( W- k0 x& O1 F4 U
{
& R9 s) V2 t' V+ |" O .active_low = 0,9 ~" s8 B- y0 r8 Z- j0 {9 F$ _1 e$ Q( F
.gpio = DA850_USER_LED1,
, ~. P7 V+ l! `* h .name = "user_led1", g+ y. Q) |8 { Z d
.default_trigger = "default-on",
$ K% _2 f" W$ e- m4 }. Y },
7 G$ x, x8 \ @0 M3 E6 z9 H {
" T3 a! Z1 K0 F7 G5 o& J/ L2 N .active_low = 0,
; F' q' ?: y1 c) _0 K7 K5 C .gpio = DA850_USER_LED2,
2 K7 ?* ~% R3 m( T7 T" g; l .name = "user_led2",
7 S; @1 w% @4 d$ ~( G( m; O .default_trigger = "default-on",
1 _+ E/ d6 M+ L7 _ },
4 W3 ^: l! P" q/ n% n# x# t$ p {
# ~9 U0 ~ q% g1 l .active_low = 0,1 N( R( w8 T a6 y% {1 n y. L, d/ a
.gpio = DA850_USER_LED3,
. i t5 B* ] q+ q+ m .name = "user_led3",
! z) g" y5 s$ p) o5 [ .default_trigger = "default-on",& z: Y" X: I0 n
},. @) F1 P, G$ l
};( u G+ [, i: m7 V" Y
3 q& S: u) X5 Y3 y' X7 ~- P, X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' o& P/ m6 P( s; u. O% W) t) n' w .leds = da850_evm_tl_leds,
# t- W# t j" N1 ?, t9 b$ Q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* l B& @& f4 E" l
};
1 V" m3 ]) V1 u5 e/ A l" ?2 f4 O: r1 t$ Y% ?8 ]
static void led_dev_release(struct device *dev)
9 M. Y$ m1 m: H! ]$ q{* r. ~' B3 v7 C. M6 S. C. W
};2 q# F, u0 D; s
" P$ G2 r' n8 M: pstatic struct platform_device da850_evm_tl_leds_device = {
+ z- {8 `- U( d- N. N, q .name = "leds-gpio",6 [: ^& f5 U# X* s/ d' U }
.id = 1,
% r( y) f9 m. _& A2 S .dev = {' O: ]& Y/ i0 N4 e: w
.platform_data = &da850_evm_tl_leds_pdata,% u5 |! b2 h6 W0 ~
.release = led_dev_release,
2 |, ^. z, \5 ^4 n' x+ L }
2 c5 {. V: `! B( v9 X6 E* U};
1 n' Z, R' N- R: a: `
0 z1 B, J9 e9 v) T( Fstatic int __init led_platform_init(void)
5 I# E6 {1 I5 t) u. @/ _{% X! p v+ i8 q! q
int ret;
# F9 k) D/ a9 H3 ~' e0 E$ P+ |#if 0
: A! x) m0 s( ?1 ~7 v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( L6 ?' |% F9 X if (ret)
( }8 F8 Z+ e7 Z2 x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 Z7 O( h1 j* l* c# K! P "%d\n", ret);
3 S# `4 t5 H6 [5 G6 V#endif
4 |( H8 h' k( a1 c ret = platform_device_register(&da850_evm_tl_leds_device);, S. R! k4 Z7 Q5 x
if (ret), E* }& ~8 b/ D+ W8 u1 L
pr_warning("Could not register som GPIO expander LEDS");
* f6 k: p' `( y# S2 ~2 E3 [ else
0 L+ V7 r# f% p" Y7 \; H; i( { printk(KERN_INFO "LED register sucessful!\n");3 V: E4 ^6 R1 ?9 l2 z2 v
5 ?% e* {. m9 M# J: t9 c
return ret;
( D5 N" N9 z. z}
7 ~! [7 t/ w2 b( Q) F9 I
0 ~0 N, @/ L* ]6 @static void __exit led_platform_exit(void)
8 `# b( j5 ?7 }' K8 u{
! S+ T5 h- z- ]9 w2 r5 k" F( | platform_device_unregister(&da850_evm_tl_leds_device); p, Y& ^: X7 h3 l6 F
) {& M2 v' {, q2 q. _1 j
printk(KERN_INFO "LED unregister!\n");) x5 O6 V5 B' T4 d( k9 f
}
& {: _* G+ ?2 A/ A& Q5 ?) I* ?
, H2 L$ \3 u0 i2 ]4 |module_init(led_platform_init);% B* g( }0 a; D& I, u7 w+ N9 w
module_exit(led_platform_exit);5 B: u$ P: \# j7 `. c8 ?
+ i, ~/ D6 I5 K* w2 h& r1 vMODULE_DESCRIPTION("Led platform driver");. I3 L! T( ^/ C$ c0 q
MODULE_AUTHOR("Tronlong");
. l" w; w# s- ~MODULE_LICENSE("GPL");
# v7 Z0 @: L+ k# q& r5 N$ {% M' A/ ?2 [1 @3 {2 W/ Z
|
|