|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 p# \6 [* m: e( K8 K! y
#include <linux/init.h>
" V! I6 ?1 M+ o- e& ?#include <linux/module.h>
: L" W! U I* ~# g& C7 k, M#include <linux/kernel.h>
- c e6 b+ ^/ ?! F& @+ z#include <linux/types.h>4 b- h) h5 u" l( l9 A+ V Z
#include <linux/gpio.h>
/ M4 P, g Z, H5 h; F: {! Z; \#include <linux/leds.h>
) j" [1 [2 Y" ]3 Y7 s#include <linux/platform_device.h>2 M0 Z% W" W; j e. m/ }
) V; L/ J+ `' B2 B#include <asm/mach-types.h>8 ?7 k5 @- N) x+ t
#include <asm/mach/arch.h>* Z( y' u5 |8 X8 a% r
#include <mach/da8xx.h>
! e3 h% Y# ?# q* ^- k* m* @8 ]6 A#include <mach/mux.h>
% ]9 @5 K/ ]" Y: M
3 j! T/ r; d8 A' K0 o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: n3 l" V& v8 P8 X+ H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 s. t9 [9 U1 t, x6 M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ X+ r& Z9 {8 A3 [% N; }1 `, p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 g2 i- J7 t, D5 _' n
* B8 o( |# @6 {, L( P: m9 t/* assign the tl som board LED-GPIOs*/3 a0 d6 W1 N2 ?- a$ ?
static const short da850_evm_tl_user_led_pins[] = {$ w$ P5 E1 a6 U- E
/* These pins are definition at <mach/mux.h> file */
; e; l& u% ~5 ^- |9 h, X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" s3 D1 N! Y9 Y, U( A% Y( T -13 V8 I9 }3 y5 y
};
) J2 A# G% M8 j
% b: G9 r7 \( Zstatic struct gpio_led da850_evm_tl_leds[] = {
& g% z( t" ?' J2 |% {$ b {
- O! @4 t0 C% h .active_low = 0,' \$ J0 y5 B' T' k
.gpio = DA850_USER_LED0,9 w& f s) k8 s7 [2 n" N0 c d p
.name = "user_led0",+ H5 D; G& A! n7 D6 V* s
.default_trigger = "default-on",
. S5 m. {, [6 D2 R0 M },, I. V- E- r* G, j) t- ]! l% q6 G
{( f5 z/ H) |2 r6 |6 @$ O. g$ J
.active_low = 0,+ v7 d( ]: A7 n- @- r
.gpio = DA850_USER_LED1,/ o0 L5 [6 k) t/ I3 a
.name = "user_led1",
. O) I( F5 G1 A9 I; _ g( C1 w/ b, d .default_trigger = "default-on",4 o# I5 N0 E2 w( T6 V) _3 l
},
' D0 w- Z6 q# X; p$ G: m, H6 K {; L6 H( t; E% y) v, c {# g* |
.active_low = 0,
% v ?" k3 _/ t( s K .gpio = DA850_USER_LED2,5 Q- r1 a3 Y L3 O* c B% Z
.name = "user_led2",! r7 b0 l+ d b! p5 a! M
.default_trigger = "default-on",
2 i! d+ s' G5 i& D t0 Q/ S },
+ ^# { g; S: V3 b {
* P: P W- G- p7 J- @2 f .active_low = 0,) j/ U+ L$ |( J9 C0 f
.gpio = DA850_USER_LED3,
( f4 s7 v1 d+ j' A( l .name = "user_led3",
/ l' c$ r/ v/ A8 A$ { .default_trigger = "default-on",# x; `2 H/ p& e$ P" v" I( Q
},
. {" D1 I9 H4 j' v% }0 p) j: D};# }: y4 P( _2 p6 O* t1 K* {
0 s7 x% c) F9 o$ o5 p; sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 [4 X2 f! }- p5 l
.leds = da850_evm_tl_leds,
5 K3 K7 E) m+ T4 H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 g7 I" N. y* i; z) T, ]7 M! }- [
};
6 `; {( X8 T" _3 W( d% d( l1 N$ @9 N7 x% J
static void led_dev_release(struct device *dev)+ i: x- M- x) e5 I8 \6 b/ K! N6 A9 z
{" G% B& Q& V! b/ E; [5 E( m# G2 S
};
* v9 f8 C0 e. Z7 @ K+ Q0 h7 ]% @3 w8 q
static struct platform_device da850_evm_tl_leds_device = {3 I7 W' u) n, y: E s$ N3 T* H
.name = "leds-gpio",- ]9 ~+ P' w4 h; Q$ S. A
.id = 1,
' a& ^' z5 Q1 |5 z9 \ q7 f, b .dev = {
. S/ f9 o2 F" U5 K- M' C0 l .platform_data = &da850_evm_tl_leds_pdata,
5 u: d% ~, K' ?8 E2 H .release = led_dev_release,
1 M' s- i; G B; b/ ^ }* u1 f9 R K; t2 `4 Y: Z
};
1 {1 U9 j) T9 {" H
- P- c0 f, U# l- G( e# W) T+ Ustatic int __init led_platform_init(void)
S5 {/ L+ s+ Y. K! ~0 `{
$ y/ N+ N/ Y: u4 v2 o+ d int ret;8 p. Y D/ x5 |
#if 0
8 c; i# p2 R" V D# B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 {6 Y" c: K! E g
if (ret)/ h% R9 Q8 z7 N
pr_warning("da850_evm_tl_leds_init : User LED mux failed :": f% q& X( V' ^$ S
"%d\n", ret);
) |/ j' p# o# O( a- Y6 D( }#endif
! L2 h2 k5 ~, M ret = platform_device_register(&da850_evm_tl_leds_device);
+ T$ U0 R3 w) K* L2 o! i if (ret)6 ]8 A, m- s( j) l4 T
pr_warning("Could not register som GPIO expander LEDS");9 H9 K2 X( w o- F
else
( M" V' q! I, b: N3 D printk(KERN_INFO "LED register sucessful!\n");
- y; T3 h! Q) Z& r) b& l; d
9 U, q* \4 g( B. D; T return ret;2 l. [7 ~# I( ~* F5 y- Y
}; R: z, ?+ b& [5 V7 Q$ @# t
) O. g* c- k3 I+ j2 {" a: A* a2 Hstatic void __exit led_platform_exit(void)
1 M. ^) H; O/ O* e8 p/ `{; { b/ j+ c: U& C$ e) {/ u9 G
platform_device_unregister(&da850_evm_tl_leds_device);6 @2 _- [* g: s5 ]
4 P2 q, \! e5 q+ d9 C7 s2 ^3 Z% k printk(KERN_INFO "LED unregister!\n");
1 f0 h$ Z c0 x p- M}! K5 _8 M% x! @7 L& `9 I8 B
2 j3 N% G: u, r4 q$ F5 Cmodule_init(led_platform_init);
2 m" t2 Z8 M% }/ {) I- L. xmodule_exit(led_platform_exit);
: B0 `5 h& f/ B5 s& ]' o* t- q
' K" s% b; s+ y0 d0 ?/ QMODULE_DESCRIPTION("Led platform driver");5 h' l6 T# ?% G8 p R+ K. T
MODULE_AUTHOR("Tronlong");( M6 W" W$ `4 K/ P
MODULE_LICENSE("GPL");" x$ }6 f; f- W- n+ x- d# j. ]$ S! p
2 j8 H% S/ b8 |2 M) g8 V ^ |
|