|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% s% Z) \" X4 c) n4 P' Y# i
#include <linux/init.h>
! B* ?, Q- f7 X$ L5 l" j# X! Q# U8 V#include <linux/module.h>
, E4 i3 ?! H. C* F/ u: Q. A#include <linux/kernel.h>7 h J( I" |6 c! Q
#include <linux/types.h>) g. R$ l1 Z, |* f( {) j1 n! j
#include <linux/gpio.h>( Q8 D2 D$ s1 l6 L; h
#include <linux/leds.h>
& z7 s9 ?$ O; z5 y#include <linux/platform_device.h>0 m, t4 n: ?9 S- w8 _; }9 Z
" ^# k! D R. f, C
#include <asm/mach-types.h>
' }+ \; O$ e3 x+ X; ]9 Q#include <asm/mach/arch.h>
# ~6 N! p( G4 Z! I: K+ n7 ]; A$ M#include <mach/da8xx.h>6 J8 T' ^" a3 C! Z, C4 l
#include <mach/mux.h>/ `; K; ~/ M/ f3 f5 h
$ ~0 p6 k) a) N1 k t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 G: g/ \& u; ~- o( s, ~% A& n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. F v5 q. [$ D5 g' S2 J! S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 Z# ?7 ~# I2 s6 ^) a! |+ Z8 a7 V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: n- K: R# }" N) X4 q2 x4 ]
, J. f' d$ ]1 s; A* ?7 E, h! y/* assign the tl som board LED-GPIOs*/$ U8 L: X4 ^2 H6 e7 N. j
static const short da850_evm_tl_user_led_pins[] = {
0 M2 _/ `+ M+ t. ]$ i8 P6 W) O /* These pins are definition at <mach/mux.h> file */, n/ T8 i! F* r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, R! ~6 ~$ G2 w0 W -14 T" Z+ K, ~7 {# |0 g! [. }
};
( O7 X4 l3 A) w7 C& |6 }# z% m9 x g! F0 G4 n7 }
static struct gpio_led da850_evm_tl_leds[] = {* v* L' H: k: W
{
* b) X: T' V! N i# i .active_low = 0,
! z( u r- J/ P .gpio = DA850_USER_LED0,7 ^) {/ {- }: I3 u/ l. k! C4 z- @ R
.name = "user_led0",/ N3 d" [; F$ ]: \& G/ P
.default_trigger = "default-on",/ b, E- Y, U" R$ p
},. {3 r6 h6 Q2 f* J/ d
{
, k2 ~2 l/ ]( O: N .active_low = 0,
6 V& s% E: n, H5 N( `4 e! r1 d- _ .gpio = DA850_USER_LED1,
. d6 {0 O* s+ q9 E$ D .name = "user_led1",
0 k/ X& O& \5 q3 J5 z: s2 } .default_trigger = "default-on",/ C8 t" N: P) [6 P4 @
},4 z0 E" Q# ?8 V O, w
{
_1 | R7 t; x) \" Z: ~ .active_low = 0,
" e r; a( A( c% w .gpio = DA850_USER_LED2,# I- x. T; c' F; d7 D. q
.name = "user_led2",, e! H' a p: }. H. g" I
.default_trigger = "default-on",* `6 e {; P6 V# f& W. @) m
},
6 ?3 B! Y/ P: i# }" Z b2 S {
# w' R& S, t$ t/ H8 U3 V$ P' C: P .active_low = 0,7 A. @( R$ n0 ]& F* [9 J' u8 f( M1 J
.gpio = DA850_USER_LED3,
* k6 {& m- [, j) |8 } .name = "user_led3",
( y0 j* D5 _) c, k4 l" ? .default_trigger = "default-on",
, O# {4 K9 T2 f' r, @" w },
& Q0 O: P! g' R' O4 \3 t5 c, P" L};7 L2 u# X' u' Z0 q5 o: ?% G( R
$ Y! b, t0 a7 F4 \ `2 M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 k6 A6 I: _1 _7 Y
.leds = da850_evm_tl_leds,& N" W, v; q; p# J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 D( K& T( R+ }};& T! E+ X' _- b8 n
$ ]# l/ O& f4 e9 |0 {! @3 ?- A( `static void led_dev_release(struct device *dev)
; A- i! r+ D- z3 ?1 C{
" C) m3 X0 @7 T+ \/ n};& W- x @3 Z6 o) x! A( y+ g4 [
, l) ?- T2 {+ i( m
static struct platform_device da850_evm_tl_leds_device = {7 g& {' N' c9 E( E( C8 z
.name = "leds-gpio",( [1 @3 O$ T; X! X* z2 l
.id = 1,3 a& V( x* b4 d
.dev = {
* a+ ? k: e+ f .platform_data = &da850_evm_tl_leds_pdata,
4 n( m1 H3 w g, y .release = led_dev_release,/ y2 Q9 H' f) X: L8 \' F
}
+ D6 [4 G8 j; G- w- I};" \+ H% r8 R* j- {! i; {) M
4 A! Y- y7 o( |' rstatic int __init led_platform_init(void)
/ I4 z/ Q. ^0 ^3 u{& f3 a8 w/ G; O% \/ Y
int ret;6 l7 R8 j; J4 A K; H* A6 b
#if 0
' I" i2 V% w3 ^, { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; Y M3 R* R; {/ h) ^
if (ret)4 F; ^* g, i3 Y5 |, ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ {! r. T/ f3 b3 ?( v- _. v0 X; ?* P @
"%d\n", ret);) F9 @6 ?9 ], n0 J
#endif7 x A [5 O. l! L- w n
ret = platform_device_register(&da850_evm_tl_leds_device);
! H. E. v1 G0 h if (ret)
$ F3 Q$ N( f6 I: f! c" O. G- Y/ | pr_warning("Could not register som GPIO expander LEDS");+ f: ~+ A7 t6 a$ @" h
else9 s, }" n) z6 a ?1 n% R3 _/ O5 }5 p
printk(KERN_INFO "LED register sucessful!\n");" a" J, K/ N/ W* r" a. x, `
$ [' P' {! _& g A$ x return ret;9 y1 U$ w$ e& ~ v/ U0 V- ~( C0 W* ~% B
}4 E" J- {- T, ?; U
5 \9 n0 E1 v ~static void __exit led_platform_exit(void)! M! |' U& w' b L
{
: y7 G+ n- q$ V0 ~ platform_device_unregister(&da850_evm_tl_leds_device);" p' h" G. b! c; o9 a4 ~
( t+ U2 }* f! H printk(KERN_INFO "LED unregister!\n");! j, {7 n9 ?/ ~$ ]- J. b% I$ ~
}/ F3 N+ f8 B5 f( O+ y# y
# q# l6 G3 o q: P, h7 g; m
module_init(led_platform_init);
" S1 Z4 v+ P( o) n6 i7 S% p. `; K! \module_exit(led_platform_exit);
2 r' ?2 x8 j/ M
/ i' _; x8 s, S1 ?) W7 O$ M' m+ JMODULE_DESCRIPTION("Led platform driver");$ G! N& b( n! y5 u+ r
MODULE_AUTHOR("Tronlong");
6 u2 b; L5 }$ W) B; w2 GMODULE_LICENSE("GPL");
% V# U4 ^7 O0 f, W) ]0 I
3 C! ]* ~; X: B& X0 q' a |
|