|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 D) x1 ~' w8 j, E2 Q/ e9 W/ [0 f
#include <linux/init.h>9 [6 o+ n% o! B2 [: ^* m- D
#include <linux/module.h>" ]- H6 A! [4 R z, n
#include <linux/kernel.h>4 B% d) R% K' m
#include <linux/types.h>( s* K; J( L/ ^" u6 n* T
#include <linux/gpio.h>
6 ^7 g( Y# { T- ~, U# \# M#include <linux/leds.h>
, E7 C0 A% V# h0 z#include <linux/platform_device.h>$ \) a N* ~1 z# t# I
2 I+ P4 t0 T- B( z9 j#include <asm/mach-types.h>* K* Y" I4 N' D- A2 r. J/ a
#include <asm/mach/arch.h>* k. i- h `( ?
#include <mach/da8xx.h>: G8 W" F+ j- e8 b4 j8 ~+ x
#include <mach/mux.h>( ~$ v: u) w& x5 \+ N
. t1 T2 C) ^; ~5 q. P8 g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 g X V; d% M2 J& j& u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 n, G6 D/ h( B$ E, l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- H1 P3 j7 @3 j$ B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 b5 v3 v* c2 o; \) ]% V( _7 ~3 r# W, S) A& O( C; U# @
/* assign the tl som board LED-GPIOs*/* y4 D) Q+ @& x6 M! Q, D
static const short da850_evm_tl_user_led_pins[] = {
& W5 G: T, m- s/ q0 b/ b /* These pins are definition at <mach/mux.h> file */
`9 l$ t$ e6 h. S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) \! s6 D$ Y7 @4 d
-1) ]( X2 ~# F G( a, x
};
( w$ c- q$ w: L, ]) h
6 n( q0 m) \ g7 M& r$ istatic struct gpio_led da850_evm_tl_leds[] = {, A. k* J$ p3 w' @5 u) y, s2 t1 t
{
! y' l- _, w6 k+ A3 m .active_low = 0,
0 g9 j6 A, B$ ^2 _ .gpio = DA850_USER_LED0,4 f2 w; [, `( t3 I5 x
.name = "user_led0",' [% z V5 G2 N# q& `) ~ K
.default_trigger = "default-on",0 Z& S0 Z t K2 N- q7 f# `. r
},
- g3 S4 F8 K; ^. m- K# M {: ]8 N6 n& q, p: p4 G
.active_low = 0,
5 X: U9 b" P1 K7 Y) A' n; Z .gpio = DA850_USER_LED1,
1 T+ F; k# X$ W% J' z .name = "user_led1",2 f; z6 C7 }) J
.default_trigger = "default-on",
2 h- l6 u6 M8 Z) o },
! r9 {) N% s* m {7 q6 P/ t% f b! p* f
.active_low = 0,. \, M- g% h4 E; Q; W
.gpio = DA850_USER_LED2,4 x2 R1 w! X# F* t3 k
.name = "user_led2"," g( _$ K8 w; t% a& [* S2 g1 D) x
.default_trigger = "default-on",4 l3 I }/ i/ {. L+ Y0 p
},; {3 X g" z( f( R9 D3 v4 ?0 O
{
& I0 v1 Z* K3 f- U3 g2 v2 q .active_low = 0, a2 [. t" H$ ^' Y2 k
.gpio = DA850_USER_LED3,
2 y9 N Q, T* R1 Q1 i .name = "user_led3",
8 d1 O# q5 r- @. L4 L2 D% Y .default_trigger = "default-on",
; u7 t: @) E9 n( v; [7 G },8 f7 i/ F- N( b# F+ s9 g1 j
};
7 g W' g0 Z' l |
+ X# s6 Y1 c astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 Y+ R0 [* K6 \& q+ P8 y$ k ?+ B
.leds = da850_evm_tl_leds,
) v5 |( @/ f2 ^% W2 Q: l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, ]* D" s r$ G0 v# O8 H7 D1 s9 ~};0 Z% G! m6 e; h4 P/ h
|3 d% b" J, O/ l
static void led_dev_release(struct device *dev)9 Z! [5 U4 h3 ^: |! g
{- G5 H- y8 w9 w1 t) b l0 O
};
) |) ~5 s' i% O6 L5 A, U7 |. j* R0 Z% v- }/ D
static struct platform_device da850_evm_tl_leds_device = {
: l: D, t2 B) [+ I3 T. J# F* M .name = "leds-gpio",/ g L8 ^9 Z( N$ Q/ ?; T
.id = 1,+ c. a/ G4 u& @5 N3 T6 _ `
.dev = {
$ I0 G* [0 x3 B) _) O .platform_data = &da850_evm_tl_leds_pdata,2 @2 i d( l+ Z) `) p, P# @5 A+ T7 a5 C
.release = led_dev_release,
2 U. W$ x. j& H( X% h: L }" u% A) T9 b! t
};
; e4 k4 q1 Q9 i4 o5 y3 g# \
+ n; W" J5 V. v7 W2 q6 O S% {3 estatic int __init led_platform_init(void)7 k& f" j+ P' P) m7 z
{
2 \. d. t0 Q9 q- d; ~ int ret;8 a, B! r+ }. V; @3 x
#if 0
. W$ @7 a2 m) [9 e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* \( m9 [; f( ] if (ret)5 v8 e/ I6 b$ E% W, @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 w# d6 V# j' E
"%d\n", ret);: \9 H- E' T' Q! T/ R8 \
#endif
2 g7 A% {! U9 x( ]% C3 @. y1 h ret = platform_device_register(&da850_evm_tl_leds_device);
6 i& ^; @4 h2 G4 R if (ret)
) e5 A, X b6 `$ h m pr_warning("Could not register som GPIO expander LEDS");. M' p( m+ t% M7 x9 y& g
else
4 k, M- @/ ~1 I printk(KERN_INFO "LED register sucessful!\n");
1 _1 `& ] E2 `. R' Z( l h/ H) g7 {6 ^! q: M
return ret;9 h- w: w( O* q' {
}
5 w( ~7 P0 G: f; T3 Z3 W" V' }0 v1 e
9 S, w. M4 D9 ~' A5 Y+ mstatic void __exit led_platform_exit(void)
5 F5 V' @! ]& P% l2 z0 g' m{
" N k Q0 {+ j @9 a( q2 \ platform_device_unregister(&da850_evm_tl_leds_device);
4 ?2 @8 x5 ~$ h9 A& q) [# y: h8 {
1 V% q5 B3 V: k printk(KERN_INFO "LED unregister!\n");- k( K% N. v' X
}/ A) b& Z* h" |& V3 v2 ~: H, j" S: R/ d
; z0 l! L. T* f$ L5 p
module_init(led_platform_init);
- t6 L" i+ g+ B' a' {; w5 [$ J6 t2 vmodule_exit(led_platform_exit);# q( k' @6 _6 Q, A# Y% O
# C: B. ~$ F. Y N/ n. F
MODULE_DESCRIPTION("Led platform driver");& Z( y1 I' j6 d
MODULE_AUTHOR("Tronlong");" A- c) ~- H; J3 U0 u* N- i# b3 h U
MODULE_LICENSE("GPL"); p* |7 O4 b! N- Z
1 e, B- m# {( a
|
|