|
求大神给下面的程序做注解,请稍详细些,谢谢。
" j: y9 t$ A+ u* w% Q" N& b#include <linux/init.h>7 W, e0 I& O! h4 o0 U" y: \0 c
#include <linux/module.h>% Q4 o: H! ` V3 `- D# [7 R
#include <linux/kernel.h>
+ C8 z J) e: G6 I2 y9 T#include <linux/types.h>" B' j7 r) @6 x/ e+ ?% s' ^
#include <linux/gpio.h>) l7 J% c1 d- X F3 H* d8 X) F
#include <linux/leds.h>6 \' k7 r7 n) M- u+ i0 Z
#include <linux/platform_device.h>/ B4 _, i) T j$ x. K5 H9 r
) B6 N$ O( {- Z- r( i#include <asm/mach-types.h>8 q/ z, Z8 I; e. b; v% m w
#include <asm/mach/arch.h>
9 @( n( o; V: B% C% m, ]$ m#include <mach/da8xx.h>
1 ?! D3 {- \% U+ s#include <mach/mux.h>
) y! S5 G( `& y( U
* Y7 i3 }# q4 y2 H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! K. z9 [5 y9 S2 b8 _: U- f+ n: R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) _0 \+ L5 e' U& h& D C4 x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' ^+ T% L0 l% O% j1 x. Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 q2 Y1 ^6 F0 O0 H3 I" x
# Z2 z, E1 g2 }# T* _
/* assign the tl som board LED-GPIOs*/
: J' \ L: a7 J6 K% pstatic const short da850_evm_tl_user_led_pins[] = {
. H7 B/ n$ H. k9 c u /* These pins are definition at <mach/mux.h> file */! R( h+ F5 |: F) q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 w# x p5 a7 ]- M3 x9 g
-1
& ~- s! f" c4 G2 ~' c; |3 c$ s8 f};% \3 V8 Q! l l" I! Q* Q( L
N" A, L( l: ^) T' Z% F! h
static struct gpio_led da850_evm_tl_leds[] = {
4 y7 X6 _' l2 m3 F, q+ | {
2 |6 @! \% i, s5 ] .active_low = 0,
& L1 |/ _. ?$ i% O. f .gpio = DA850_USER_LED0,
& x; T, v! ?3 c# T, h5 Z- ? .name = "user_led0",. C: x1 I. e5 ~6 _9 B( g# ?
.default_trigger = "default-on",! {( A2 b% R1 U6 C
},
/ [7 w ?( }% h0 Q, i: ]1 F% ]6 y {
# |0 a% S! ?8 x+ c" s% G .active_low = 0,
4 K% a& J4 J( {! Z, Q1 W .gpio = DA850_USER_LED1," Z* D& h; P; q
.name = "user_led1",
- p# e: i0 U' l( M a+ I9 v8 Y) ^ R .default_trigger = "default-on",
) x' f& A \" ?$ q8 [/ Q },1 [3 [* N# X3 W) J
{
( e/ Z& J/ [1 l) s7 G. [0 C8 ? .active_low = 0,5 D2 U7 Q4 T$ W4 A1 i
.gpio = DA850_USER_LED2,5 N' s& e- b! }# J
.name = "user_led2",: F' v8 I) y& i7 V, q z
.default_trigger = "default-on",9 I& E s+ I" s
},
7 I$ e0 }, \0 p% C; u1 a4 C2 z6 g {/ i' H3 f: M- L+ ^- x9 }' u4 f/ n+ P
.active_low = 0,
' y n/ c1 e p& q8 N1 F% [ .gpio = DA850_USER_LED3,
9 s: [. [$ z4 [7 C) b .name = "user_led3",
: M( ~) b( @8 [( {0 _ .default_trigger = "default-on",
) a: A4 |- v+ @5 T" l },
8 |9 X4 O' m/ y5 l/ }};
- f! E& i$ f6 `4 M N9 L$ T
7 e+ B* Z& H! ?# l* U! |) p6 {1 rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" v- d- Q7 P6 o! Y1 f6 v8 b' X
.leds = da850_evm_tl_leds,3 a2 D+ g# F# d- `6 ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 A b# E( w4 C B: `};7 f9 z1 W/ G* K0 e' |
o; A+ k5 y& H ]
static void led_dev_release(struct device *dev)% m- Q! `$ J3 |' d2 G% X
{% t% [9 _8 p8 s. w& M9 I" b
};
4 ]9 d3 V2 |' J3 f6 N9 J% V+ D7 g+ V& C* D+ w2 F, N
static struct platform_device da850_evm_tl_leds_device = {
2 W& [! p* h |0 g4 V8 k .name = "leds-gpio",
8 g# A& a8 Z5 b* v `/ k! u .id = 1,
& Z$ K% u3 V. ` .dev = {
3 k. w" C, [+ ?. w .platform_data = &da850_evm_tl_leds_pdata,/ b# Q8 W" `6 _
.release = led_dev_release,
! F( G- l, h" J0 w/ y; F }
' V( L+ S& g' h( Y, ~7 l6 p};
; u6 G0 D) ]5 d u$ t, Y; A
6 F( ]7 L6 o D( @+ |9 @static int __init led_platform_init(void)( n3 {+ c5 M& ]5 G* R- P9 Y
{7 h" P4 |' `; q7 z& _3 e# o
int ret;
8 F8 s/ u9 G2 [$ A, M#if 0
8 q3 q3 D4 X# j2 y2 t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: K, p# R) v( g' N- _
if (ret)
& L/ m3 k. y5 v9 ~ p: a2 m6 q8 m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 {. F* n3 E/ t! A! C) X6 X
"%d\n", ret);
0 x6 `: \8 l3 n#endif
1 O& _, u) n* O; L s3 {5 _1 r ret = platform_device_register(&da850_evm_tl_leds_device);
* t3 N4 e& E5 M if (ret)3 M7 w2 ^6 i; F/ D: |$ k: l
pr_warning("Could not register som GPIO expander LEDS");
: [7 g% _6 [% d8 n+ S else& t! V+ O) d! E% |
printk(KERN_INFO "LED register sucessful!\n");
7 n) j; I% m `& O! L- d- l4 f" I+ p- \1 k P+ ]! ~
return ret;
9 T6 g" g, a- c5 H( M}& ^; t$ A9 L4 Z3 g! c- u
8 i7 [$ I4 j! }static void __exit led_platform_exit(void)
- ]7 A1 _$ i% q6 Y. t{
5 V, \" x- H3 y2 a# U platform_device_unregister(&da850_evm_tl_leds_device);
" @% s' ]5 b9 {
( t/ v# Z K( w+ U, W printk(KERN_INFO "LED unregister!\n");& ?8 J. d$ o; u/ z% A
}" H7 P1 J) c1 t0 q7 y+ r/ E
* l: Y- b8 }' k5 H# l
module_init(led_platform_init);
7 F, S( D) j4 c9 H; m6 [module_exit(led_platform_exit);
. F1 c% ^6 J7 A7 Y% m. K/ o
! `8 _2 U4 J( w4 D5 _8 Z5 f% m+ `MODULE_DESCRIPTION("Led platform driver");& g8 ^9 h5 [. i4 D
MODULE_AUTHOR("Tronlong");
, U8 X% V" t. G0 H- j! q1 P. KMODULE_LICENSE("GPL");1 w0 I' Y0 ]0 X% C- g/ u
7 h) ]5 |4 D! P6 ~! v7 @2 T1 V
|
|