|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) J( R* ?. a' q6 n; K
#include <linux/init.h>
$ [% z2 F1 w3 E* R) `' C" Q( I% V#include <linux/module.h>+ t5 S# K; ?! S% t! M/ B+ |
#include <linux/kernel.h>
2 B- l' M5 \) n; J3 o1 Y/ \7 w8 ^#include <linux/types.h>3 J" a, Y6 r2 \2 [* T; X
#include <linux/gpio.h>
* e/ b2 V7 ^" h8 ]#include <linux/leds.h>
6 [% w; V( `8 M) E9 y, E' O#include <linux/platform_device.h>
9 A% A* R1 Y/ V# c! _3 C" B8 V& G8 j' l- J# ^2 u
#include <asm/mach-types.h>
; z/ p) S P- I' @4 Q4 V5 Q! k#include <asm/mach/arch.h>
0 w) k; _1 u, p+ E J% r) a+ T* `#include <mach/da8xx.h>* ]5 W+ F- K3 G7 S5 M4 n7 e
#include <mach/mux.h>
% ?; h& L' X% c0 W. N
) r% |6 \" \, X% v' X" B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 }- D- x6 c% w- l# V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* F4 ]8 j' t5 P3 n( Z+ P+ t. b; |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 I& t" j" K, D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): V+ A% W( F: r
. U' ?% t5 G& t# w/* assign the tl som board LED-GPIOs*/
5 `: }5 ?4 ?5 @; @3 W" e. ustatic const short da850_evm_tl_user_led_pins[] = {9 s3 N* w2 w" Q9 K! }
/* These pins are definition at <mach/mux.h> file */' C4 ` U' m1 e; s4 ]% T$ a7 E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 A, m( e4 R7 _/ G2 V* a; b2 c
-1
/ p7 U9 o# K* W) M' t+ h};
- y, A) m4 P) A( N% s+ y6 Z5 @7 y7 z! u: P. e6 T7 X5 |1 ?: T! C4 i
static struct gpio_led da850_evm_tl_leds[] = {7 r# [# x- v, r' m; Z3 r
{) P, o! n4 U4 p' D3 ^
.active_low = 0,
* Z6 N1 _0 z" p6 d& e, q/ y .gpio = DA850_USER_LED0,
u' R3 y% @9 w- y6 ^& h; a .name = "user_led0",- \6 v+ V) M4 b) e) Z4 s7 U
.default_trigger = "default-on",
4 E& c1 @6 b+ o5 L+ D" h },+ }- i# t$ [' p- Q5 F
{
2 Y8 U: q- Q% u. z- X .active_low = 0, D% G& t2 z6 f. I* ^, z/ L, A0 C+ [" H) o
.gpio = DA850_USER_LED1,5 g7 ~5 P- _4 f! W
.name = "user_led1",
. D; D# F( n( z .default_trigger = "default-on",
& }: x" ?6 v* X g7 {! M* y },3 b+ G6 w# U9 J: a
{0 W% b. h& @+ M2 L1 y+ ?3 r
.active_low = 0,
" J1 s& z0 a! B( n# b+ g+ S" e, ? .gpio = DA850_USER_LED2,5 G5 o. D, p! C9 G: L7 X
.name = "user_led2",
; \# j- S) i; d7 y9 [$ ~8 y: ~ .default_trigger = "default-on",
! z& N- t- k5 R' m! D },' y( {, ^% P" e) F. a& ^/ l1 R6 Y, D+ p, o
{
6 X" O6 b- o; p O% F1 n .active_low = 0,
/ |4 i* B! l8 d8 L .gpio = DA850_USER_LED3,1 V5 s' r! L5 |
.name = "user_led3",
! j1 v* x' L* E: I; z* s# Z/ y .default_trigger = "default-on",7 t/ [/ ?* q! \% y" Q! ?* V9 C; X
},
! [ L% ^/ W. {& j' F8 P};4 }4 @- H7 y. l {5 i0 T6 y
4 |) V7 \% H n: l8 X+ `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 |2 |) D# V# Q s% Q0 e
.leds = da850_evm_tl_leds,
; R2 v3 n0 S5 m9 N! \: U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. [0 X7 y o3 x/ R- X
};6 X1 m3 b9 w/ m* S/ Q
0 n0 Q5 @% F7 \3 q N) C' m8 xstatic void led_dev_release(struct device *dev)! R. `9 K' ~; Y4 l) l
{* Q' X& h: R) t$ i8 ^! C9 q! W
};# G% `" E( m" [) F7 d: B0 H! c
1 W2 o( v% }' ^( \( x
static struct platform_device da850_evm_tl_leds_device = {
( c% l" k6 N/ p# d0 X .name = "leds-gpio",' [3 I: b n: F- V& m" g. K) ~
.id = 1,
4 w/ S5 d' |; `" [9 l" K1 v .dev = {
, h& i f5 n/ C .platform_data = &da850_evm_tl_leds_pdata,
2 p8 `% O8 K* I8 B& U .release = led_dev_release,
3 V& J$ `$ }2 n% e) X3 b" Q }
- V. U( x: Z# j: B/ y};: r$ o) Z5 D2 L7 Z1 L
) O/ e [( W+ T1 Dstatic int __init led_platform_init(void)8 @# P2 U& X/ C- |5 h
{
b0 `, \' N1 c: t8 z; I& ~ int ret;
1 Q& B3 ?+ d6 Z$ M7 S8 y1 h#if 0
) U2 f, d5 s( G$ R! I1 U ?% N6 a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# @2 N. f* G9 k+ u6 ^
if (ret)) U( ]9 ]( T f, o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 L. I1 x. q+ s$ }" R* ?# u. b
"%d\n", ret);
0 s7 n0 c' F3 A2 g8 e$ G0 ], B* a#endif. H+ m7 i, S& }+ P+ n+ A
ret = platform_device_register(&da850_evm_tl_leds_device);) e! ]9 H9 o7 X2 V
if (ret). e# e. C% I1 z
pr_warning("Could not register som GPIO expander LEDS");; I6 t9 S! ?& O t8 Q7 V, \% f
else6 h+ k: w7 W' n, F' W9 S5 i; h
printk(KERN_INFO "LED register sucessful!\n");
* G! Y" j, a6 {% `6 Y8 R' q2 Z4 P* y; t0 G# ?: ^6 ]/ K
return ret;
3 h. b9 F. R; G$ c4 E& a. e; R& [}+ L; {% Q% j& C& J9 F) O
" h/ f& m0 p% kstatic void __exit led_platform_exit(void)
, ]& U9 f1 A8 v{; ] A8 _ q& n
platform_device_unregister(&da850_evm_tl_leds_device);0 _5 a/ _, i; r- a
% k" U8 U5 Q; h+ F- ?( Y
printk(KERN_INFO "LED unregister!\n");) |- q2 X$ ?. U2 w/ @
}$ J: Y6 F9 ^$ q- b
h! I! p5 t% X @2 ?$ Qmodule_init(led_platform_init);3 w/ V! G. l2 Z$ u4 I ^
module_exit(led_platform_exit);, Y! x/ ]- X' y0 }( h
- n2 X" D! g( Q6 w9 z4 {7 S4 f: ]MODULE_DESCRIPTION("Led platform driver");4 ^; v6 o, [& B& D3 @! K
MODULE_AUTHOR("Tronlong");
& r3 Z+ ~$ w3 OMODULE_LICENSE("GPL");
, P3 R7 I7 `- K. Y9 ?; }. h
. C' q, _- c5 O |
|