|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# [6 z$ Q c4 j. k4 O3 i#include <linux/init.h>
- _ y% l# G" v& H) X- P- X% |" y#include <linux/module.h>
/ P& w7 h$ ~) C' u2 D/ x( m0 M#include <linux/kernel.h>
3 h, }. J& i+ E7 {#include <linux/types.h>! w; L2 C7 {, S. V
#include <linux/gpio.h>* o, h8 {9 R0 H4 C% X) T
#include <linux/leds.h>
4 w, F/ o; N/ x% D. B#include <linux/platform_device.h>: G% n T& v( X4 Q
0 _9 e4 u' `1 X#include <asm/mach-types.h>
4 ~" q( Z0 A8 d ?#include <asm/mach/arch.h>* d7 x. i- S$ M& E& R# }
#include <mach/da8xx.h>
3 q1 j) k5 S( ^, |* ~$ i/ H' n$ W#include <mach/mux.h>
$ {" F) p' {7 a8 O
9 q5 m v8 h B q9 J! X: y- E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' b `; {/ b# l- w- i5 m5 z: b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 w( p' F+ \7 ] Z! G% L/ w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 Z/ l6 L! t6 N3 k5 `$ z1 q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) B* j- B( B' G9 w; o
" @ z# k4 B( }5 _$ d4 o% V
/* assign the tl som board LED-GPIOs*/0 i- W5 T) Q+ v1 z9 a
static const short da850_evm_tl_user_led_pins[] = {! ^* G: z) g* {/ H
/* These pins are definition at <mach/mux.h> file */
" p( G+ w" {: d' W1 @9 h5 q* A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* U1 ^2 w4 o, ?2 M1 x0 I6 ^( }
-10 F( w' m% _( p- v. ^ p; [
};9 H: a9 ?, X- _3 C/ P Y. v' c
+ s; d) N9 ]0 O$ B/ t l1 U; r! `
static struct gpio_led da850_evm_tl_leds[] = {" G" n# q5 O* J% R2 a7 T
{
3 [3 y# I; f6 Z- A# U1 r2 G .active_low = 0,4 O# d1 R& e; w5 ^% C
.gpio = DA850_USER_LED0,
8 m/ a* H T0 S! I+ `) [ .name = "user_led0",! Q" c& t0 u) d& W1 G7 Y
.default_trigger = "default-on",2 G/ j9 e) o1 Z4 s5 {
},$ y) k% f4 l; N7 ?
{7 q' _/ [/ _$ h3 B5 G
.active_low = 0,
\: o( |% B5 f! s& ?; l; s .gpio = DA850_USER_LED1,
3 j- ~3 M4 r$ ^0 E% {( r: V9 f .name = "user_led1",; [2 j l# L. V0 X! ]' N
.default_trigger = "default-on", P5 F; E6 \+ z0 u4 ]- R0 \8 F
}, s, K V, w+ |1 M) X) J
{# y& z" I7 m9 I) e# M# `5 }& B
.active_low = 0,
6 Q( J3 v. N5 z. U& P3 m, j$ g .gpio = DA850_USER_LED2,' T) g; p! @! I1 Z$ W. i+ h8 }' v- i
.name = "user_led2", D) s6 D" q& x8 g; |7 j, W
.default_trigger = "default-on",
6 I0 c0 U- c( z, q: p0 T },
5 @6 E9 d! J2 { {) m. K/ T6 W, L: I
.active_low = 0,
( C( U! @+ Z/ l6 ]' V w .gpio = DA850_USER_LED3,8 y* @ Q# T2 b" c* c
.name = "user_led3",
, |" q x: d; z5 A8 y7 M .default_trigger = "default-on",* E% T6 r2 L4 {" m& C; }( D: u
},7 N) `1 w4 w U6 E
};
) o% @: _4 j" p7 D: `) L. v' Y
7 D% E. g) `+ H- f1 t' ]8 gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 O0 Y$ c6 h0 S. E' X1 ]. R3 x2 g .leds = da850_evm_tl_leds,3 {2 S% W9 N \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. ^# z* ^/ F. a2 @1 i5 i7 S1 Q};3 U# z; v& s. U1 p
$ V" }# v8 T) `: c) ?) N
static void led_dev_release(struct device *dev)
# `0 _" H2 S. n* r9 H+ i9 u1 s{
6 n4 D' K6 K4 P+ Y( d7 K3 j5 e; M};! P- h |1 f5 s% r5 a
% z" j8 ?8 S' D: }9 v5 }
static struct platform_device da850_evm_tl_leds_device = {2 s& b: ^; r7 o! v
.name = "leds-gpio",: V2 J, b5 ~3 D9 V; o5 _) G
.id = 1,# ^4 `; T2 L# \6 ^0 l- u$ q
.dev = {
' R# v8 G$ U9 H .platform_data = &da850_evm_tl_leds_pdata,
5 Z. A7 F( }" f5 J( |/ W8 y .release = led_dev_release,) W X- {1 [* r2 h
}
5 a$ k. N7 y/ h2 N, n2 b0 i0 f0 ?8 b};5 N( o/ J2 p$ e
. o2 e% I7 Z/ ^- ?! k1 ~2 d$ u4 x2 rstatic int __init led_platform_init(void)
: @4 q# u: x4 ?! s" w2 Q4 g{- Z; s* ^1 D2 c# D" V8 }
int ret;
) C, H3 y1 b7 ~+ t9 C#if 0# |5 t5 |! m! M1 ~, K, T4 p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: v6 m$ x* L1 {. I9 o3 y* P
if (ret)# K% g# a# [( V9 H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( P! N( M7 p5 n# P6 D" c "%d\n", ret);4 b9 S7 J- M9 a" w5 g3 a
#endif( M+ Y6 Q* A3 c! E3 m) k5 P {, [
ret = platform_device_register(&da850_evm_tl_leds_device);
9 Z8 o% x; D: B g if (ret)+ W) X+ r3 R" m r
pr_warning("Could not register som GPIO expander LEDS");
6 N4 T2 M3 T1 [ U6 X else. o: l& i/ e3 R0 N8 ^% N
printk(KERN_INFO "LED register sucessful!\n");
$ p0 y1 ~9 i4 l' n3 c. e( N4 k' `1 y' m: r5 d% S1 [
return ret;
2 K) P; l0 c" C/ j4 K# |}
6 t8 I5 n5 e9 R+ {' f, l, G# X0 S! n. ?
static void __exit led_platform_exit(void)
- ~9 c* {$ S1 ^# e& H+ a{
4 y# @. f( Z; s9 W$ A1 D) B4 X* H platform_device_unregister(&da850_evm_tl_leds_device);9 h% C' t, e) L: @1 W8 e8 W
- |4 a! W# B d3 l
printk(KERN_INFO "LED unregister!\n");
% K7 U- ?( k. X3 Q2 J}
: c' f# h. h- Y# ~, `& N2 r, h& d$ h) }" S1 Q4 s7 u; E1 H2 v6 u
module_init(led_platform_init);
/ ^1 V; I9 q: \& D7 m7 X0 ?. lmodule_exit(led_platform_exit);( K V; t# w$ Y3 a8 k
! t4 [& P( m- d6 I8 D
MODULE_DESCRIPTION("Led platform driver");$ Q6 a+ l) Z+ z9 j" C$ G4 V6 n
MODULE_AUTHOR("Tronlong");6 O1 y6 h" H1 o1 ^% C
MODULE_LICENSE("GPL");9 B+ J% s H. p( w
2 v9 Z9 o8 F2 H! a0 t
|
|