|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' y- o" d8 }% P2 M U, Y- O7 w+ g
#include <linux/init.h>
0 i, l' R. G: ~#include <linux/module.h>
- l {! V3 G2 K5 m: p7 t9 k% B8 O#include <linux/kernel.h>
( p: }9 {% R/ W#include <linux/types.h>/ _3 F' f6 P1 p8 Z- S
#include <linux/gpio.h>& |! k' s+ J) h2 w! J# d% S
#include <linux/leds.h># y# N! H5 H( `, `/ |
#include <linux/platform_device.h>
2 z# @4 N% ]2 y: o6 }( \7 x
' N; I( F" i, D0 ]/ l#include <asm/mach-types.h>& u9 q8 T) J: H" B+ f
#include <asm/mach/arch.h># q, @, h9 }! a4 ` Y6 h& E
#include <mach/da8xx.h>( P* \" l0 M- Q2 O: J3 F
#include <mach/mux.h>/ k1 Y7 s3 h$ @& P5 u1 P( B# R
# E; l8 \1 W; e$ u#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% g( q E4 ?4 q. Z- d" z3 ?7 |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ i) _2 E' \* W9 M8 N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 m. [2 G) I* e/ f- T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# g5 X. c1 ]8 Z
: R! `! s" v) w2 C
/* assign the tl som board LED-GPIOs*/% Q) j1 l! b) }# U4 j
static const short da850_evm_tl_user_led_pins[] = {. i2 e; G$ Y( X3 V. `+ j
/* These pins are definition at <mach/mux.h> file */
5 X' Y- a; T' P; ^( |& g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) V0 P7 d" j2 O* A i3 `; m; j
-1# e2 u2 t& o j: t6 s6 m, Y
};6 S: T. ~4 y! {, b4 w3 _
" V/ Q; }1 ]5 t/ [& c. z
static struct gpio_led da850_evm_tl_leds[] = {
7 d; ]& L" A5 t- r! t: w$ @ {
4 k0 \. `4 D& ~; I, b @ .active_low = 0,8 O1 O0 M& W& k" p4 \- o& B0 q
.gpio = DA850_USER_LED0,1 ^# g( n: G+ }
.name = "user_led0",' M: q. N% C+ d/ G
.default_trigger = "default-on",
* v0 [: {2 \7 P9 B/ k- |# n },
! s/ C1 B* p7 D9 ]! H {
0 i3 f0 ]' B* y .active_low = 0,7 k1 {- a2 U2 J. `+ C$ v; {, R/ N5 X
.gpio = DA850_USER_LED1,% M& G2 ]5 k1 \& {9 Y
.name = "user_led1",# j: B) t4 {( R% N9 i1 V& e! e; e
.default_trigger = "default-on",
' p9 C1 {- Z; y* z0 r },. y' }3 h6 z! U/ H9 B( `' S4 D6 @
{1 D& m5 t4 l3 D) g6 s j
.active_low = 0,4 `+ ~% C* _2 h
.gpio = DA850_USER_LED2,
6 ^9 k% r% J, U& G3 h9 Q .name = "user_led2",% |8 J$ ^. J9 m/ a; w
.default_trigger = "default-on",
% {( ]" C, R( ` },
. A7 [2 D" ?* O; r! t {
* U9 J; m' L5 ]( |5 f6 j- \$ b .active_low = 0,$ q; }+ O( |6 o' y5 {0 X. T
.gpio = DA850_USER_LED3,
& s: X+ \* b2 }6 z .name = "user_led3",
5 [. q) ]- W: p& q/ T, Y .default_trigger = "default-on",* j& E. v+ ^8 T+ w, c( I5 `
},# \9 ^4 A# N o* U5 e; `9 N
};0 r! U$ _- f3 ~" `
) g. s, F" y/ n/ [% r1 j- V$ O# dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 H7 @( O: Q, [& C5 `# n .leds = da850_evm_tl_leds,$ q2 X6 M! b0 M) R1 F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ E& A7 f2 B0 F& H
};6 w: R" a$ Y0 l% V9 G/ Q
! ?1 ]9 G* \6 S' K! C9 Y* I$ P" bstatic void led_dev_release(struct device *dev)
, c, C; X/ r( S, n& G. p9 y/ Q+ i{
' q( D& N2 u" W1 S+ a p7 m7 [};
0 P! @ S/ q' v
) F1 c {" \, H; Tstatic struct platform_device da850_evm_tl_leds_device = {
+ f- m, c! x' T4 s. d; ^2 s' M .name = "leds-gpio",8 ~8 e+ {& ?: O1 n
.id = 1,
6 m8 U8 t z- b! `8 n( ]$ a0 o$ o7 z8 f .dev = {
/ e+ J$ U# M( i* L. f% R4 b% ^ .platform_data = &da850_evm_tl_leds_pdata,( a/ x) J% p- Q% v: W9 Q+ k5 \4 W
.release = led_dev_release,
# g* @+ x6 @( Y! r% f }% F* e7 ~. f* y! X: }1 A
};
! L% U' l( I& p8 y7 b5 N, G# k# O0 p
! ]& \# z& g* \static int __init led_platform_init(void)
$ F4 L+ `! L/ r- b9 e& j4 [4 V) `{6 `( U5 w6 z1 ~! B
int ret;
' j0 L$ {% p( L0 ]2 D; B! x#if 0
; j3 ~) n; w& V! _, q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( c( b9 y0 P/ L8 J if (ret); ?, u$ \# K) N
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! m% C) v1 H+ ?5 ]) |" W$ z; G9 M "%d\n", ret);
$ d8 K4 d7 s2 }& p0 `#endif
9 j3 ^7 @( m! g3 `3 t ret = platform_device_register(&da850_evm_tl_leds_device);
3 X- o% I: Q5 R6 P. I if (ret)- R$ a! e. N& n5 l" I1 D
pr_warning("Could not register som GPIO expander LEDS");
& Y5 W4 J; Z0 f else
( E; h0 d. ^5 }4 {- t7 V% i8 T printk(KERN_INFO "LED register sucessful!\n");
$ `* i+ E/ ]3 w, v
9 s0 m! {: o9 C: A, o) T6 H' W' [ return ret;
7 t! M9 X7 n/ a$ ?- a. D% c- A}
, g' k2 k: S& P) U5 L/ K" i
3 `) s8 n7 g8 H% ~+ \0 _ p4 jstatic void __exit led_platform_exit(void)
" c; d+ l5 [; w/ V5 H- K+ j{
' l2 U* u, u2 o platform_device_unregister(&da850_evm_tl_leds_device);
/ J4 \. F: h; n. P9 e* C4 P7 f6 r; X V9 b4 h& }6 S+ k, x
printk(KERN_INFO "LED unregister!\n");2 Y6 M8 _# m; ]2 r$ E
}
0 l% G9 M( c1 l. t% L
" R* |0 O, [* W: L X; v7 _, M' V* ?module_init(led_platform_init);- e F; J/ [: ]5 m7 w W/ a- X# h
module_exit(led_platform_exit);
5 ?7 O9 g# @# U3 S0 d9 u! l
5 l8 J4 r1 U0 `2 h% |' ZMODULE_DESCRIPTION("Led platform driver");- d4 C! V! N5 u( @. t% D* M
MODULE_AUTHOR("Tronlong");& h E! L3 Q v. s1 Z8 L# l9 ^& E
MODULE_LICENSE("GPL");, |$ K% b& a- y- W0 {1 o1 a/ ~3 S
) }2 y1 J) w# h. u- n% f |
|