|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 K% w2 e1 T6 g" i2 I1 y
#include <linux/init.h>/ x- S" \0 u$ W9 H2 d( ~( Q
#include <linux/module.h>
; [& I% L# h/ D$ ]4 E( x#include <linux/kernel.h>7 r/ A' `0 D# Z$ R" J
#include <linux/types.h>3 Q7 W a$ @& g& [' p1 K% y- i
#include <linux/gpio.h>6 J' f- v2 g% U K) v. _! b h
#include <linux/leds.h>
* P* U/ u Q; C#include <linux/platform_device.h>5 S I7 ?) s1 i O- `5 V! A
, n7 d. U* I% e ?4 y- p#include <asm/mach-types.h>' I8 R* ?* d# B5 U6 Y) Y# `
#include <asm/mach/arch.h>3 x* `2 j2 T# _8 B" p4 [
#include <mach/da8xx.h>
" B3 E1 y q5 Z#include <mach/mux.h>
7 o1 u6 r( Z7 Y0 K; G( s/ k! Y0 U7 x w K4 n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' _% a; T8 A2 l; g6 K( @#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 V3 Y" q% K, A8 Y7 j, G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" n7 c& G8 t3 a. Q' v9 N#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. G n# g( h" W) Z0 m5 O9 g! F8 f: O, ~
/* assign the tl som board LED-GPIOs*/
1 W3 }9 Q6 M u' S' z+ @- `static const short da850_evm_tl_user_led_pins[] = {8 [! L' m- n5 G) x, |8 D& x8 M8 ]
/* These pins are definition at <mach/mux.h> file */* A& o0 r9 t- L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 S, | o6 t3 Y( G/ b( A% s- b- i, c
-1
1 O4 u, v" Q' w7 o};+ k& Z3 M, o% A
# M g# Q6 X0 q t
static struct gpio_led da850_evm_tl_leds[] = {
0 u8 M5 W/ Z. `3 n- U6 q {5 e3 x' o) m# e7 s3 D& y
.active_low = 0,
. f1 X- h" C0 T+ i7 Q .gpio = DA850_USER_LED0,
2 Y$ i8 t& E3 ` {% l6 x" v( |' J .name = "user_led0",
) K6 ]! X. l! @ .default_trigger = "default-on",' |) K h. n' ?- K% C' ^
},
7 v' F7 L3 b& w- n) O7 r {" `9 P5 q5 [$ {! |5 U+ K4 `& E
.active_low = 0,
! D+ L ]0 J. \' R- a8 E .gpio = DA850_USER_LED1,
; x4 ]9 `: R+ D! I4 X1 g .name = "user_led1",
4 F- t5 J7 L% [2 ^1 l1 X/ z, F .default_trigger = "default-on",
( S1 @, O9 t$ G& W. p5 o },
, J- z# s# W1 k4 o {
, H7 b5 {$ m& P; r- w .active_low = 0,. h( J( {/ o3 @! c& k2 \* ?% m, ~
.gpio = DA850_USER_LED2,
( y( F0 q+ B$ Q5 ^9 D .name = "user_led2",) @! Z; V1 M2 m* I# w: [/ z0 c
.default_trigger = "default-on",
{: e$ J1 O0 L },0 m0 b$ M! m- M) [: P
{1 R" x. s. K c: S: \5 w" K
.active_low = 0,
7 T# \ d% |! J! i .gpio = DA850_USER_LED3,
& S9 N* a9 j, c* [9 g J; i .name = "user_led3",
l& _: Q1 j6 @2 k .default_trigger = "default-on",
3 N. M$ o: J" A },& s5 ]% R# P3 c. B5 `
};' q8 ~6 a5 w7 {0 i
2 m& R( d; W" o' _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 |1 Z& I& [. r1 b .leds = da850_evm_tl_leds,& X6 M1 ~6 I0 i( q, X4 F) G* D! e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( a8 M+ q* a. @" {6 b# D. w+ |
};
* @( y( P. _3 Q4 v. u% o; Q& f
) w! _5 l* Y2 z8 I" ^+ }3 M7 Mstatic void led_dev_release(struct device *dev)
( c1 v6 g- a U+ ~+ X{" b$ y; z" T# K( m/ v
};! Z& l% N+ W, z+ _' B. d
1 F2 t: s$ s3 y) Z; G+ Y3 Bstatic struct platform_device da850_evm_tl_leds_device = {* p) |" P5 u2 H4 k, D1 ]/ E& u: [
.name = "leds-gpio",
5 ~0 F/ f6 x" P, F0 u8 j/ F0 i2 I D" [ .id = 1,9 H. |2 ~3 e( H+ E' i7 Y. Q; Z! w
.dev = {
, e0 o3 h! g/ o* j* ]$ i: a .platform_data = &da850_evm_tl_leds_pdata,1 x' `7 Y% v d- H" @# ^
.release = led_dev_release,
0 L' \; e5 t# o, r }2 o& s8 f5 D6 U, n
};
' J7 a P/ X1 g3 l, d* d( s, ?8 R5 Q* R! h! ^, G
static int __init led_platform_init(void)
7 C0 Y7 o3 ~* ?{2 [7 Z8 u3 b, m- O1 e4 R1 q
int ret;
) d# k* q: Y1 L: j5 c$ K1 F% u#if 0& W3 n) y/ q' C7 z+ E& p6 v) P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; u( I. z( P" d/ Y, H9 K5 P" ~8 z if (ret) h# g W/ P: Q9 d& b! s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- w% G) g5 W( Z4 H7 n! E3 q. ?9 B
"%d\n", ret);' U/ G- v- p/ T. G+ Y
#endif; [# ^# F q! d( G- B+ \7 p
ret = platform_device_register(&da850_evm_tl_leds_device);
T' ]( Z9 J2 \6 m* D0 T if (ret)
% z$ x; A D# b1 z7 Q) K+ V# V pr_warning("Could not register som GPIO expander LEDS");
; t0 H' Y1 J( k, V, I+ d8 Q else
: B" w7 o& ^$ v2 j9 C# t6 @ printk(KERN_INFO "LED register sucessful!\n");7 F9 C" `0 T% m: g
) R# D0 v+ @# U, F' j- W w return ret;" w Y* [3 o2 n$ x K( z- h; F
}5 z7 [8 X l" N( x; X$ j4 Y( j% ~8 s
( ]0 \* }. F' z W- U! wstatic void __exit led_platform_exit(void)& m& i: C$ ~% o! k) D h
{
+ b" e' m6 }- s: r, N0 U( w L platform_device_unregister(&da850_evm_tl_leds_device);/ K0 @; F( t1 @7 C
* p: [* K' c8 p; L
printk(KERN_INFO "LED unregister!\n");: T; ?9 b1 `8 Z2 `! j
}
+ e+ b) `3 g1 X' _( o- y# i7 q" K. ~, x
module_init(led_platform_init);. L5 t7 P( n5 F J) @2 ^: O: G4 A% I
module_exit(led_platform_exit);
; g$ {) q* E, L2 l0 k3 l, u- b7 k: x2 w6 N
MODULE_DESCRIPTION("Led platform driver");0 x4 j! m- [9 S8 _* i2 G4 {
MODULE_AUTHOR("Tronlong");
5 {, o; V# |3 a0 wMODULE_LICENSE("GPL");" u$ U% \# H0 ` G# }
' T7 f% ] x! u3 i7 O7 p% F: X |
|