|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ B; A: e% k N: J/ y% c#include <linux/init.h>
" @' h7 O+ T2 r( V z#include <linux/module.h>
! ^5 y9 [: [. ~" y% o N- x#include <linux/kernel.h>5 I e$ A8 n) v3 V
#include <linux/types.h>
6 g9 F7 z) b' i) t- u: m#include <linux/gpio.h>- k% X. Y2 T, J0 b2 P# j6 Q: d
#include <linux/leds.h>
' Z9 _, T2 y1 I! t L- c# t#include <linux/platform_device.h>
( k; K0 v& y) @# Y) ^) ^# z# P9 O7 m3 k" a; H/ s' O/ l, g$ H
#include <asm/mach-types.h>6 ~2 v3 o: ^/ A& k$ H; X+ f8 b
#include <asm/mach/arch.h>, P0 Q2 B$ F' ~+ Z( @* Y" Q' _
#include <mach/da8xx.h>
, R1 A) D! K0 u+ Z5 p& }#include <mach/mux.h>
- \8 ?* o- P9 z4 v- y
1 \0 R6 M+ w; `7 R9 W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), n: ^! J. X- |- Z! d3 u o2 v3 H! V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; D5 E* k4 L! q9 T/ \+ b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ K' Q4 q0 U, ]: ]0 o2 T8 D% k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( L) g) z! o) x% O) B' [ d
8 F* V" h$ J& C6 j. H) h/* assign the tl som board LED-GPIOs*/
: x6 t. X6 C$ c: Istatic const short da850_evm_tl_user_led_pins[] = {! [, d; L6 [1 D+ h8 o1 m
/* These pins are definition at <mach/mux.h> file */
$ q) O# P% t7 u4 E( H$ u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 e" m$ d+ U- g; Y
-1- u; w; |! m5 R2 _6 i
};/ j* M2 Z0 |6 Y/ @3 m
* e4 ?+ N5 L8 ] F/ Istatic struct gpio_led da850_evm_tl_leds[] = {
& g& B/ ~* ]3 C1 G. e5 [4 g% w {- K; l1 x. j3 c' f K2 ~
.active_low = 0,6 t A& u- L6 k2 B: O* {
.gpio = DA850_USER_LED0,, B' D; w& f; ~) r3 Z
.name = "user_led0",! L" N0 O8 Z# ?
.default_trigger = "default-on",4 F; r- R: O( E3 ?6 M9 X
},( k" K$ y; w) K* h9 ~
{/ c' c& x$ C" W7 r0 B6 g6 T
.active_low = 0,) R- _' _# G1 f9 {: _8 q- ]8 D C
.gpio = DA850_USER_LED1,7 E9 N! X5 K* t0 V7 D7 z
.name = "user_led1",! d9 l. m% n7 Y o# }- s
.default_trigger = "default-on",0 V. ~3 [" h" b9 k
},
+ A2 H: M+ o: k: s7 M4 s0 B m {" O( n) _5 b2 d b- u% z
.active_low = 0,
/ W% v1 n7 h" V P .gpio = DA850_USER_LED2,$ O, A9 e& e7 t) D+ x# I2 S- x
.name = "user_led2",
- G) T: |: N1 z& t2 `( p& b2 v .default_trigger = "default-on",
4 ~ u% h V) L% m: {) J! ~ },2 S2 P7 O: |- T6 w2 ]; v6 D
{* u# V0 g! b1 t; o2 R# p- y- E
.active_low = 0,$ R. |8 W" `" T0 ?- D
.gpio = DA850_USER_LED3,; R; I) J( u1 Y8 n
.name = "user_led3",
8 l5 r; J. P( p0 i7 q' Q .default_trigger = "default-on",4 f+ O5 [+ Y3 V( |
},6 W" o* U, u* [2 m, Y
};0 Y( p+ t R' _2 z8 K5 ^ b5 H+ @7 Q
# O1 ^8 R/ D0 c6 @% ?9 _$ I9 O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" Y" c) y$ I9 O# S- q
.leds = da850_evm_tl_leds,
& l3 B! N8 `7 N" A0 ]0 f3 _ i/ @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# f# Y6 `) [' h. M+ o* f$ e0 p: K+ N. d
};
$ q$ J+ A2 s1 ?% U; u. G
/ Q- p, a, X: Y, i) [static void led_dev_release(struct device *dev)
# U6 B5 |& C0 c" ]5 B# Z{
2 v$ E' B4 b( A% q};, l" }" G% n- d) S2 b
: w- \& T# |0 K1 W
static struct platform_device da850_evm_tl_leds_device = {) d4 z: L. {3 I( P# [% [
.name = "leds-gpio",& X2 ^) G7 a( A+ f |" s6 | e3 C$ S
.id = 1, q+ |* Q2 r! ]& q2 _5 w2 e
.dev = {
7 P0 S5 C) n: P Q, z1 _# ? .platform_data = &da850_evm_tl_leds_pdata,
' i9 m! U" ~1 t, w9 C .release = led_dev_release,8 Q' ?8 C& L; E: N
}% ?5 m- B+ C. e$ G2 X, ~! D
};4 y; i& U" c: J3 z: _
% D. E1 C% P' zstatic int __init led_platform_init(void)
9 _3 a9 u0 _ G$ i{ Q- N0 P, t' I
int ret;
& X$ d N$ z0 z/ j8 ]#if 0! T9 B4 [, w- ~+ X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); n2 D6 n* x8 r
if (ret)
! Y1 j" A: E9 T* x% i8 d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" f9 l8 y( d- U6 g1 E1 {: y
"%d\n", ret);
- `" ^- Y L# Z& O5 G& }" _#endif# n/ A- B9 i- E1 n% b! I" W
ret = platform_device_register(&da850_evm_tl_leds_device);
: X+ ] i8 Y& u$ A; b( S2 G if (ret); s( n$ S3 G/ B
pr_warning("Could not register som GPIO expander LEDS");4 s( ~6 a1 d$ y0 `6 _0 N
else0 ]" D: j- P! }* G7 H0 G
printk(KERN_INFO "LED register sucessful!\n");5 u% V2 M+ H, t. S6 A; c
" J) F) W: u8 _) `! e; r return ret;' o; P7 s9 y' ~( x. N; n$ X0 {
}; I8 B. x. W$ A6 f. u6 e
; a6 ^$ P1 @9 V7 a4 z# s$ w% k
static void __exit led_platform_exit(void)
. {) U% e$ x5 U, A, P* c{
" y$ x& b4 d2 G$ G% s3 _4 d1 B platform_device_unregister(&da850_evm_tl_leds_device);
) U9 j8 ~5 L1 D) \
8 R$ {, L9 ]" X8 `$ S printk(KERN_INFO "LED unregister!\n");
' L; m U8 V6 {, \/ _) p. k+ }- f, o}
s. Y, o' w9 g1 ^7 E7 Q
v9 r! _4 H$ x& p* x4 d' x) s# U' lmodule_init(led_platform_init);. V+ ]) Q) y$ E$ j0 F4 S
module_exit(led_platform_exit);# U& Q5 B4 `4 b2 i2 w- F
. p6 z- H. \; h2 L4 G8 E1 R3 n3 bMODULE_DESCRIPTION("Led platform driver");+ ]3 ^9 `/ K' i3 }
MODULE_AUTHOR("Tronlong");
& D' K( k( }# v$ G2 ~" {MODULE_LICENSE("GPL");1 y m% j" ^, t1 X! V7 A% |
7 T5 Q3 ~4 m2 m* O
|
|