|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 Q+ g1 _( {* z" c0 r: N5 t7 Z: E
#include <linux/init.h>* x* q" v9 E+ f3 `! E5 d
#include <linux/module.h>. X* @, g" `, ]2 M* T' l
#include <linux/kernel.h>
4 H2 V4 V; h2 g% I#include <linux/types.h>- Q! ^0 C$ i- N( Q2 X
#include <linux/gpio.h>6 h4 s+ A+ v# A2 D e2 {
#include <linux/leds.h>
$ P! j4 ~: V! w. k3 N#include <linux/platform_device.h>) }$ ~' I5 u9 z) K
; ^* I6 g, @( e: g
#include <asm/mach-types.h>
' R) y" n# D# G% f3 S4 m H#include <asm/mach/arch.h>+ Z2 G* h& `& i1 b0 C
#include <mach/da8xx.h>
: Q6 [4 F# ^! f* W5 ?#include <mach/mux.h>$ f, f/ b$ L$ M; r
o/ O, Z! R7 n' {: P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 o# ^ G9 e0 g) h1 O" u, J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- G0 b5 I7 r0 p3 G9 y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 [+ Z. ~3 {) {5 o#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! N7 u1 e' P9 b! C1 K4 W7 d7 h
! A, _7 S$ N/ l5 {; z6 ]6 K
/* assign the tl som board LED-GPIOs*/" w* y7 n; C: G9 F
static const short da850_evm_tl_user_led_pins[] = {( \' ^1 a* w" j- Z+ G U& e! {
/* These pins are definition at <mach/mux.h> file */
- p, x9 `5 j6 e' h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! w! z& l8 z+ s; H
-18 ]) O; u! [' Z w7 }
};
" {, U3 B6 _9 N7 h8 P+ G: r1 Z5 }( t
static struct gpio_led da850_evm_tl_leds[] = {
6 [, f7 J0 P2 Y* h; @7 D- p- _* V {
* M& \! r+ I3 j0 n .active_low = 0,, C4 |0 ]0 V9 _, Q" M
.gpio = DA850_USER_LED0,* W9 I; o+ f4 y! B! q* ~7 y; D1 q
.name = "user_led0",2 q8 t) S' L! B* [! B; C
.default_trigger = "default-on",
4 s8 h, R8 j8 y$ V- c$ |& O },
) e- ~9 Y2 x' p2 {: u" e: e {( ?) g9 x6 P: M5 {6 s
.active_low = 0,: C j6 H- P. c$ ^ J
.gpio = DA850_USER_LED1," r6 u5 [* i5 m) y) g# X
.name = "user_led1",( I* m) A; O, b! \5 j
.default_trigger = "default-on",
3 X5 g% W% A1 Q* C },
8 ~0 w# v& ?5 U7 g3 A/ s {
2 v' q) K$ A- C .active_low = 0,& X6 ~* v1 r; q) \
.gpio = DA850_USER_LED2,
+ R0 ~3 I& y0 {; A1 u- z9 K .name = "user_led2",
1 |; _+ b. B/ | .default_trigger = "default-on",
r/ P8 V" D: y },
/ X8 t' x1 }2 ]4 }# t {( v" y0 _' D' y8 D& j T
.active_low = 0,
/ |1 O5 _, V4 {+ O9 X7 u' F .gpio = DA850_USER_LED3,& k" b6 I4 J/ Z9 x
.name = "user_led3",
2 z% ^9 b+ |- Y8 G8 B .default_trigger = "default-on",. I$ d0 k- F' L: a1 p" k4 L
}," N! S, m1 R/ n2 B7 g# d: }
};- [! ~/ Y( A* D. l8 _$ I
* \( E0 p9 Q/ k# Z4 s. Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ R7 E: _& E0 F) h .leds = da850_evm_tl_leds,1 ?1 L6 m0 w3 O( q' {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. j7 T( \3 o9 O/ W, K9 T) A};
) \, K+ ~2 g, Q1 Q7 c: H( K7 I, \( c5 @* x; P4 M
static void led_dev_release(struct device *dev)" v3 V; f/ [, f+ U, U
{
4 z5 A! I {8 D( d8 d2 K};% R) r5 l' V j4 ~6 h
2 J( Y% D+ T0 s8 m" qstatic struct platform_device da850_evm_tl_leds_device = {- M+ X C1 h9 D, Z7 R. ]# ?" P
.name = "leds-gpio",: E B# ^; ]* H: g
.id = 1,
$ w- A. m0 x. @ w# m% z8 b .dev = {
8 t: k& y5 B2 _4 u5 F+ Y" \ .platform_data = &da850_evm_tl_leds_pdata,, f& W9 f5 r. m( c! m$ I
.release = led_dev_release,
: b- j, m" F: Z: I- G7 N, H }. _+ i ? }& }/ l& b o
};) D+ k/ r5 Y* A8 r- x: P
+ N! R$ y9 G- y5 n: M& E! g
static int __init led_platform_init(void)
; L6 h# T; C/ D, p0 x; U{
4 I- ~" M4 M5 [3 k6 _5 Z& ~$ d int ret;
9 R% v2 \$ L4 [, g, \( |#if 0
9 ^3 F3 O6 `9 B: S2 } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 \, |) S6 [4 j
if (ret)6 `4 Z' U, [6 z( h
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 R {8 V1 V2 y
"%d\n", ret);
' e4 { n0 I* A, j- y8 A. L#endif
6 Q) ~, L% c% _: h1 D ret = platform_device_register(&da850_evm_tl_leds_device);+ a8 Z F1 [) y# D8 {9 O5 h& V
if (ret)% ?/ g( @: n* q% `! {" p( t! |
pr_warning("Could not register som GPIO expander LEDS");
$ `3 c! O( a: h7 E) K% v2 q9 @ else
, `% C- i/ w' p. v( i/ M+ x printk(KERN_INFO "LED register sucessful!\n");
) J' y- k7 L4 K5 c; B/ K K
( b" o( X) b# n return ret;" j* ~- d% z, g" [3 t! E2 e1 s* K
}! Q6 v4 A K: x5 {$ U
5 Y9 T1 H* X2 u4 O) r$ T* i' }9 h
static void __exit led_platform_exit(void)/ l3 I. J* z3 |) J/ l( }! r: z
{
' K1 Q, e) w; F' E5 y platform_device_unregister(&da850_evm_tl_leds_device);2 I( Q& i: u% T/ \' ^# }
0 U5 F: Y) a6 j" ?$ H printk(KERN_INFO "LED unregister!\n");
9 v D+ }1 i8 ^8 p9 {; P4 o; \}
# M3 Q: f5 `- Y" a
+ ?0 K' L2 E9 T( J5 s8 n4 Amodule_init(led_platform_init);
# t& n* ?7 h# rmodule_exit(led_platform_exit);
, f6 W% _+ W* w2 g3 @8 E, `
3 v. F1 X9 p$ e% LMODULE_DESCRIPTION("Led platform driver");3 q' f1 d1 D! I+ f
MODULE_AUTHOR("Tronlong");, y9 ^- {( e7 N3 {5 B: x: s8 i3 b
MODULE_LICENSE("GPL");( n7 X0 U. c. I, O
0 A$ z% B4 |" b: W4 g& v* A) i |
|