|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 F& J$ p1 I+ {5 d7 x$ ~0 T#include <linux/init.h>- S0 k. p+ W' W7 K, D: l
#include <linux/module.h>
) Q. r/ A0 T& _0 I#include <linux/kernel.h>
" l m, ?7 g' V. P/ g; }#include <linux/types.h>
0 L% p7 M) ^+ _0 {5 O#include <linux/gpio.h>& ~" Y% R. b. e# X
#include <linux/leds.h>8 G& y% x; y& I
#include <linux/platform_device.h>5 v% m6 \( k/ E4 u" S g7 t5 |
. n! I9 m, Y, D" Q- t! o
#include <asm/mach-types.h>5 [: j5 [0 u; ]6 C1 P$ d
#include <asm/mach/arch.h>
" C/ Z% X. K8 p W( d5 U1 { Z#include <mach/da8xx.h>
0 _$ {/ S- i, b, s4 p' n; Q. ?: G#include <mach/mux.h>
# q+ f z3 F9 d2 [1 Z/ f$ t3 @8 g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! ^# e. F$ l1 v" M5 i
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# o9 i+ s: \7 G% I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 h, o; | H4 e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% m7 \0 y8 C+ G; U" F2 i
& R1 P3 i$ O0 U/* assign the tl som board LED-GPIOs*/
7 J" T/ a& i; s" j4 estatic const short da850_evm_tl_user_led_pins[] = {
1 b6 x& {3 }/ O) i) |4 J /* These pins are definition at <mach/mux.h> file */
P6 Q5 {' P. D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 M/ x7 ^# N( K1 w! h/ b
-1! y# c8 f) {# m& a( Q% |
};
/ U) u1 c) m' a7 W
/ d9 c5 w6 I; q: dstatic struct gpio_led da850_evm_tl_leds[] = {
+ ^: A' Z" C1 Y! X { k2 W4 T" X( n7 S; i$ d
.active_low = 0,
# d! y7 {& c1 n" p3 g* D .gpio = DA850_USER_LED0,& b T% y' c1 s/ }. ~
.name = "user_led0",
( s- y h2 z- \' k) E9 H .default_trigger = "default-on",
" p% a8 P9 x, [2 A },
: w( n- `( C+ Z+ _% h* Z# }6 f" p) { {# A2 ]. E3 ~0 }8 V$ S; P7 w, e0 Q
.active_low = 0,
9 B1 w* @ [: |9 e# U, Y .gpio = DA850_USER_LED1,' E3 c8 c" I* W% `" G3 ]
.name = "user_led1",! O" H5 h3 j/ T& k
.default_trigger = "default-on",+ P4 i. ]& H' h9 p* Q) G6 r, j, F
},# Q' B- O: l9 m2 E& S* a
{
+ o, q1 n: [. o( J+ _; m' q0 b .active_low = 0,
' s0 {% f, o s5 ]* C .gpio = DA850_USER_LED2,) f9 z- m! w5 K% q5 u, F
.name = "user_led2",
$ l% H$ K, a6 m. I .default_trigger = "default-on",
1 L" e" J1 {2 i. j5 A/ w },$ O6 b+ W( F% x4 a' h/ T
{" u& F" T7 w+ [4 C$ p& m' k5 j
.active_low = 0,4 {# y: z- C- [8 O4 d- R& Z) U
.gpio = DA850_USER_LED3,7 ]" V$ \7 u9 l9 k9 N: x1 j
.name = "user_led3",
& E! Z7 W: z5 O2 ` .default_trigger = "default-on",+ Q* V! a2 v3 I: B& K% _+ P
},
) Y! J' _3 O; F3 M" d5 o};$ H4 ^/ w5 y3 b% @$ p
2 m |: g2 l+ C+ d2 Y- c2 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 P) M: y6 J* E ~; F+ F .leds = da850_evm_tl_leds," S/ r0 A; F" m0 y7 o# [- H
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& E- m4 i' o& E4 U6 l* ?};
0 F( G/ }# }5 h7 p- E, H7 y
4 F: \# F( }. Astatic void led_dev_release(struct device *dev)
6 _7 c- U* h G{! x! z1 d6 v1 i" h$ u
};
& N( Q' H2 d. K E7 ^, ~
) ?# L& Z* g0 J$ istatic struct platform_device da850_evm_tl_leds_device = {9 ^+ k! u# c# {8 e) l1 L9 a$ E
.name = "leds-gpio",
6 u% E$ U: q9 n2 H+ N" f .id = 1,
( P' o) Y' _/ ?( {1 x7 B7 ^8 E. j9 { .dev = {3 Q; p. B1 F2 u+ a
.platform_data = &da850_evm_tl_leds_pdata,
/ l& Q" c5 Q" V v4 ]1 \4 k .release = led_dev_release,
( S! S! |1 k+ i! A }
1 |. Q; X8 U" l6 e M X};7 e% Z' v9 w' L
1 t5 ]4 L6 Q; W; v0 d0 H0 {9 Z
static int __init led_platform_init(void). P# x- }1 w( H/ D) g0 ?6 b1 K, f
{! H1 {: N6 X& g- E
int ret;! n# \7 r" z! M; j7 c
#if 0
0 P8 p3 \. z! D w( M0 P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" x$ T( _: j' U! G6 |7 p7 O
if (ret)$ ]9 c# c J+ c$ A5 o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; t5 k$ H9 G; e' @
"%d\n", ret);5 @ m9 t" ~1 M" C5 a7 n
#endif
5 ]8 n8 u% p. h4 E, N ret = platform_device_register(&da850_evm_tl_leds_device);
0 P4 r4 e" ]- a% k; K if (ret)* B& J0 m6 F! A3 q W% K6 u9 E
pr_warning("Could not register som GPIO expander LEDS");
' l% s" B6 Z3 p( ? else
# k6 Y0 p* k/ `" k printk(KERN_INFO "LED register sucessful!\n");
) c6 v: a: H7 n# g: {
2 V2 }( N& o1 v# ^& V5 Q5 R0 _ return ret;* ~/ _. H1 R$ D2 W" ^' ~; c& k9 c/ R4 n
}
5 V U, G0 S" f" O7 _$ d2 n' S0 f+ I |$ X
static void __exit led_platform_exit(void), a4 K7 X" Q6 C# b
{5 a: o( a, I( I$ m0 U9 Z. q
platform_device_unregister(&da850_evm_tl_leds_device);
+ U. I9 t. I- O. @2 d4 S, W2 r1 J0 R3 ?; f" [7 u
printk(KERN_INFO "LED unregister!\n");
* Z% b* a9 S* z u& K1 e: e0 b}* z8 y1 f% {( i& e( L1 T. y
, |) u2 w4 Q# [/ ]7 W- Y- u$ O1 Amodule_init(led_platform_init);
- E$ ?; Y, \7 ~1 } W+ Nmodule_exit(led_platform_exit);
% o, x$ S% e% i9 \6 O' U
! e+ r2 `$ h* m# @MODULE_DESCRIPTION("Led platform driver");! ` o7 I$ |$ M+ d ?2 S+ k7 B5 H
MODULE_AUTHOR("Tronlong");
0 Z# U4 }& L8 r1 m3 o9 QMODULE_LICENSE("GPL");
0 a* B+ @ s0 k
9 r0 ]/ I, X& O( t" x+ x0 r |
|