|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& T. p- U3 g1 \3 O9 S#include <linux/init.h>
/ I4 Q2 B% L3 y6 E, m- W. @#include <linux/module.h>
" m! K1 d" _+ W8 f2 B#include <linux/kernel.h>
4 B4 j5 I- r5 C7 {) y2 ]#include <linux/types.h>% l4 d( `) U: X- H: V' M
#include <linux/gpio.h>) a2 n$ u5 E( ~; B% p( ~! ?
#include <linux/leds.h>' d5 C9 l9 D; u" {; C3 h: P9 O+ o& p6 N
#include <linux/platform_device.h>5 i- T9 l! J; g$ q( z
+ k# m# \1 `/ W( j
#include <asm/mach-types.h>; v0 Z- i/ b( c( ^) _
#include <asm/mach/arch.h>- ^1 p7 ^4 n) S/ k y' g
#include <mach/da8xx.h>& _0 [9 Z- t+ h& q) ]. Y) q% [
#include <mach/mux.h>4 t, g3 w- k R% U% X, v! T
7 @$ ?! y; Z, S$ P$ _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
z# o1 { G6 y- M. W: a0 |) b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ s o8 B) l; P) N. m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* j% o/ a( y! e( |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" m! u$ x. r5 q' r+ p& X, O
$ b3 \+ U* U$ `
/* assign the tl som board LED-GPIOs*/
* U1 j" E+ g! Z: w9 O' d$ i6 [static const short da850_evm_tl_user_led_pins[] = {1 I) u, t$ N2 v6 |
/* These pins are definition at <mach/mux.h> file */. H/ W o6 m( f: Q b ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 U$ v J& m S5 m4 n7 ^% Y
-1) {4 Q8 ]. L6 o# k
};$ e6 P3 X: l' m1 ^$ O
2 B4 i; [9 }8 n9 w. pstatic struct gpio_led da850_evm_tl_leds[] = {5 Y1 E" u. j! L6 }0 r
{
7 B$ `; |0 K2 l+ Z: G: t .active_low = 0,
5 r \6 I$ P8 l1 x7 r0 h .gpio = DA850_USER_LED0,
' Q' ]# N c0 [- P+ f .name = "user_led0",
. b D: [- Q- o9 e6 g3 T .default_trigger = "default-on",
. S0 G1 \$ Q( p0 Q' G% y },& R- h5 Z$ T- |& c( i$ I3 t/ C
{: O5 B: P9 D; I
.active_low = 0,
( c- C Y# L) i" w .gpio = DA850_USER_LED1,
! P+ P- B9 i$ B .name = "user_led1",
, z, U( T* Y0 ~5 E9 t6 f .default_trigger = "default-on",& ~! g; M3 ?2 E) ^
},4 z S7 ~% h4 ^) S: U `
{
9 t1 W# ]* q3 M. K3 R1 Z% q' E .active_low = 0,2 E Y N3 D7 x, t* R( i
.gpio = DA850_USER_LED2,
# j0 k2 \: [7 Q% }/ {4 g7 {( ^ .name = "user_led2",
) b7 f% M; s, t# { .default_trigger = "default-on",
0 K% ~; E* F( j l) N9 ^ },; `5 }7 M( u1 p
{* ]) r' j" ~; n9 Z$ `9 }
.active_low = 0,
1 M# V1 K5 U9 T3 c2 n3 B! z .gpio = DA850_USER_LED3,
& _. b/ o8 k3 l .name = "user_led3",
6 V3 b$ X: i% x- f8 b- N .default_trigger = "default-on",: w5 @+ z! ?5 {
},3 C0 k1 @7 M" Q
};
* v/ l9 \% e+ B9 A+ s4 G' s
: M8 o" m2 f$ C5 E/ i/ ~% nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 N1 G8 C7 L7 i% H! d8 i .leds = da850_evm_tl_leds,; l/ t/ u1 @8 z6 M+ q. ^3 h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 e2 B* D3 ~% q( `2 b
};
- o x7 S8 `) Y/ O, y
. J/ _9 \) p1 P9 c8 Y3 Ustatic void led_dev_release(struct device *dev)$ c/ l [! i. N0 A3 S( y
{/ S0 p. C2 T# d# V6 m* Z& F/ B0 s6 j
};
7 Q2 [ b" W* ], I3 U
! Q" B* _* p% M! V! Xstatic struct platform_device da850_evm_tl_leds_device = {' N# i: W4 T# v& c
.name = "leds-gpio",
1 [% c; i6 f/ Z3 x: O- t$ G; J0 v .id = 1,
5 B; O2 u/ U: e& j- l3 q .dev = {3 f1 Q5 v* N" A0 s s% E6 n
.platform_data = &da850_evm_tl_leds_pdata,
- [0 Z5 P$ M" o" T .release = led_dev_release,
4 {9 U0 j1 L: }( C; h' t }
0 m& _# l" J J};/ C* d7 u0 R z1 K1 x% g
' [+ b1 ]+ P4 O6 k- Rstatic int __init led_platform_init(void)
8 y- J# J5 w+ U8 C- L* I{3 d. U" f* u6 r: g
int ret;
+ y6 C( k7 r: S; W#if 0
' _( ~; C7 m X; P/ i! z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* o4 b+ U T: `# F$ L: F+ }9 f
if (ret)
8 ]1 V8 k3 S8 [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 i6 B# F7 P0 T. F' m1 k3 u "%d\n", ret);
) w8 {! ^5 _( S% X. n& _4 o#endif
9 q8 Z* W2 H$ W% b$ I ret = platform_device_register(&da850_evm_tl_leds_device);
% [, D* v `0 |$ B, v0 ^6 N if (ret)7 Q9 s, U# G2 @; l
pr_warning("Could not register som GPIO expander LEDS");+ v$ _( j' k1 D5 c4 b5 Q
else$ O$ J4 Z9 f1 o! b1 F) D
printk(KERN_INFO "LED register sucessful!\n");. e; E$ ` k/ T0 G5 D8 l
6 L6 u" U! b9 n' r, o return ret;0 R- c8 P! T8 F. Y- `
}
9 N% ?+ x3 S6 |: j$ t8 O/ k
$ A; H8 Q: U& X3 N7 R! vstatic void __exit led_platform_exit(void)
" F1 ^% S( h- @# w; |5 F{
- C: P$ z7 w4 L$ v platform_device_unregister(&da850_evm_tl_leds_device);
: ~" O4 K1 l! B; J; b2 w: S( ^6 c l3 m$ i" `& `. a q, k
printk(KERN_INFO "LED unregister!\n");
7 h, f* k0 B; E( C}
# |+ y ~& D# w& @8 a* }0 z8 i
7 G6 c9 B5 t4 G2 G- |& umodule_init(led_platform_init);
& t/ n7 N' E6 G$ Kmodule_exit(led_platform_exit);" z( ~) Q+ I- q) W) b
5 d% _0 Y7 y, O+ nMODULE_DESCRIPTION("Led platform driver");
0 P# D( `6 o- J( f6 k0 Z5 o8 {MODULE_AUTHOR("Tronlong");% I: \) S% w/ m7 q! X
MODULE_LICENSE("GPL");3 k R& ^/ [8 r: s
5 l( \, Y! A+ w' M7 B8 G; a, o0 s4 D
|
|