|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 P% ?' J1 _" s S
#include <linux/init.h>
* @3 w3 L0 p7 L+ _8 Z#include <linux/module.h>, \% ^; J N1 @# e
#include <linux/kernel.h>+ W% G8 F3 R" ?& R- L; |, ^
#include <linux/types.h>
. Z: p) U6 g' g3 U+ h- A#include <linux/gpio.h>7 I* I$ R2 |, N7 f
#include <linux/leds.h>% n/ M. ]" o4 f+ ~) T5 o/ K' q* ?! P; F
#include <linux/platform_device.h>
9 Y" S- A# V8 \2 |$ Y( H! U- [' l, j4 y: j8 l5 ~) H- o5 c
#include <asm/mach-types.h>
- ~* {- T ^. J) D) e, Z( T9 r#include <asm/mach/arch.h>% [" c4 ^7 U, l' G# Q9 X9 I
#include <mach/da8xx.h>
! P, c) g8 \% L! h#include <mach/mux.h>
$ u1 Y; n% z- T" G
" S; x' C8 v- S0 K2 @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! w2 n) _+ l( D1 |! s. A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ W5 [! C( c" P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 I( K3 ~7 J) [: ^, _2 {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" ]" A! U* }5 S
6 g! [' y5 w: u, n: H) f W1 h5 Q/* assign the tl som board LED-GPIOs*/
2 V2 N( A1 a9 _+ `5 x9 Lstatic const short da850_evm_tl_user_led_pins[] = {4 f7 O- b0 n& X0 H' z
/* These pins are definition at <mach/mux.h> file */. d% @9 ?1 N8 J' C! `5 R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% `: |$ t; b: f0 M, `! n -1
; l. a( L1 i1 M0 c i5 h) i};
/ R! h# q5 Z( ]! k
1 w; S6 ]; c% u$ @5 ?static struct gpio_led da850_evm_tl_leds[] = {
# c6 L$ t3 ]/ c% [, x+ S8 H {
4 R8 J7 q4 G6 f .active_low = 0,; |* h( J) I, V7 j+ O1 E
.gpio = DA850_USER_LED0,
. c( Q) I, y3 k$ p# u9 k3 m7 |+ U5 l e; w .name = "user_led0",
( f) b! g! E& w* e9 } Z .default_trigger = "default-on",2 I2 a/ Z& l' ?2 E1 i
},
3 | c3 R3 v, w; _0 A3 Q {! a' u. K1 k$ n" @
.active_low = 0," J* ?* g! n. g/ `- _; J& M
.gpio = DA850_USER_LED1,* D. @6 Z- ~. M& _2 h
.name = "user_led1",' H. D, J' J( {7 Q. w1 }' A# P+ P
.default_trigger = "default-on",# K* E& a' l% h% n
},1 h! R% ~* q! ~9 w# ]$ q6 L
{
4 B$ C# N4 B" f .active_low = 0,
; f2 V1 Q5 I3 o8 [- X1 d3 L .gpio = DA850_USER_LED2,
8 p# [& g3 a& q9 [- M .name = "user_led2",
2 ]- ], _" A. [' k .default_trigger = "default-on",
8 i. i6 d. }( l P },1 z' F) y/ ` W
{ U; ]4 Q( ~9 @+ n
.active_low = 0,5 T1 ?9 n/ ~& ~7 f
.gpio = DA850_USER_LED3,( a J1 D9 {7 Z/ U7 B2 F
.name = "user_led3",/ a( H; S% o! O- Z
.default_trigger = "default-on",1 A0 S+ m0 l+ p6 b
},
) @) F! U, f! s- }, h% Q* g0 s};1 u1 j. I+ o4 s: ^* }
& q/ A9 P" s" U/ o( Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 F m6 x- v4 P% e
.leds = da850_evm_tl_leds,7 R' n, b' j' [( u, ?. f0 @+ @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& N2 u @, S2 s. y$ u8 C};
6 J) ]* s2 A" [
. |# w5 N) ~# v# t) @3 T: Lstatic void led_dev_release(struct device *dev)
; k$ ?' o0 l% ^7 ^5 F{
6 g m# A' f: h; f1 z% f};. \: |& S7 N( F& Z
3 ~3 Q) ?4 j8 e. Y
static struct platform_device da850_evm_tl_leds_device = {4 n' r; \! Y# E( K
.name = "leds-gpio",
. m% ^# c: H1 ^! K* d/ X .id = 1,) r4 s( q9 G9 S; P9 C: H0 O
.dev = {
; B4 K* T6 r, F' t. {* ~ .platform_data = &da850_evm_tl_leds_pdata,
8 f) x) {3 {6 [6 i$ Q2 J1 s: D .release = led_dev_release,; S) X& N" j0 u! |, z
}
' k# e: Z- ~- u5 Q* r. y9 V};: d3 b1 @$ K5 I$ H, A+ ]
; s" w5 D& c* T: L5 h% ?# }+ pstatic int __init led_platform_init(void)# V3 G0 I/ Q3 ~: Z
{, m2 x7 c* D/ W6 g! Z y% z
int ret;
8 q+ i9 ?- W, I0 O4 O3 d#if 0% n! H9 A J9 Y* x7 R& V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 t r7 |- e9 U+ a# p+ Y
if (ret); O n! j3 s1 |9 g* ?5 m
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") l* L& s" I7 U0 {7 x) M- g) G+ f7 }
"%d\n", ret);# R! [- |& G( M2 C5 Z; e; q- U9 n! O
#endif
8 J: }4 u$ E1 Z; p' p$ u1 V/ | ret = platform_device_register(&da850_evm_tl_leds_device);
4 x \0 H7 b5 {- h6 J, S if (ret)
: z6 t% p3 k3 l pr_warning("Could not register som GPIO expander LEDS");
3 I" A( T% n0 v% I9 _& J else }7 U* t8 D5 A8 N. M+ l0 }3 Q/ G; E4 z5 q
printk(KERN_INFO "LED register sucessful!\n");
6 n! c5 I! |1 ^/ H; Y+ C0 P* k( r7 `
return ret;
# S2 _, o7 z# r$ S7 v, ~}
: T) E. f( K. o- P. O! m9 E2 s( ~
2 V% P5 K6 G# Mstatic void __exit led_platform_exit(void)
$ P4 Z* N, `( x B) g9 t. G. A{
d# z& D" g/ h* D platform_device_unregister(&da850_evm_tl_leds_device);
0 {. o- C' Q- n1 T2 U' T5 ?- D8 i" N7 p$ E; G
printk(KERN_INFO "LED unregister!\n");: \( E* V* P' U& f
}
# L# v3 V5 I/ i+ e: U& K
. y2 i! g7 a6 v0 `module_init(led_platform_init);
3 {; T& L R' T7 ~" lmodule_exit(led_platform_exit);* ^; \& ^# Z$ g& r
6 S& ]% s& ^ ?7 Q; f: MMODULE_DESCRIPTION("Led platform driver");9 A( k* m; @" ?0 W
MODULE_AUTHOR("Tronlong");; q5 F8 f0 q; _" M( l: u
MODULE_LICENSE("GPL");3 {1 B6 I6 Z5 K3 {( {5 \! ]
1 R9 a( w6 r$ f1 c3 Z+ x/ J( _ |
|