|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 W/ H" I Z+ {9 C" W# u
#include <linux/init.h>& W- B, O; b4 p# g9 N
#include <linux/module.h>
: G% U. c, s. U& l: A#include <linux/kernel.h>- c+ Y) W" r" \5 e$ z+ e! e+ I+ Q; U' [) C
#include <linux/types.h>0 v% j3 D8 }, `6 l1 g) |: r0 G! U
#include <linux/gpio.h>* g5 ^) F2 K7 I& y* I: H" o1 H% h
#include <linux/leds.h>
3 J* y; w6 N+ E) ?0 B, g#include <linux/platform_device.h>7 [6 L& h; c. b- A! X
9 i5 b3 Y. ]' h/ l#include <asm/mach-types.h>) x1 \3 u& I+ C( I5 C2 t9 B! m
#include <asm/mach/arch.h>
8 n9 q v" l* o8 _% R#include <mach/da8xx.h>' ~; j& L2 h( j$ z
#include <mach/mux.h>
$ J/ b& o; {2 S! K5 o% d7 N' H
1 g; H3 x& m* ]9 C! b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 f* ~# X! X1 T$ Z$ v) c* V, q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' u; B) P- L3 N$ Z. m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" _. |) N/ b1 E" j: @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: V4 C3 A" [+ ?' C" T% U5 Y) e- \% K( f3 p) H5 e4 F# m
/* assign the tl som board LED-GPIOs*/ D0 o3 g5 m b9 P3 d/ E: `0 |( K
static const short da850_evm_tl_user_led_pins[] = {2 ~- x' W% w* m1 W$ y4 Z( a+ G
/* These pins are definition at <mach/mux.h> file */
% u- x! R4 `; i e0 d' [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! r7 e; @: X* p8 n- V/ S
-1, P$ P3 u% j0 `8 }3 f
};
# t. R; H$ f; R* o
4 q0 P% G6 g- y4 b6 R) Astatic struct gpio_led da850_evm_tl_leds[] = {
/ d% E/ p6 Q, A! [8 T {' a5 P. y( _9 n* e( d4 u
.active_low = 0,
& r9 B) X. a Z9 D" {/ i) i/ z* r .gpio = DA850_USER_LED0,
9 @8 a: r X9 c& @$ @- { T .name = "user_led0",
2 f9 @. T9 T) E# g8 g C .default_trigger = "default-on",
- Z/ P3 s+ K3 g, ~; K },$ M/ F% ]7 s; G, Y0 C
{6 y# z, A% N. X! n
.active_low = 0,; A4 N/ u8 I% y6 A6 \
.gpio = DA850_USER_LED1,' B4 k0 k1 b9 Q
.name = "user_led1",
% x9 k4 Q& v+ ] .default_trigger = "default-on",5 R2 q3 d( i9 @! h" ~
},/ R" d( \+ y3 Y. Z+ p' E+ o
{" X/ A p5 }* h: b
.active_low = 0,
4 u8 D! t% y4 w. y& k7 p. d .gpio = DA850_USER_LED2,
2 _( r+ l* d6 u# F! V! _ .name = "user_led2",
8 b) \: J, E/ R. i .default_trigger = "default-on",# c' v+ c" f+ e6 `- ? j
},
/ c3 T) {- |: J b/ ?$ t {
8 F8 a+ ^0 \1 j, D0 l0 { .active_low = 0,2 u7 b* `+ r$ G' B
.gpio = DA850_USER_LED3,
9 g. r' X5 o8 G7 A5 T2 h4 Q .name = "user_led3",7 W) W" r% g% B0 W
.default_trigger = "default-on",
& M( p% B8 F" o8 o8 h },# i/ c8 L9 y) s" j
};
5 d B+ b0 E1 _2 T/ u+ @
. Y- i9 F. S8 L" S% u" qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 ^3 B9 A; N* ~; h" f2 \& A .leds = da850_evm_tl_leds,
: t. E+ g) p' N9 _( g0 ~6 o: _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, S) h4 B# d+ y3 v' J) w' {( G! t
};
9 {! Z, e+ M# C; g# G* h3 f7 k0 v0 @" c @0 b6 C2 t4 S" a
static void led_dev_release(struct device *dev)+ n9 Y9 i5 M6 G5 A0 b6 {$ r. q U. J
{& R5 r9 {- ^1 A8 B4 a
};' N7 O3 c Y# h& S2 \+ k
% v" l. g, d, M ?static struct platform_device da850_evm_tl_leds_device = {
" Z# X( y0 E* e( x. H& Y .name = "leds-gpio",( z( s8 P: B/ G7 C/ g; }
.id = 1,- U- p7 g% c+ z+ v, S, E* \/ m# p
.dev = {
, k7 v* k, f7 P9 _4 ?, e .platform_data = &da850_evm_tl_leds_pdata,7 z) a6 U( W; r* c3 i2 m7 \
.release = led_dev_release,: W7 E- G! Y5 f4 j+ o% w
}$ r* S9 H/ y! [! Q$ T) B# I) E. ^
};
0 r/ o4 [) F4 s; [' _4 h( I) F. Z$ @9 O9 q
static int __init led_platform_init(void), H& `% c) T! i+ X h# d
{
" p" t1 v H6 v- U0 j' p int ret;+ v; P+ n5 Y: \( e3 x
#if 0) |5 s4 L2 }" q0 I& f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% m# Z6 u5 N& P m
if (ret): y( ~5 `3 B; ^6 I$ M7 y( ^! e0 Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 V+ U9 y! a% `) Q2 j- J9 c "%d\n", ret);
' I0 k3 ?" B2 v9 A) R3 K#endif
U6 A# z$ N5 T0 z ret = platform_device_register(&da850_evm_tl_leds_device);- S M9 h4 H3 t0 l3 A$ n0 ~5 t5 A2 w
if (ret)1 z5 Z0 V& U6 ^& b' k
pr_warning("Could not register som GPIO expander LEDS");6 x0 x H- T; T3 z
else9 {" q& L% }* g% i4 H* f
printk(KERN_INFO "LED register sucessful!\n");
2 q# J9 _- h6 W: j- E+ E; ^9 w! t
return ret;
! {$ F: f$ _+ }9 |6 |, S: O' G}5 b- a* E+ t3 @' I) c$ d" D. g
& J) \% |2 [) dstatic void __exit led_platform_exit(void)
# d* c2 Z, n2 O, e{
8 I$ I) ~- i/ n3 g; Y$ o- B, ?, T platform_device_unregister(&da850_evm_tl_leds_device);
, d* q2 w# W6 i: ]/ |' N: |1 q% q- { s! O% x2 K- [& L
printk(KERN_INFO "LED unregister!\n");
% k" C# r8 a- t2 F! z5 A! F}
( j9 E8 q/ {$ ^$ B; U; t( Y9 b$ `0 K1 d) w( f1 v5 T
module_init(led_platform_init);
_9 H$ T' N Q {) g; nmodule_exit(led_platform_exit);/ I3 o4 G! m; V6 w9 ?+ K" J
$ v7 w& f; f, h; J$ U$ H7 G
MODULE_DESCRIPTION("Led platform driver");
' h# D! I: d* C; r% x0 U/ yMODULE_AUTHOR("Tronlong");. l9 f& y' r2 x
MODULE_LICENSE("GPL");
: D1 D2 b5 [* h; t, L0 C: F; e5 @! J$ q
|
|