|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
|) `1 n# l2 z5 _( o#include <linux/init.h>
4 `2 h q. ~% h4 e! M#include <linux/module.h>
9 i( e7 p( o* \) m, T0 {, y. \#include <linux/kernel.h>
1 h' |) k& M0 G6 c! r+ T#include <linux/types.h>. u- H" C* A' \+ A% P+ n
#include <linux/gpio.h>
9 J# P4 |% c0 V1 E. j#include <linux/leds.h>
# @3 C d9 b m7 F0 |7 @#include <linux/platform_device.h>) ^ B0 ^* }) v% |1 _. [
5 V! t/ ~, r. g( r#include <asm/mach-types.h>( W+ T+ m$ R+ c0 T8 c! g
#include <asm/mach/arch.h>
2 D2 s8 V7 j5 ^) {' D: @( I8 [$ l0 ^#include <mach/da8xx.h>* q6 v# R8 D5 w# O
#include <mach/mux.h>
& f0 B$ A' f/ R: S& J7 m
& l/ d5 l6 E ^( J, ~% E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# {# g2 z6 u3 W1 L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). T, k6 M- i3 y9 Z, Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( T, { s7 o& q, @/ I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' i* G2 b4 P! B" Z- G0 @
( ?. G- t: x [; F; [/* assign the tl som board LED-GPIOs*/. R2 e3 v7 I; t. u
static const short da850_evm_tl_user_led_pins[] = {$ ?& `& w0 q# l- B: M+ H4 c+ z, O
/* These pins are definition at <mach/mux.h> file */2 q* U6 E8 B( w5 O' s: _8 c: K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, f# ~/ \ c% b g$ w
-1
* Y* h# m* S6 [7 U9 p: d4 w};
- B5 Q) [4 z( ~& |8 b3 U; s: w
static struct gpio_led da850_evm_tl_leds[] = {
0 n" h$ Q3 f K: R1 A. I {0 l8 }1 z' d& S1 N
.active_low = 0,7 _! a$ X4 q. \8 o5 S5 G! {
.gpio = DA850_USER_LED0,
; f# M+ O, {4 O .name = "user_led0",7 t3 U1 Y5 i; M. `; Q+ f/ L
.default_trigger = "default-on",- S0 ~' b7 ]! V3 e6 S+ y) H$ l
},
; e6 A9 M0 o) H7 G7 D% \3 K A {; O- B2 ^' t \# o1 ^ l% Z
.active_low = 0,
) L/ W+ R0 w: H. l! b( [3 s3 w .gpio = DA850_USER_LED1,
8 E6 d; i+ \- |& e9 H l .name = "user_led1",1 R9 `! y" h' e: ^" U \; \
.default_trigger = "default-on",
" k5 |& g( C% S/ S: M- I },4 ? A& V/ T _) |
{
; F. J. k. c7 s .active_low = 0,
: ~2 [ c& Q9 F$ l .gpio = DA850_USER_LED2,( }9 b, L5 `2 n) c Q! {8 A, o( z
.name = "user_led2",
$ ?- ?8 v+ s6 l. V: T+ ?; G0 z .default_trigger = "default-on",
" G+ \, c( p9 n* K, v% q$ n },% L5 G, e2 y4 Y
{+ f" m3 l# A2 ~8 H
.active_low = 0,4 _8 R+ Z [& ^; J5 p5 I. [
.gpio = DA850_USER_LED3,
5 K" K8 @6 g" Q& J2 H5 _# f! @ .name = "user_led3",
! p: i9 y5 S4 J c% r- \ .default_trigger = "default-on",, f6 Z5 r" Z$ a6 T
},6 i4 l. P1 G) Y& ~
};& C; G4 y, ]6 p& [- S [, x( x$ ]8 G
, o$ Z% y) v" s8 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' v! i' Z: n3 z" ]& h! V .leds = da850_evm_tl_leds,% x! d6 k; T" \/ D4 E- R6 T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 L# d$ S* H" i9 Q6 _( F};
. p2 k) r: Z a7 l
. y+ i! C, Y8 f2 Mstatic void led_dev_release(struct device *dev)
/ K1 f p; [9 f! @5 ], g{
$ \, T6 |6 r5 }; d% z};
. b3 U* M/ r7 [& y: z% B2 Y. x0 |4 V" E, Y3 I4 R- f
static struct platform_device da850_evm_tl_leds_device = {' i( g, M6 x+ }
.name = "leds-gpio",9 y& S+ V5 |, u0 i: [
.id = 1,
7 Y q# ^2 l# D8 W .dev = {2 {; D8 O6 ?( ~6 w
.platform_data = &da850_evm_tl_leds_pdata,) X4 r6 M8 t8 J3 i% Y
.release = led_dev_release,, m0 Z6 h/ O" p. G
}
3 a3 Y' |3 u3 u0 L/ C/ Z};2 \, Z7 f6 n- A5 w% G
' E+ G- V) d6 Q' N- ^ G
static int __init led_platform_init(void)0 c a% Y, S) t, K2 z% ]% u" Y
{
+ ]$ O! } D' R: I9 x1 W3 y int ret;! p* k3 G3 ]) F1 t+ U
#if 0
0 ~- o; _* t# y% ?" J4 q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* S) P1 B7 i4 o3 V' H/ Q7 l' Z( t$ P1 R
if (ret) G) {4 |# ]! d: p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& _5 `2 u3 z9 Z7 }5 R "%d\n", ret);
1 m' _8 T$ h5 a; s1 G2 _/ J4 O0 J#endif
! a) z9 [5 G1 {+ Q ret = platform_device_register(&da850_evm_tl_leds_device);; i* O" T, B& \) j1 {. R* z
if (ret)
. ?- i- W. }- e% k pr_warning("Could not register som GPIO expander LEDS");) j. H2 r5 i4 c0 \+ E& T
else4 c- }3 h& n6 |6 ~
printk(KERN_INFO "LED register sucessful!\n");, N: }6 F5 Z: T: l' z1 C8 _: i
, P5 J% {1 e* X! H# z# @1 z
return ret;
1 ~9 ?! F% u9 G6 ~( W}
0 ]! C1 O$ y+ ?1 @5 m! r/ ~) H6 X# \ [6 E6 m
static void __exit led_platform_exit(void)+ q) _( m+ o4 r
{2 ~8 m4 I# C. B4 ?
platform_device_unregister(&da850_evm_tl_leds_device);. g, w( ]: Z, ~6 @) h
0 p$ a* ?: s# N; n" {; g8 N% B
printk(KERN_INFO "LED unregister!\n");) S5 v6 \( z6 _4 }
}' H! `2 `4 B2 W8 n
- T2 [* s/ t) cmodule_init(led_platform_init);
% o0 W3 p8 ?: @7 L0 V0 Q* smodule_exit(led_platform_exit);4 t1 Y0 D. G6 u& E- j ~3 ?
5 ]' t3 o b1 y3 b1 |0 v! r0 LMODULE_DESCRIPTION("Led platform driver");
; |, G/ {2 n$ Y$ @8 N* j! VMODULE_AUTHOR("Tronlong");3 V) ]. Y# x; b/ K3 P1 k
MODULE_LICENSE("GPL");+ g0 J3 C! j6 o4 @; q& W! Q
$ n! j' G0 L: j" }& T5 @ |
|