|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ p: E, n3 }" x. s' U) W#include <linux/init.h>
" T" H6 N2 q3 _3 V+ B" n#include <linux/module.h>( O( r: K0 n# S$ L/ `
#include <linux/kernel.h>7 x1 x5 s2 |# d( v
#include <linux/types.h>1 \- @ p9 `+ @! S, ?
#include <linux/gpio.h># P- S- W+ Y, z' V
#include <linux/leds.h>
! J2 i' }7 y/ }; G6 U( B6 }& |8 X% Q#include <linux/platform_device.h>/ c! m7 R& O5 [) h
6 Q6 Q) P, c: c9 O" U7 ~" ^7 u% L4 C#include <asm/mach-types.h>7 z+ G, I2 P% J
#include <asm/mach/arch.h>* Z/ M! F% I9 {
#include <mach/da8xx.h>5 `% K# D% A# H0 D5 l5 F0 W
#include <mach/mux.h>
5 v0 q n6 x9 B' O9 J. {, {8 F' M8 p* T4 O7 ]6 Z" a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, X$ l6 E% x( i1 x9 {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% P7 }% x% H, b+ E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% V" @+ d/ B0 [- _7 n; j' C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ Q' G5 i7 c6 u9 B: c8 \. o4 U
. ]2 X( p* K7 J) s" g5 m/* assign the tl som board LED-GPIOs*/
; i3 P5 ]' ^0 ^1 l- ?' E( K; C Pstatic const short da850_evm_tl_user_led_pins[] = {! y# ^9 E) z4 R Y2 G" t
/* These pins are definition at <mach/mux.h> file */
) b% A1 d& ^% _, e( W$ }, }5 E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ g! v2 ?; ]/ R% ? -1' R8 y8 y1 O2 M9 q' `8 {5 {( Z
};9 y9 ~" S9 X1 K1 h+ b
1 D1 K. E9 R: b& R" Y
static struct gpio_led da850_evm_tl_leds[] = {" o" w, ^1 s7 v: W* x# w/ H
{& {& E% B$ j/ o1 R7 T, s/ h7 Q
.active_low = 0,
2 @" i* b8 {5 z+ _ .gpio = DA850_USER_LED0,
2 X, H9 ~) R6 i$ A% ^: h .name = "user_led0",
7 j1 V E: y" W/ H. ` .default_trigger = "default-on",
* J/ w7 h" @- r9 J },# m8 R u$ L2 D! l7 `' Q+ K0 ^
{
# u& r$ E; Z% q/ _6 j2 a .active_low = 0,
4 u& R' H: p0 X4 K( L% l .gpio = DA850_USER_LED1,' W2 E; f& B* J; k5 b/ `' m( ~ a, a
.name = "user_led1",
3 a2 {; _, V( r+ U .default_trigger = "default-on",% m( B* O0 U9 f8 s; S1 w% ~2 A% M0 H
},
$ A1 ~6 I" m V8 N. F( R+ ~ {
% j! q+ [) U1 z8 x# l5 `% Z- e# f .active_low = 0,0 C4 b- W' u6 ~4 T# p* _
.gpio = DA850_USER_LED2,5 D! U) O7 }2 V# @
.name = "user_led2",
% Y: X( F4 J: [0 X/ a .default_trigger = "default-on",3 B# C) L* k. N, M% r
},# I. [0 {" W$ s' ]. `! \
{% I% k+ y6 V5 N* v* b ?5 B5 ^+ t
.active_low = 0,$ C5 I! q: E F/ @0 C, j
.gpio = DA850_USER_LED3,
+ J/ U3 I& _$ R, f, Y4 O% p .name = "user_led3",* [' y! W7 \2 S+ d1 e$ Z8 s
.default_trigger = "default-on",3 c" {! f1 r& Y) |( b! o! f, }
},, i" S) H; t% {5 ?5 r( E
};" l7 A3 t' d+ |' c8 |- h: e& K
; S& K9 H+ I! g2 wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 y, |1 I6 t7 g8 T! U: L
.leds = da850_evm_tl_leds," A. k2 H" |9 V9 j+ h7 k
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- h; m6 d& t: r7 X" T1 Y) r
};$ {& _( K8 O3 B4 f, y0 O4 |
3 B& {& Q0 Y8 h1 v, F2 \, ]
static void led_dev_release(struct device *dev). ]+ B# P$ e V& w6 ?
{
/ k z' k6 D8 L% G: k/ V5 D: Q};$ Q/ o' b; t0 U$ n8 z9 J4 a3 _
" n& X$ Y/ J- s
static struct platform_device da850_evm_tl_leds_device = {' g1 p0 T2 c0 ]& v2 t7 S
.name = "leds-gpio"," M; [' K& q1 @
.id = 1,6 k# ?7 A" x1 h' W! Y9 w. t' t
.dev = {5 r. C; B; {5 W/ C; Q% b
.platform_data = &da850_evm_tl_leds_pdata, o. R' V! m4 ^1 X. _; f* m8 v
.release = led_dev_release,
, Y; X2 Y6 d+ _. w* j }7 u0 M6 V. ?) E7 m1 ]1 M
};
8 ]& U, m0 E* h- ]- C
9 N" a3 f% l1 l# ?+ Ustatic int __init led_platform_init(void)3 w* |2 J, k1 ~2 Q/ r
{- y6 q4 S w9 l2 \' t! i3 @
int ret;
1 e3 a7 L8 w3 x) F#if 00 g ?8 r, B4 i3 T# R V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 p+ U, u. @: Q! D( M% P if (ret)
, w. Q9 Y t+ v pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# O4 H* Y9 m( i+ e! E" X6 O
"%d\n", ret);$ d: M1 p7 ]0 P: C: J) j, n7 i1 A
#endif
9 X8 v7 Y9 _6 l/ A/ \& X8 \ ret = platform_device_register(&da850_evm_tl_leds_device);
) O2 k$ b/ Z: f1 t1 m- f if (ret)# @9 ^5 J, Q1 H B- c
pr_warning("Could not register som GPIO expander LEDS");. Z1 ?0 K& k+ q r; D
else
! N, J4 X* j5 q. D printk(KERN_INFO "LED register sucessful!\n");5 ]9 ?4 t1 ^( c; T7 q" j8 I; ?8 b
# x- l) U+ m/ A2 p2 t
return ret;
1 m+ x4 F+ m( p* S6 C( o7 Q7 \}3 Z" l q" t* e4 U. }1 u$ I
7 m* W2 n% E4 v4 c% t& V
static void __exit led_platform_exit(void)+ V7 M4 V' F- F) s
{
+ j% F5 ?' m; o, J2 o! Y platform_device_unregister(&da850_evm_tl_leds_device);
- D. d- y7 w/ d- C' n) S
1 ]) T+ Y5 U' b5 ~' \4 b1 S printk(KERN_INFO "LED unregister!\n");
0 \- H- B6 {( A. p}
. p# ?( m3 V. g f+ j& W
, W. o" f' V: jmodule_init(led_platform_init);
" n; G6 t9 q: [6 X+ \, Z/ Emodule_exit(led_platform_exit);7 h: Q% \( j2 d* [; [7 U6 }. v5 E
# C( h0 k5 f# q6 D$ C+ H5 {8 Z' hMODULE_DESCRIPTION("Led platform driver");
7 e; N$ r) c$ b3 @MODULE_AUTHOR("Tronlong");/ i8 E T, s( B7 G; M- b
MODULE_LICENSE("GPL");
/ j" L+ c+ h+ L
. N& x/ j' g0 m |
|