|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& m, P2 k6 N7 E; R8 _& b: n! f& ]
#include <linux/init.h>
. R `8 P$ Z b5 _/ D2 G8 z) `#include <linux/module.h>
, E* F' Z+ ?3 a#include <linux/kernel.h>; {2 S6 y- X( D0 ]( v( e5 @7 y
#include <linux/types.h>
9 d3 \( r. x1 V k. r) G' T#include <linux/gpio.h>
, J/ D5 @4 ^5 S3 b#include <linux/leds.h>0 ~9 ^0 }, E U: p4 D
#include <linux/platform_device.h>
3 b& {# i4 n/ j1 x5 t% K
+ ]& {4 Q1 e( Z+ n" s8 b$ z. {#include <asm/mach-types.h>
; L9 R* A( S9 K#include <asm/mach/arch.h>
% p1 H: {3 h/ {6 D#include <mach/da8xx.h>) R, ^! X1 u- C: {7 f: U# k
#include <mach/mux.h>8 G/ M) I" E2 \! _# S8 S. g" J
2 w$ @7 \' N0 o5 x* K& z$ Q" c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ B1 J4 C) w/ z& p4 Q- w* J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); V2 W! h% v) K7 W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 L! @$ f8 F4 ~! e, |( `5 F; q( E; v1 }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 L! j% S; u( O) Y
+ ?: D4 M8 h0 Y3 v. H3 V5 u/* assign the tl som board LED-GPIOs*// ^2 l( A6 N6 H& {" k( l. d
static const short da850_evm_tl_user_led_pins[] = {8 g" L% q% ^; l6 m5 W4 ?- b% _
/* These pins are definition at <mach/mux.h> file */
8 M3 N5 x! z; q) P- L+ ~) G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 j8 m( m7 T R+ ]* y7 y" }' c
-1
9 q# N7 o& h) p2 D1 ` [};' v( n+ s \* r0 E
0 h* e9 h, t) rstatic struct gpio_led da850_evm_tl_leds[] = {
2 H ^, q, G- I- f {
! Q1 [$ t, p9 f9 O" L1 \* T .active_low = 0,% i7 i) W' e# m" S- @
.gpio = DA850_USER_LED0,! D* c' ?* J1 h6 i. F C( u' e' Y
.name = "user_led0",; r" f* I' d! T( Z7 z
.default_trigger = "default-on",
1 u2 C9 N' Z O6 x },
' ]9 p* v9 w, s9 R( U! a5 y {+ r7 C3 F* |- M! x) o9 ]
.active_low = 0,; Z/ y/ G* S% ]
.gpio = DA850_USER_LED1,
; [" i0 c0 e% O$ w M* Z) i( Z .name = "user_led1",
& }6 y3 r% w# g .default_trigger = "default-on",
p( E6 t' j, d, w* s- C" p" u6 h },
, }/ T- E" N, P; } {
7 r6 ^# K: e+ V' ` .active_low = 0,
U: I# W0 r# V z! ]- _ .gpio = DA850_USER_LED2,
8 G O% _% C3 Z2 Y+ T2 S .name = "user_led2",3 t/ I4 e, T% d% j
.default_trigger = "default-on",
* X p/ A; U/ f; w. \' q },$ S& K& B M1 n! a# h O
{, N. \* A9 D5 k8 S- F
.active_low = 0,% i7 d: c: c! B, m+ q
.gpio = DA850_USER_LED3,
6 B$ L: i8 ?) d6 B Q .name = "user_led3",+ o) w6 g* F6 {- ~) L
.default_trigger = "default-on",
2 t |8 n, U7 {: n },
% ]5 |* r1 f, ^! {; g};
% E1 S% Q, A6 _4 E* V- A6 j- @+ ]/ O q4 R l8 `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 Y3 g% ]/ t3 N; q1 T
.leds = da850_evm_tl_leds,
$ ]* R% _* \9 q9 ], l( e .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- c) d8 ~" x4 ]0 y3 k( I: `( _
};* k* f3 q. M! t! a, P" k' `! G
) w# i8 F# U8 n8 n' X" n* h k& R, @static void led_dev_release(struct device *dev)4 o$ s* @8 y* ~( M8 ~. R) L
{
4 _" S" Q- k4 }: }};
" v, N; }/ G% m6 ]" a) Q& K! y1 R+ m* H
static struct platform_device da850_evm_tl_leds_device = {
4 u) w4 V, E8 P1 i .name = "leds-gpio",
# z; i0 O$ ]& r .id = 1,* } T( n* p7 B
.dev = { B0 J) K' l' T1 r) ]0 p
.platform_data = &da850_evm_tl_leds_pdata,+ X, X6 H0 M8 R% h3 O8 ]9 Y
.release = led_dev_release,9 ?( o/ w+ a. a+ o9 b
} B t0 V* Q }9 R. z
};
4 q2 T% Q+ [6 a- {: h
& t& A0 \0 E& {6 Istatic int __init led_platform_init(void)
0 J9 {; n7 Q3 t) B{1 K9 u% S% X. \7 g* g8 W/ I4 F1 M& \2 K
int ret;
" N7 I* u9 e0 p/ h) B#if 0
* ~9 u+ F# I0 G4 ~7 Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ v5 A/ o1 ~8 X' r7 \( r+ R if (ret)9 g) {0 I3 `9 Q! J5 T8 @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ t3 ?1 F: ^' p; X "%d\n", ret);
: S$ ~$ }( ~ {+ ~! i c( a#endif; L3 K- L j! Q/ o
ret = platform_device_register(&da850_evm_tl_leds_device);
# E% M; t$ L/ r9 I+ G( D if (ret)+ }5 V) r3 K' N4 d+ z
pr_warning("Could not register som GPIO expander LEDS");
6 T/ O4 b/ N- x9 ~2 G6 } else
I5 L) q) Q4 ]4 a/ P5 h printk(KERN_INFO "LED register sucessful!\n");
8 A) s0 |4 m; v& p# Z/ d; l8 |
( P0 z: y& G5 A6 a6 L* k return ret;( Z( q: }+ F F/ ]. o+ Y7 Y
}
9 t* _* E! w0 I& r& n# T' z) v0 j+ B7 y @/ o
static void __exit led_platform_exit(void)6 [ a) n1 y( r, t G5 q' d# |' I
{
4 j; R8 E0 h: [# @7 [' U' R: D platform_device_unregister(&da850_evm_tl_leds_device);% Y2 p# z2 ?- V* s
5 w/ W1 I6 |2 ?8 }8 O
printk(KERN_INFO "LED unregister!\n");2 ]4 B/ Q. p, N& J' H8 ?
}, B* Z1 E0 r$ B, X2 d8 h- a0 d. C& m. j
& Y$ m. D/ I" f8 u9 D9 F. Zmodule_init(led_platform_init);
/ {- N: i7 _1 E$ w+ Y; Lmodule_exit(led_platform_exit);
7 N$ f3 G9 ~; Z: p; T& w. H! ]
* `3 D+ j, V1 J& m8 h% zMODULE_DESCRIPTION("Led platform driver");# M9 y( m* p+ ^2 d) c$ O
MODULE_AUTHOR("Tronlong");1 r. L. U; \0 Z2 I4 o
MODULE_LICENSE("GPL");6 Z$ Z A; `/ q2 w
0 w" G/ F w4 C* t* o+ p5 V
|
|