|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; I" h- G' b Z#include <linux/init.h>
h" c2 r& `+ a; g2 ?. P5 F#include <linux/module.h>' {9 v/ K" B& ~' _$ M, w
#include <linux/kernel.h>
( z8 E3 x; a/ h#include <linux/types.h>. z; N* f% L; V* Y" R
#include <linux/gpio.h>. h. z) T" x; m! ?( b# K
#include <linux/leds.h>& p$ a2 V; Z! Z' i* z ^; y
#include <linux/platform_device.h>
" L' s& k0 v" a% P
' W5 c1 u; x; @8 B L* j#include <asm/mach-types.h>4 u, S2 y% e5 C$ O, F H3 I
#include <asm/mach/arch.h>) g: ?4 s: u0 ~. C
#include <mach/da8xx.h>5 W$ a% {) M/ [1 M3 Z/ E/ X$ X
#include <mach/mux.h>/ j! t9 e( v# U! ?& l. @
# K1 v* u, t( {6 R F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 b, |' W! w8 p: l7 Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& H+ v3 _/ N, a& H' H7 g% J4 @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% W4 z: b! }8 w* r& ?8 [1 X7 C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 D2 o8 P- P. ?' A7 x
% W# I+ S1 J- x0 s2 h7 _/* assign the tl som board LED-GPIOs*/4 @. s; b w3 k9 F5 ]+ i& @/ [. n
static const short da850_evm_tl_user_led_pins[] = {7 R3 W- [: k7 e3 ^9 G: F. v9 R
/* These pins are definition at <mach/mux.h> file */
; U% Y+ U9 ?0 R4 b* t* z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 U8 K& u |: z/ ?8 [- d1 L -1 A7 v: y w- j7 b, N8 r/ f4 d
};! C: v5 F+ x, o$ c' w* P2 |
+ D8 d3 z) A$ A# e1 t$ D* Kstatic struct gpio_led da850_evm_tl_leds[] = {
5 d/ }- d5 R" E( l9 x {9 ]; ] \' p3 B" W
.active_low = 0,
, P7 b' b- }& E .gpio = DA850_USER_LED0,! F8 x3 j& e% z( E4 A
.name = "user_led0",/ f+ t2 Q: K9 F9 C5 a, I& _" E
.default_trigger = "default-on",
& g$ i- O5 C- Y; [1 v },
' D$ [* k. i; D9 a {
; @ T6 | v& ? .active_low = 0,/ |3 V- m: Z Y% Z* M: D
.gpio = DA850_USER_LED1,
. m3 b* j% d4 I( q2 S .name = "user_led1",
/ S4 c- r- q# T' j2 T .default_trigger = "default-on",
' R, }( D/ T* @ t. y( W+ `0 P },
9 V. b! z( e z- n- x {
4 X+ T2 b6 E: | .active_low = 0,
( T+ |& V) X1 x& x" T .gpio = DA850_USER_LED2,# ^( l: J# ]( ^7 J; S x
.name = "user_led2",
! v1 l9 k* U0 |+ n& ? .default_trigger = "default-on",- N& M! y, {% H1 Z o4 E% V1 D3 M
},+ n; Z% r. i, S, t* L7 ]% {
{
/ i* W9 Y3 @8 M9 s" w .active_low = 0,# {/ m9 q1 D/ ^6 l
.gpio = DA850_USER_LED3,
" `3 J! S) W- L2 Q3 {! L V .name = "user_led3",2 \( o5 e/ u. t" j, i. R
.default_trigger = "default-on",- y0 q% Y5 a) X8 f
},
! J/ ~/ m. V$ k: G8 c5 l. X};$ E+ n q0 }9 @8 P6 b* D4 n
& n" h p) ]2 H% i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! `( s! B9 L! ^( I .leds = da850_evm_tl_leds,. {4 O( C4 s# @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 G) T: G* L% l2 Q! P};
+ T+ M) K+ ~6 i* b: N
8 ]7 L7 p1 d0 a/ L) t( o% nstatic void led_dev_release(struct device *dev)
2 z( s. w- w7 ^{( T6 G, F2 Z* c* Q; a$ N
};, V% n6 j9 C: t2 E! |" e" S( F5 c
- }) q A. b& ~5 E/ Xstatic struct platform_device da850_evm_tl_leds_device = {
& V8 d6 ~3 ]3 j8 }1 W .name = "leds-gpio",& s; d- Q6 k' F. ]3 d
.id = 1,% a+ I' ]1 M7 @
.dev = {7 d) j7 r- I, J& d# U1 k( f/ ~
.platform_data = &da850_evm_tl_leds_pdata,
% s, ]* x6 n& b) p# v( G .release = led_dev_release, C3 v( u# y" @5 i! V
}
) F. T9 L+ @7 y' Q, M8 @- B};
6 D$ h7 S) a; ^& _+ U- U$ q9 @/ B' P* w
static int __init led_platform_init(void)$ `- c& O6 ]( T% K2 _
{3 C+ ~7 v- E% q W- H' Q
int ret;( I' C8 @2 w1 S: g
#if 0& Y: F8 M y, o& G: w a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 Q: g3 I* `- ^# P/ n/ S if (ret)* p9 g- Y- {, |. X; p- O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% t7 o! [9 b8 H1 b
"%d\n", ret);3 X) c* Y: L3 E& y8 V8 z% F( D# c
#endif
# a. y/ S4 m0 g' t* @0 B& p7 m- k* H ret = platform_device_register(&da850_evm_tl_leds_device);
5 Y9 j+ `( C2 P if (ret)3 Y9 } ^4 G( W) B( K7 @2 }3 X
pr_warning("Could not register som GPIO expander LEDS");1 M q' w2 Z- S9 G
else# ?4 C9 Q5 X. @1 q) n6 i2 b( l
printk(KERN_INFO "LED register sucessful!\n"); i1 x" t9 W0 u; g& W8 v
# P. x- s: L' f J6 U
return ret;
}1 ^ S6 _: [}
- z) P) N0 i: q, ~- v
. {, S' E0 X7 Gstatic void __exit led_platform_exit(void)
$ M- l( J% _+ t" T{# u3 k* _4 R: W
platform_device_unregister(&da850_evm_tl_leds_device);; U* ~" x, |( N! o, B1 h
/ i$ D7 l& G1 R8 z$ `; W2 f printk(KERN_INFO "LED unregister!\n");+ `# J6 {6 g* `% P3 E
}; O) T& B; @* l0 e
0 l6 Z c V7 q( Y6 p
module_init(led_platform_init);& [# Y0 B; l/ T' _5 A- X1 X
module_exit(led_platform_exit);" C, |) P6 ~2 o
" J+ j5 f, x( F. b
MODULE_DESCRIPTION("Led platform driver");
S6 X& ~8 [" W9 Z+ Z9 CMODULE_AUTHOR("Tronlong");
( [( _, Z9 B VMODULE_LICENSE("GPL");8 Y) ^; J' W; N& b& ~: ~9 W
# R0 w3 C9 @+ B0 i0 L2 k/ `
|
|