|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 X7 _" Q. T/ l% B$ J0 M" m
#include <linux/init.h>
6 U5 n4 D/ ~4 {% ?, B#include <linux/module.h>
6 u) R5 U. E; w O#include <linux/kernel.h>" n% K: V& ?( C+ V
#include <linux/types.h>
/ h, c7 C/ S$ b, H1 D8 e( s" T2 }#include <linux/gpio.h>* O: c: e$ K* P! F, L6 K0 R
#include <linux/leds.h>
: W z @) M5 k' Q1 z#include <linux/platform_device.h>
6 Q& M5 y: F$ D; y2 X- J- d4 m; W+ g/ W3 e/ N. J
#include <asm/mach-types.h>
% v. {/ z4 V: S) z! ^#include <asm/mach/arch.h>" u9 f6 e7 Y( [6 D
#include <mach/da8xx.h>
! o( K6 Z9 ~# `4 Q% f! b7 W( X: t#include <mach/mux.h>
! m* l; T o3 U) {/ U& h) p" {+ B2 t: q9 i1 Q2 e( S% Q. W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' A. C7 i t6 a3 k) r
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: x; U5 `& G7 u+ h; \% o9 |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 A; s1 n0 ~' Z7 N+ v/ H, j8 p, ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& D4 K N( i3 H4 k
9 H9 y9 i! u6 `
/* assign the tl som board LED-GPIOs*/" m; \( A5 Y1 @+ l1 E, a$ i
static const short da850_evm_tl_user_led_pins[] = {
/ N4 k5 h5 k( t5 @, U; C, a /* These pins are definition at <mach/mux.h> file */. k( u5 c$ V3 H; I/ e' u2 |4 i' g3 f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: x5 \ p% n8 L0 e, O; ^; R/ W; p- g
-1. Z9 u; C. }2 s+ s1 X
};4 ]8 q0 G V6 s0 q5 n9 P
" l2 o9 c. r. ]: tstatic struct gpio_led da850_evm_tl_leds[] = {
# R' q/ _! R* |- u4 O4 c6 J {0 r- N0 s2 R: w5 s- `, t/ _
.active_low = 0,9 P- d. p- j1 ^ d; A1 U
.gpio = DA850_USER_LED0,
. u# [/ u$ d% E* i* c .name = "user_led0",* z/ S( e3 K' Q- e( G. l
.default_trigger = "default-on",
9 u' N) n7 h) f2 t9 Y1 H },& R; t S$ g% B
{& b! t- @6 \4 e. q
.active_low = 0,- @6 h/ i6 x' ~6 N
.gpio = DA850_USER_LED1,
0 X Y* R. }- N& p' s3 ^. ? .name = "user_led1",
) E4 I; y; Y" x- |+ h( j2 D, [ .default_trigger = "default-on",
( u3 h6 j5 B9 k0 A$ f9 ^ },3 s) E$ _1 t# B; @+ ^; s8 {6 L3 r4 D
{
& L2 `6 s& ~& \( r. f Y/ a .active_low = 0,! x! }9 V+ y! R+ g$ ?& Z
.gpio = DA850_USER_LED2,
! K7 u6 P' R) J5 \; J# P .name = "user_led2",
( w: _! I' u' R- _& ` .default_trigger = "default-on",$ z( t$ X2 u3 t' K' {; s9 q
},: {- R, K A2 }" _8 ~- K* m {! O
{4 ^$ g" K+ v/ }. a' ]) V% u
.active_low = 0,
1 g5 t d9 A2 @9 V$ l .gpio = DA850_USER_LED3,* H/ q9 F& u; \8 U$ q
.name = "user_led3",8 M1 r. @* `% l/ a G
.default_trigger = "default-on",
3 ~6 D: T3 p' h0 V+ L; L4 t4 h },
+ n) R& w6 [- `9 G( A};
" z% z7 U8 ^8 ^4 b- ]$ z; Y9 R$ r% Y0 A' n7 `' }- t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; `2 K8 ^9 l5 t3 [
.leds = da850_evm_tl_leds,
* J) v5 P8 \2 |* X. B5 S B, } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 o7 [, ^: r0 M7 M# e
};# O9 G$ o, e2 A7 v9 O' f6 M) M# P/ X. r
% U2 |9 P `4 L! f
static void led_dev_release(struct device *dev)
( H, A8 e& l$ K! U( q{
- j, ^; e4 C( L+ u( F* W};6 r& w: ]+ c( x, x6 R1 |2 H I6 _3 H
. L$ Z a8 m! j) Z' h7 D
static struct platform_device da850_evm_tl_leds_device = {2 ? E: p3 O, ?8 }! _7 N. @
.name = "leds-gpio",
2 O/ @$ |- f" U .id = 1,
5 K7 X H" t. s9 P8 a' G .dev = {- Q6 D: w& v' A$ z2 b0 w
.platform_data = &da850_evm_tl_leds_pdata,
. Y4 N1 P9 q; x .release = led_dev_release,, z! O) `. c% B& j9 y
}
, u6 v9 x6 r- E' `5 n/ j6 i4 _};
V4 X3 o; x: n4 V9 \* _! F( ]2 c/ G
static int __init led_platform_init(void)( s! i! ~- H: T( `* K/ g9 C1 M
{
$ l: E9 A, U6 t8 r q) c int ret;! L- W: L3 L/ P, b- ^/ B4 m: M
#if 0
* q( k6 X4 v8 S# v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. B* ^3 I0 q. l
if (ret)& M1 N" K7 q- ]4 \7 t; ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 W3 M+ l% a$ n! }3 j4 x
"%d\n", ret);
8 J- k1 W6 B! V( R% Q2 c#endif X- p+ c( W+ X8 a- u, V; \
ret = platform_device_register(&da850_evm_tl_leds_device);
' N) j8 G( z# q' v0 F$ I if (ret): Q+ U- [3 S! }$ I% n
pr_warning("Could not register som GPIO expander LEDS");, z9 I. f# F0 a" k# q# ]- F
else
- h+ K' \1 x6 r0 b( h0 m printk(KERN_INFO "LED register sucessful!\n");0 f0 [- b# E; m8 G
/ a$ d, K( r4 S5 a# V7 L
return ret;3 ?. s" ]& L/ l9 r
}
2 n X0 ~" d& h0 ]) g" H6 q/ j1 M4 x! @( i6 R
static void __exit led_platform_exit(void)
, a" r6 {- {0 s{* ~; i* n) t, u# e8 \) {6 u
platform_device_unregister(&da850_evm_tl_leds_device);
n V/ C `3 k$ T4 I
/ G/ G* T! N2 ^5 Q0 z9 c( f printk(KERN_INFO "LED unregister!\n");. t% U0 H. W* g8 }3 p8 ]
}
& s, u8 C! c9 g% l+ a- e+ t9 M5 N. ~. A: Y1 \% h+ @
module_init(led_platform_init);
' N: \6 t# z( X6 r) ymodule_exit(led_platform_exit);
% v( ]5 P- ?; W! h; `
% {8 B* s4 a$ T' b' T8 P/ qMODULE_DESCRIPTION("Led platform driver");
6 T9 \; r# |; G% B. rMODULE_AUTHOR("Tronlong");
- n, z: V3 |% Z; C( l% z5 fMODULE_LICENSE("GPL");
7 A5 q; |& A5 m& G+ A# v* k5 D# x7 _, T% `0 Z# F9 k
|
|