|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( f6 Q( t$ {/ K1 t, R, c#include <linux/init.h>
' f8 U& W; d+ B" A* `: a0 a+ R#include <linux/module.h>0 x8 z8 N2 U/ X4 J+ R6 r4 w
#include <linux/kernel.h>. i& }+ P+ ]9 C
#include <linux/types.h>7 A, a( K* c: v7 }7 b
#include <linux/gpio.h>
% T5 p5 Z; M; B' C#include <linux/leds.h>
( o( N& C- Q+ U; D: a( l#include <linux/platform_device.h>& `* K8 Q2 D* X" T) |
. u$ x5 s' P* O h* C
#include <asm/mach-types.h>4 H7 X" o+ y! c& u" O
#include <asm/mach/arch.h>
$ o8 U3 q/ X% N4 D, A6 N2 H% D# p#include <mach/da8xx.h>
]' `0 h( t ^9 Y# f) D7 I' R% z#include <mach/mux.h>
( a3 b y3 y9 `5 Q& I0 q; Z3 Y( E; Q- S$ x+ Z+ R& _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) [2 ]) R$ x; n+ O* t: g* g3 V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- e5 Z* l, U0 j% w: m& `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 E+ n- n1 k: F* P$ z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 Y4 C8 O) A2 n# u; H$ c
3 i4 L; O0 Z' E9 b/ x( c u/* assign the tl som board LED-GPIOs*/
9 J: e- T. e) G& ~ `/ r, estatic const short da850_evm_tl_user_led_pins[] = {: G/ w# `! }4 m! `; v. ]" J0 R
/* These pins are definition at <mach/mux.h> file */
6 A- A% v0 i- u% O" }) G S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, z; {$ }9 H- w! `3 |/ V9 ~, x
-1
8 O& V9 \: d" @$ U0 {# i& W};
9 m2 A* W2 ~$ M
9 r; Q: G( k4 Y% C" L- Rstatic struct gpio_led da850_evm_tl_leds[] = {
8 l5 e% b3 n7 b2 N' ]9 | {1 i& _ q* n% D& }- W1 J0 l7 C
.active_low = 0,
; Q$ ^8 F5 ~8 h4 T8 z .gpio = DA850_USER_LED0,
( b7 b. w6 C. h .name = "user_led0",+ @7 Y+ N9 B5 q j, u
.default_trigger = "default-on",
$ A) q9 i u Q1 ?4 }: R+ `/ u },, G8 Q4 p) I3 a
{
% T2 G* K# E" A6 `' h .active_low = 0,
$ q/ k( p" n6 E! l3 X .gpio = DA850_USER_LED1,
. Z F0 x) S0 \ .name = "user_led1", E' U( A! [8 ~. O
.default_trigger = "default-on",
+ Z, l/ d T5 q7 g- @ },
" v+ z; P, P1 q, ^2 z" y* Q {. g9 d$ }- |5 b% ]
.active_low = 0," S1 G( R$ t( a! c5 u
.gpio = DA850_USER_LED2,
4 t# y9 r; I3 }0 g( j2 Q: f .name = "user_led2",2 ^5 T9 [( u3 h8 `3 R, E0 r2 I
.default_trigger = "default-on",
1 o: _! O/ E; F+ h& b7 x9 @+ A8 P },
7 x3 ^1 u) K7 q/ ] {
- ~# G1 a5 T C .active_low = 0,6 d6 z3 e5 o, e0 E; F1 s9 W
.gpio = DA850_USER_LED3,/ F! t( h' F% I' K7 P" I
.name = "user_led3",
1 k, g: G2 i, d .default_trigger = "default-on",4 y. S: J" q9 g0 v
},
9 F" Y2 ]& e% k: g$ s9 l1 G};2 {8 G9 S5 T/ [0 u+ Z1 j7 Z
g6 M2 d: C+ w: d* O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- J) f% o! E9 w7 m0 \4 J
.leds = da850_evm_tl_leds, b2 c6 A# d9 e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: E- B3 b! A- q
};
( {9 q* u9 `3 L Z8 [
+ E$ O: E0 f9 Y0 @3 G; ]0 xstatic void led_dev_release(struct device *dev)
/ z/ e2 S5 K0 a( U6 v{1 a7 c9 V6 J; o2 Z% M- p$ J
};
1 ?+ y: w7 P. P4 I! \
! Y, O. A4 e9 g6 h' `' Rstatic struct platform_device da850_evm_tl_leds_device = {" s# Y, n* S1 V/ `" A# g
.name = "leds-gpio",
; `/ } @) h' q5 M; y- m& [$ g .id = 1,9 l7 E8 E3 O f; ?) i4 c9 d
.dev = {
( y" W* B% d" d( V, n( s( z .platform_data = &da850_evm_tl_leds_pdata,4 Q' Q3 W+ |7 Y+ O% `0 t" Q
.release = led_dev_release,. J; z9 t$ Y+ Q3 K+ p. h
}
0 x, ]1 ~" W p% H};5 O; W* \, f, y0 M+ [0 G! z# |
) c% r' }' C9 ` u6 nstatic int __init led_platform_init(void)
3 Z, ?3 n, [2 A. ~/ C# \{
8 n0 N) N# L6 {" s% h int ret;
9 |3 m8 b4 u1 y7 a* d#if 0$ P" R+ F. p( F; K" u! k4 s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; [- S" k3 z& L( }) o0 X if (ret) i6 g7 Z3 q! n" c! w
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 n3 O; T0 B% @* J. U "%d\n", ret);4 d I7 E4 a, u
#endif# n; I% L/ @, y8 T
ret = platform_device_register(&da850_evm_tl_leds_device);$ w3 ?' H* r; u+ x0 D; x- s. b6 z
if (ret)
9 j9 f0 o" Z# T5 W V pr_warning("Could not register som GPIO expander LEDS");
; D0 i- u' v3 `' z- G0 j/ P3 h else
5 q4 V( b- E+ b) L printk(KERN_INFO "LED register sucessful!\n");- s* S1 Y, q& \0 W# u
- v+ k* O, k" w+ F return ret;' d, r3 H; q( l% K. E/ k( G
}! C: b ^* l8 X! N1 V4 p7 I* m: a* |$ S
) D9 @! _( n5 H4 L$ |static void __exit led_platform_exit(void)/ c5 N( q K3 V8 A
{ t4 ?0 f/ s) \2 t7 V/ Z
platform_device_unregister(&da850_evm_tl_leds_device);* i6 w6 ^* z+ b! @) c7 q2 K4 e0 b8 X
" ]# B, F- F6 I7 F printk(KERN_INFO "LED unregister!\n");
0 V8 o) }" n8 ~7 t/ u* A}+ \6 F# H6 `8 t' ]: m% L A1 C" R
/ n5 S/ K5 P) x, p
module_init(led_platform_init);$ E. g+ e6 }2 Q4 g$ C* h& ^
module_exit(led_platform_exit); ], e9 [8 I# x
7 ?$ w1 I$ x5 F" v% ~MODULE_DESCRIPTION("Led platform driver");- j2 @/ {$ P# C Y* G; i# t% C
MODULE_AUTHOR("Tronlong");
8 a- {" Z) L7 R7 o& ]7 mMODULE_LICENSE("GPL");
, x% L- |/ c: \ |# M7 a/ o, {3 J7 F; M: X" U* D
|
|