|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 e& {! T& D0 l) A Q8 }% H
#include <linux/init.h>
$ t6 G$ u0 Z" {& W#include <linux/module.h>3 f' M0 X' }8 f$ @& |% D; {" r
#include <linux/kernel.h>
0 @5 p6 D2 j! g# R#include <linux/types.h>& t; v; G t$ |
#include <linux/gpio.h>6 `" M! J+ Z1 U* n
#include <linux/leds.h>
4 V7 _' t% Y% K, |' l#include <linux/platform_device.h>8 a) k3 X! T( _# ^. P8 s
. R- v, P; t- D+ q* b#include <asm/mach-types.h>
1 g3 \+ l" p0 y% y1 R#include <asm/mach/arch.h>
, R) G5 S7 ]' S0 R. |#include <mach/da8xx.h>8 ~* z3 l' n; Y. [! T3 B4 u* }/ |
#include <mach/mux.h>; w3 Z2 @/ O5 {2 S
2 R' I! u* T/ \/ w" f: O( z% w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' {$ H) t5 G( K5 ~$ I1 W& _8 S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). v. ?4 ^) c3 w2 U8 {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 Y0 ?9 r* _. x$ {6 E- I2 a6 v#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 \( y/ v5 i3 @: D# m
- w# W4 U3 X9 D4 l! |0 C/* assign the tl som board LED-GPIOs*/
" D' S* k e$ w' B0 x0 jstatic const short da850_evm_tl_user_led_pins[] = {, `3 D8 ?+ j9 a2 `4 u
/* These pins are definition at <mach/mux.h> file */9 W. B$ L% q4 a' K% q. ? r! @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 ?: g6 n1 D* P5 c5 E1 _+ M
-1! U7 l* T5 `3 G
};
; o l- E8 d0 ~6 b7 B# i5 g; {& y% x0 E0 m& H: P
static struct gpio_led da850_evm_tl_leds[] = {
% ~, A* d0 H7 O+ a {
; [" k6 Y5 n" @3 r .active_low = 0,
, e( ~% H: F% X5 W8 q7 q .gpio = DA850_USER_LED0,% u8 m Y2 B% Z& x
.name = "user_led0",5 ^1 {. m' O, T; t. ~
.default_trigger = "default-on",. U9 V- H+ L5 Y7 d
},
, [: @- d* r/ g% i: f0 a1 r {
. I' r) V4 [& i8 F8 A .active_low = 0,
# t, v+ ~; U1 r, T .gpio = DA850_USER_LED1,& I/ I5 y% g* y
.name = "user_led1",
8 J. ^9 A& k# p .default_trigger = "default-on",6 H+ }1 X( u" p6 {/ `
},
4 i" ^1 o$ L4 H {
0 N) k: k" H7 K: m .active_low = 0,! B) C; C7 x/ G0 j
.gpio = DA850_USER_LED2,! A8 X4 V& v6 z/ L2 e
.name = "user_led2",0 z5 R& h; E6 P/ V& o4 ^
.default_trigger = "default-on",
1 r/ E* ]7 G$ R$ L. d9 T$ J; v }, U; t+ d! E# N7 h+ }: ?3 z" a* a* Y
{( V6 {. N- V/ v0 S# b/ C
.active_low = 0,
9 F5 P9 b, [" H .gpio = DA850_USER_LED3,% Y1 V6 n+ Q$ @% L
.name = "user_led3",4 ^" w+ h) v5 V+ M6 } P
.default_trigger = "default-on",
; m6 a# T+ l# b3 F9 |$ R },4 _+ I# X( \1 P/ Q
};% v; G# U; g' T; I# s' k
% K* M& C9 F" n( t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 d3 [. c* k' x* ]
.leds = da850_evm_tl_leds,
7 w6 \/ b' \) X3 J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 L7 W& N; s$ y% s};: |1 y; b1 _$ ~! C% J9 H7 a
2 X2 }$ E4 {2 i) i
static void led_dev_release(struct device *dev). v3 W/ [: r& E! r7 F' a& w, Q5 s
{8 Z0 p6 \. M1 U; I. E2 I
};
7 l% K; t. R: j4 j2 d1 f9 I; R: D! s1 g3 J. U
static struct platform_device da850_evm_tl_leds_device = {. X+ c; u% @; ]5 ~5 `$ {5 q1 j2 C. F
.name = "leds-gpio",
& O8 E$ w7 @# j8 L& ~ .id = 1," P/ E5 a9 M$ N4 Y8 K4 K4 J9 n
.dev = {
. E8 a3 }! r, R. H4 w- O4 A o* { .platform_data = &da850_evm_tl_leds_pdata,
. K7 V# R+ z+ @4 K .release = led_dev_release,& K" L+ U4 S# Q+ E V
}
# N6 [/ g4 r1 F3 X};
+ p+ T# i8 s1 K/ K- T- o6 q
' O. P# P6 x" Nstatic int __init led_platform_init(void)+ j) |4 @! y# X5 A" s$ E) L) n
{
8 w& |) [) p- V2 t$ V! \ int ret;3 {) |5 S5 f6 x e7 P' }: q8 p
#if 0& y. |, w3 ~5 A& ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% W9 ?$ O9 }4 V. L) x5 l/ w
if (ret)
6 C, w% c2 ~* T; O& `, }; m! v# \$ ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ a$ N* {5 Y! T "%d\n", ret);
5 P$ |5 A; C9 K! b5 O#endif% N8 \& }' ^6 k5 R% h
ret = platform_device_register(&da850_evm_tl_leds_device);
1 F3 s8 Q: j, p2 ^+ f6 V if (ret)/ G% H" k8 A# }2 g
pr_warning("Could not register som GPIO expander LEDS");
! s& ~; B0 u7 D7 Y0 ? else
0 a4 k$ e% l A/ Y printk(KERN_INFO "LED register sucessful!\n");# P# j7 y8 x) v- f9 K0 y6 L: s
* k3 Q& L& N# _( d& O
return ret;
6 K8 B$ x& O! ~; H}
+ U: {9 ~7 t4 X" o
: r+ T3 |* i. p; x+ u% `static void __exit led_platform_exit(void)
3 U' Q! I& Q" |6 z# Q. q{6 o4 v0 H7 o( t# y
platform_device_unregister(&da850_evm_tl_leds_device);1 t- X6 Z1 Q! p
9 D4 t2 J8 P1 z2 H+ r' p- g printk(KERN_INFO "LED unregister!\n");/ s1 p+ u6 e5 Z# ?
}* G, [2 k2 K+ S, V1 Q: i2 c; `! o
' r2 H7 @0 e7 X. L; X! l0 q0 Emodule_init(led_platform_init);) W% [" l+ W/ q* p
module_exit(led_platform_exit);; G8 R8 i' Z" o3 P
! `9 n. J, I/ YMODULE_DESCRIPTION("Led platform driver");: A+ ?7 h" ]/ r( L- z
MODULE_AUTHOR("Tronlong");
7 A/ \ y; p/ | I9 R. E$ NMODULE_LICENSE("GPL");
6 T$ Y: p9 ]2 u" R ^- K! Y1 g) h) ?
, M% c6 B V2 o3 \- V4 T |
|