|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ D# s$ \! w1 w: u
#include <linux/init.h>& V* V' f0 q9 E1 _# ^& A9 Z
#include <linux/module.h>
" t M$ h4 i4 m; d1 w#include <linux/kernel.h>
# o* q0 U7 Y0 u$ V4 T* A6 y#include <linux/types.h>4 q" F# s I2 y
#include <linux/gpio.h>
`0 y( G. Q8 m l3 I$ |#include <linux/leds.h>
% Z3 L5 x+ S9 E( R#include <linux/platform_device.h> V% Y6 S7 P' P; K
& i1 ^2 t* W W& |1 H/ t2 Y. Y( }#include <asm/mach-types.h>& s$ o y8 [3 O* Z: w
#include <asm/mach/arch.h>
) p+ }3 Y9 I/ k3 }#include <mach/da8xx.h>; L) S2 Y O0 K L* _8 C
#include <mach/mux.h>. ]" i2 b/ e) D4 K9 J
, E: ?2 N" {0 w& V2 N4 W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
p# s _! W8 d1 H! d" G% @1 g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' w0 o- [0 P$ W n- h#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 N/ X$ Y2 M9 q7 V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) N' t$ C$ G, R8 K, _. c+ y! F
$ A* l) h+ l! t" w' b/ Q. n
/* assign the tl som board LED-GPIOs*/& k% f6 |0 A! j7 s$ e- l' G
static const short da850_evm_tl_user_led_pins[] = {
& n8 `, z! u5 K m. [( G8 r /* These pins are definition at <mach/mux.h> file */3 r/ N$ O8 S" m$ y/ m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ n8 I3 \$ S6 i2 }- Q -10 n1 s1 v% j2 n
};
r2 [ K: O6 p# Y; w4 a
3 b: h* \; {- W8 u" n# ?( A! ?static struct gpio_led da850_evm_tl_leds[] = {3 ]- @: {3 P, M s
{4 q* b$ h( b- ?; a4 R
.active_low = 0,
+ G3 I P }0 U: h1 w4 K0 v; P .gpio = DA850_USER_LED0,
- c5 w" ^. a- K/ w5 V9 J6 N% B .name = "user_led0",/ [# N4 Y. M7 N& N& Y. r& Y% u
.default_trigger = "default-on",
9 S. P- j7 g9 I1 Y },
" v6 W4 H8 ~# V( c( f$ o7 e% s {' M/ b; r+ z' D8 B
.active_low = 0, x4 E5 o7 {6 \- f! o* m. N
.gpio = DA850_USER_LED1,3 U. ?$ E7 V3 M4 h
.name = "user_led1"," Z' c0 c3 f8 `5 O# u R/ S& c
.default_trigger = "default-on",; w7 A$ O6 D4 c) d1 N8 e4 ?
},
% K& J" X n5 ~ {2 _% j. H) d6 @
.active_low = 0,
6 D, Q7 w" T) C5 Y/ } .gpio = DA850_USER_LED2,
( e( U& m. g$ z! ]6 z1 q .name = "user_led2",' q; o+ c3 w* _+ y" W
.default_trigger = "default-on",! A$ ^2 Q/ ~ c7 k: N
},3 {) ^. e' [: U: H0 A, |7 s3 e
{
9 E* F& R2 ~- Y9 N .active_low = 0,
$ x" {" o& J# I9 A7 \ .gpio = DA850_USER_LED3,
& {0 q( C' ~7 X3 y6 n) v5 h .name = "user_led3",
6 n, w1 V4 f( f/ q% a .default_trigger = "default-on",, Z. R7 H L) q4 C
},
( y: P# w8 |9 r' Q0 g6 S- a};
' o: ?: A7 C7 ?1 [ N; D/ H, D. Q/ A }* d- T! ]3 k7 W. S ]0 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: k/ l6 V( u0 }7 o2 S0 g: G2 C1 k& r .leds = da850_evm_tl_leds,
. J$ h/ j. x2 A! |3 ]7 Y2 b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 ]' {8 I8 \9 j4 H4 k3 C
}; p2 L3 b% s; n, Q$ R4 X
' R. T* z3 B% e+ {' [
static void led_dev_release(struct device *dev)
1 x% x9 ^7 ]" ?- L4 w1 }# |{
0 x; Z- \. S/ p6 @ A};% A% |) X# r r+ M( S
& |1 G; E( a- t2 w- U! o: o8 t u* vstatic struct platform_device da850_evm_tl_leds_device = {9 l! y. _! E% s( C+ f& E8 z
.name = "leds-gpio",$ Q" C. s% {" [0 K x, F8 U
.id = 1,( y& z: b( G' ]$ c" [
.dev = {7 U# ~9 K/ q+ e3 X0 L" M
.platform_data = &da850_evm_tl_leds_pdata,
# W- Y* Y* e" J) B) M; m5 b3 N .release = led_dev_release,
5 v7 w. A/ p' ?8 Y8 |: |. `- C6 h }
' ?- Y! J7 i# Q! W};% J6 N2 r+ }& z O8 v
; T8 T+ z3 t. d! R9 @6 Lstatic int __init led_platform_init(void)
9 @* f9 ]: t9 Q{
0 [. w w2 @. Q/ O+ ~+ z int ret;3 v+ L- t+ ^! i+ n3 r7 d. q8 R y
#if 0
* L O$ m- }9 ]$ g. u. Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; m. n+ B& Y1 B9 ~9 I; F, |" v- K if (ret)
@7 ^1 p0 o2 e& D9 f$ ~0 u pr_warning("da850_evm_tl_leds_init : User LED mux failed :". } k9 }% v1 V& d9 S& S/ }5 h
"%d\n", ret);
. M! v! i" C7 `0 i#endif
' }6 e' t: Z5 ]! R$ o& W2 ` ret = platform_device_register(&da850_evm_tl_leds_device);
# w( c& B/ v7 d* } if (ret)
4 D3 |) u( G7 f( P$ D# l% D! i pr_warning("Could not register som GPIO expander LEDS");
% f+ C) }) C) y else- B5 E) S( a% m0 i) O! K S+ i5 Z
printk(KERN_INFO "LED register sucessful!\n");
7 ^5 O- B4 E1 U1 e/ |
$ s+ I+ j6 G: n+ A4 s return ret;
( O0 Z4 W& m' a7 N}/ Y) ~1 ~* r! d" t5 o/ g
+ e* n1 e. B. o# h/ v
static void __exit led_platform_exit(void)
2 y. v" `4 z0 j' Q" D{
* P: u, O2 t: m3 e2 Y# q6 A platform_device_unregister(&da850_evm_tl_leds_device);
+ h/ X- p u2 s( T* l& p! y3 Y% H9 P- g0 f; U
printk(KERN_INFO "LED unregister!\n");# r5 V$ H( x [# g8 M6 A
}0 d `) l7 @$ l* H7 T& K: G
2 ^0 k6 v1 C1 R% y5 B8 Y3 z
module_init(led_platform_init);
0 T9 d7 n- s4 mmodule_exit(led_platform_exit);1 C6 a, w% |! h% P1 W2 j' b
( _, _8 v# t+ b$ k; _MODULE_DESCRIPTION("Led platform driver");2 z. g, y7 Q* f, `" ^! P
MODULE_AUTHOR("Tronlong");7 n: O1 }2 X* t8 u
MODULE_LICENSE("GPL");
! o8 s/ U) O5 ^8 n& ?- }( y
& d' c9 M. c1 t4 B7 Z |
|