|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) Q& F& B0 ]9 b! r+ }) g7 q U2 O#include <linux/init.h>% n( ]2 P) z! ^4 f4 U. |+ `
#include <linux/module.h>
) i6 a1 a( Q- I6 W) U. h1 a#include <linux/kernel.h>
, C( c9 ~: ^4 ~: x- e#include <linux/types.h>' E5 e/ r8 d$ _' y }; `
#include <linux/gpio.h>
0 o t+ x( s" R! E u) W. r$ B5 f#include <linux/leds.h>
& w, M' r4 x/ T* j#include <linux/platform_device.h>
$ J+ A1 g9 K' p
. X/ ?7 g1 M, s, }- Y#include <asm/mach-types.h>/ k2 f7 |6 o& z. O
#include <asm/mach/arch.h>
9 w. i7 z- |' Q8 l1 Z+ C#include <mach/da8xx.h>
6 V ^ X: j, G1 |9 r/ b; b2 J#include <mach/mux.h>
) S! s; V6 m1 T! Y% g" J& X; E5 S0 s$ v# G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' C; ]* H+ H6 [; r3 q3 r8 u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% t' }4 F, L9 K% B4 {) I" ^) J) Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 A& ~5 O" R2 z' D# l6 g# U: z4 N4 ?#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 N7 H* \0 j/ }) |. w+ R9 E
R8 }( Z; p- z, _) T/* assign the tl som board LED-GPIOs*/
6 z9 B& v( R- w7 jstatic const short da850_evm_tl_user_led_pins[] = {) N$ v$ ?( ?! g
/* These pins are definition at <mach/mux.h> file */
7 b( y3 C2 y- O+ ]' j% ?. q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ p, F; B3 f9 v& D
-1
; C& t+ N6 M4 _) y};
" E1 D4 S; m$ S% j) e# T! b$ d7 s* b
" w$ L X' V, _0 c3 Tstatic struct gpio_led da850_evm_tl_leds[] = {
& l1 O9 S1 K1 o" {1 B {
* p0 v4 h5 j! X .active_low = 0,
% v- n7 D6 k; F3 F .gpio = DA850_USER_LED0,) \5 r7 T& M8 q
.name = "user_led0",. a* ]: a5 N3 n: `0 J$ B, p. f2 |
.default_trigger = "default-on",- O( W$ q2 o7 ?# d) T
},
- p. x3 c6 C" v. _9 G {/ } j" e6 T5 ^: h: m2 H# L
.active_low = 0,
- j) Q& R6 L# O. |* e% A! d5 ^ .gpio = DA850_USER_LED1,8 q* w3 K" j$ V5 c Y+ u
.name = "user_led1",6 @- ~, }1 y4 p/ v# k
.default_trigger = "default-on",
F. s: o5 ^1 u/ V1 Y },5 b1 ]4 w* ^. T6 K+ T- H! y
{0 M; v7 ?5 }. o: Z5 y, A4 w! B% O$ ?
.active_low = 0,! y i) y R; ~% I
.gpio = DA850_USER_LED2,( `1 m% B+ R% N( E9 m# a/ v
.name = "user_led2",
3 }, _: m! s- A+ ]: `8 _ .default_trigger = "default-on",
3 o+ _ Z1 ^, U$ I, V },; s# [! ^ W! z+ |. ~' w/ W
{1 n: H% X+ b, D8 c: a
.active_low = 0,9 _7 t2 h. ]# J' S
.gpio = DA850_USER_LED3,
, j2 u, G! I! v, ^0 T .name = "user_led3",1 F. |# E" C* ]
.default_trigger = "default-on",
" }/ _. a6 D/ n3 X! r; B },. [( f4 g5 D5 n7 H# G) W
};
1 M7 U" K- \) v# b/ {9 _6 \
9 \9 v7 m3 ^3 ?8 n, @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- w5 H1 @; }* M
.leds = da850_evm_tl_leds,8 d& W, N/ g0 h( P" X# A/ A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ a" D- q# Q8 C+ F6 }& h" j
};
$ g. R# i* \- u$ F5 _; {& n; [0 ]3 K% j9 _% p& v# U* @
static void led_dev_release(struct device *dev), U4 f I7 f1 U9 v
{) O0 O/ Q0 I# [0 [2 d5 d! X
};. J" c9 r3 ?) L3 u5 b7 S
" w4 b# Z; k7 N: ~static struct platform_device da850_evm_tl_leds_device = {# Y* F' m9 x1 R$ o, f
.name = "leds-gpio",: i% ~4 x0 ]9 m) T! }
.id = 1,7 _# i; K+ H# d& h; O; c' M4 q
.dev = {" A# e$ j9 X' v3 c
.platform_data = &da850_evm_tl_leds_pdata,
3 v4 Z# A& m' n$ f7 ] g/ N .release = led_dev_release,
+ X% c& n+ J7 h# I }# U0 C+ g) v3 x
};! f# `; A3 F" Q0 N- s6 ~
6 N1 Z) n& |$ j# A
static int __init led_platform_init(void)
( d9 t9 s& P5 H( K* L' S: [{
8 X6 C2 \) e9 ~6 u \) l- B int ret;) |+ g+ K; Y# f8 h- T; |
#if 0
. L) ] X; J$ Q; U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); {2 k; I2 W3 _" t" w# j) F ~
if (ret)' a! f3 ]# ?/ o8 M) d1 |& a: k" L c; @2 V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 L, J( Z0 x5 H/ H8 {) L
"%d\n", ret);
5 b" j: J# n' b# q#endif
* G6 ~/ _9 c0 o, a ret = platform_device_register(&da850_evm_tl_leds_device);
2 S" W8 k) x. P if (ret)
2 x) }4 ~, G1 F( b+ t. ]5 D$ U' w4 k pr_warning("Could not register som GPIO expander LEDS");% `0 g: }% @9 R' R' l
else
8 [* f1 ]: Y% B3 b; t0 [$ ]1 q4 [ n printk(KERN_INFO "LED register sucessful!\n");% T2 m* F) I8 @
8 K: |, X+ I1 z8 t return ret;- {/ }+ o6 Q, f' }. _- ]7 J
}0 i4 M: }. U; _ T
5 } m- {# h9 f& Xstatic void __exit led_platform_exit(void)& A' {3 _. |$ m4 j6 k
{0 X. Y% W! n: r/ {2 \) O
platform_device_unregister(&da850_evm_tl_leds_device);. r6 O8 [. q- C/ }% {
. f0 Q- |5 P6 ^& Z' N! X printk(KERN_INFO "LED unregister!\n");
. D! o+ w3 f% S}3 g3 {; _, g) }8 J# m+ ?+ p! s$ i
7 Y/ r+ h# Q* G9 X5 Omodule_init(led_platform_init);3 O. V8 v- j" \! C
module_exit(led_platform_exit);; x. }5 g6 U5 n
) Q J7 K) M3 G# L9 D8 f7 [MODULE_DESCRIPTION("Led platform driver");; E, p8 [: b- o$ p2 G
MODULE_AUTHOR("Tronlong");8 S6 L- o9 n5 P! z+ q
MODULE_LICENSE("GPL");3 d7 J! q7 E* I/ g
- q/ S3 v" f( p |
|