|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 Y" W& l# r, O; T' U#include <linux/init.h>/ o I6 F" S& R3 y8 o* Z1 v% R
#include <linux/module.h>
w6 f4 C6 k4 [! s0 F9 Z8 V#include <linux/kernel.h>
; W( ^/ O2 h8 Z, N- [#include <linux/types.h>* b% j3 X# W0 M0 a* j8 f
#include <linux/gpio.h>/ s3 _+ z( G' J5 x
#include <linux/leds.h>5 i* J. A$ a$ i) t0 c3 p) l
#include <linux/platform_device.h># s: W. t! z1 L/ I3 P
' j: b0 z6 h$ o8 k& ]
#include <asm/mach-types.h>
9 I2 n8 F3 | _* I5 ]/ e3 g#include <asm/mach/arch.h>
3 h8 Y0 d) ]( O6 G/ ` \& D6 z: G#include <mach/da8xx.h>" h& }6 z' i3 N/ z
#include <mach/mux.h>
9 C9 g% Z7 ~8 Z5 V$ B* j
8 J5 n: U) j5 k2 O" G- o+ {1 M" O2 R; i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! Q7 ?8 R! \/ ]; ^5 J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( k5 R- N% J' n7 B$ u7 q7 O7 m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 ?1 ~) p5 a& h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- p r: t. y8 b9 @
2 c4 q! ?8 v! r( J, R
/* assign the tl som board LED-GPIOs*/2 V2 Q1 Y( W4 l% @( A$ h4 v
static const short da850_evm_tl_user_led_pins[] = {. h, r8 y3 [) m& c1 {: ?
/* These pins are definition at <mach/mux.h> file */) ?6 Y4 p. s1 w7 g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 Z9 Q% R+ w; r5 I4 h* e! v. d! u -1
/ R, x$ {( H7 x};
' ?8 C3 o0 t8 {/ i: M" p' @! W
static struct gpio_led da850_evm_tl_leds[] = {
* {3 Z$ h6 s6 H {0 z/ m& u+ \: u
.active_low = 0,3 s' y/ i* t0 h) {
.gpio = DA850_USER_LED0,
+ Q/ b" D7 Y) N .name = "user_led0",
" M0 q2 w8 F2 S& d( B: x .default_trigger = "default-on",% n9 `7 V# u7 h' w) [
},: S" C/ s, q, r/ V( d) K, w( R
{+ K9 F- H( ]0 t+ w" Q9 F" b
.active_low = 0,: Z9 V3 }# ?; Y
.gpio = DA850_USER_LED1,
' ^* M" b+ S7 l .name = "user_led1",) C; k+ O: g7 P- U; H
.default_trigger = "default-on",# ~8 `& c4 @' \8 A' k/ Y+ j! M
},
% ?$ \1 I R( U9 k# i: I2 W" Z {
( m- N- r! x1 j .active_low = 0,# w) M1 ]" c, W7 ?
.gpio = DA850_USER_LED2,
7 Q* ^/ w) w) z6 n+ \ .name = "user_led2",: R" E3 V4 T; g& I V
.default_trigger = "default-on",# R( N) M8 C+ h; F8 l
},
8 C/ \# x* h2 p3 t& R7 ~* ?+ N {
- `3 ]1 {; h0 U: O* f" q- S1 X .active_low = 0,
1 m4 ~& L1 R X, E- k .gpio = DA850_USER_LED3,0 s& f6 c) m& B; a- I; O
.name = "user_led3",
8 l, a' h- K0 j( b( ^; f [: m5 z$ q .default_trigger = "default-on",2 L8 r) E, [+ ^7 Z& j2 t. G
}, t3 s0 A3 ]/ y6 i2 S
};
5 Y; M1 I4 j5 A/ J( a( ?
! [' U2 A0 u" U( C8 l4 Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 f4 w' W( z* Y; ?) \' T* d8 { .leds = da850_evm_tl_leds,
e4 k# Y( Z/ x5 f. g$ w1 ] }( c .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 \9 e1 w6 E& s' h k
};
' C, a+ b* G, {6 e% b: }. t/ j8 f8 Z8 g9 ^
static void led_dev_release(struct device *dev)5 g" S; [" s. a# t5 ^
{
4 p4 f# \* |( \) X};
' s& \1 a/ W0 t- x5 A% I0 w1 e, e0 n3 ] }
static struct platform_device da850_evm_tl_leds_device = {8 J# y2 o i# ]7 m0 Y5 e
.name = "leds-gpio",' I0 l/ a* Y- k* B" r4 X$ `
.id = 1," c* M$ d6 z0 T) [/ D( v
.dev = {9 }( z1 b7 P5 e$ w0 C4 f# \
.platform_data = &da850_evm_tl_leds_pdata,8 \0 M A; M$ k/ X
.release = led_dev_release,. v0 x( r" `$ l
}& P+ O- h# f* i9 q5 w" a+ _ ~
};
0 i4 Q! G. E9 U1 s4 e: }/ ^! _
& j8 H+ f6 T" M3 U' r v7 k7 |. Z3 {static int __init led_platform_init(void), A+ y0 C( b/ \5 j" X7 e; \7 D
{
+ j4 c' B2 f L4 h% B( M7 ~* ?* E int ret;
( R4 p1 h& ?# I, R1 D5 m& \. }+ q, ~( C, D#if 0
6 | }2 q0 O% V% T- n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( P, y P0 {- K' B9 d4 D
if (ret), v! Q) {/ s7 U' g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* n4 e; n2 A# Y& q5 v. `
"%d\n", ret);0 r" M. o H/ }, o9 B
#endif4 b7 @( K: B# ~1 [, t% d1 J
ret = platform_device_register(&da850_evm_tl_leds_device);+ N+ V9 O7 c' y, `- P+ M
if (ret)
: u# @. a7 }% K pr_warning("Could not register som GPIO expander LEDS");
/ V/ x* A5 d& U& X- O& G& n else
u$ D$ B; ]- P: O' i, a* ~6 W0 z printk(KERN_INFO "LED register sucessful!\n");
" C% n3 U. j$ A& R* N, z5 @* T; ~* A) F, Q; Z
return ret;
. }" Z8 |; u5 r8 B F}
) v, Z1 B; \" t! i3 V _) m& C0 V: ]$ v/ h
static void __exit led_platform_exit(void)" W# c% e( c/ R; r7 {/ \6 |
{
$ n6 @* u" e: ? platform_device_unregister(&da850_evm_tl_leds_device);9 t8 ]5 R* ?; b8 v& _' a' S
% d( k# f& I$ @, M+ u printk(KERN_INFO "LED unregister!\n");
! X* S. F2 p+ Y. i) u! ^* h}- q: {; H3 q3 H5 o4 |& p" f
! y( j! X ]0 k& N4 Amodule_init(led_platform_init);
4 {' ?: X) h4 ?) ~# o& Emodule_exit(led_platform_exit);
7 z H+ q$ F1 W1 h$ R3 ~) n# o
. G, R0 ?6 ?) u# w8 MMODULE_DESCRIPTION("Led platform driver");
" Q" J7 c3 T6 A6 q. \MODULE_AUTHOR("Tronlong");, b( W8 v( @4 q8 i0 a
MODULE_LICENSE("GPL");
$ [; c% a- U* x5 \! z! h9 E# k) A: C- \5 ^& [% W- r0 J- _
|
|