|
求大神给下面的程序做注解,请稍详细些,谢谢。/ a, G! z8 ^9 j* ~2 A+ N. P
#include <linux/init.h>
5 _" C/ J4 V, M9 I: ?6 {#include <linux/module.h>7 {* `- }5 ^9 x, p2 p; I
#include <linux/kernel.h>
& N3 M7 N( g' K#include <linux/types.h>
2 X1 E0 n# t) o3 _2 Q v- f#include <linux/gpio.h> p) b/ U7 U2 i/ u+ {* C
#include <linux/leds.h>% ^$ r: p7 \6 p7 A
#include <linux/platform_device.h>
; a J3 [9 ~1 C' m1 z, _4 ^) C; ?% [; u) }$ H8 i( M' |! S4 ?# Y, W% w
#include <asm/mach-types.h>
- h: s$ l- a' o& h5 t }+ H' g1 u#include <asm/mach/arch.h>' Q9 z8 P- z8 w. z7 a1 P- a
#include <mach/da8xx.h>; \; r5 O/ B# {7 e/ o; _. Z
#include <mach/mux.h>* ^3 S& z( y" N) R4 H
3 E' r' Q0 T+ C5 r: [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 O8 ?. |* \9 u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" D& h! q3 P/ X5 j0 ^( \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 a& J" N" U0 L. C8 o5 L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) o- g( F+ Q* i M: k0 j" x2 _
; ~2 ?" E$ \1 b* V% T/* assign the tl som board LED-GPIOs*/
0 B8 K+ G# M& d' a. _8 dstatic const short da850_evm_tl_user_led_pins[] = {* j% k: P4 C! z/ }" u. b" g9 C
/* These pins are definition at <mach/mux.h> file */
" D J4 u( r4 R6 _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, u5 ~$ X# P4 F7 h. W9 z" V; h. ?
-12 x6 o$ E0 X9 ?$ l
};
9 g6 i7 Q) Z+ G
b# r2 X: ]9 {4 L; vstatic struct gpio_led da850_evm_tl_leds[] = {
# ^* j( q. Z, [ j5 Y% D7 [ U {! t5 A# A, S- h6 x D
.active_low = 0,8 L1 u3 J% r# `+ ~7 d8 }
.gpio = DA850_USER_LED0,% C! q0 z1 X- J* q/ j0 `
.name = "user_led0",
: A' _4 N5 |0 N- S .default_trigger = "default-on",
, [( O7 B0 t! M8 h" b9 ?1 r" c },
e% R1 b3 G1 m$ v {* M' [7 ~' F& d; W/ W$ o9 L
.active_low = 0,
) i2 `4 e2 k! f& |# ^ .gpio = DA850_USER_LED1,; d7 M8 O& I$ w! \; z
.name = "user_led1",* ~4 G9 x5 e6 e. p- ]- V
.default_trigger = "default-on",( V/ s* l( Q" b- U6 _% U
},
4 G9 l: A$ u+ \% W! L. |. V) L5 J {
5 G# F8 k& G" S, [! V! | .active_low = 0," K, ?8 V4 o: H. h: O
.gpio = DA850_USER_LED2,
: m+ ~' \- M2 x* O8 E9 c c .name = "user_led2",
6 O+ w3 T. D9 ?2 r$ g8 Z! |& Y i .default_trigger = "default-on",
: d' E; R% a' p" s },
) R( n% W+ o1 Q" q {
* f' g, j$ F8 D* ]' S .active_low = 0,* a" k1 ~# x! s0 A1 [/ |
.gpio = DA850_USER_LED3,! K3 z) U; G! F
.name = "user_led3",9 ^- f X* [+ m" N' x
.default_trigger = "default-on",
, x; u+ _' b" b% K },2 D, ~5 D! g2 H0 S0 ]# o
};
5 g8 I/ @% u; k' E: a, {3 I1 q7 v2 M% g* d$ K/ C. v. k0 P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 e; R) {6 R7 ]( x3 Y
.leds = da850_evm_tl_leds,% v5 W% v, q9 C. _5 B! O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 D' X( o& K5 z' z};: x3 O9 a% T+ A4 f0 }- w: V4 r( e2 r
+ \( U3 O4 C4 q7 B& K
static void led_dev_release(struct device *dev)
5 V$ b2 o. x9 q4 o0 C$ }{: i1 g2 D6 k" B+ p- J: f& L0 S$ h
};
B" F+ _9 Q- p# g
]1 [7 C S" q* @1 U: I( dstatic struct platform_device da850_evm_tl_leds_device = {
. D! Y: a' s7 y6 a% @0 b- r4 N .name = "leds-gpio",
, Q+ d2 o( ` i' J, }# l .id = 1,
0 S4 m' m1 A3 f y/ B1 ]3 w5 V .dev = { e8 ~2 J5 N$ N$ E
.platform_data = &da850_evm_tl_leds_pdata,
; w) T5 u: v0 s+ w! r .release = led_dev_release,
+ u9 b8 ?3 r, K+ Z8 x- N }
# f. Z. M6 y! R2 O& T};
; O; y5 X9 @4 i7 y/ {/ }$ v, ?. u& t$ A8 z3 C
static int __init led_platform_init(void)9 @1 c2 I! N" u8 C
{3 k N w. j! Q- H" U; q8 l6 E: B3 h
int ret;" W3 [; g9 D5 D' `5 Z4 |$ @
#if 0 S: d8 x7 I4 {- J7 ^3 t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 R m1 u% r5 Q if (ret)
8 D2 B9 P6 f% @+ T& i( O9 M5 W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( X8 D& k- w; x. d* p "%d\n", ret);
) _6 C4 Y4 l* T' a J! V3 {#endif: c1 v# h5 \) u# q2 o" b& I
ret = platform_device_register(&da850_evm_tl_leds_device);8 \2 x" R+ n7 V; o
if (ret)
4 y! d- \, E) I pr_warning("Could not register som GPIO expander LEDS");
2 n: r- N' r* ~5 T/ V' M1 W( n! i else/ P- n9 `( p: _& f% Y, g7 W% f
printk(KERN_INFO "LED register sucessful!\n");/ K8 v' C! s/ o# t' S% X' J
$ Y& x. c. x, j h; k
return ret;/ E! a7 P4 ]/ W# T
}
; Z) o! p b& h: r
' s2 S$ V% x4 ustatic void __exit led_platform_exit(void)
6 k$ z8 G6 d# ^7 [2 Q: `$ J6 P4 _2 j9 x{
! x; M! a1 t" y _ platform_device_unregister(&da850_evm_tl_leds_device);- L& j# l5 g3 ^& F0 g
9 a& w, r+ y; q. d b2 T5 c- g$ n printk(KERN_INFO "LED unregister!\n");, i# v- A* Q5 h- O
}+ ^& P6 D# c6 z; v% h
8 z' Y5 T' E0 C& B" p7 l0 T' @% \
module_init(led_platform_init);5 `+ U3 n* d$ l( B
module_exit(led_platform_exit);
$ h2 g. g0 K6 I' `' }( P4 x' Y7 }6 j. v" K/ ]
MODULE_DESCRIPTION("Led platform driver");
* Y- }/ ?" d" N* a# m1 l% iMODULE_AUTHOR("Tronlong");( A* A2 |. {8 n3 D5 G1 v
MODULE_LICENSE("GPL");3 n3 K2 \5 |4 C+ e5 Z/ G/ O/ \
; @- D0 V9 ?8 A& l1 w
|
|