|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) s0 Y) w7 B. M. S1 b, s" r#include <linux/init.h>/ a1 @$ L: m1 b
#include <linux/module.h>
" v- k8 P6 b$ X2 ]3 P4 U#include <linux/kernel.h>
5 x6 j/ H" t' a' T. K#include <linux/types.h>
6 ^3 f- L( h2 G# j#include <linux/gpio.h>* w* q2 _0 _1 k8 T
#include <linux/leds.h>7 z) J W5 Z0 j9 B* f6 M) N
#include <linux/platform_device.h>4 U9 G) [$ h5 i3 m& m- N6 i
* ?! [4 _& A# F- q. a! @9 r
#include <asm/mach-types.h>, N, c$ X7 o9 @2 g$ Z5 Z
#include <asm/mach/arch.h>
$ Q7 n, l& G& T8 q( b, h6 i; R6 W# a#include <mach/da8xx.h>2 B9 I$ G8 j0 G5 ]/ E
#include <mach/mux.h>
9 u/ j6 q% P* K: [ i" u( e' A
5 }2 f# Q; g3 \% N. u0 F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ i3 Z+ [# u; \7 p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 l7 Z0 I% C9 P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 N2 d' f6 I, {9 l I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 O2 x( A0 x. P2 k) J" ^- y
! ^" N# N0 z! \& L7 ~/ Y; d/* assign the tl som board LED-GPIOs*/( A/ x/ ]8 C8 @' a8 z9 o8 ~
static const short da850_evm_tl_user_led_pins[] = {
. i, l5 t% m: Z* q) Y0 e: w /* These pins are definition at <mach/mux.h> file */% K: Z, k" t5 [ i0 `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; Q" P1 ^( d# | -1 S0 H1 y$ n ^" t. R) L
};
8 h" _# J9 A, q, u; J9 D m
$ p; |: c4 i X b F. m8 H; Zstatic struct gpio_led da850_evm_tl_leds[] = {
; _( V- O% [ v& J/ p {
0 t6 p0 H, _( `2 t .active_low = 0,1 n) c4 r& j. N" D" i. L. t$ Q
.gpio = DA850_USER_LED0,
/ T% L! M1 L6 P' T- i0 m) p* Z .name = "user_led0",
7 G/ m/ @4 R; C+ m4 Q9 a .default_trigger = "default-on",
$ l# @, X% Q1 o P+ I m },
8 ~, T7 @+ A& a; m: f {
+ U* y6 k" v2 `" \" `) \ .active_low = 0,
& L2 M3 Q$ C2 d- X .gpio = DA850_USER_LED1,5 b& F2 l4 G+ K% x0 d- x+ @
.name = "user_led1",
. M) i0 L" }$ U: J .default_trigger = "default-on",5 s5 k5 U9 W* `+ @
},+ {- S& W+ D" {% ]/ f( ]* [
{
# Z h2 o' k8 \8 B( E. D .active_low = 0,; k) y' O2 ?* h% R/ A- C
.gpio = DA850_USER_LED2," o+ ~4 F. P: w f# g
.name = "user_led2",
5 Y9 p" c+ [- y. r .default_trigger = "default-on",6 o* _/ Y$ c2 B; O* D1 x1 J
},
7 i& A2 G f3 H8 A7 w/ _+ h {, h4 |$ @, @/ P, ^" ?
.active_low = 0,
& @6 g; L0 ^; Z& K0 B+ ? .gpio = DA850_USER_LED3,
2 N: E3 ]; X; [" ]7 v7 x% b .name = "user_led3",
; }5 n9 N! K3 W0 m .default_trigger = "default-on",
8 _% ]4 ?% U7 G6 Y r2 \ },- g ?( [( _: L2 }& i
};# B4 _* T% P/ n# a# l% Z# {
& o& q8 y- H2 C% vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! k) |% f2 j9 Q! J% ?/ L
.leds = da850_evm_tl_leds,& w3 l4 x' z* i4 D) M/ C( D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; G2 I A4 V2 T' O) `
};
8 [1 y6 l, |& ?) m1 `$ ?6 G, y- z q
static void led_dev_release(struct device *dev)) \3 ~% _! Y& y9 Z! M
{
( [+ S3 X( O; p0 s};
7 ]5 u" b) K3 C" l. B$ A4 `- w4 f) m6 V6 a
static struct platform_device da850_evm_tl_leds_device = {0 I! A: Q/ I5 _8 n% u: P9 h& {9 {
.name = "leds-gpio",
' E" c; o0 y3 e) R .id = 1,
( ~) d0 O" ^/ u) w J: R: [0 O .dev = {
A0 |+ P% Z7 l .platform_data = &da850_evm_tl_leds_pdata,6 A5 r2 h2 z4 {3 ^7 ~) O
.release = led_dev_release,2 g$ \6 s! }$ w H; _, Q
}
! R* ?/ D# d+ E6 t8 l. Q# J};, x% i& R; P4 ]+ g, V) Q6 t9 {9 ?
; ?5 y6 L7 Z$ j- V8 w8 estatic int __init led_platform_init(void)
( t' |3 v+ ?4 ?! ?2 d |7 Q0 Q; Q{- W; m' E) A; ], u6 b4 q( g
int ret;' t- U+ v) P2 t) K: j% v' u$ M$ ` }9 E
#if 0
+ h7 Y( ]9 g1 A$ N8 C" f ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 r( [) V% }' e
if (ret)
0 h. }6 G" S2 u( _9 } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ \/ J1 K6 X1 d4 Z( B1 I; D. i
"%d\n", ret);
* Q$ i2 B& u4 [#endif$ T; T4 F0 E H. A5 ?! o" f& k
ret = platform_device_register(&da850_evm_tl_leds_device);
% s$ b7 n0 t/ r' f+ Q if (ret)+ U- f' ?8 \1 ^
pr_warning("Could not register som GPIO expander LEDS");
. ?- p( o2 V9 a+ M W else
5 ~4 r$ ?6 m8 W$ L. l! m printk(KERN_INFO "LED register sucessful!\n");% z/ y& _6 _; J( O0 d# K
, T2 A: f2 t. `( B
return ret;/ O/ |% K, k8 G" t, a% l, ]+ y6 w
}
% r2 R% t6 w! X' e. R+ C; O" C! {0 r5 C( w1 i. H
static void __exit led_platform_exit(void)
6 {0 P1 B. S5 i{. c5 Q9 e0 ^& T2 U& E8 p
platform_device_unregister(&da850_evm_tl_leds_device);
( Q8 x8 x3 m+ n: V- }, S+ r, G6 b3 K: Y# B5 v6 I
printk(KERN_INFO "LED unregister!\n");
. g# L1 C/ y# w* z* Z}
9 }6 @+ p+ p) h# B! ^, ~. f' c, o) K/ [$ K/ A' X" X& y
module_init(led_platform_init);' [( r4 f0 h d& Q' Z8 g- h8 X
module_exit(led_platform_exit);
# \, A6 P$ x1 n/ v o1 _
+ j4 M; Q/ R) g* J: h7 gMODULE_DESCRIPTION("Led platform driver");
& t+ {3 m, S. c3 oMODULE_AUTHOR("Tronlong");
& E3 `: h' r7 q7 S* S9 bMODULE_LICENSE("GPL");
0 M6 ^" j0 N6 i+ Z' r, C( T9 Z- D, } G6 k, m4 E
|
|