|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; I1 C" p; K' r. r# R+ {#include <linux/init.h>
/ r4 k" `6 L; M( W+ o#include <linux/module.h>4 K4 n4 n5 q7 b5 K% S# B
#include <linux/kernel.h>. ], h% D3 ~# x: A
#include <linux/types.h>+ J$ w/ N9 \9 u# E0 }' W
#include <linux/gpio.h># @, ~5 I6 p+ k% Y4 S$ e! D/ f
#include <linux/leds.h>. { K& h- m7 A+ P* C+ M& h
#include <linux/platform_device.h>! L. Z; K4 _" K
! c( q7 Z4 G: f) i# k' y$ w! M#include <asm/mach-types.h>6 J# [' b5 c/ L
#include <asm/mach/arch.h>) q& ~( a/ k4 ]7 w; B
#include <mach/da8xx.h>
/ h& N; k: s' y h#include <mach/mux.h>
% ~6 K5 d) z! ^6 R. \1 _( R# L, d: L$ `4 Z; X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 i/ C' }2 u/ K, u7 L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
j6 k5 D. H8 d# V+ }% |; O#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) p3 s7 a; Q# W7 \* E. u. W m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ u+ d R, v+ r1 B) o* F* J7 f
) B- b; [5 [ c% ^/* assign the tl som board LED-GPIOs*/
N R; s: y# [' jstatic const short da850_evm_tl_user_led_pins[] = {" u j; h6 u6 B9 X5 U, p
/* These pins are definition at <mach/mux.h> file */
( w2 Q0 |7 r, L: _2 ?$ V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 c( f1 \4 K8 A% t
-1
p# S P( g9 H& s4 u: e2 g6 A! F" \* l};& \3 k \! u5 Z) X& W
7 n- ^" l, Q2 ?static struct gpio_led da850_evm_tl_leds[] = {% |( L" v8 o& K/ A$ {/ F) u
{
: r3 K7 C- m7 m' _ .active_low = 0,
: d6 i+ r% G" O( e$ ?2 h8 C2 C .gpio = DA850_USER_LED0," | N5 X8 u s6 S# @
.name = "user_led0",/ o p1 T% f* J( y0 U+ h
.default_trigger = "default-on",6 o$ S7 Q9 ^ {/ D! l: \2 V
},
$ a4 W& f' g* |' u% ~6 V {
$ V, {( h5 l( X8 D" @ .active_low = 0,6 S* _4 F' p$ y; E
.gpio = DA850_USER_LED1,, F/ W: ~: _% H7 T& q
.name = "user_led1",
3 J! |$ n$ r4 q2 `4 ^4 V% ]% k. } .default_trigger = "default-on",: b6 C" A5 t/ @( G, g! k Y- z1 [
},
! d+ e* z8 A1 f6 O, P {9 V% x& P. c+ @0 a; \* z' V F' a
.active_low = 0,
0 @& h9 U$ |* t1 n4 v .gpio = DA850_USER_LED2,% x6 V& j8 U, r1 e6 k
.name = "user_led2",4 P3 e2 p \3 i! _: Q, G
.default_trigger = "default-on",- q: @3 X+ c6 O. U. h
},. x! S, {/ S! \
{+ S5 Q6 r4 W0 w* g
.active_low = 0,1 e# `- T) G% o7 L* F4 T% I8 i
.gpio = DA850_USER_LED3,0 q* ^$ E& \+ u2 ^
.name = "user_led3",
. B- k- b1 j5 {9 y+ Q .default_trigger = "default-on",
; [, e! `* q9 J+ V( j5 o5 Z. @ },
! M+ [& I8 C0 s W% x$ U i};4 e& S: T7 d. E
# H0 s$ X9 V6 Y- \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 h" C! U8 C% E' `$ w) c1 o
.leds = da850_evm_tl_leds,2 l' U- b" W+ k! a/ E8 L2 [+ U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: {+ u4 h& V* W$ [4 L};
1 B+ D( N' M- z: J9 F4 B: ~+ l# x3 o# _
static void led_dev_release(struct device *dev)
* O. O! E! r7 w( K. S5 o{/ i- I7 E# F# j8 S
};) p" C7 Z5 ?8 ] ^
5 C! `' s4 I1 w+ k0 _ mstatic struct platform_device da850_evm_tl_leds_device = {8 F) Q) L0 i! {# G3 B
.name = "leds-gpio",
/ k) R3 Z- o5 o1 b3 j" O/ E0 x( f. B .id = 1,
$ u1 M3 I: W. t V/ I5 W$ H/ a4 F .dev = {
- a! x' O" Y7 G. m .platform_data = &da850_evm_tl_leds_pdata,* u! I- b$ p/ K2 ~7 b+ S
.release = led_dev_release,! h+ S1 [- l+ b, h# n
}6 u* e$ e( {# u3 c- k
};/ e- X- [+ V& ?+ T- T! b" j6 `3 r/ ?0 C
. d. \6 f2 I+ `; Istatic int __init led_platform_init(void)
- X5 _1 H1 s! h{
# `2 U# y7 ^$ U' U/ ^1 d* C int ret;
5 ]% p! j6 l. ?5 z9 _4 c#if 03 Y; M& F9 f6 D8 n. M$ h$ ~1 v; H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); w8 B5 S* o$ }8 j9 w
if (ret)
! y E! F! ^. \2 W% @) n: B/ j7 P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
Q! b* q9 X. ^ u. K "%d\n", ret);+ z! Q* |- E5 d: P* _
#endif
/ {, Y g5 e. _+ D8 \ ret = platform_device_register(&da850_evm_tl_leds_device);; d8 q9 K) }9 x# p5 r
if (ret)
( g( |' }/ g, f# n& |9 [ pr_warning("Could not register som GPIO expander LEDS");' l. b7 C$ {, Z% |+ t6 k8 ~
else
7 @7 L5 {- P) Z* G* N6 a1 }) P printk(KERN_INFO "LED register sucessful!\n");: `; S! |( v& w9 Z
. @* I0 E7 B; n/ N
return ret;- K: O! W2 F9 O R: g1 v) S( x
}
- c) @( c7 r- d% R0 B. k- l! s( i
static void __exit led_platform_exit(void)
# _& Q. {* N$ _6 l. P{
" K0 x, @: X/ `0 T( ]% ] platform_device_unregister(&da850_evm_tl_leds_device);: F3 ]' q2 Y/ F* _
& o$ _* k/ F6 M+ |2 I
printk(KERN_INFO "LED unregister!\n");0 H0 [ A& [* y2 s6 a6 K' Y- x
}6 @( b2 n2 v/ E( X! G f* n/ o* |
6 v, v& D9 B0 [( }$ P" {8 Ymodule_init(led_platform_init);! u; a. |( \3 }! Z" B
module_exit(led_platform_exit);
( d: ?: m& P* _5 V, s' |* \9 o$ Q7 G. z4 o- s4 g% s
MODULE_DESCRIPTION("Led platform driver");
! e# T/ s% o! J" s' |4 r; C1 y, ~MODULE_AUTHOR("Tronlong");
8 H6 Q' e7 u& p( M- a- Z7 Q3 g( uMODULE_LICENSE("GPL");9 U+ _! n9 }( c" y1 X5 s
% f" U! w4 y A7 P% K i4 D3 I
|
|