|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 k8 ]1 P" z4 N+ T# m* w% R2 |* M
#include <linux/init.h>
6 q) S: G2 ]: r3 p( g) g) f) m#include <linux/module.h>
* g h$ f% K) b#include <linux/kernel.h>+ G; `! n$ x) o. V
#include <linux/types.h>7 [5 Y* a/ ^8 g. x% U7 D
#include <linux/gpio.h>% h/ V! K. Z3 z; @/ l7 g$ m
#include <linux/leds.h>2 ]! w' i$ B3 B3 G* n* s
#include <linux/platform_device.h>1 R! d/ O1 \* ~. P4 z5 I
! b) `6 r: S+ `+ N+ D
#include <asm/mach-types.h>
& p0 ?, R1 J! H# c B' s+ S#include <asm/mach/arch.h>
; u2 D+ k; s- G: o#include <mach/da8xx.h>. m' I3 B( ^% t% p
#include <mach/mux.h>
9 R2 T+ V- F! I7 `! | X) L- V
% W- J" U( y* G) [. F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" Q. J2 v+ I. g1 Y6 q: f) U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% t) Q8 E# }& V#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ K3 l! @$ a! B3 E9 U8 G" H4 G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 y5 k; V' a7 D) Y$ m& L# z- K
( `% ]7 a/ _7 h0 e5 l- D/* assign the tl som board LED-GPIOs*/
/ @4 c) ?1 g. g3 e6 i0 E* V* Ystatic const short da850_evm_tl_user_led_pins[] = {
, ~6 L+ ^* L6 e! q /* These pins are definition at <mach/mux.h> file */
( W3 n, C9 @! [0 M& M DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- c; O3 }# j. A6 P: ~ -1# F+ b9 D/ [( q/ n( }
};
) V! ]' v" Q6 B
. I3 Z+ |0 x# ]& E; wstatic struct gpio_led da850_evm_tl_leds[] = {
0 {7 L2 v9 y2 T n {
( \# r! {+ s0 {/ u% F# @) J4 s* R .active_low = 0,
`. ^0 |+ k/ Y4 Q! @ s .gpio = DA850_USER_LED0,; E9 p) R: G, b/ O* p% f* m6 |: B @7 X
.name = "user_led0",
6 V3 F6 [& J" R6 n: Q .default_trigger = "default-on",
) D1 i6 v5 e% y+ X; ?% C7 r2 m6 c },2 d4 ~6 H2 d" L1 O/ y. l% f
{
9 n9 o, V5 ^* W: d6 y/ n3 U9 s1 A .active_low = 0,2 R: d, }% I T8 c* L" n( P
.gpio = DA850_USER_LED1,
0 z6 ~; D0 {6 e6 F$ Q' q .name = "user_led1",
8 ~; _4 M3 c% B& y .default_trigger = "default-on",
{8 Q, `5 G, |5 Y8 O },5 j2 I2 x) J- \& s
{
7 _, F/ y* t/ Z' w# m; t: G .active_low = 0,6 [5 M! r4 q8 p" e
.gpio = DA850_USER_LED2,
7 ~& |4 a+ {% U# C9 \ .name = "user_led2", m6 ` l3 Y$ D
.default_trigger = "default-on",
- N; E+ D: @( x9 Q' J c( U3 I },
4 N% a1 ~" [# b" x {
2 y$ m9 f& p: y. } X1 O .active_low = 0,
5 g7 r, J2 I5 t9 C! j. o .gpio = DA850_USER_LED3,
5 k! J# u$ P# D+ T* |# K+ k) ? .name = "user_led3",( b) q2 c0 M+ W4 Q5 @) J" K, d
.default_trigger = "default-on",
6 y* B0 M, M& |5 a: u2 \) V. h/ [ },7 |# M! k& n- I, U
};' G3 k. S9 E T0 z
% C" F; S0 D; _4 I" Z1 T0 _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% O1 m3 k5 i8 ]4 w
.leds = da850_evm_tl_leds,) r* ?* N, M/ o/ l- A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 b3 `/ U* _. J _/ N- d0 t/ d" B
};
7 R3 y, i+ m* z
+ e4 ^6 c& s6 [. h8 Rstatic void led_dev_release(struct device *dev)* V5 | J+ S7 C: j* ^1 y
{% @# l& A. j+ i5 C( H1 L
};. i8 c, R* z6 V- N; x
4 C& w% |1 ~; r: @! [4 Z1 xstatic struct platform_device da850_evm_tl_leds_device = {: e' t. d5 w7 u3 M" C
.name = "leds-gpio",
. l! U b3 o- g7 A: } .id = 1,% }9 n* U* g3 I5 g, F# t- N
.dev = {
" k, s' M9 S; }% t7 O .platform_data = &da850_evm_tl_leds_pdata,
* _- I. F1 i) S1 X! N n0 S .release = led_dev_release,
5 l2 L o0 B6 L; T! |. F( D }& r) U# X8 o3 L& i, h. Q1 \& D1 \
};
: b6 O6 C5 {' J4 a. f
2 V. l+ c6 |( j$ k& r6 G5 Y0 hstatic int __init led_platform_init(void)
0 E# D$ E. C% Z. E0 j& E{! T. v, F/ w% z$ V7 D
int ret;& _* E' L9 W- n" C5 I
#if 0
2 m% b" D- S0 k7 X7 y/ e# l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 k% u/ M& u( q" n
if (ret)
# o, z) S4 g+ i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 k7 w3 i% r# ]$ [' b0 z2 G9 v( Q9 v "%d\n", ret);& @3 p% \, p* h9 P9 z, {$ ]# z5 t
#endif1 ]1 h) W3 o) {. x1 ~% [$ p/ `" n
ret = platform_device_register(&da850_evm_tl_leds_device);
4 Q6 _% n* `( r9 \6 `$ K# E& l if (ret)* J7 o- @8 ^# \8 Z* k6 j; z1 F9 W0 B3 t
pr_warning("Could not register som GPIO expander LEDS");( T2 }1 ^6 i' M- I1 H* G
else( t2 }2 Y& U7 R+ p* k
printk(KERN_INFO "LED register sucessful!\n");, Q# J' n" Y- k
5 K0 K0 x# _2 S5 x: h H
return ret;
6 u4 m/ [; v* s! D3 r7 M}
/ ? Z0 U$ M% B* X- y) T" E, p9 r/ S2 j; l* t0 ]- Y. I$ _, N
static void __exit led_platform_exit(void)$ S2 N: J& V6 w
{
8 F1 a* h% c T: e- ^ platform_device_unregister(&da850_evm_tl_leds_device);' o& C f+ ]8 R( C
( h# p' E# i4 A+ h. A) f printk(KERN_INFO "LED unregister!\n");
$ y- A# G/ z) k1 v3 Z" X! ~}
8 z7 |8 i5 y4 Q/ b/ N6 D" e. w
module_init(led_platform_init);7 n7 d' o1 j& y
module_exit(led_platform_exit);
* g6 @2 x4 f/ ^5 a' p f
& r$ ~! S3 T; I; A% \* GMODULE_DESCRIPTION("Led platform driver");- i% e4 b( P7 L1 o
MODULE_AUTHOR("Tronlong");
2 E/ [! R* ^3 d8 {MODULE_LICENSE("GPL");1 A5 i* [- \! R& g6 l; j% V, n$ `+ c
' P( ~! V' A2 t
|
|