|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 O0 j0 b. H9 C( M; `$ s#include <linux/init.h>9 u' Z; n# o8 F- d* l% y+ D
#include <linux/module.h>
" C+ c5 a9 e* S F. T#include <linux/kernel.h>! l7 H3 V* g9 e U0 }7 c8 N: a1 G
#include <linux/types.h>0 w- \ R# I$ j- A
#include <linux/gpio.h>2 u3 W* i8 n: X4 U- ]- X& b' O2 }
#include <linux/leds.h>
4 l9 S' I, m8 U5 l, q#include <linux/platform_device.h>
' a0 H. y e2 N0 T y
3 K! C4 M: x6 ~0 o2 o5 G# p1 D3 q#include <asm/mach-types.h>
6 \$ H) a$ x, ~* \5 C7 W, Q; c; A#include <asm/mach/arch.h>
) W$ ^2 O; \5 z7 J: T( _- k2 P/ d#include <mach/da8xx.h>/ I/ L) K7 l. @6 a
#include <mach/mux.h>! `- o# x6 D( o! q4 w
0 \" [. C4 h4 f4 p. v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, f& n R3 O: C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). T" g$ G( M8 l# Y/ O+ c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 J, H$ { ^* a7 {2 J7 `/ D8 p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ [/ r O/ f2 X! z
. ~- f4 q$ U- ?8 Y/* assign the tl som board LED-GPIOs*/% V' t$ [3 n. P$ h1 E, p% ^; C
static const short da850_evm_tl_user_led_pins[] = {8 a- M0 K, }& g$ P% O! E
/* These pins are definition at <mach/mux.h> file */
h; ]$ y. Q- I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ ?+ T$ |$ q3 z; h/ K9 }
-1% V0 p7 l* ^. w
};& J; t" d6 ?6 }3 Z7 q" J' H, B% g
) T- r0 J, p* p& @) |+ o' z9 dstatic struct gpio_led da850_evm_tl_leds[] = {
. l! R5 t' g/ Q9 Z+ P" p7 G {
0 f6 Y$ O3 t. T+ B* z V3 E .active_low = 0,
% ?# X3 {, Y+ }. {$ M .gpio = DA850_USER_LED0,
- B4 a1 W. V$ y0 i' L2 n% ^: Y' e .name = "user_led0",+ B) s" ~# K" x; ^2 f5 W) ?
.default_trigger = "default-on",- A( J& c8 }" A* t' P
},
' Y2 f& V* v/ t' P/ I {
$ i! l/ a4 e/ t( r/ U: P; q .active_low = 0,
6 ~1 S9 G* c0 j: s: p2 f .gpio = DA850_USER_LED1,% F$ `/ C& n" H/ x3 ?
.name = "user_led1",! W# }3 m2 r# |7 W. {3 @" z
.default_trigger = "default-on",
) {7 z) U! I) P h. { },2 @/ B" q) |% v. d4 y9 \
{
* u7 n: Z# m9 b2 d) V9 o- J4 M f4 D .active_low = 0,
' F/ o% |9 L8 ~' B9 w. u .gpio = DA850_USER_LED2,- Z2 `0 R* T& n( ]" U
.name = "user_led2",
, N% v- D4 a9 C/ \( O; C1 ^ .default_trigger = "default-on",
! L) b, O" i$ B },0 ~; E3 U. a! J
{
! m1 P; ^! \ ]: p .active_low = 0,; q8 p3 x* b8 m
.gpio = DA850_USER_LED3,
" z; l; w+ v' P. W/ T! x8 i% Y; D .name = "user_led3",& Y! @8 v m- @! c; O7 e+ p
.default_trigger = "default-on",2 J" @5 X, L2 p
},
& W1 v- F- h' m, N1 u6 u* m};
8 H5 h8 F( J z. U0 Z9 A
! c, z7 i5 T/ istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
j1 M# ]5 T) R$ x6 D .leds = da850_evm_tl_leds,' l7 \1 |, F. x3 y' s3 D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; i3 p6 I- Z- L8 X
};; O2 h3 D/ V/ b. U. F) ]
. t% L6 b& p- `3 V" b) S& Pstatic void led_dev_release(struct device *dev)7 R: C) q+ E7 u! ^
{
, b! C ]6 Z" H5 W};
' n; q9 S f9 e3 G" X: p
* s' o0 u0 ^1 F5 `9 K/ Tstatic struct platform_device da850_evm_tl_leds_device = {
7 d H* @- Q# A' b .name = "leds-gpio",6 p: {% v# a. h9 Y4 M2 B4 q; {
.id = 1,
8 P6 | ?5 h* ?- L .dev = {5 x; J4 i( o. Y4 v" T
.platform_data = &da850_evm_tl_leds_pdata,4 U- l- O4 ?, p% ]" ]/ R
.release = led_dev_release,8 c' }2 N+ B$ a- Z# }0 q
}3 w: \: i( ]+ s7 J- l) k
};
: U; f. t7 |$ O* \* t% N) Q- i0 A2 |% W6 o& Q
static int __init led_platform_init(void)
; u# [* S" s. o2 ~: v{3 a, e5 c1 ]: ~" ?8 p- h. [* A7 G
int ret;2 b) k0 e* ~- x8 z4 E
#if 0$ L! f, Y7 J0 h0 |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* Q& Y6 }2 s$ v5 D if (ret)
" j: ^8 @: ` S' p# V5 l6 a pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# D$ \3 S; L% { "%d\n", ret);% e; o; N8 ^" i% C
#endif
1 e6 ~2 ~. V) z$ }# z8 B7 w ret = platform_device_register(&da850_evm_tl_leds_device);
' ]2 N1 D: a, L/ n% f if (ret)( \3 r$ o8 X1 L+ Q, h
pr_warning("Could not register som GPIO expander LEDS");
7 C8 M" X+ P( G! U+ g9 o+ G6 g: c; {6 d else
% B8 u$ @7 C0 M printk(KERN_INFO "LED register sucessful!\n");2 H% g( N* M$ w* E, y
8 X" Z" V/ S8 g) ^& ]' A
return ret;. }9 P" A! b: O. N( b
}/ d+ G! a4 s) t& G6 Y9 X' E
5 i/ W! |3 T0 u: {* ^0 [
static void __exit led_platform_exit(void)
: Y$ Y6 k L3 c$ i0 i5 m' d{' h* ~; t5 x5 Z. t% W
platform_device_unregister(&da850_evm_tl_leds_device);. ]% o+ T; s9 e: t
]0 x4 t& M. a4 n9 J& V5 v8 H( F
printk(KERN_INFO "LED unregister!\n");
. A& @( e' h/ a}
+ M1 h/ u! L8 I) [# y! v8 e5 `
+ S5 ^& M- H0 O. i+ L" |/ d4 l" W; {module_init(led_platform_init);1 l6 `4 R) n4 l, Y7 W' ]
module_exit(led_platform_exit);
" g$ W( c" I& a9 B* G6 K, O
3 v+ }' F- t; PMODULE_DESCRIPTION("Led platform driver");
) D+ Z* W6 B7 D2 mMODULE_AUTHOR("Tronlong");8 G9 P7 y$ h- E- @3 d
MODULE_LICENSE("GPL");6 F* ?! V+ D7 ^+ u) a; |) D
8 G' c! R4 z% n- Q |
|