|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* U& T; n) a' Y* L0 R1 O, Z#include <linux/init.h>
" c6 W' _5 W* a7 @* y/ ^#include <linux/module.h>
7 a+ q! i) Q- b8 r$ A2 M3 j6 [2 R#include <linux/kernel.h>, i5 k) @" A% Y ]& | s
#include <linux/types.h>- _6 o4 W7 g: O% x+ x( Z! V1 u
#include <linux/gpio.h>
; p% R" Q m% l6 Q7 w* C0 w#include <linux/leds.h>/ d# |5 ?7 v, n
#include <linux/platform_device.h>
; K2 r' m. X j$ w9 P( f2 \
3 c- f2 |* [; g/ {#include <asm/mach-types.h>3 d# Y/ U: g0 E9 \( q" h7 I
#include <asm/mach/arch.h>* F2 Q) p# i# }. |' M% y
#include <mach/da8xx.h>. ]$ _" T2 _5 E F3 m/ D- D0 b
#include <mach/mux.h># V; ~% l$ X0 m, d$ l4 j3 k+ L
$ S z* m( o f0 P1 f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) E; H6 }0 C( T8 G; W7 t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) }( [2 m- N/ ]5 e S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 l$ h, _& h2 ~2 R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 o* k* q3 q$ j) T. \. l, f
, r5 K( m# u, Z+ |+ H% B! L3 R
/* assign the tl som board LED-GPIOs*/ F+ M! X8 V" a0 e7 @
static const short da850_evm_tl_user_led_pins[] = {
2 u; S. |: t3 e+ L- ? /* These pins are definition at <mach/mux.h> file */
1 U& |/ B. B. D8 y- }) g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- k( C8 p' ^/ R; ^7 X2 c/ q -1- p5 l7 q+ X# h) @+ c" c% ?- w% y
};' N. ?+ ^: C6 o% t1 Q/ W9 P- f d
- z4 x4 Q. s1 ?
static struct gpio_led da850_evm_tl_leds[] = {
^1 F9 Z! s }* u3 ^ {
" P4 z o! e; l/ b5 G4 [4 I .active_low = 0,% n1 X- I' t1 z+ A3 c$ B
.gpio = DA850_USER_LED0,
3 Z( o4 X' z/ c4 u. j, c .name = "user_led0",
4 V" h$ i6 D2 D4 _ .default_trigger = "default-on",
8 f, D$ h4 ]9 d6 f5 l8 i4 _) H+ g },
' p G( p. t, I0 o9 W {
! r" K- z- m6 n3 B- g" X .active_low = 0,
2 b, e" J7 }8 p+ A; J% S .gpio = DA850_USER_LED1,
+ Q/ M6 Q7 ]6 L+ Q .name = "user_led1",
f0 e, a s1 L4 | .default_trigger = "default-on",
. S; f6 g0 H- i0 F3 ?* s },
+ ~! J. {1 o" G% _. g {- F- D; d6 ^1 }# M. U
.active_low = 0,
; B' I! b/ G! n2 ^) F .gpio = DA850_USER_LED2,
: C; }0 _; j9 B" ^4 w- l: @ .name = "user_led2",
- E0 R0 F8 v- ^( K9 Q! ^ .default_trigger = "default-on",
4 A' V8 y& ]" x8 u: I+ @ },0 E" C- C) o# T0 J5 y
{
) e0 H5 T% _* H) S$ N; R .active_low = 0,% e0 U" p9 A: | {
.gpio = DA850_USER_LED3,
' D) e$ z& v: M9 s0 t0 y& w .name = "user_led3",. O( I9 h! P7 M. z" n8 k" ^
.default_trigger = "default-on",
. H8 T: W) r. W1 i; n! a* W( B },- z. G8 {7 e4 b- @
};
" R6 h/ E6 d8 J1 z* ]
0 D$ k5 A9 d4 Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! Q* a# u+ S/ d5 c* @/ ?
.leds = da850_evm_tl_leds,
. l- o0 D0 D) t8 M( E* N) I .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& S. t/ M$ ]3 E};
% R$ F' i+ `$ e9 w
5 l2 \3 d- ?7 Wstatic void led_dev_release(struct device *dev)
1 t. N; b' \5 e$ Z{% t/ | c. G c1 g2 j$ s: {6 ^
};
3 W/ Z, Y" b" K; t( |
( d; {3 ]& ^/ v4 f& e" d$ astatic struct platform_device da850_evm_tl_leds_device = {
- j! J. U2 C. j6 O# C, [ .name = "leds-gpio",
! H$ K2 R# [- b .id = 1,% Z: ^& y7 y& V: k x9 }2 b& _
.dev = {, K# X# _( s5 o% R, A* v* P6 m
.platform_data = &da850_evm_tl_leds_pdata,
: |: ]1 t, z: g# K f/ E+ U7 d .release = led_dev_release,
0 ~) ~& t* X6 ^; ~) \+ i }/ J' t9 Q5 Q2 h2 ~& S5 N
};
/ m: o& \# n6 S. N+ H
; J" R; ?/ {1 }) |% K0 _static int __init led_platform_init(void)8 i5 j" F) U7 @0 ^ ~; D
{
, c3 h" m, g: F" l2 u, @( N/ E int ret;% {: K P; z9 ^% x; S+ C
#if 0/ m! a# K- R% @: L% N( J- Q P; d3 r
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 b! d p8 y5 ~5 o! w. e8 y
if (ret)
1 O/ l: {: ^9 |7 u* A; n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 P$ O- y: U- r5 v) D5 p5 p "%d\n", ret);7 \. l1 W& T4 r. i2 V/ V
#endif6 X3 V& S7 {% ]6 z, v" t
ret = platform_device_register(&da850_evm_tl_leds_device);
/ r, y* [3 J4 Y4 I( H* t# ? if (ret)( a* S: T; V$ f; V
pr_warning("Could not register som GPIO expander LEDS");+ `2 a5 C) V0 ~7 ^2 z
else
8 t& s O, v6 E& c0 r7 A. L printk(KERN_INFO "LED register sucessful!\n");
9 W7 m& R1 n4 A* y% A$ ~7 ~* A7 u! P! L4 i/ P
return ret;$ o# t' }1 [% ^9 B+ B& [
}$ `; |8 x& i) n% ^2 ~3 z$ d X
* V- d( P+ `) astatic void __exit led_platform_exit(void)
% ?2 R. T0 ^5 x1 `& I$ [$ \1 R{
5 h' m8 ~( @: x% W( | platform_device_unregister(&da850_evm_tl_leds_device);
J- u! E) ~1 L& x- R2 a! h6 v5 m1 l& Q7 Y! P# Q+ l
printk(KERN_INFO "LED unregister!\n");
B5 T g% z# m$ \( Q}
* O: E/ E% v( N: v, x4 d# p# j9 L4 X- P7 B: A
module_init(led_platform_init);
" l$ F ]' }2 Dmodule_exit(led_platform_exit);
# j: Z/ H8 x! P
8 @- o# k1 l Z5 D: I7 L& b( |MODULE_DESCRIPTION("Led platform driver");
9 v" G3 a4 }% t3 |% iMODULE_AUTHOR("Tronlong");
1 j8 y& m+ F9 h# w5 MMODULE_LICENSE("GPL");
! k& d! e+ e, N* S1 ?+ a/ o& Q
. ^9 A9 d T8 g5 F |
|