|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) R/ S, g' x- @" {* ~+ R4 Q, ]: E
#include <linux/init.h>1 d& B) Y% a: Q* A6 l! X# `
#include <linux/module.h>; k4 v0 r5 u4 }! m3 K7 A
#include <linux/kernel.h>
& n; ]) C' t6 {- A' p#include <linux/types.h>9 p+ s+ ?/ e& h- E
#include <linux/gpio.h>
+ t, d- g, G% h#include <linux/leds.h>
3 J2 c m/ l$ {' M: @* J I#include <linux/platform_device.h>
2 Y. }5 U$ i/ ~3 |2 ^+ L. k
7 ?# E n8 w- B* j% b) K) g' [9 Q#include <asm/mach-types.h>
8 M, N" G Z0 r#include <asm/mach/arch.h>
9 I) `% I! C! [#include <mach/da8xx.h>" M; `& X2 b5 l5 b
#include <mach/mux.h>
! d8 a* ~* i, n# k' h' y5 P, {' ?/ J- a) k# R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" s: w9 b9 L# g% h/ x( r#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% k6 H3 F) s0 O: Q8 g, F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 o' S" {2 q/ `* Q8 ]/ s$ f7 V#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# [0 J8 }( D; O: l& T7 L ]) M& i5 o8 n/ Z5 W6 T
/* assign the tl som board LED-GPIOs*/. o2 _5 R3 o/ E" Y5 c$ [
static const short da850_evm_tl_user_led_pins[] = {
# a5 V, o, m5 G$ V& b /* These pins are definition at <mach/mux.h> file */
% W8 i }6 T% s8 S" ~, H6 l( R DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 ^" f- v. {& O$ Y L j
-1
5 t2 }6 h% q M- s# U2 Z. }4 h};1 c( {# R; H7 j! e7 d& j3 q
! K) c$ q+ Y0 w( ?' B* }! |static struct gpio_led da850_evm_tl_leds[] = {) f; p7 Q; R. m7 C4 s% V* ?2 d: Z
{% E5 s# T6 W2 c+ P* l* P4 J0 I* j
.active_low = 0,
8 p0 \& D. a! \& n, ]0 x .gpio = DA850_USER_LED0,0 L9 }1 P7 z9 v* g- Y7 q1 b. s
.name = "user_led0",
# a1 ?) x% W8 M5 [ .default_trigger = "default-on",
2 g* E" m2 [2 O0 b5 Q. a* ? },
& P2 B; |$ s8 O, P, ^6 n {+ p0 B' p8 v2 L- H
.active_low = 0,
, Q# o; W* i7 i1 F+ k( l .gpio = DA850_USER_LED1,- S. m* j5 @7 }6 d/ Z1 K
.name = "user_led1",
% ]6 G" Q( g0 C .default_trigger = "default-on",& u, `1 E% k% g9 R. R8 y
},
" }3 t1 k" P: Z9 g2 s# f# L {8 ]: M3 w# ~ w0 M
.active_low = 0,
5 V9 |+ Z/ ]- k .gpio = DA850_USER_LED2,
V+ u2 H7 F& K6 m; s .name = "user_led2",
! T2 S" z& \+ H& f .default_trigger = "default-on",
9 e( a! s& i# n },
3 \; a/ R/ F+ h3 S! y6 s* J {
# D) J p7 q; T! g0 s% V .active_low = 0,' ~) y* s/ R5 S) \
.gpio = DA850_USER_LED3,
& P m! _8 Q+ V& }! p3 L5 T1 z7 { .name = "user_led3",
' m0 [! s% i3 h) ^2 q) s' M; d: i .default_trigger = "default-on",
2 W& i9 j% k: s+ d0 Z },6 s" Z2 C7 n6 k3 E" [
};
) G+ p9 D/ p2 | C
! j3 ^( |& ]% [2 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ |; {1 `% {) R: T, A3 v .leds = da850_evm_tl_leds,: S% S; X! a. ~, K$ ?. J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' @4 c3 ?" }/ V- \; ^+ z: d
};; b2 T3 Q' r0 F
. l1 Z& \# p' X9 Y) _" Qstatic void led_dev_release(struct device *dev)
# J$ I4 _& q1 D" M! F$ E* N{6 C5 o. n" a, k
};
. N' D+ u+ V$ F* D, a
7 E# o" ?' q* Bstatic struct platform_device da850_evm_tl_leds_device = {
5 S8 A3 u" Z/ R) X# C .name = "leds-gpio",
+ K% [; T7 Z! e% ] .id = 1,
& F9 H5 d. Z- v0 i/ U .dev = {0 L; r" S, l3 j
.platform_data = &da850_evm_tl_leds_pdata,* m+ O5 k8 ~7 x& T. A# I
.release = led_dev_release,) ~( _! z! a3 h6 f. Y
}
5 f- V/ M3 A2 `/ M};
m; \/ ^6 L( E9 ]
0 c3 F" g1 B9 J' n5 I1 Nstatic int __init led_platform_init(void)
' ^1 v' }, F2 y0 ^+ R- k$ M; v9 e% O{
}1 i9 T M5 z+ l: r4 L$ b/ p# ` int ret;. C( Z5 L4 T% |6 E- _7 H) O
#if 0
/ p3 Z9 X) a8 _4 _7 h. z+ W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( H5 y( g6 m2 Y a3 n if (ret)
0 ?2 f2 t) T* e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 f& Q3 e6 i# ]
"%d\n", ret);
' f' t6 t* b1 }6 {4 V% Q0 h5 M#endif
& V9 F g! b/ q6 N7 j5 e ret = platform_device_register(&da850_evm_tl_leds_device);
7 c7 K" L( u& m if (ret)) w2 W V1 n/ j" i. c6 O k
pr_warning("Could not register som GPIO expander LEDS");3 @/ n( ]1 D! U/ u" D: D- e& Y
else5 w( R, B+ r: B( ^
printk(KERN_INFO "LED register sucessful!\n");+ ~( |2 a1 O+ S$ j' R' E& y
' |7 \2 K$ I- ]( ?+ } G: N0 V
return ret;* Z- x% I0 P0 f1 z$ d
}5 [2 @( k3 ]' F' z
! X9 M5 j; D8 B! F# n, r4 K5 U
static void __exit led_platform_exit(void)
) J) c" ^. }) S; Y7 u0 {& |# f/ E5 R{
5 s: G7 A0 {8 o, A platform_device_unregister(&da850_evm_tl_leds_device);
4 p0 l* z" C8 }8 L, h/ ^ V- B' t7 ?* h' C
printk(KERN_INFO "LED unregister!\n");
% B) O* M W: ^" d4 Q$ G}+ }1 M) M- f1 X4 r1 x
I- u; @; m& V' j- _$ D! {5 z; U3 D
module_init(led_platform_init);6 ]" A! M1 Q9 n3 a! o' }% |
module_exit(led_platform_exit);
. S3 @9 p4 y+ H2 _
0 t) P0 R O3 J/ Y( D, N9 z7 L1 }0 p% zMODULE_DESCRIPTION("Led platform driver");6 R- s5 P2 w7 T0 ?" L: g
MODULE_AUTHOR("Tronlong");5 g& [, Z5 X6 O3 d3 _# T0 A
MODULE_LICENSE("GPL");
) F, B/ a4 q) K Q$ O# s0 B" E) D1 ^0 P6 |5 y' }* S
|
|