|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( ^2 n. }" K" t, W5 T: e1 y#include <linux/init.h>
% g. x, r8 D4 ^#include <linux/module.h># ]% n3 G2 A+ J) {1 X( A7 J0 o/ ^
#include <linux/kernel.h>
% x/ ~0 L! }' J2 w% V6 C#include <linux/types.h>5 k h, s* Y) @: l
#include <linux/gpio.h>) e: Z) m% N0 i5 l
#include <linux/leds.h>: P! V; ~' J# R% e2 `
#include <linux/platform_device.h>+ k/ l; X8 X8 D$ Y% t) T- {7 P
9 J, C5 f1 J* s
#include <asm/mach-types.h>
& W) d. _! u7 O% ?( {1 ]#include <asm/mach/arch.h>
. G* B$ |6 B2 F: Y W#include <mach/da8xx.h>
/ D I& l9 N4 N! f- C#include <mach/mux.h>
8 j p J& l: x$ k9 k, @
1 o5 c% W0 b3 B: z6 K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 o' P$ U9 O5 J4 A* J8 M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 x+ R! s- e8 t" e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- o+ K: s% v. @1 Q/ x0 M7 R( k
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& Q2 k: O. u7 N
9 u; I7 ~' I" C- Q4 f
/* assign the tl som board LED-GPIOs*/6 z3 H" u+ X/ _4 S
static const short da850_evm_tl_user_led_pins[] = {% P( u# z( y3 t
/* These pins are definition at <mach/mux.h> file */
; Z3 `: |2 s4 o7 e+ n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! I% n. N% v. B1 ~( f
-10 Z3 t: U) D9 Q+ a7 d! t! K
};
1 \* @2 F/ j9 M3 Q6 O+ L# D. V7 V8 p
( O) F/ b( Z1 nstatic struct gpio_led da850_evm_tl_leds[] = {
! k5 k* }$ k3 M$ M/ }8 k3 t {- D+ h2 h. o, M2 j4 |- X+ {5 N
.active_low = 0,, O! F2 {0 G0 U7 M' w& M" {7 z
.gpio = DA850_USER_LED0,# R* t- n5 W" U8 \
.name = "user_led0",! O) z# a/ V. T- Q( v1 p
.default_trigger = "default-on",
/ q: i: m' s/ Y1 ^1 Q5 ^' {2 L },
0 H9 O4 S3 x! t# } {! Z6 U# I8 L9 |6 Z
.active_low = 0,* h+ s2 ?3 @! m, i; S. ]3 ]: d( |1 m/ R
.gpio = DA850_USER_LED1,
( n' Z1 Q& j9 I! | .name = "user_led1",
9 r" M/ }+ F+ \* P8 P- R/ A1 j .default_trigger = "default-on",2 T, Y: z2 [6 r$ H
},
. O. b* g' @/ G' o {0 V* U" _) X9 o& B
.active_low = 0,% _: T! C3 e: h7 s
.gpio = DA850_USER_LED2,- K/ S! x3 C" B* s- |
.name = "user_led2",0 u ~* H3 p$ D
.default_trigger = "default-on",
& Q8 W+ }8 k: I. i! S# ]* Y+ k },
* e+ |8 L y1 ~ u. m {; u9 Y) i& f, A
.active_low = 0,
- g0 i5 ]* D) ^& J5 H0 \ .gpio = DA850_USER_LED3,
% U! T& }9 |& }( l8 C0 C6 ` .name = "user_led3",
- w! u. Q9 }4 n b .default_trigger = "default-on",% t2 n" F" W* g- q
},* C C7 h7 y4 ~% F& m: _
};- A' d8 s4 v5 K& x
& @1 g4 `! ^/ ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 O- K2 ~. |2 @' D
.leds = da850_evm_tl_leds,
1 Z8 M# X* w3 b! ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 R. q1 O7 j* @6 B" Q, |};* i3 N( P8 u) ?# V, w
8 i# p% m3 @8 e: C% G# tstatic void led_dev_release(struct device *dev)
5 A% k7 ?6 S3 P% x$ B: R% C& L0 i{0 A9 s$ }$ g" C
};
! [ }" \* a9 @- S+ u! i. b
# n& X* A3 \& ^0 ^% E0 N4 bstatic struct platform_device da850_evm_tl_leds_device = {" I) c3 M8 A) g5 H. Y' _- l
.name = "leds-gpio",
) V k# B2 @! a8 k8 S! l .id = 1,
& K1 O; G7 z x .dev = {
, K7 Y* w9 v. I3 Z: Q .platform_data = &da850_evm_tl_leds_pdata,1 W' A0 j" M; A( t
.release = led_dev_release,4 n" @$ O$ u3 z! t
}* H4 M0 B- e- O+ y0 D! F
};, k4 |2 W+ j0 H4 G# G
4 E x0 X# F; f6 Ystatic int __init led_platform_init(void)
N4 ?; P6 h9 Q. A+ B& y{# w' J2 `1 n" j5 N! L; f
int ret;
6 c1 j7 w Z3 d/ g3 J- c3 B#if 0
" m+ @ L4 k) i. r6 V ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. ]% y8 x7 J8 Q: Q' j7 h+ {
if (ret)
w. C8 L, B* g6 I6 J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 r" Q8 I5 D, n+ Z- H: b! _
"%d\n", ret);" E/ t O+ R3 Q/ k5 r' W6 |; ^
#endif2 L3 r; y: K; Y
ret = platform_device_register(&da850_evm_tl_leds_device);
0 ]1 ^4 q: r; v: M2 T if (ret)
! T* A+ _) R4 _) e: R( f5 E! D pr_warning("Could not register som GPIO expander LEDS");
$ j7 B+ y# S0 }( _0 l" } else
! `+ d/ m2 [' q5 o, ? printk(KERN_INFO "LED register sucessful!\n");
. }; M3 Z$ Z7 Y& j1 ]( T1 M9 O6 z( u! M# U! s& z, b9 ^/ J" l
return ret;6 z9 N# W% E, T: r$ Z1 i- G* e
}8 ~0 d# m1 Y R) Z X
: Y( t2 D* B' T0 g [6 K% c y
static void __exit led_platform_exit(void)* m! V* A6 O+ m3 M4 _
{
- O% D- r5 z. T* t: {& t platform_device_unregister(&da850_evm_tl_leds_device);
# I1 J* w6 ]- M
; f _* n- {8 o; t( r; g O# r) B printk(KERN_INFO "LED unregister!\n");
8 |6 E4 t& F2 i9 c' g/ [9 ^}. l$ k+ ]+ |4 M0 T. Z: W
& z2 K- x8 |$ r# Omodule_init(led_platform_init);5 |' v; Q+ x$ |( y9 w: ]
module_exit(led_platform_exit);- e, s/ V% F' j/ M% U8 r8 T
% v# v% P4 _" M7 l9 G6 S+ E4 A
MODULE_DESCRIPTION("Led platform driver");' N. D) F. g( Y" k% c2 r
MODULE_AUTHOR("Tronlong");9 F) |+ s. l8 }; ^5 r( f
MODULE_LICENSE("GPL");
* t% W: X% r, D8 g" M
8 v6 p, P# \3 r* L) m8 o- d |
|