|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 c5 S; m$ X( A% K+ M; ~#include <linux/init.h>1 V4 c1 Y$ N$ L# Z7 o$ E
#include <linux/module.h>/ z) |* i7 M, l9 I/ ^4 f
#include <linux/kernel.h>8 z$ ?2 P3 a( c1 w7 H& Z* [
#include <linux/types.h>* j) S6 {; Y- ` E. N! D% J
#include <linux/gpio.h>6 E( k' R, j w! Y6 v
#include <linux/leds.h>9 g8 N. B) K9 B$ Q% o( L: J h
#include <linux/platform_device.h>
6 q5 D; L j7 ^: D; H: J9 @8 Z3 |
- l. ]* t. \* H4 `8 c9 ^#include <asm/mach-types.h>
' D# W2 Z! t; j' H z2 u$ I#include <asm/mach/arch.h>
# I* a# H, U( m: E#include <mach/da8xx.h>
' Y, F0 U- V% N#include <mach/mux.h>
) ?- S6 Z% G3 u" Z
4 F9 n' a+ F ]( n, C" ?- q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! {' F+ n3 G3 U) e8 I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) ^# u. _6 h: d& q& n) N, j0 H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& y5 |7 }, b K% H$ q+ {+ O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
s; ]& `. {1 ~3 a
' W. x7 J$ }- ~, }* {* ?% o/* assign the tl som board LED-GPIOs*/
& f5 b# H, u" Ostatic const short da850_evm_tl_user_led_pins[] = {& A% m* f' ?* S
/* These pins are definition at <mach/mux.h> file */* D8 ?8 ~, L0 g+ z) M5 j) q: |: j+ t" h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 w* @4 d. _( M( o1 e$ c6 O
-1$ w C8 E$ H8 B# K% t
};0 q {# R6 B. ^ u- d! u+ l# O
; W. E! g3 |, W
static struct gpio_led da850_evm_tl_leds[] = {
% T) Q! A+ ^1 [, | {! N4 ~+ S& g) F9 B9 K
.active_low = 0,
# N5 w6 {, ~8 S$ J5 | .gpio = DA850_USER_LED0,
! [, ?/ `$ T L2 ? .name = "user_led0",
8 D% q' J7 \2 Z .default_trigger = "default-on",
/ k/ T% n. O# Y6 t },
. N/ \" y8 i t4 E/ O% |/ t {1 T& l: ]5 R! k$ X5 ]0 D5 J8 M0 h
.active_low = 0, o7 l' z! X5 F( Z2 K2 z+ G% }
.gpio = DA850_USER_LED1,+ o! p% l( H5 J3 ]' Y2 \& A
.name = "user_led1",
, I, n$ @. i; D .default_trigger = "default-on",* i4 d! s5 X4 Z* g+ z5 N
},' T/ W9 C c! d3 ]
{
" o3 j! a( B6 m# Y% ?+ r' k7 N .active_low = 0,
; w/ {1 ~% F9 e% s" L) i S9 z .gpio = DA850_USER_LED2,
4 U9 g1 `) d' L! [4 A8 z" u5 w .name = "user_led2",
1 ^& J+ v, D7 Z: C4 s2 K) _ .default_trigger = "default-on",* j1 V# h/ j7 g' @, J0 S1 S
},2 d& }* B$ y, l0 Q+ i9 ?3 ?
{% {4 R' ?$ z3 ?& ~6 P7 z; d6 h
.active_low = 0,
4 W5 C0 [! q; L7 z# }8 r4 B .gpio = DA850_USER_LED3,
- O* D- v1 J; Z* Z- D7 R# ~" T1 u7 E .name = "user_led3",
, I+ T' ^6 ~9 N5 E% Y .default_trigger = "default-on",9 Q) {; f, o4 E# H; W+ q
}," `6 y$ _/ U, H3 h
};
5 }$ |& ?8 @1 ^- v; U5 ~" d
* N, f6 R' N0 P/ h2 T/ K( c2 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 b& b2 W( w$ N% I; C* u9 n& x .leds = da850_evm_tl_leds,
, i. q8 @ [) v6 ?# u .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" v1 k( H, I$ Z* Q, H};
+ u; R6 e1 `/ A, y5 s* o2 V9 ?' ?
static void led_dev_release(struct device *dev). F# S6 m& V+ W* }: I
{
, M/ v) b8 d) I4 t7 B( c( f};
1 G0 F- m2 F$ s. V) ^7 o, |( r* R) r7 M& N. \4 Z0 e
static struct platform_device da850_evm_tl_leds_device = {( v) ~ ?4 Y& K, [0 y. J
.name = "leds-gpio",
; c5 D* a- z9 c E .id = 1,
$ j& O; ]. ~- z3 P+ k" L& ] .dev = {; i2 R- x0 e1 H9 P" W- J
.platform_data = &da850_evm_tl_leds_pdata,) }5 e- ~+ a, I1 w' f4 F
.release = led_dev_release,
% b+ o3 w2 a0 o3 U( G }5 F" k( c0 F$ _( V# u! G3 N! }! U; F
};
, n: x8 y/ V3 s# U7 Z- u7 D1 F$ N8 I) k3 x1 u
static int __init led_platform_init(void)
2 u9 s# I6 S; O+ a{0 s5 E: d% T' r) _$ ~, H$ w/ }
int ret;; C+ ?; g0 [3 l h+ Q! A
#if 0
* ?2 p" G) @2 G0 y% b, f ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. B& R5 F* `1 {% P+ f8 l" g, G if (ret)
/ ]; b0 V: S1 R k4 ?9 ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 Z! w W `' u R( {; n2 u "%d\n", ret);
- s7 \6 \* B8 c8 k( L#endif+ T; l+ ^: Y' Y; a6 {: i: F
ret = platform_device_register(&da850_evm_tl_leds_device);
0 x* ~5 V' l5 i7 t* B8 y+ ~ if (ret)4 g8 X0 h. Q1 ?+ Q3 c; d
pr_warning("Could not register som GPIO expander LEDS");
6 z: q- d; K/ U n9 I0 j1 p4 ]4 N else b. Q: _& }3 T8 [/ X+ u$ x0 Z, H+ E
printk(KERN_INFO "LED register sucessful!\n");
3 K; A# f) |" z# c) f6 I
9 p* O5 }8 [: ^ return ret;$ r- z$ J8 u/ L/ J9 D& v
}
% R; z+ }6 Z. L- y
$ ^! ~; X# N: V( C* H; Z ~static void __exit led_platform_exit(void)
5 B# _8 s: {4 V1 D! |& G7 K{
! P5 s c( _+ d) Q! b) E platform_device_unregister(&da850_evm_tl_leds_device);9 N& [5 }( X: ]. x4 A3 W
# z0 ^, g& X, X, Z2 ^ A3 N2 X1 D
printk(KERN_INFO "LED unregister!\n");. M+ X3 ^" p1 b% P# w' F2 O+ B
}3 z$ O- D# b9 _+ z& y$ z6 L j# ]
; v, ^, y. r: r2 x5 x% R" B) z$ r, A
module_init(led_platform_init);" U# b6 t- w# E) V; h
module_exit(led_platform_exit);2 q. v. y+ }2 A2 I% X0 k
7 s. [* H% Q- `, Y1 lMODULE_DESCRIPTION("Led platform driver");' G3 Z% G# D' u7 i# n
MODULE_AUTHOR("Tronlong");
1 U, ~9 D, M6 kMODULE_LICENSE("GPL");& s0 X8 `1 t! l+ \! H, V' z
+ U8 b0 i" u: v! @' Z |
|