|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 e; Z9 U7 g( Z; {#include <linux/init.h>
% H# H& d4 O2 G% P0 j v) {#include <linux/module.h>7 T9 ^5 E7 f+ i; {4 V
#include <linux/kernel.h>
4 A: C# a* x. \- p8 m#include <linux/types.h>
% @) [4 y0 P' _& ]#include <linux/gpio.h>
; J. ^+ P$ o( B$ ~#include <linux/leds.h>! _4 U1 |6 ^6 M5 }+ X
#include <linux/platform_device.h>1 S) s; R3 ^1 E+ t; ]9 `
m' r7 Z6 @( J' `#include <asm/mach-types.h>' R7 J+ h) X; v, X
#include <asm/mach/arch.h>0 [% \2 }% p2 ]" {
#include <mach/da8xx.h> t7 R: l: j* C$ w+ a, P/ W# ]9 m
#include <mach/mux.h>
s% Q% ~6 ?/ g+ v! T! \
, `0 @4 ^* r( A; |+ E: V( y8 `/ N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). \: p; \: u8 @) k d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- R( r. v% }( L1 ~+ t1 ^9 W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- M2 G, F! X. Z" I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( i! v$ j; m5 B, R# F5 W, `' O
) @- N: _) C% [" n/* assign the tl som board LED-GPIOs*/6 F ]& y. p" O3 y3 R1 U
static const short da850_evm_tl_user_led_pins[] = {
) q1 [. e8 p0 O$ q1 P /* These pins are definition at <mach/mux.h> file */
" @; ^- o; L- g& { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% M: c( G8 d* u1 \! C3 v' I -1' t) {. A9 t/ Y+ R; Z% x
};
/ B- N. C1 `) ^
5 Q" g, j" X/ P; E! U0 f1 ^static struct gpio_led da850_evm_tl_leds[] = {. u( `0 u9 e, l9 T
{1 A3 z* d% R, P, h$ V2 w
.active_low = 0,
) Q. E- H& v _; u0 B .gpio = DA850_USER_LED0,8 T4 I/ ?; N, P' L3 [
.name = "user_led0",) [1 G5 `4 t/ \# T1 s6 |
.default_trigger = "default-on",9 q* y5 ]3 @4 p" L
},
( I- n Z7 s% V {. `0 ]8 v5 t9 r) d9 E6 K* F
.active_low = 0,
' g" K- h1 R3 {- [ U. L3 h .gpio = DA850_USER_LED1,
+ ~ ~$ c. `- y) j% e! S .name = "user_led1",2 D) ~' o& }$ g m5 `6 j
.default_trigger = "default-on",! O7 \5 A$ \% D
},% o$ R* R/ A, S! f: p2 [# U; ^
{0 z8 y( ]9 J/ n7 r% ^
.active_low = 0,
/ w/ \/ t6 }8 ?7 l H .gpio = DA850_USER_LED2,0 C* y8 \; I" @6 x2 h2 X
.name = "user_led2",
/ | W1 Z% t+ |$ {0 P .default_trigger = "default-on",: J& S1 i1 w! F; i; Z, l
},+ ^* h5 z* H7 d# F+ R W2 \
{, G2 S9 C5 B/ D. _
.active_low = 0,# b; M# |- F% S3 \" H
.gpio = DA850_USER_LED3,
' m( m3 i4 j& C! U# ~1 f. S .name = "user_led3",
3 I* @9 a4 {, h5 l- Q- H8 ] .default_trigger = "default-on",
Q6 O) J8 E, D" `8 Y0 A2 w$ x( F* `, E2 S },
! G/ q# o1 O4 ^' s$ r};, w8 |) l r' a2 N5 P: B
1 w% S- N6 `2 b3 t% f7 E6 b7 }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; G! X. i9 _0 q; W" Z( f+ {
.leds = da850_evm_tl_leds,
7 A/ ~7 G, e% q- t# k9 `" K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( {% E6 x1 {/ X. x. d
}; D2 d' o# d% i; u
4 Z! B7 [: J1 ~$ i, R3 m* V/ a9 Zstatic void led_dev_release(struct device *dev)
L$ V8 ^) _. q1 E" X! w% C{
% E. b E8 R8 b( U$ E0 e0 F};9 O; c$ d Z c$ @3 v
3 L) L9 g& _) ?0 j1 g1 `static struct platform_device da850_evm_tl_leds_device = {! N9 n+ c2 T2 H2 B; S' T% U
.name = "leds-gpio",5 h) A) W7 u8 k; U5 s6 a
.id = 1,
7 }; C2 w* T2 L9 h5 A .dev = {
0 L3 G9 A# x) ]0 k. w# ] z) ~4 [ .platform_data = &da850_evm_tl_leds_pdata,; K2 M l8 y/ N% h9 b( M
.release = led_dev_release,9 E+ G5 a4 v4 D2 ~" g' {; T6 j
}9 x7 F% ]& n- g! I E4 i" n0 l+ w
};
9 {; ]+ l c& u& e7 H+ S6 M, l; y0 F3 Y5 f j2 r' f) W/ Y( K6 l; c
static int __init led_platform_init(void)1 O! Q/ |" A% U8 A6 n2 L
{
0 \, y3 I, q# g% v; l int ret;
/ g; G$ e# p/ F4 k; c- W- b#if 0
) G& k$ d( E1 F6 v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* {' ?2 L* w* R# N if (ret)5 Q- T1 W" \4 X3 M/ D0 h# Z6 F# y4 ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) Y* a. y. w( L; X% ~8 r "%d\n", ret);5 U! S. \4 |: q0 s! u: B6 q
#endif% q, J+ c, X) _9 R. H1 X
ret = platform_device_register(&da850_evm_tl_leds_device);
' H" f/ k) Z# ` w7 e: j if (ret)# @6 m& a7 _) z" }* f6 i
pr_warning("Could not register som GPIO expander LEDS");# i3 ~' x' o s9 V4 k8 ~
else
4 v, _ V6 Y8 h printk(KERN_INFO "LED register sucessful!\n");1 V, ~$ o$ \$ |: v7 [6 ?7 N& k, v
0 b/ C2 d2 @2 e4 E I. r! ~
return ret;3 l6 ]! p$ a; B- ?+ ?; ]9 Q
}
0 r& q# Z3 A Z/ s2 V, B
8 T+ U) y( p, a. s4 N Rstatic void __exit led_platform_exit(void)6 y, U% h) o5 s' J0 \/ S" ]6 d
{8 [" i, \+ k' u4 _0 E. z, E; M
platform_device_unregister(&da850_evm_tl_leds_device);
% q }5 W, @- U( _
& k5 ~0 a# M9 y$ J' C printk(KERN_INFO "LED unregister!\n");' m) _2 H. e! H& G
}* g' V' Y7 e9 w2 r- V$ g0 N
; F; @4 G4 ~% z+ Pmodule_init(led_platform_init);, Q* a& u2 q4 D9 [& n9 _4 b
module_exit(led_platform_exit);
2 \% `3 U, v2 h2 o; k# J, q" x; @
- g7 r& V- F1 ^/ iMODULE_DESCRIPTION("Led platform driver");
6 G9 O0 J/ `# U( U$ EMODULE_AUTHOR("Tronlong");% x# B. R# m% L& P
MODULE_LICENSE("GPL");
5 E# V! i" m) z7 K! ? o5 U+ d, l* @$ N+ U/ u& B+ E; P
|
|