|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% D4 y$ U+ M! [! U4 ?#include <linux/init.h>* t% \ i* K" c, ?
#include <linux/module.h>' a$ r) V$ Z' C- j. E: z, f( x
#include <linux/kernel.h>
$ p/ i) K3 |! u3 g$ _* ~6 E& l#include <linux/types.h>. ^- _2 e2 Q( _, H' x( ^
#include <linux/gpio.h>
: y6 I& H/ C8 N4 w2 f3 p; |8 X- n#include <linux/leds.h>8 V+ E* R( s" E
#include <linux/platform_device.h>
6 Z' `( I( f: h N s* ^0 ? m. q7 e- H5 l
#include <asm/mach-types.h>
e# o* Z! T$ p#include <asm/mach/arch.h>4 g8 G8 E% u, x" g0 p9 b2 L% y# i
#include <mach/da8xx.h>: N2 {. e: X; y5 A/ h8 ]* D
#include <mach/mux.h>/ X. z4 q+ M, z, _) h
5 H! D' @8 ~# Q1 C% T! {
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): \- \$ q7 ]# s& [+ O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ F7 @7 x# c0 ^1 ~) d& T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- v$ G4 c" e# C. k3 t6 B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); t0 U& r% O) Q" v
" A5 t# N0 x. b7 P; d
/* assign the tl som board LED-GPIOs*/
; b- A# P2 W) \% Q& ]4 z9 fstatic const short da850_evm_tl_user_led_pins[] = {+ o$ D+ n# |8 @& p! M Q
/* These pins are definition at <mach/mux.h> file */7 B$ ?' r: m9 P& `& A2 W" Z# \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* A, Q l6 Y! J- ^$ r -19 ?5 U% F* q m4 U9 `% ?9 x
};. L: F( u7 i2 A( T8 M& ?
2 D/ A) J: d! W2 h$ [/ {
static struct gpio_led da850_evm_tl_leds[] = {
' m- T) f1 X5 X4 ] n {
5 f6 H/ _6 z' t .active_low = 0,( V, s7 g' s5 u U* F& Z
.gpio = DA850_USER_LED0,
6 w2 Y6 g1 [" |5 u& Q .name = "user_led0",
( G* I, m/ ~. A .default_trigger = "default-on",
: K) ?7 P* F( f- U. K },
n Q. d, N9 H/ k1 {! a% g D {
, x( w# A' H" ~) t4 O9 g: B .active_low = 0,
3 `0 A, y4 v5 o: C* N- I .gpio = DA850_USER_LED1,7 {; R y5 c; }3 d) t
.name = "user_led1",
. u3 S) m( ?% D) f! G .default_trigger = "default-on",5 ?9 D, m0 L! O
},- t8 ^$ ]& N8 R- v
{
$ R% U: P" z, W' D .active_low = 0,
; z3 g$ l* D: s/ Y+ T& \: ?# D .gpio = DA850_USER_LED2,
' \; g" R5 d$ H |5 R O l- ~' O .name = "user_led2"," z; A2 r# {, V: x
.default_trigger = "default-on",) c; w; Y- t3 Q& ^! I- x
},
* S, P! c! h! c5 k) e* J {
( }9 T% @0 @& ^ .active_low = 0,6 |" \1 _+ S. I; G- K
.gpio = DA850_USER_LED3,8 l* J3 Y! b6 O( H* i
.name = "user_led3",0 ?0 X( ?- U8 s8 \$ H* k7 j
.default_trigger = "default-on",# s4 \, y. l; _" w
},
- S' ?: M( p8 x0 l$ b! @7 K};% A9 K9 a _, r, c( Y- H! `& Q
$ D: s3 b3 P ]: `" }1 Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" h& t7 Z/ ?" v R .leds = da850_evm_tl_leds,& B' [" C3 n3 f+ n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ P, f: ?+ }4 z7 p$ k+ M# o};
- B1 a6 i& J& h, Y/ b/ Z q& S% A# r! B9 n! X+ J
static void led_dev_release(struct device *dev)
8 }7 C ~+ _5 T8 Q, p) d{' s, q& x% H8 v5 c! P
};8 N1 X/ ~6 L" W! ~7 W6 Y! `! K/ v% ?
. F9 j* y0 s& O# ?0 v6 r# A @3 G
static struct platform_device da850_evm_tl_leds_device = {
1 v1 o" z+ P+ S' S' ~+ p/ O .name = "leds-gpio",
& B5 o5 E- d7 y: {# m .id = 1,
0 H3 e7 e( [# V- |% }/ n .dev = { C2 V, C" {# k% c$ @, P. @# W
.platform_data = &da850_evm_tl_leds_pdata,6 U! W9 p. r6 L( t$ V
.release = led_dev_release,
' I- K8 ^, |$ M7 L6 D }* I- q h; b& _" F; d
};* ]4 w2 t/ ?: O+ p2 d0 c, W
- P1 r) {* t; s& G! q( G/ V1 `8 p
static int __init led_platform_init(void)
2 y& \4 Y/ V/ x+ `# Z9 M/ _{1 [# n5 ~. F1 [& y1 [" q, o
int ret;; |2 i2 E/ x; C: b1 ~
#if 0
+ n! J/ P7 p. R+ o# @, h0 [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* z& E+ ^2 Z7 B6 e# C if (ret)
) L: O2 ?0 j' C h6 F8 ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 y4 {9 Z2 `$ r- h
"%d\n", ret);
0 U9 }2 `3 N- W) P#endif b( l% q$ |$ F ?4 i, H7 ^; @/ K
ret = platform_device_register(&da850_evm_tl_leds_device);
8 ~8 J! C2 t [9 z) Y- I2 ^ if (ret), B$ Y8 m5 J e& ] E$ R
pr_warning("Could not register som GPIO expander LEDS");5 g2 X6 r- n u( k+ n* _
else0 r! e+ o6 N' y: E
printk(KERN_INFO "LED register sucessful!\n");
" a3 c; O. _2 ~2 q% | F. j+ j3 B4 @0 S k0 d
return ret;$ L" K, k; I0 q! a
}
1 ?* c/ A6 {# N- _. M
( U+ C: Z& m; Z; Vstatic void __exit led_platform_exit(void)
S1 U2 z; d7 q{
7 _9 W& P. b# `8 a! ]. e7 N" L platform_device_unregister(&da850_evm_tl_leds_device);* W$ o% _ \& b- d# m' P" Y* p. v
8 v- e2 k# A, q. }: n) g0 @
printk(KERN_INFO "LED unregister!\n");5 k/ J* K: j& x: d d0 U
}
9 T0 e: k \, u( W- K. i3 E
, \+ Z3 j/ a! z* y4 K% rmodule_init(led_platform_init);
* e& n8 P! u) D9 k5 Zmodule_exit(led_platform_exit);$ Y) b) _7 P6 Y% v! a
2 H) o0 M% O8 }0 L
MODULE_DESCRIPTION("Led platform driver");
. }0 q& m) M- e- mMODULE_AUTHOR("Tronlong");
" d" W/ v5 f: O X3 V8 `4 K9 hMODULE_LICENSE("GPL");. @# [1 y3 a) j+ T2 ?1 x
( C! Q0 [, `6 n: N4 j% g2 M |
|