|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* D: s/ ?/ R$ x9 J
#include <linux/init.h>; Z6 n1 F: l5 }
#include <linux/module.h>
9 n! G. b% z$ D& H6 _6 z#include <linux/kernel.h>. a7 [: o( c) X- f
#include <linux/types.h>, b% V: K' @5 Q
#include <linux/gpio.h>, [! H- L, z" {0 ~0 \
#include <linux/leds.h>
, |0 i S" F8 g) G#include <linux/platform_device.h>$ B2 Z2 C+ `; d1 ?6 s6 J) k
- T0 m+ P( r/ ^( T# x" S8 B, U9 M4 f#include <asm/mach-types.h>
2 K+ Z+ T2 Z6 R2 y$ R- t5 ?% `/ q1 U#include <asm/mach/arch.h>
; d/ N2 ~. J3 Q1 E2 H$ b; n S#include <mach/da8xx.h>
) {- p2 ~/ v, P" P; q! X o#include <mach/mux.h>( w4 R, D; X, X4 r7 A& Q+ F2 z
$ a7 b0 g' j3 ? E2 T7 a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 J( q# N$ Z# h1 _2 ]6 R7 |% g# Z5 w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- j4 {4 l) { h! t( x. Q _. a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! E S" s. y4 V7 n5 z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* D! L3 f6 {$ l. Z/ o3 \
0 M) N7 W- Q4 K/ h4 X/ C8 ?
/* assign the tl som board LED-GPIOs*/
" y v5 p+ v% s& {5 Fstatic const short da850_evm_tl_user_led_pins[] = {
, u$ q3 B$ I0 ?1 z; |. J- V1 f /* These pins are definition at <mach/mux.h> file */
- x+ q; H, Y7 Z% G1 X' ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 E- [0 Y5 j4 U" F
-1
# T, O& U( X8 X7 M2 z# l};4 j! j4 n7 N) k+ z% h1 g! L) F
4 d/ l: \0 R- Z" D0 o& B$ H6 hstatic struct gpio_led da850_evm_tl_leds[] = {
1 q& }5 F- j9 H5 c T; f* @6 x1 { {4 d4 u7 R+ W6 D- e( g/ G/ A% A! ^3 v
.active_low = 0, ?6 I3 W. i- Z' N& {3 F
.gpio = DA850_USER_LED0,
; D. D. `$ u: B8 [( Y .name = "user_led0",
4 ?9 q% H3 q6 J. Y) Y .default_trigger = "default-on",
& o, ^) F9 U S9 F2 t },
5 k/ E6 Y6 e% [: B+ d X0 {5 j {: V' N9 h: A1 Y* H9 b( f& W! z: R3 Z
.active_low = 0,' C, M8 D! I# u3 R4 {1 B9 X) s
.gpio = DA850_USER_LED1,
1 _( B' @' S1 }" |9 @/ T .name = "user_led1",
& J/ j5 l7 p9 o .default_trigger = "default-on",2 J$ R( t. ^/ c/ b' s6 m
},
2 o0 a4 b% M$ K" z& G/ Z {
: L5 Z1 Y' s% ^$ c; r .active_low = 0,5 [! s3 u1 S/ C$ d
.gpio = DA850_USER_LED2,& B4 @- T2 {8 o- z1 ?' u
.name = "user_led2",+ D) x! u$ U0 ~. s% k0 v
.default_trigger = "default-on",' T+ C9 F' z5 ]9 a7 e# F) z* B
},) ]1 h, K- J: s6 e# I: e" g
{! V7 H" J0 a! ^
.active_low = 0,
* ^) O C4 F2 _& b .gpio = DA850_USER_LED3,( V2 C2 H$ k, z0 a: E
.name = "user_led3",/ b4 N9 U* |2 P3 q/ T* q7 ^3 l
.default_trigger = "default-on",
4 O9 U! |1 q# s. x },
' R, t+ m0 r% ]- j& _5 N g" X};7 a( Q' X7 R0 T ?" ]% `5 u
, n* q! x* V7 Q ] Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' x' o6 y& l+ {/ L( e: r9 S# ]4 e .leds = da850_evm_tl_leds,6 F. |2 l( l- c" Z0 F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, N" V2 z! l' I0 Y" C, _" d3 E};" V9 e& c! I$ N7 v/ _1 O) v& u9 ~
% T" I, K+ u, cstatic void led_dev_release(struct device *dev)1 W2 f& W. y3 o1 k
{* K/ i: k n1 Q p% I
};
* b7 b! s; e+ a) C( V3 V" C: ~6 T9 h. F' v/ E* L; C* z% `. i7 I$ I
static struct platform_device da850_evm_tl_leds_device = {1 C6 R0 N! C# }3 b4 C
.name = "leds-gpio",8 Z0 S# Z) Z K+ h7 k3 m+ s- W+ t, F* @
.id = 1,9 r- N9 L! K H- t/ I9 p
.dev = {/ V: p7 ?5 b' s2 I1 \" M. w
.platform_data = &da850_evm_tl_leds_pdata,
6 |- X, H5 ?; d' c4 z; I. @ .release = led_dev_release,
! V" D7 Z' i& {0 ^6 c' } }0 Q6 r2 {7 @* V
};
5 p8 N. w6 p9 a0 R3 v3 ?0 }4 V8 C8 [. l2 y1 F, O
static int __init led_platform_init(void)
$ [% }2 v Q! g. }% H{3 V2 H; c7 L: s* s
int ret;
3 s* ? S! g, r- K2 U4 n#if 0# N1 i8 w7 o9 G! x- \* P X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! U* U6 O$ a- B1 x" j+ f
if (ret)
. g' I6 o7 J$ R9 J4 y7 @# P/ ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 s# {# }' G1 j8 T: y0 G "%d\n", ret);0 _( I* j4 r7 }6 R
#endif
, X* ?$ K; M# t3 ~! T3 Z5 |3 L! x ret = platform_device_register(&da850_evm_tl_leds_device);
& T" s4 L3 L1 c8 X0 x if (ret)
7 L& e3 }, q8 Z$ ]. Q4 h3 S, | pr_warning("Could not register som GPIO expander LEDS");' K, k t1 l" x$ A( H. j) s0 \
else
: A! J) [8 t, H4 W printk(KERN_INFO "LED register sucessful!\n");
, {# J) c U& ]% m4 i5 T0 s4 G) D ^& C
return ret;
( Y& N+ A( R3 j0 K4 F}! J) r0 l% S- |
8 L. H% _! I; k* Ostatic void __exit led_platform_exit(void). U8 v7 c$ g+ O! F% Z/ n4 b# E
{
" r3 x6 E, e: R( Q2 | platform_device_unregister(&da850_evm_tl_leds_device);
% |& h3 m: ?6 W8 j$ M) k. b
5 B/ V# d% d& ~ printk(KERN_INFO "LED unregister!\n");
8 X% L7 A: y( B# p}
9 P# d) P! |4 K2 W2 m x* a
% _& I& b7 Y, b# y2 w! `3 Jmodule_init(led_platform_init);0 {# A# F, r: [# u7 i+ \
module_exit(led_platform_exit);
2 a) a7 D6 u- k
1 }1 W# f7 }& GMODULE_DESCRIPTION("Led platform driver");
/ E4 j- D+ w& ^MODULE_AUTHOR("Tronlong");1 l6 t; g$ [7 _" P; |7 q0 r
MODULE_LICENSE("GPL");/ [4 W9 @; f3 ]7 }+ S
, q: o; ^- I5 x. ] |
|