|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% k& V3 h" t" R7 r% b" _#include <linux/init.h>2 T; ~' _+ R8 _9 R8 f+ Y
#include <linux/module.h>6 K$ C. L. r) E# g$ | N
#include <linux/kernel.h>
1 `6 ]# @4 v" W! n/ ~#include <linux/types.h>& k0 h5 x* R: s) W
#include <linux/gpio.h>1 l# Z& y* @5 y; @% K4 j
#include <linux/leds.h>
6 M, \$ S# r: v! ]# m; k' V+ y#include <linux/platform_device.h>0 o) b2 j/ {2 B2 c4 i# c5 b5 |
( `7 F7 t$ O2 s0 N T#include <asm/mach-types.h>; b. w% B2 Q+ [2 G. z1 i4 U; v3 v
#include <asm/mach/arch.h>) g1 P9 M% H' K/ n# [( r
#include <mach/da8xx.h>
1 i2 R, H( y6 ^3 n% q#include <mach/mux.h>
9 \8 R/ {8 L, C+ O8 q; ^" E; d9 U: D) Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ x7 E& l# Z- e; `/ E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 a* r9 t: X) x4 H/ R0 P- z6 ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- ?1 K; ]$ {. ?& J+ D, B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( S4 X A+ u0 |% I+ t! D
; l$ g5 i' d. a, ?/* assign the tl som board LED-GPIOs*/- x \( _3 D) |" r
static const short da850_evm_tl_user_led_pins[] = {7 Z- d* g) t1 l* Y. p3 k
/* These pins are definition at <mach/mux.h> file */
/ s4 F+ x6 X" h/ H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. e( V5 k% K3 ^( {, N0 E' N6 T- z- ] -1
3 `3 }' m& ] r5 L};8 ?( p& H1 O. j8 l2 P
1 H( w* M( X) f2 U* Hstatic struct gpio_led da850_evm_tl_leds[] = {3 ], ]8 ]5 V, z q# H( C; W4 R
{
3 f4 T3 b9 P- u: q! Q, q .active_low = 0,' q0 h; l- V2 B
.gpio = DA850_USER_LED0,
# k- P! m) j8 ~; n- _( i* N4 R .name = "user_led0",& g" G- t8 h! P, ~* W _
.default_trigger = "default-on",
6 P9 C4 ?5 Y1 I# Z8 ]2 k },
, t1 U$ } f9 M( h {2 J8 j5 d4 W' G
.active_low = 0,- |% C* k0 j7 U# s
.gpio = DA850_USER_LED1,
; ~9 X4 m- f0 E* m9 D1 @6 `$ L$ _ .name = "user_led1",' j8 b, N% b; k
.default_trigger = "default-on",
/ V8 u8 C5 u# C: b% c" { },
}/ `# _; h' G' V9 F2 n {5 _$ ~2 B: P6 u* L) A8 Y7 y
.active_low = 0,9 D3 E" G+ b: f/ D# _" X7 y
.gpio = DA850_USER_LED2,
* s" \- N# e# X/ S) b8 w .name = "user_led2",' K, j* ^. J$ Q
.default_trigger = "default-on",6 s/ Z! ] K s( f) }: l' r
},9 V I- v: }+ x! {5 p* p/ z
{
3 t0 d% h3 I9 g3 C: Q5 F) X .active_low = 0,7 p! {1 e3 m6 Z' D% `5 b0 D
.gpio = DA850_USER_LED3,5 f% }/ b' L3 {; |" |# c
.name = "user_led3",
# Q. Y( u8 q% k .default_trigger = "default-on",. L5 V8 S$ }# q" ~
}," `5 L) ?" z' Q2 u, _) m8 L
};
0 e( K" U3 Y! n: x% H9 c; `
& i: {* Y$ v. k" cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# j5 Q4 k4 ?9 P9 f5 J1 \- a
.leds = da850_evm_tl_leds,- s t I/ e3 [( D1 J) S0 t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 I. q s3 Z9 X' k! i8 q8 d) S) a2 @ e
};/ Q% R) F% T) b; x
0 h8 r4 U# J) J- W
static void led_dev_release(struct device *dev)
$ I* t2 W7 }; ], g{
% A J \! `/ B% I8 i% [};
. F5 J& a8 @+ e+ R; ]5 P0 C' b+ k! U* D/ L( ~( {! y
static struct platform_device da850_evm_tl_leds_device = {
$ F1 K+ v! E4 B7 d. L .name = "leds-gpio",% y/ @6 \1 b1 B. W o
.id = 1,
) L# V* }7 Y1 x3 N9 V* ^0 C .dev = {
2 h6 y2 l' j# z0 [( m. B& q .platform_data = &da850_evm_tl_leds_pdata,9 c1 j$ k& u2 z
.release = led_dev_release,
* M6 G9 ?# G% l4 k ? }; U/ [. T4 O! J
};! r$ ~/ B1 w' ~
1 v2 d* G4 Z2 W9 q" ~5 R# Nstatic int __init led_platform_init(void)
3 |8 T1 l' d" o0 ~2 _{4 Q, c8 Z* l p' A
int ret;- W2 t c: F1 W- x, t+ H. }) u- j
#if 0
) g0 {, q1 m0 i( z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 H' M+ d: K f S5 M if (ret)
+ T6 `6 M6 X) X5 P/ w pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 V9 {6 h0 Y& D3 O5 x5 I "%d\n", ret);* X' O6 Y$ e+ `* X* n! p' U
#endif2 P, g3 K3 d! @1 x; _
ret = platform_device_register(&da850_evm_tl_leds_device);% R9 p; Z1 g& B
if (ret)& _3 x; i/ e+ o s( L, Q. [
pr_warning("Could not register som GPIO expander LEDS");
6 `8 W4 W* o7 }( J, ` else& J9 \, |8 r7 v* P
printk(KERN_INFO "LED register sucessful!\n");& R3 |% L+ V4 G4 _- A
$ T. t3 t/ T9 _0 J5 m! w
return ret;" c2 `8 n2 |/ S& d1 Z1 ?' d
}3 u0 H5 C+ `* C. M: N1 N1 n% n
3 z0 Q8 J, x) A5 ^4 }static void __exit led_platform_exit(void)1 T0 T1 W) X! N3 }. c( Y7 O
{3 g- K: M: U' E1 o+ ^! C) h
platform_device_unregister(&da850_evm_tl_leds_device);
* I2 r7 ^8 r8 W9 R: d: w- a" G+ X: P1 v3 L4 G2 e) }8 o$ l
printk(KERN_INFO "LED unregister!\n");
, s7 O. y N0 n g}" [1 o D0 P; K4 b7 M3 T* p2 c7 R! r
, S' o3 g+ M+ r f9 L7 S5 C3 Cmodule_init(led_platform_init);3 @$ {) L' ]. Q G; p
module_exit(led_platform_exit);
3 K2 W& u4 d( y* `2 q) T
# W8 A! d) N+ ?8 p+ p. [MODULE_DESCRIPTION("Led platform driver");
/ @8 h% \' z% e' q# BMODULE_AUTHOR("Tronlong");
; ~2 {5 ^. ]$ ~5 O2 d1 zMODULE_LICENSE("GPL");2 e2 I/ [1 e8 u" Z$ V: _7 C
$ I: ~& G5 [% j$ @9 J |
|