|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 s4 H4 Z% r. }9 ]# a0 D9 T#include <linux/init.h>0 {8 S2 ^: ?9 `6 [4 z; c
#include <linux/module.h>
( d4 \* _& n$ c8 ?; b9 G6 j7 {9 i#include <linux/kernel.h>
% {; A! F0 E# E& \#include <linux/types.h>
# X9 V; g) `, k6 }& w9 w/ C#include <linux/gpio.h>
9 m2 f) v( n" y# K#include <linux/leds.h>
# O- [& z0 \' @1 S' }#include <linux/platform_device.h>/ N# c4 ?# n! |
( B6 {2 c8 A1 c2 y
#include <asm/mach-types.h>% E# ~; g' m* V0 z& G: ~8 J& [
#include <asm/mach/arch.h>
; I7 ]/ N/ q" G; @4 `& |+ F#include <mach/da8xx.h>
% c: p/ F& i+ Z/ a- [* l, w/ d#include <mach/mux.h>
0 u9 y# z$ W7 t9 L& M% Z O: B& t0 I& q2 i% C& e8 n# X1 `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; ~. \! f0 m% B; R4 D) X7 y/ D+ X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): H3 x( Q0 R0 h* C4 ?( S- w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) _! y- c2 _ ^. s8 O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 J) _. N4 [0 K
; o8 r# x& P4 B. r. O W; Z/* assign the tl som board LED-GPIOs*/2 m# |0 K6 }+ L+ V5 B! i& V
static const short da850_evm_tl_user_led_pins[] = {
& i/ K: U8 U2 o5 ^ /* These pins are definition at <mach/mux.h> file */
: R z3 g1 y& m$ g5 h" ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- ^! f( y/ o0 p -1
; O! e3 H8 ?, X! Y |6 [, `7 Z2 r8 v};- D5 I8 X* x2 K B h- B+ ]& R
0 T" j, F+ C/ W2 [' C- ^static struct gpio_led da850_evm_tl_leds[] = {
2 S: J! B5 Y" o$ R( Z {
! C( ]7 I" q F# r5 C" H2 L! d4 l .active_low = 0,# j( K' w+ A7 g4 {/ o
.gpio = DA850_USER_LED0,
9 X# f) [4 z( b: k .name = "user_led0",
) e* N# Y' N( E! b5 ^ .default_trigger = "default-on",% h% |* p5 z+ z8 |8 [
},! M2 u5 w: G! w
{
/ B! J# \6 Z' f1 X- p/ O$ i .active_low = 0,9 G5 ^, t) j: J! _7 M) S
.gpio = DA850_USER_LED1,
h. e, }" n6 d1 R7 Z .name = "user_led1",8 B; d, r6 n/ y1 S
.default_trigger = "default-on",2 C" J M9 t4 r# y
},: e& D3 |3 W$ f3 q# }( ~, J, X+ K5 F" K6 }
{. a! \7 m S' n; K$ F; O- D; Y
.active_low = 0,2 g. J/ F6 y9 g6 i- u+ p7 w
.gpio = DA850_USER_LED2,
% O* W9 D5 k( I* X+ [7 a8 } .name = "user_led2",
. q r* I9 \ b. O9 @ .default_trigger = "default-on",
0 Q3 c L' i! c },
2 q) f2 z, r- V4 o {
7 p" p2 Q* \+ X9 H: L% a! t# _ .active_low = 0,: y! a7 x6 a) k# Z& t6 F
.gpio = DA850_USER_LED3,7 C# c: r3 j0 o+ x1 d" u2 W
.name = "user_led3",* ^8 v0 _% H4 @' x% b( u
.default_trigger = "default-on",
1 u. v+ }; p9 a1 a/ o% q },2 t$ |. c& L0 J7 B+ I. x
};% _" K4 i1 e: [+ P) T' p+ }
- h0 I x; f! o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 Z) a7 ]/ O) ?* U/ L, Z. {! s( a .leds = da850_evm_tl_leds,2 w' `8 t! u; w. t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* E3 r- S. G, a. e; z
};
3 F* o$ P, A r0 n& i4 g9 i7 _/ W4 h% d) _; o4 P( F
static void led_dev_release(struct device *dev)
; h% X6 p5 J+ Y7 j; c9 @{
4 }2 ~# e* J1 [- @) m};
* z5 d! Q0 }7 P" F Z
3 m0 n$ B) W+ X% Dstatic struct platform_device da850_evm_tl_leds_device = {$ M" |0 A3 v1 g' y. p
.name = "leds-gpio",
7 V" d5 F* G# j! I .id = 1,+ i/ a( J! t6 s' v, C
.dev = {
: ?/ p7 u! f# A3 `" V3 A( f' P$ x .platform_data = &da850_evm_tl_leds_pdata,
4 l/ c7 A$ ]- T0 r. N, F .release = led_dev_release,( M! a! p4 `+ V+ `! d2 w5 G0 [
}
3 [) T; e. V% a# J- _$ }, C/ F5 n; L};3 @9 L8 U6 C& C; T
- R3 E% V) p* Q
static int __init led_platform_init(void)
3 e* ]. r3 r& r: D& ]% g{
6 J; y% i: k1 A int ret;5 S# w6 o% h; K" W* F3 I( l6 u
#if 0
; }# k& D: Q7 F- b2 x4 {0 \- E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* X: _2 z. c2 p Z; I3 v3 y
if (ret)8 [* c" O- C- N( R8 u. k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 h3 ^: [) P0 S$ |/ ?) l# G
"%d\n", ret);8 N4 M# a& {9 t* D
#endif
" u1 U/ z8 i i8 d+ j ret = platform_device_register(&da850_evm_tl_leds_device);
. K2 D$ ~7 w: [7 _ if (ret)# F" K# v7 R1 |; b$ e0 M% v* I* Q
pr_warning("Could not register som GPIO expander LEDS");) d* o; W4 y% s
else
8 g6 }. H9 i6 w# r printk(KERN_INFO "LED register sucessful!\n");% ~" Q( B6 R$ i7 r
- G, w9 x8 R' E1 k( D# l
return ret;
) \! d: S( B0 `4 `4 z) v5 n5 J! C0 }" r}
" w' ^1 E$ h0 c$ G, y3 p; V
- k# u, B1 v2 ]9 Mstatic void __exit led_platform_exit(void)
7 H. @9 V( R8 p* L% I) _{7 s1 j0 f6 W C8 g$ p1 J
platform_device_unregister(&da850_evm_tl_leds_device);
- F( D. S( b, u
! Q8 ^9 b! q/ ~1 j+ |7 N7 _% a printk(KERN_INFO "LED unregister!\n");( {& t( o# T+ l& U. J
}
8 [1 A9 I. g# ? A) d, J9 M6 B1 G" }4 p% c
module_init(led_platform_init);) d+ r1 y7 v7 M- h! a8 P2 n
module_exit(led_platform_exit);
, r9 ^* L& n' Q
) W" q8 T+ i& s$ k1 JMODULE_DESCRIPTION("Led platform driver");
3 `% a, x$ I5 j. b1 V9 J$ K& V& \MODULE_AUTHOR("Tronlong");
. D+ ^8 }4 a, o7 {! EMODULE_LICENSE("GPL");9 q7 \9 r$ o' l) ~( H4 V
) r$ r. ]1 D2 g |
|