|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% J) v7 t% B7 t" F# T Q0 P9 L
#include <linux/init.h># d7 r, \" a3 |
#include <linux/module.h>- U( v% |* y9 A8 I2 \
#include <linux/kernel.h>& Q4 Q0 Z" Z) X% e; l9 {( j0 i
#include <linux/types.h>+ G9 g+ B/ |4 f( `& u# P: @
#include <linux/gpio.h>
$ H. e* f& t c$ E3 g) h2 z1 C#include <linux/leds.h>8 w" ~+ V8 e/ Z! X2 D
#include <linux/platform_device.h>
1 o" z% o& y- Y2 p8 e) S7 m$ k% L% L; }5 a% O
#include <asm/mach-types.h>; P# f6 W4 V- [7 A0 G
#include <asm/mach/arch.h>' T9 Z/ S2 b6 H/ s' J6 I) s
#include <mach/da8xx.h>
) g3 P B B. O: @#include <mach/mux.h>
; w# ]0 X# N6 I u8 z3 ^- }7 R) E" Y; P- A2 F
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ J+ x- b+ l( c J& [* L) ]3 T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) b9 f w. i+ v; }( l! S9 d; Z, y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 S: v/ T9 x8 j! \9 g% q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) Y, [! u( F0 b8 W% ^' ]
2 X; I- {' y/ @" H
/* assign the tl som board LED-GPIOs*/
) j: Q. P6 P. [& Q Qstatic const short da850_evm_tl_user_led_pins[] = {
% t. Z6 h/ a7 |7 o% O3 t! g7 y /* These pins are definition at <mach/mux.h> file */" j2 R$ d) \) m2 \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 P) V7 _/ N7 f$ s* _ l: l- I
-1. [7 H e4 L% ^' U5 b3 s* {
};& m: Q6 c# q# ]) `: U) ]
/ E' a4 N- q0 p* f& S+ T
static struct gpio_led da850_evm_tl_leds[] = {4 X$ K( s% ]$ B: P
{; V5 p% f# @# L
.active_low = 0,: _. ^" O0 P$ u, Z- L4 ~* q& I
.gpio = DA850_USER_LED0,
% \. }( Z2 n0 L5 O0 j& O$ r .name = "user_led0",
3 I, [3 X$ X' c- j6 [ .default_trigger = "default-on",; F: x1 P7 B& h6 M/ F3 D; H
},
% ?0 C; I( a( @8 s {# N5 ]# I$ s' r, J( p# M
.active_low = 0,6 d. G2 U z+ O* i% _
.gpio = DA850_USER_LED1,
- {* q3 J. c2 r# a" G .name = "user_led1",/ w; u$ t! T1 w9 U! H
.default_trigger = "default-on",* D) E* w+ E% @+ s+ j4 B8 b$ E
},
7 h' V! z: C( s, N {/ f! n7 ^* s" v# G! ~2 i8 y
.active_low = 0,
$ d/ B# r7 D) U$ Z- m% W2 u8 g .gpio = DA850_USER_LED2,
; U; C) S# j% Y .name = "user_led2",
. W% N& b- I5 h) [9 ~& Y& H: @! H3 y% x .default_trigger = "default-on",
; {+ g6 K" h. N+ U6 w },
, ]7 \) N o, ?4 U0 L) F {3 e( e3 x5 ^6 V7 n
.active_low = 0,7 L; d2 e& _1 Z6 u- s
.gpio = DA850_USER_LED3,0 I, o2 l9 i% [; x/ Z% J( R( e
.name = "user_led3",
- o) r" l9 k+ G0 H, Z% T .default_trigger = "default-on"," Q# s2 n- N+ v% j
},, f2 {! {, S. L( z. y$ p; n
};: y* k+ g: E0 |8 x5 n
O8 L& U% x0 s; I6 q, P7 Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# q: |) `) U) Y; A* g .leds = da850_evm_tl_leds, C Q) l" E/ l; z; w1 k
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% J) ~/ |. \: ~- p% {6 M" d};
. Z/ ] W# T* C0 M5 |" H! E8 [4 p9 O* Q
static void led_dev_release(struct device *dev)
9 h. d1 e" E& e; `" _0 ]{6 N& y4 }, b% v+ z( y1 S8 R2 D& ?
};" q/ _) \$ x4 e x# k/ m
$ F& q6 @% u7 vstatic struct platform_device da850_evm_tl_leds_device = {
5 Q2 H1 c- u0 Q& R L8 [$ q4 | .name = "leds-gpio",
; T' C8 s r/ L% a/ i7 t; p .id = 1,
7 T& V: H# }) T: o Y0 B" P .dev = {
- X) V: h U( j0 r5 ^6 w+ ^ .platform_data = &da850_evm_tl_leds_pdata,. ~% J& I) Y7 P o( @
.release = led_dev_release,* _) j- ~: d' B+ D& _- D' R3 A7 T
}. V) [8 M1 k8 n! h
};# j4 F9 U! n) I
; @# x5 t1 p! t1 q
static int __init led_platform_init(void)- {4 C$ b' z% j7 h" L# {& P
{
3 B0 f8 U" d3 q4 f/ `) j int ret;
. e/ V+ b# k1 _! v7 v#if 0
$ @$ {' x2 e4 r) s# F2 v3 } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 i+ W/ L5 q/ i( W4 q6 j& ] if (ret)
" F2 m/ ^" e$ w# B( _, j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 L4 P' \3 E$ `
"%d\n", ret);
' ^- ~8 E- y# n' L, ^4 s#endif
. C8 h* S% b; l9 d9 @ ret = platform_device_register(&da850_evm_tl_leds_device);# W# m2 S& d; }' e$ ?3 M3 i
if (ret)' _! ?9 d2 \; F8 I
pr_warning("Could not register som GPIO expander LEDS");5 m0 F6 V- c, N3 D9 ^% x3 H
else' j3 p U' L+ L
printk(KERN_INFO "LED register sucessful!\n");
4 `/ J2 c1 a: x# m, l8 K2 Z& S; p; K
1 B9 W0 T7 S5 w9 v+ C return ret;' k- @* B& Y: h' ?* k! y
}& y; g' T$ ?# F
0 c) C$ ]2 j4 r, P2 u
static void __exit led_platform_exit(void)
5 V% s7 K9 x) x* m- A{7 t% E4 C3 V& P2 @$ y
platform_device_unregister(&da850_evm_tl_leds_device);, n- p3 n+ O7 w; C: [3 o
. D6 @) L3 }" E8 G U printk(KERN_INFO "LED unregister!\n");' ^5 ?5 V+ o& W6 z
}$ H) c' P! G) y z2 @7 D- f
- o+ o0 \/ g0 r4 B: a8 z' w
module_init(led_platform_init);. N( Y% o5 _ Z; \
module_exit(led_platform_exit);1 }( T6 S8 ]9 s. M* }1 e. d0 b
' a+ P+ J# a# ~8 {2 r( ?
MODULE_DESCRIPTION("Led platform driver");) I* g' d" s5 Q, h8 T2 ?; }
MODULE_AUTHOR("Tronlong");
, z5 a1 V: R& Y7 `/ k2 w: d" Z7 w% t1 RMODULE_LICENSE("GPL");0 a }7 {5 i+ j% ?" |) F' u
& m: S- ?7 W6 ~& c9 l |
|