|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! _* Z4 {# k( L$ O, A#include <linux/init.h>3 V' f. c0 h3 W. Y( [
#include <linux/module.h>
1 }! i1 ~9 N" @#include <linux/kernel.h>
4 M; J/ u9 E! M3 [) |' l, w: G/ I#include <linux/types.h>% o* b+ f" O0 {5 y) x* D5 T
#include <linux/gpio.h>
; |, C4 g. I+ G+ i6 c, c* H1 r#include <linux/leds.h>
% C" q6 e/ r' M, \0 @. j, ~. T#include <linux/platform_device.h>
( u) X, T( l8 C: a" E; \ @9 b2 X1 x" O8 S3 n
#include <asm/mach-types.h>
5 V8 R5 _7 r! ?2 U) F* g#include <asm/mach/arch.h>: }0 T0 x$ ]* J7 T* X" w& g
#include <mach/da8xx.h>
& N3 O% l: l& Q! S! y) s7 y#include <mach/mux.h>
- j Y2 O% P7 w
4 F [) C I* r4 w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" V% `8 F6 b7 P- E3 c: U#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), E. O- N/ o9 V7 j, P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) j9 n2 S8 _4 D+ r% ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), i! I. H" m I$ {+ I9 d |7 K; _
, x. s0 ?, d" ?( q/* assign the tl som board LED-GPIOs*/
9 z: |( C2 C- R, Y" Z! g& v6 Rstatic const short da850_evm_tl_user_led_pins[] = {6 o1 c5 i2 M F6 v& J# i0 G
/* These pins are definition at <mach/mux.h> file */
7 |) X) C, Y9 F/ P9 U8 E0 i& s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 T/ b% K' k' X+ Z9 L' |2 x0 R -18 o3 p, d6 n5 b. N8 g. A
};& x. p' t8 _# M* C7 u5 Y& T( R
& X# H" l U& H3 \9 cstatic struct gpio_led da850_evm_tl_leds[] = {
; r B, ^0 a: j2 H, ^ {
3 n4 p9 @0 b1 L% W .active_low = 0,
% _& K) Y* [8 @ .gpio = DA850_USER_LED0," D2 E j8 J" T
.name = "user_led0",, S: x! q% J! k! S* T( S1 w
.default_trigger = "default-on",$ ]% Y$ d$ @& ~2 o' R2 y
},
& B# c: S) Z! b% g$ @2 P {8 t/ G" q7 M: M% B8 C0 m
.active_low = 0,
) ^' | a( j/ V! m .gpio = DA850_USER_LED1,
/ h3 C2 ?6 f/ v: x .name = "user_led1",7 F0 r M8 s( \& b s
.default_trigger = "default-on",3 Q4 ?$ {; H7 j9 K1 M2 I9 N
},, m" S8 R& ?: ~/ s
{9 S7 |8 n6 h9 ~& m
.active_low = 0,1 x D' l3 m4 K8 A; {4 _
.gpio = DA850_USER_LED2,
! e: P* U" q* x* ?2 A& s .name = "user_led2",
& z# J3 X- k8 g .default_trigger = "default-on",% L }3 O3 K Q6 B5 y9 P
},; n. s4 Y! O4 e m' e0 p9 M
{
* v" e l2 ~8 f% v3 m' t" g- C .active_low = 0,
1 F4 U+ X: M/ l: \5 u .gpio = DA850_USER_LED3,
+ H4 D; `( a5 E' @# I, l) Z .name = "user_led3",+ t4 I' a: B+ v% P$ i4 ~1 F
.default_trigger = "default-on",
* Q! P/ {5 P* O/ i8 i },
6 W* I W7 v* D5 `' B+ j};
% j" G9 d8 ^$ A
6 l2 V; |2 t" g# l B9 gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 N; i: _4 V7 G$ V2 Y e" t
.leds = da850_evm_tl_leds,
! i+ p1 Q5 t3 J* D$ O$ k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. b, Q$ m+ e" }' E, }/ R};; O3 e+ G/ L& M, S
( @2 x9 U( B9 a# w- M/ K ]/ x* s! y; Astatic void led_dev_release(struct device *dev)+ T9 v9 k0 E1 t( z
{
/ q/ I/ j* x" K' U};
5 t# b8 v7 r& C U$ O' i& B
3 [6 u2 O+ J r1 qstatic struct platform_device da850_evm_tl_leds_device = {' O% e3 g) y7 N5 h; Q ?4 P
.name = "leds-gpio",
- @: j; J7 _0 k# I, ^% M .id = 1,
2 d6 {8 C7 R9 U& }* M5 u .dev = {
' O# h: c" t! B$ R/ y .platform_data = &da850_evm_tl_leds_pdata,6 @( }3 c5 K( K& Y( O$ W
.release = led_dev_release,
! w% N; ~" Z1 I9 r }8 a4 r5 r/ c" [* ?2 B
};
, u) I* [/ o" ?- j2 @* y) i3 i; [% y
static int __init led_platform_init(void)' G! ^3 }0 O, t% [: V% I6 G
{
' Y" e% ~# N/ ]5 H# E; a2 n5 n" d int ret;
6 r' H l& Q2 W8 w$ B0 M#if 0
% d9 r2 y3 ]) G+ V7 t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% a0 x! ]5 c% _0 |( S
if (ret)* M" v+ K0 z; h# F. N* d9 e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" v' d4 Q/ p" t S, P4 K
"%d\n", ret);
2 Q8 d, C8 r7 ?8 P1 g#endif! x4 i3 x# D2 b" F* p$ V6 x4 \4 K
ret = platform_device_register(&da850_evm_tl_leds_device);2 y1 N |( `1 L/ h+ d' ^' L
if (ret)
# K: V; D5 _8 S8 O( h- V8 F pr_warning("Could not register som GPIO expander LEDS");
& r) U# ^; h+ Y" @ else/ o* Z1 |' T, ?9 g, O
printk(KERN_INFO "LED register sucessful!\n");9 z! ~8 t( T, `! o6 I, A- q' G
8 X( A, d* K) J/ g
return ret;
$ P7 C- f; }6 D; x A}
* O; T7 o" N N8 d9 |$ O" ?3 R3 p+ @
static void __exit led_platform_exit(void)
- h% Q# Q6 v; i; B9 g{
$ }/ @% V7 s+ F, F/ q* s platform_device_unregister(&da850_evm_tl_leds_device);+ E9 I5 ]+ R n4 e$ D
9 M4 c9 q G ~5 G2 Z) S
printk(KERN_INFO "LED unregister!\n");
0 D2 T6 \. ?. g5 g$ Z8 U0 p}
, V7 e4 V. c' h8 B0 d
* P* j2 r$ y$ M3 [; Jmodule_init(led_platform_init);" X- R( b% G, L( M* B0 J/ g
module_exit(led_platform_exit);; H/ E/ ?: U7 j1 Y# u5 w
& y1 O4 l( y0 K- R; o8 aMODULE_DESCRIPTION("Led platform driver");
, C. [7 y- b- x- c: T. y# z* y& pMODULE_AUTHOR("Tronlong");
' k. t$ Y' m& L& x' bMODULE_LICENSE("GPL");- {* j* _0 Z9 }' z6 M5 n# P
: {6 r0 p6 d% ` v7 R3 U
|
|