|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 J$ y* }% G3 I% p7 }#include <linux/init.h>3 x8 ]: O3 j6 [- ] W
#include <linux/module.h>& |/ t, {0 D' B8 t
#include <linux/kernel.h>" z9 w/ s5 { i6 ]9 i
#include <linux/types.h>
2 D2 `1 n; r* V* c2 Z#include <linux/gpio.h>
+ G/ e. k" }9 ^( w#include <linux/leds.h>
5 b0 n2 b6 P7 _$ @7 S7 p2 H#include <linux/platform_device.h>
- @# \7 i9 k) S3 v3 O6 M c$ m) c7 w$ e
#include <asm/mach-types.h>5 D3 Y* R$ A! t/ W- w0 H
#include <asm/mach/arch.h>( S. e* A$ m+ x7 |* J
#include <mach/da8xx.h>
4 c2 B) Z- Y* a0 C6 ?/ k7 S#include <mach/mux.h>* G# R- X# Q. e& X0 E5 J
- u& a) i& V" R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- C2 S6 S3 B% }* i* T* |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' D5 k4 C0 B$ M$ C) v& o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' |* r$ }( }2 ?' i
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ I* t( G* T! S+ B2 J% G4 q
4 F; V% @3 q* v# K/* assign the tl som board LED-GPIOs*/2 F/ w ~ [' y( a, p0 `* B% Q
static const short da850_evm_tl_user_led_pins[] = {3 m5 {* n. `, ~; @( Z
/* These pins are definition at <mach/mux.h> file */
- j4 [6 f: Q' A8 a3 v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% h3 N4 W& K0 J -1
) r4 Z/ `- D# j/ E};
9 r) u9 G3 u' k0 F# s/ c$ ]% K3 n3 H/ @4 V, Z8 |& E
static struct gpio_led da850_evm_tl_leds[] = {) i8 v" [. o, I$ g# s, c
{
8 \" k v4 A% i4 x( ^3 b( `9 Q) A .active_low = 0,
3 G" h! `$ j1 M& }, _! N1 I .gpio = DA850_USER_LED0,- d1 ?) Y& a! _" \* k7 R- B
.name = "user_led0",
8 A1 s! N1 g( S2 [# ?$ l .default_trigger = "default-on",
# I8 s2 X6 o% N) O! E+ a: u0 ] },+ Q( p$ A" X: q ~/ x! W; t
{" m4 [+ R! r3 f: ]$ L* B. r
.active_low = 0,- u, E3 q5 u P% F
.gpio = DA850_USER_LED1,
' I b# Z& d* r .name = "user_led1",+ F' L6 S1 A$ D: m( G
.default_trigger = "default-on",
: D% E9 ~% h7 {& \4 ?; ~: H# o },
4 q* W; Q( W7 P8 l {! L' N& |. R$ I4 I8 I+ J# I, o
.active_low = 0,) O4 Q4 e- G* s+ Q2 F8 {; c: i
.gpio = DA850_USER_LED2,
8 f: w! ], I3 { .name = "user_led2",. m$ A$ B+ {* C9 ]
.default_trigger = "default-on",+ a: L2 w$ j: M+ q" I6 o- F9 p) x
},
* t L% D$ _6 B% @0 ]# d8 a3 o {
- i* X" Q Q6 g1 d .active_low = 0,
0 c- X( u9 k3 M6 L .gpio = DA850_USER_LED3,
, F/ u6 I9 L/ P .name = "user_led3",& w9 E5 g3 t ^
.default_trigger = "default-on",
6 i( D( s; w& R },
, T+ S1 z; X, `- h};
( k4 f' u3 O. [% J3 B( O. i; n0 R2 r" u% E* H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- w) D2 C1 x0 i t% z8 f
.leds = da850_evm_tl_leds,
7 U" o% }) L3 b. P( t4 | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ y( j- H; ~9 d' J
};! \% K# W! C; E' h1 D3 ]
1 e0 d" c) Q) t/ H8 ?; |
static void led_dev_release(struct device *dev)
5 P* L- X- A1 j- v{1 W- Q8 `- p5 U) n
};
4 Q/ f+ f6 Z5 B# B2 H/ t' d( y% @8 E& q+ ~ [- u
static struct platform_device da850_evm_tl_leds_device = {
8 g; f; s% a- U: t! `/ ]% t .name = "leds-gpio",
Z9 m* n0 A' Z8 B% g: t3 d .id = 1,! i( O0 D4 Z* Y+ }0 c$ ^" r Y
.dev = {
! ` N( j1 I9 b& G5 a .platform_data = &da850_evm_tl_leds_pdata,
h' \# q- \- G, X, b3 ^( C% X7 S .release = led_dev_release,
( E& N7 k5 Y$ A3 d }9 P4 q7 B. R) w0 O! m
};
' c5 J) K2 [; j% ~- ]
2 @2 I8 z/ K3 F$ l3 n! H1 Wstatic int __init led_platform_init(void)
* v1 q) o& B) B3 i{
0 ^% g# g% J+ D- Z% e6 x: F int ret;
8 z3 m' `, Z& b# V0 A#if 0
! U% t, F1 F5 k- W; D8 D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ S4 ]2 s+ z0 g1 _5 C
if (ret): Q, {5 E# A- B- J' ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- v' u% n8 r# N "%d\n", ret);6 C7 I% D$ M+ J
#endif
1 D, A" J4 d2 _; c6 Y ret = platform_device_register(&da850_evm_tl_leds_device);( x/ p/ X' @4 h+ N& q+ q# W% W/ F
if (ret)- e, E1 B5 S$ a* j0 D: n8 T; L. t
pr_warning("Could not register som GPIO expander LEDS");1 o% K: U# y+ _, \& h. s
else' E8 ]; T- `4 V; C4 e3 G
printk(KERN_INFO "LED register sucessful!\n");
* \1 e- D: |1 f$ H$ M3 f
4 @7 B8 ^$ O1 Y# ]! c return ret;3 b) n# x( e0 |/ f3 B* T- ]
}8 P/ Q% \5 O' B; i% d7 h# P
# V4 g6 h3 y8 V4 m& M) Sstatic void __exit led_platform_exit(void)
( a2 n$ k. T: n, ]- A" X{( L. o! J M, Z# I9 ]
platform_device_unregister(&da850_evm_tl_leds_device);
) P- Z% O5 A [8 V' Y$ ?# i
. k z) f2 s2 k. C printk(KERN_INFO "LED unregister!\n");
' S x9 T3 p5 q4 T M4 K5 W}4 ^7 [" ?& M$ I3 H- n2 F% [
3 u ^' @% z2 r
module_init(led_platform_init);
9 n9 O! D0 H; m3 _module_exit(led_platform_exit);
" l7 X" T8 k: @! u6 ]+ @0 o8 B5 K3 Y7 F; p
MODULE_DESCRIPTION("Led platform driver");
8 N5 g3 T" p1 ?2 v# n3 }% A' }MODULE_AUTHOR("Tronlong");% d( w4 M& G. f4 T1 ?% H& _; a; e
MODULE_LICENSE("GPL");
- i* T- g0 W8 z7 E- \# ~" C& s2 n0 O$ v- u& F6 ]5 G }4 H- h
|
|