|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 K' _) G3 z1 d' m& S
#include <linux/init.h>
1 L) j% a* {/ Z, A! H7 S& h#include <linux/module.h>
% \* ]# c; z4 P" G. }#include <linux/kernel.h>0 L2 e4 P# |1 `: J D- L# u4 }2 T$ u( L
#include <linux/types.h>& R8 n; c, W5 l
#include <linux/gpio.h>5 C! y2 @4 I4 ^) o% j
#include <linux/leds.h>" L4 s7 [1 h; N" }5 K/ B% R2 J
#include <linux/platform_device.h>! n# c" P# f; K1 P, C
% }; C5 Q! Y9 U& ^, N: r: Z
#include <asm/mach-types.h>1 l8 u8 |0 m6 y# Y- Q7 ?
#include <asm/mach/arch.h>
1 [! O2 b$ v) V# S7 N/ L& k! ]3 v5 N#include <mach/da8xx.h>
( S4 L9 O% \0 K" M- z#include <mach/mux.h>
1 _& O5 Y! F. [* ^! w: ~4 v( n5 Z; P5 a0 g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; @! l& Z( v4 N, l! h& z( x z0 B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ c& I7 @/ c' ^$ y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" F* l2 L: e) `0 r: s: B& {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 R+ V, i: c8 }0 @2 H0 @ h
( u9 U. {( ]: t9 l- e, i4 G/* assign the tl som board LED-GPIOs*/( f9 h( D4 h2 R y$ W
static const short da850_evm_tl_user_led_pins[] = {5 e* {3 f) X. G% q, `" }2 ~+ S
/* These pins are definition at <mach/mux.h> file */
* S @! Y9 J* r. j! U$ e. a( U- c# _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 H4 D; T% s% ^7 J4 \' ?+ ^9 c -1' j% x) L& S! j& f$ p8 b: L0 P
};
9 J7 z- X T z4 |: s! ?+ V X( t( S+ Q% K9 J! @4 S
static struct gpio_led da850_evm_tl_leds[] = {+ u8 {# o: O6 a) @
{
$ s% V9 g, _2 Q* ?( v7 U .active_low = 0,. C' N/ `3 B7 b- b
.gpio = DA850_USER_LED0,1 X6 c# @3 m) [
.name = "user_led0",
, i& f0 n' K$ {: }/ E .default_trigger = "default-on",
( w, o3 I: e/ q },$ ]$ O, j# Q9 @3 t4 v
{$ m! Z. ?+ k. N; M2 G' h$ G
.active_low = 0,
5 j1 F+ b/ h( I3 l .gpio = DA850_USER_LED1,# t5 }" R3 Y4 p
.name = "user_led1",
* g$ \4 J N) s0 J- ~7 r .default_trigger = "default-on",
& V+ g. n& J2 u4 D" l: R3 y },9 y( L8 X& i" h" v
{
& v1 @! N3 u/ _* S. t) K% I .active_low = 0,( `$ j$ |' q- S6 ]! U% B
.gpio = DA850_USER_LED2,; e* \% q+ c! i, R! M1 w
.name = "user_led2",
: ?1 j9 L2 P" k .default_trigger = "default-on",
2 L$ s( m$ @, u8 T" f },' [+ t# @# p4 B) t& O1 f: f
{
9 L) b4 g ?* z8 x; a: r! j .active_low = 0,
" q8 u) i& |1 d .gpio = DA850_USER_LED3,3 V- m2 `# w/ x9 B8 b; \
.name = "user_led3",/ X& }' T: h2 x) O5 |( r
.default_trigger = "default-on", e$ a- ]; W# V0 a* R: m( P+ H
},+ D. y% ^2 l# k# v
};) L9 z6 O$ m5 U% p0 y) T1 }
% K: {* l+ p, \6 istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 P$ B' h& k3 K: @) B) N/ p" K .leds = da850_evm_tl_leds,
9 B# i, a* C1 @' q2 v' f .num_leds = ARRAY_SIZE(da850_evm_tl_leds), b( ]0 {) `+ ^/ i! S$ r$ W
};
; h% v" d- Y, G) C
) k m' V7 ^" Gstatic void led_dev_release(struct device *dev)
. |, z# k# b3 }' X, c4 F{
* p9 O' H( e |* f. _* T};
+ \! ?: Y4 u4 f, n% A! N. j! }) d# x: c6 Z6 j
static struct platform_device da850_evm_tl_leds_device = {( A$ e4 J# ]$ g
.name = "leds-gpio",
, @7 e; i) D% ^3 g, ^ .id = 1,
, J5 ^9 v! q( v5 J% M .dev = {
: Y; `' d0 i; h% K* G3 f .platform_data = &da850_evm_tl_leds_pdata,
6 a7 G% s% A2 o& K( f .release = led_dev_release,9 {4 X8 G( P3 V4 W6 Q! e z
}; i" b0 l- C' Q" E
};
& o: a; ?% P" ~/ b/ j- e1 }, {* P( f' n* ]
static int __init led_platform_init(void)
! ~" b0 p* }" K- Z1 Q6 l. h2 L$ v{0 T$ h7 n8 f) E+ Z
int ret;3 @, i- A, `+ ^8 p' m/ s& {! ^
#if 0
3 Y4 K7 s& o* H& y' s+ ? ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: O4 K" K* y ^) g/ ? D! r- O Z
if (ret)7 \+ X1 _$ `( F
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ a6 b: _" q9 K2 Y/ R
"%d\n", ret);
2 M6 a: _; l6 V& j& N+ c3 h#endif
* a* j, C2 N8 n! h+ w, V ret = platform_device_register(&da850_evm_tl_leds_device);# _$ ~* W0 v( ?1 ?8 A
if (ret)
$ l P3 {- ?3 H+ w, b pr_warning("Could not register som GPIO expander LEDS");
9 J1 I! E+ ]' N else8 g& _: g% G) K, m
printk(KERN_INFO "LED register sucessful!\n");8 j: o9 B+ D: @0 o: B2 L
: f+ H# @! F* I- J return ret;2 }+ {" K3 |% a \
}
# Q r1 U `( c9 Z) S
6 w, H o1 K! q7 O5 b0 ~( I# sstatic void __exit led_platform_exit(void)
/ ?9 g( v) W- Y! w( }{3 V W, X2 _6 r0 C
platform_device_unregister(&da850_evm_tl_leds_device);
; ]5 B, @+ \ z, J/ ]3 V
. [6 P6 i/ x, K# O R, h' u. A printk(KERN_INFO "LED unregister!\n");; s' m( Z" B8 u m8 _7 X6 V
}
/ g4 W5 ~# P: e( S6 @9 O
: z, T% k% O& x1 P' c+ Gmodule_init(led_platform_init);
# @ H, Q# I, v' J$ omodule_exit(led_platform_exit);: [2 K1 S# }- G) h
( ?, c$ u! I q1 l) }" c; lMODULE_DESCRIPTION("Led platform driver");
- j$ f6 }6 T' q$ f) n) l7 J* }MODULE_AUTHOR("Tronlong");, v1 u, I6 x2 H/ O
MODULE_LICENSE("GPL");
" h0 ^8 |9 n* j7 { i# Y8 Y
0 P% f& B6 |" b( t8 X, W+ V |
|