|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 i2 o. J+ q( e% {, t' G6 `3 r#include <linux/init.h>& ~% X- S% H5 I7 K: r: ?6 e( V
#include <linux/module.h>
4 f- F; e" q: Y# i# K$ [#include <linux/kernel.h>3 T# v% w! h+ T& X; Q+ ~' @- u
#include <linux/types.h>9 W3 ?# F* S( q& ~8 Z o1 U
#include <linux/gpio.h>
0 y/ n+ l: M! V#include <linux/leds.h>
0 H/ Q/ ?$ R6 q#include <linux/platform_device.h>
# o( B- O: D2 g7 Q0 F) }* `, B" A( m$ T
#include <asm/mach-types.h>
0 D9 m6 }3 d- L9 s1 @3 z! C, U1 K) ^#include <asm/mach/arch.h>
- m! J4 ^$ p; Z2 v#include <mach/da8xx.h> R( y5 X# y# q+ z& Y3 {; T2 }
#include <mach/mux.h> R7 K* v: n! M$ u% M6 a2 h. X8 Z
$ C a4 W2 P) t `4 a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' t6 t1 V4 E0 y; \; s8 F$ y q% Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). e: N9 S- D. K. Q8 ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" y1 q9 T8 H9 X5 X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# h+ x/ e9 S( \) |9 g. E
4 G3 t: A2 Q% o( w7 @6 _% V/* assign the tl som board LED-GPIOs*/# {; g, B2 s9 c& _# s$ }7 k
static const short da850_evm_tl_user_led_pins[] = {% `: y8 I$ o& u$ D8 f
/* These pins are definition at <mach/mux.h> file */
" {6 v% x: b$ H1 H8 v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( v( M) r# }2 N7 x. H -1* O( S2 H0 j0 j: s- J
};) ]' i* r; h: ^& L. Q* ^
! I7 [6 d9 b. U9 u4 \
static struct gpio_led da850_evm_tl_leds[] = {) w0 |" }! v& a
{
& l) _5 U+ ^% n/ C1 q7 i* t1 k .active_low = 0,# _3 e8 Y' H1 j! ^6 v5 V+ R
.gpio = DA850_USER_LED0,2 N0 N) V s/ B. Q _- f
.name = "user_led0",
; b6 Z: j+ W; B: y$ Y) g$ y .default_trigger = "default-on",$ E$ t( }4 h) t% a) S( L$ P
},% D- ^/ b# `; u% a3 f
{) p: {" g* Y ?% f0 ^
.active_low = 0,' }$ J; c# ]* t W3 \
.gpio = DA850_USER_LED1,; v( l8 W- s/ H1 I) ~- n9 n3 u
.name = "user_led1",; c+ r! M5 J+ ~0 ]6 u/ T
.default_trigger = "default-on",( M0 |6 e! q" R4 {; l
},; y' j. @& e3 C5 ?1 d& t, c$ c
{2 H+ ?( G) ]) P7 P2 A
.active_low = 0,4 a& p; s- g p: Q/ X( N- {2 O
.gpio = DA850_USER_LED2,
1 c. O+ S2 ]' y# U .name = "user_led2",
) b' V$ y( Y! E9 [. q8 R M .default_trigger = "default-on",; f6 x1 I) W1 M5 Y4 o
},4 w& K3 L4 E$ w9 \+ G% ?5 G% ]$ {8 s& H
{2 c: H g8 l1 H. m$ F8 }
.active_low = 0,
+ h" o- v) s" z3 t .gpio = DA850_USER_LED3,& ?0 W; |% S9 h
.name = "user_led3",$ T9 h6 d. Q4 X2 @' r
.default_trigger = "default-on",* L; A" K" o" \( A$ n: K
},
% ]! @9 P7 {6 F6 Q2 ?9 q};
. p& @0 N6 m- M; |' r$ W
* ^' h1 e' Y6 u4 ~+ H; ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 {6 e& j. i1 ~
.leds = da850_evm_tl_leds,
7 j+ P( j3 v+ X* |& t3 F) m9 d .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* Q1 V, S L; [2 g( A};
`9 W" l8 |6 e8 X" v! R# J2 _ |$ l' B) x* w- h/ @
static void led_dev_release(struct device *dev)
- w* e5 d2 e& P. |/ P{ {6 y: u$ `3 j* N) o# V i
};# r/ ]5 m: U# R; G
. ?: y& k0 R, \8 \- {4 U
static struct platform_device da850_evm_tl_leds_device = {% s% p5 D. z) ^! E: _- @/ o
.name = "leds-gpio",
0 G# p' y. V4 F$ W$ Z .id = 1,
5 N% L: s$ k5 t .dev = {
" n& z2 K4 s7 c4 A$ y0 z* ] .platform_data = &da850_evm_tl_leds_pdata,) n, ~/ x4 ~* u8 c
.release = led_dev_release,
/ Q8 Z$ ?& k' q6 X }' z: c( e4 Y8 z a2 t- O# t
};+ y" S) g5 N" ^' ~( T
9 `/ {8 m0 _9 I u1 ?+ _static int __init led_platform_init(void)9 R" `& w4 K9 F! _0 q u7 l
{
$ Z7 t- J/ q& a0 |! [1 n int ret;
" j; b3 P( @9 s( d. B/ u3 w#if 0
8 H& ^/ l9 y2 [, H+ A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) a' z- j4 f2 [( ~8 D. F/ U$ I7 A
if (ret)
7 I6 `& T, } d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; W$ q* E' A p9 ?' p "%d\n", ret);% q- T0 E0 |$ o# `
#endif
$ W5 _" ~# r) ~" z2 T& {! v: t ret = platform_device_register(&da850_evm_tl_leds_device);; I& j! Q1 h) b" O6 E6 K. P1 F
if (ret)
6 v. {$ S. _! r# U v, w pr_warning("Could not register som GPIO expander LEDS");5 w7 t; U& a9 R
else3 i8 U% a- U. D! e" W8 d
printk(KERN_INFO "LED register sucessful!\n");+ c& o& ?( e1 b o2 ` J
+ _1 ^! G+ ?0 l/ o2 ~ {3 {) g return ret;
3 |0 I) a$ a+ F4 s# T) s# V}" |2 _7 Y7 ~' y% w! m. t2 R# ^
' q( D3 m X L+ ^static void __exit led_platform_exit(void)
+ J ~3 H+ Y. _' [4 G, C: B! u! X# _{
?0 |8 W) |5 G' K platform_device_unregister(&da850_evm_tl_leds_device);
0 q7 F) L8 P0 d6 W# E2 [
8 V4 `- ]8 x6 K0 }& D' ~; B* R printk(KERN_INFO "LED unregister!\n");
$ Q Z2 y# O1 D' E2 d1 d}
2 X5 _1 [8 p2 [% ]0 p3 |. h, Z8 V2 T$ R4 {8 y1 A* t! J
module_init(led_platform_init);6 L% c: ?4 `7 z" `/ G/ Q
module_exit(led_platform_exit);4 Q( t4 v- J4 d& W4 S
: O/ I+ E0 ? \; [; D! s- i. sMODULE_DESCRIPTION("Led platform driver");
/ [! L# c) V3 GMODULE_AUTHOR("Tronlong");
. U$ g% C7 g3 SMODULE_LICENSE("GPL"); _8 Z) \3 s2 \* x# c6 i
) i: |9 | n) q" j' K! _ |
|