|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* N e' c3 x' V; ?4 O0 f4 A1 f! t+ y
#include <linux/init.h>4 Q/ G- l f( W- o3 d8 n( h+ U2 U5 v
#include <linux/module.h>8 j4 v% t5 N8 E L
#include <linux/kernel.h>7 I9 K* b) J3 m( G! u: r
#include <linux/types.h>' T! v2 s5 r% F/ P3 X$ ~
#include <linux/gpio.h>
9 m6 K5 W5 B* G#include <linux/leds.h>1 [ M: g( k# r/ g7 V x4 Z
#include <linux/platform_device.h>
) Z$ y1 d" e* q4 ^9 \9 t p5 m- d# `& B0 [6 F
#include <asm/mach-types.h>
$ V+ R3 ^$ Q! U& T$ c#include <asm/mach/arch.h>
2 G) I3 n# _) _2 r Z7 }# W- P#include <mach/da8xx.h>
8 o8 h& H$ n) m2 N j9 |#include <mach/mux.h>
, Z" ?: }6 {. a6 u- V5 f' d; K
' \. a2 `2 p6 ~* J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 P; m" W O# Z, w N- {6 M$ m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! S" X5 g; H: M6 L
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 [- p1 V. d+ a' }" m3 j
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! K* w, f: x1 ~8 F* j
* `' M1 s1 G+ f& i& V" n/ Y, U% |- O% O/* assign the tl som board LED-GPIOs*/+ o/ U' Z/ m h3 x$ D' E
static const short da850_evm_tl_user_led_pins[] = {
8 S7 I j7 ]( @" @/ W; d- q% ` /* These pins are definition at <mach/mux.h> file */
+ ^( J0 D4 L% K* k+ @/ K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
@0 v3 b" }+ Q; ^1 y9 F -1
- X5 i3 g# |! S! ]7 O6 p" i5 F};
$ }/ b5 y1 z$ [6 `. q3 G: v) ^7 A" i0 |* m3 Z) b
static struct gpio_led da850_evm_tl_leds[] = {; d2 i( e; @/ q
{% {+ l+ K/ R# N4 B! f
.active_low = 0,
% G& h. b: {( Z6 c .gpio = DA850_USER_LED0,
' Y+ E! T0 U; V8 K7 `2 ~ .name = "user_led0",
3 |; L/ H9 J2 g( O1 v" C .default_trigger = "default-on",* t# B/ i( e$ }0 `1 ? ~% M$ M% b
},) F% o) O9 d7 n( g* e# n
{
& Q3 Z: v' s+ M8 Z .active_low = 0,9 {2 P3 M3 p( D) k, d% P4 `
.gpio = DA850_USER_LED1,
! g1 L) a9 s9 M0 c2 D% X1 H1 R# e .name = "user_led1",1 }9 K% X! v2 X( ~
.default_trigger = "default-on",% [ V/ B( p! U
},
C# w9 _: g8 b7 Q* `7 M9 H {
9 S1 S- }: k6 o1 H .active_low = 0,& A0 h6 I, j1 _' b! y6 U0 q
.gpio = DA850_USER_LED2,
9 P0 W+ I( n* v8 D b" U6 Y .name = "user_led2",
0 G9 |7 j- Z, Q2 O! [8 w% k .default_trigger = "default-on",
; k( B* `! B, H4 O& p& ~3 k! F },4 z0 \- R' K" ]- r5 W( Q# G# r
{2 A1 h! A9 R: d7 z0 _ o; |0 O
.active_low = 0,
( f3 E ?: ?9 S/ A+ D. `4 Z: \ .gpio = DA850_USER_LED3,5 N$ R7 N* l" e" ~" ~
.name = "user_led3",% O0 K( b4 o- m& E% i x8 z
.default_trigger = "default-on",
- x+ C, ]9 q5 z/ k },
, e g' Y0 O, G, B# v& ~};
6 J% @* e5 X+ x, r! g
1 i5 N. N1 Z6 e- ` qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- n# E$ T/ K) @7 @2 ^& Y& f9 c .leds = da850_evm_tl_leds,
# s/ [0 t' K. E _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) z6 _$ Z: ]6 H# S2 q. U};
8 O% q1 O) v: ~( Z3 \: }
! ]/ R7 U+ U1 c! b1 G- Estatic void led_dev_release(struct device *dev)
% A& O* ] e, b8 I{
9 N& w4 \( B1 `" [1 j};
" f1 A+ @9 a) J3 V) k/ O3 j0 h. J! k, z6 T4 A/ H- A8 k, i
static struct platform_device da850_evm_tl_leds_device = {0 u6 X7 P s/ U
.name = "leds-gpio",
4 f$ P& v' a! b: \" ^- n1 k .id = 1,
0 C+ J. m; \2 Q8 w- z: R .dev = {
- }$ Y; {# M2 S+ a( l! ^+ G .platform_data = &da850_evm_tl_leds_pdata,
" f m# N2 E2 H7 B* ] .release = led_dev_release,
3 ?, i1 x% @& F# r! _. E' _ }6 k' J I( \7 F. @
};
9 x y$ O) K" P. l" b0 _+ F6 \1 q- P$ [% u* S% g
static int __init led_platform_init(void)
# @; ~$ p7 P, m8 p{
) P0 J4 K c) A. ^ int ret;$ S3 F+ T' q5 K- _
#if 0
t* W3 X' l% L2 E1 g9 u( b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ _. P( ~7 _( ]3 Q8 h" x9 V
if (ret)
/ ?( l/ k: c; x4 g- Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 d+ u* i. [+ E3 B& V7 e" Z$ O" D& P
"%d\n", ret);
- P4 h# _1 v" I' t#endif
, [8 H$ U; R6 _4 q ret = platform_device_register(&da850_evm_tl_leds_device);
# c0 c/ O7 c) O9 h7 ^8 K if (ret)$ b4 T- j# E& N0 R5 ]" W5 C
pr_warning("Could not register som GPIO expander LEDS");& l0 k2 O* P. t3 K, J% b
else: n+ U2 D2 ~- W* ~3 ^
printk(KERN_INFO "LED register sucessful!\n"); ]# N" S% I% n3 D1 [1 s$ f
+ y- X8 |9 V" T( s+ F
return ret;
/ |8 J- g0 b3 R8 f; P}8 ]0 B0 t$ f. ?. n5 N9 }/ `' p
6 ?, A: a L, [- h0 ?9 C6 a9 _
static void __exit led_platform_exit(void)
/ T" y! E. _+ o. n2 {$ e{/ p; Y1 o& B- z
platform_device_unregister(&da850_evm_tl_leds_device);+ U, z$ \8 s' ~4 j0 s. S9 U
% A8 S+ [' d2 P, o
printk(KERN_INFO "LED unregister!\n");- {. z+ \& T i% A) C
}, h9 b9 \& G4 [+ \
4 N8 e0 j! ~$ |3 |7 P: z, v& r
module_init(led_platform_init);, }, X# y+ @5 z1 n f
module_exit(led_platform_exit);# d. f B% m) i6 O4 q6 c; b
. V0 J# K1 M2 U( y' b
MODULE_DESCRIPTION("Led platform driver");
) \. q% ]; s/ nMODULE_AUTHOR("Tronlong");
) z8 T! a+ @' l) @, w/ l% vMODULE_LICENSE("GPL");& |9 m, B' s6 [% D7 C8 b3 }
3 y( e% z \! O; B% j |
|