|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; ^# `; t6 j9 H9 }. K! I# p
#include <linux/init.h>! b; c/ ]" w. D1 h3 w5 i& m
#include <linux/module.h>, Z, [# x2 J& ~, F# T2 m0 }
#include <linux/kernel.h>& m) ~$ d/ D' H0 H! @3 L
#include <linux/types.h>; u# ?/ H6 ~0 B& _9 G4 ^. f/ j
#include <linux/gpio.h>! }- d. o( b1 A |) {
#include <linux/leds.h>
9 y# f8 r0 a2 j' B; `+ F#include <linux/platform_device.h>, L5 u! O5 ~+ U% B! L
' O: l8 h2 H5 Z
#include <asm/mach-types.h>
, R* |, l% L# F5 _& ~8 l4 c#include <asm/mach/arch.h>
! i: X1 n. ~/ ?" f* d#include <mach/da8xx.h>! }0 w5 K) k0 l6 k/ j, y; \* t. j
#include <mach/mux.h>
0 b& A4 o% ?5 k+ }8 P. @
- m/ e" c8 Y- e# g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 q" c+ P7 X/ f8 }; I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 U& h9 F" z6 \4 P& Q' @0 p( ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, C; I5 P5 ]% S) g0 @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 C" E0 O* v+ t6 I
% j! J1 I- s/ H: w' ~% ^7 `
/* assign the tl som board LED-GPIOs*/- U& P9 v, ]- v1 i" t+ b
static const short da850_evm_tl_user_led_pins[] = {3 f0 I5 n: a! j( E- B J7 T2 ]
/* These pins are definition at <mach/mux.h> file */
& I/ [9 p) }, o9 k DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: r! O. ]- K- A5 S* P. H- d
-1
2 {9 \; G9 C1 b8 I9 I};
) j8 _- G* \* I3 m' {* v5 p W& T
static struct gpio_led da850_evm_tl_leds[] = {
2 F4 r5 K3 m7 h0 P" _4 d {, \) O$ R# _2 A# o- T3 I4 G
.active_low = 0,
" f# y1 `* a& @' h .gpio = DA850_USER_LED0,7 u) o. v' |8 ?4 R- V4 r2 O1 l0 j# J. q
.name = "user_led0",1 f' A2 h" ^" `2 _" L/ h' v
.default_trigger = "default-on",6 ^$ c2 {1 ]( M8 H1 P
},
7 k$ N2 b- c9 j# Z" T {
# v8 h4 X6 t$ q .active_low = 0,6 ]$ y# L a0 `' Q! W
.gpio = DA850_USER_LED1,6 Y, a* z7 z/ Z* v; B! I# r
.name = "user_led1",
8 a0 w, q" e$ T$ U- l3 n+ u" m .default_trigger = "default-on",# D) P. k4 j9 v9 z6 @- X
},
9 s- F, z' h2 T$ I/ ^ {3 B- r$ t1 m4 y Y: k% A" _
.active_low = 0,9 |4 t$ d4 I5 L% I4 o- V
.gpio = DA850_USER_LED2,+ X9 ~: ^+ M! |) J. B
.name = "user_led2",
. |0 Q0 q$ d7 @ w .default_trigger = "default-on",/ \+ M4 N+ Z l3 W C5 R
},: v) `: K, N# `- u7 _5 q" H
{8 k; T0 h* @8 W$ Y/ d/ X2 N0 I
.active_low = 0,
+ T% y1 o, r6 n' V% W7 g .gpio = DA850_USER_LED3,5 ]. c6 E/ h/ _8 p6 n5 w5 u
.name = "user_led3",
: x; Y3 W, I; p; J2 g .default_trigger = "default-on",
- J. i& Y; w1 F" ~- C5 V8 `& a" o },0 [" b' Y1 ^( Z; T m1 H
};" y. s' Y \7 ?& W2 Y; _# k% l% Y* p
% t& r' r* q3 Y' F. X) {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 w/ r( f+ U4 _& Z. b" M) s+ L3 H .leds = da850_evm_tl_leds,- S: B( a6 W- V. l. V+ ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 |5 `& A. B/ k! K0 o# `};
) i2 q! m y! g- j3 A
1 M; p) w, r1 ?: y9 \! l) h& Pstatic void led_dev_release(struct device *dev)
4 V9 j( ]* P9 f6 ` N{! y" \; X$ @7 g8 _. r( X
};4 M1 z1 V: [) Z, ]& g h
/ c! k3 j; R0 Q% ]- jstatic struct platform_device da850_evm_tl_leds_device = {; ^5 _2 L, N' c" v4 h
.name = "leds-gpio",
( ^- S+ _/ R4 O( y3 j' k% P .id = 1,8 S" l! A) ~4 w" c. l% Q- k# J% q: r/ ~( ?
.dev = {0 B8 `7 {4 } Z% I$ ], I; A" Z. h
.platform_data = &da850_evm_tl_leds_pdata,
! ?0 b. O( a" C# _, }. y .release = led_dev_release,9 ?& q, x) G; n7 }1 r( | i: w
}3 k. a v$ n/ _# V! w) ]+ v
};
* G l& F& L, C6 Q$ v" D' @
; p, M0 y4 V/ S& zstatic int __init led_platform_init(void)
4 ?: B7 Y) n Y! _0 l6 k; T* r- X, O{- g* [9 G$ L1 \ \. z j0 n
int ret;2 Z3 L, _ w; y- Y) m3 y
#if 0: r4 K; i6 M/ S# I: L6 C& V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, f3 @, n7 |/ E" |0 v5 O \2 d3 m
if (ret)
+ \+ a2 `1 H4 }+ | y! ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 ]* D$ d) F# H2 D- E7 V1 o "%d\n", ret);9 y; F- X3 O' z \$ r/ }8 W
#endif
; P% Y+ n; f# ]$ a ret = platform_device_register(&da850_evm_tl_leds_device);
" p$ o9 {8 ?6 t5 s9 T if (ret)
8 N9 J" \ w1 I% _! ]. N pr_warning("Could not register som GPIO expander LEDS");; p% H2 Y* }8 b4 [% }3 z
else
/ e1 g& i8 D7 ^7 S5 c5 Q$ f printk(KERN_INFO "LED register sucessful!\n");
, W$ ~" s' O& b# F8 {+ ~+ P: _# R* ?1 c" e; J: h& {
return ret;1 }: M. V" }( a6 w
}9 D8 V, N. l! {( a" ~& M
" Q* S u' I0 Y% s
static void __exit led_platform_exit(void)8 ~* z" x8 c! Q
{
5 z) q+ t) f) \. i/ V5 } platform_device_unregister(&da850_evm_tl_leds_device);" e* v* R: x% ~% l
% B1 T+ E6 I# j( w4 X% A2 q printk(KERN_INFO "LED unregister!\n");
# \: }8 B& e9 l2 i! @# I4 H) P}
; ^1 G: E }$ V, z
) c1 P5 ?& q4 g1 Y% o* Umodule_init(led_platform_init);; h# \* J. {, G# v- i0 c" B5 ?. H/ K
module_exit(led_platform_exit);8 m. U8 l1 k+ |# x
" O4 J! G x# O3 t- @; q) M
MODULE_DESCRIPTION("Led platform driver");
0 M- ^, ~! d6 ]2 Y$ FMODULE_AUTHOR("Tronlong");3 b% T. A8 [( ~# I
MODULE_LICENSE("GPL");5 H9 { D$ A& k3 g
! \" [9 p! ]6 t1 f; M: p( E% i |
|