|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- x' _1 P. ]; M- l& V% E; ]4 h9 r2 @#include <linux/init.h># f0 h5 P3 q9 U% U W) ^" y
#include <linux/module.h>6 {5 @% P2 v5 J& e h- W! `
#include <linux/kernel.h>1 N4 g2 G( z' g! m1 q
#include <linux/types.h>
' g9 [4 b5 v0 } v" X! Z( R#include <linux/gpio.h>
. }! h, O; d9 ^, q& F$ i" j: g#include <linux/leds.h>
( A' a: R: o* c#include <linux/platform_device.h>2 w# M/ H8 s/ q. W3 x% r
4 n) a; @+ ]2 p1 d8 @) o: E#include <asm/mach-types.h>& W. d$ c. o1 Q) h4 U9 b A$ }
#include <asm/mach/arch.h>
/ Z& h- ~2 C+ @#include <mach/da8xx.h>
0 h- I# U9 {7 W1 Y. D# ^#include <mach/mux.h>6 ^% Y- o3 v- ^" r
* W, _8 R0 c# D! r/ R3 \% _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): I7 n$ t$ R3 S( R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): I, R* x: T+ ~6 p6 ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' c9 h+ b" O* A, w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( F5 B9 Q( H, [. j9 Y$ @, u- E0 R4 C C( F# V
/* assign the tl som board LED-GPIOs*/
1 j; ?' J2 l$ Y3 ]static const short da850_evm_tl_user_led_pins[] = {
8 N0 c4 C) @, z; G9 v9 t /* These pins are definition at <mach/mux.h> file */
# y; q( y! Q z0 {3 U& g* ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 e! e+ f( I, ]2 m+ t -1
* g! |- c% G8 G) _/ ]0 x3 c; _};
' M! `2 k( q# d
. W8 w. V9 s/ g/ z1 [% [# p* sstatic struct gpio_led da850_evm_tl_leds[] = {3 N9 O3 ~3 a; Q& @# b
{1 T! I' }5 w& y
.active_low = 0,
' U, |) {& B& I! r) a! u .gpio = DA850_USER_LED0,
. a1 o$ V) A# ~4 ~9 O6 b7 A .name = "user_led0",' A# l9 j/ G0 ` M8 a! m
.default_trigger = "default-on",
. T5 _" {$ v1 f8 S. y4 ] },
: k" s+ d& b0 Y+ W7 J4 K {7 M& s. a1 Q1 Z
.active_low = 0,; ]# s. R2 y4 c* {/ Y: k ?: t
.gpio = DA850_USER_LED1,
% a, L) F+ d$ M .name = "user_led1",1 n) e5 X* ^" ]0 v; x, h* b( U3 a
.default_trigger = "default-on"," W1 \( p3 c7 H# V# N% X
},/ t# ]" m1 v, y. p8 O" R' j, R
{% a8 ~# v0 [4 t" o2 B7 {8 l4 e
.active_low = 0,
0 @1 [8 N |* ?% U' t! A! A8 Q .gpio = DA850_USER_LED2,6 B( J4 A( n! s" q
.name = "user_led2",
1 j; N. `9 e0 U" @ .default_trigger = "default-on",
* C& x2 a0 k1 N0 K/ W2 l) _ },. T# Y* f; _5 g$ C4 `0 p* n/ B
{0 S- |& j% g" U4 Q( Z
.active_low = 0, b2 n j# @3 Y6 H5 J
.gpio = DA850_USER_LED3,/ w3 K- G4 w v& M/ r: W
.name = "user_led3",' L l; Q* u2 D3 b
.default_trigger = "default-on",5 P5 i, W9 Y @3 X
},4 Q7 Q4 o+ Q, Y" W% s9 X
};
( C2 [) y6 L0 Z/ ^1 [% a$ }6 ~# u
/ i9 l3 M. V5 L% x0 g3 `3 istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# j1 ?! |1 V5 |2 L6 I .leds = da850_evm_tl_leds,
9 a9 ^) V0 P7 y8 f8 J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 q1 A/ e% h5 \, n% n
};
& \3 D1 o% ~- U+ r( T* I! o" q9 ]& q8 i) r/ @
static void led_dev_release(struct device *dev)
1 f `4 M2 c- K{
, C- p7 `' m4 k8 W/ Y1 x};
[2 ~+ c5 L o2 a5 ~* m
- r/ e9 [ D* k; Istatic struct platform_device da850_evm_tl_leds_device = {0 y5 @3 ? Z0 c q
.name = "leds-gpio",4 g/ K* ~# f3 A4 T/ V+ C
.id = 1,
5 x; ~* D) B( O' C/ K$ @6 A .dev = {
6 R7 a# S: o: v/ r" g5 Y .platform_data = &da850_evm_tl_leds_pdata,
9 ?$ J+ l- y4 G7 ~' Z .release = led_dev_release,
0 s2 v+ I" O3 j( p5 d- S0 C }
* \2 b j# V% ]& q/ M};" C' v3 {# m2 n( }' L5 V$ _
. p: h1 P& \$ Z
static int __init led_platform_init(void)
F( [6 ]3 m* T+ x$ @{8 {& h1 u; z }8 p: k" S
int ret;
3 }* C: s7 l. o#if 0
! P5 x2 I+ l" G% \' Q, s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 I9 O' O6 l' r$ ^9 r& w8 ?9 u7 [/ K if (ret); p* g& X4 |( a/ K5 K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- a9 c M) K! F4 A
"%d\n", ret);3 q% @9 @+ f" }# {. N5 a
#endif; b1 F+ ]# g% S. Z
ret = platform_device_register(&da850_evm_tl_leds_device);
. i6 v9 g$ `/ X2 x if (ret) W) `, I# o5 g5 o" k
pr_warning("Could not register som GPIO expander LEDS");
. Z. c {6 y4 b; s2 }" D& T3 \/ J7 _ else
2 E+ @& r4 ^- H2 | printk(KERN_INFO "LED register sucessful!\n");
6 H* A1 B6 ]( G" v( U" r% Z& _. R
, D; _9 Q1 Y4 M& y# w return ret;" s0 s* v" v1 p' }! L0 b) m
}
" M+ }( i% d' g, h
, T+ T4 H% w1 G+ D9 p# D, Zstatic void __exit led_platform_exit(void)
) f$ {! o" A6 H) c) P# E. [# A. l{
8 N: B( Y4 N- R J platform_device_unregister(&da850_evm_tl_leds_device);: L5 }) f7 @6 y% n+ x7 E4 M
. K/ b( J* g" C4 t+ W' n8 Z) N printk(KERN_INFO "LED unregister!\n");, M3 N* g) R' b! a" W& s
}9 M. S6 P7 Y. V1 V
# X2 u1 \# h/ z2 ]" u; w2 \module_init(led_platform_init);
& H- }, l, m: O: Q4 o9 Cmodule_exit(led_platform_exit);
% A; D/ ~5 R& I: S: j1 Q, h
, c9 J; T- s* t) v5 NMODULE_DESCRIPTION("Led platform driver");
. Q5 g- ~- I/ u; W! U; q% RMODULE_AUTHOR("Tronlong");
2 U" v. h) e' i: U. W% eMODULE_LICENSE("GPL");
9 d5 R; a: y- `2 g+ x4 U; S3 ^. X. s/ \1 n
|
|