|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ C, b1 h! U5 `#include <linux/init.h>/ f% N Y) w7 F) M3 b7 H5 h
#include <linux/module.h>
( T; f% t$ j' L- {% H+ }) H#include <linux/kernel.h>( E* ]: W/ ~( [5 `6 i9 H2 U" A2 U6 x
#include <linux/types.h>
/ F! T! T% _- G#include <linux/gpio.h>
( w H" I9 w" @" d8 `( N#include <linux/leds.h>8 ]' d7 D2 v4 g: c8 L
#include <linux/platform_device.h>
5 B8 `8 X# d5 G; p6 b( U1 B6 F3 g% ?. Y+ f9 S6 e
#include <asm/mach-types.h>
' N1 L- r, x2 b8 O2 f. ^#include <asm/mach/arch.h>
3 {* u2 M- u! \5 u#include <mach/da8xx.h> g; e1 ^) ?% e6 N
#include <mach/mux.h>
5 W# p( F9 E9 f; M% G2 G* w5 z/ R
% w' r$ W4 D4 Z0 ~/ h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): }4 m. W) t; W# j% w2 K
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ F2 ?' x% I, u! W8 B0 h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 G, y' X6 S! D/ V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 g) e6 b/ X' k$ L0 I
8 S. m" K4 k8 R7 R9 h* o9 I
/* assign the tl som board LED-GPIOs*/- D4 e* n, U7 f
static const short da850_evm_tl_user_led_pins[] = {/ a N( Q ]% u) `4 ?- e0 o- G
/* These pins are definition at <mach/mux.h> file */" X& _1 v/ |# W0 Y# B& r8 h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) Z/ P2 ]4 f( D( d' f: t" S+ C
-1
0 G' a. t8 Z7 J' t; n" K};
; x$ N4 V/ {! b) S9 W
' n8 @" `! l- Astatic struct gpio_led da850_evm_tl_leds[] = {( b* t; O: Y4 f+ P% i: ^, z
{/ d, H! P+ p* W* v7 s1 y: J" L8 M
.active_low = 0,5 r' k* A. h) t T) h7 A
.gpio = DA850_USER_LED0,
8 O+ F% w- @' c$ _2 e .name = "user_led0",
9 s+ c' E3 ^& I .default_trigger = "default-on",
) O, o8 b- k. y& r },1 c* ]- A5 i) @( I
{2 y" T0 B4 H/ f$ z
.active_low = 0,
( |) L% x8 o9 [( s .gpio = DA850_USER_LED1,
% n; \& z8 F9 B: M0 w4 C4 n- S .name = "user_led1",% u# y9 o H+ D* _: h) h
.default_trigger = "default-on",& s2 R2 f# S1 q& e4 L- } d; k
},
% k, z; a* ]6 B* V- V) b/ ~ {1 j; A9 I; o' X" |1 d/ f; r$ S
.active_low = 0,- V$ H# U4 b0 l; V8 k7 j3 e- T: }
.gpio = DA850_USER_LED2,( z' Y! Y1 q$ K6 U3 R: y. I9 S' Z
.name = "user_led2",
* |, c- N" O, N' N: P .default_trigger = "default-on",
) u: e/ V: f! p, X },8 E1 H4 t& h9 n K9 G5 @
{7 s9 q* q( e. B# M. e* x8 p1 Y
.active_low = 0,2 _8 r+ }& d/ |( d" E
.gpio = DA850_USER_LED3,
6 a7 w( w. W1 v* s$ g .name = "user_led3",
3 \1 b* i5 J, Z .default_trigger = "default-on"," A: C9 f$ d8 Y; ~3 [: M
},
5 r( j2 b+ ^& s$ ^};
% t( {2 _7 \; W4 m. u/ M5 H B' e0 R0 s' j( H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. I# w! a* C8 x; Y( [& U .leds = da850_evm_tl_leds,
' b }. U* E3 y6 X( Z: |$ M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! o) {' x; u, y* |+ Q4 \- w
};: D) Z7 l& g, G2 }( p4 y
( b% A9 Q# x5 `1 l" f
static void led_dev_release(struct device *dev)
+ i% }$ e9 W/ q4 u; k$ C{
Y+ |. Y! U# l7 H; q};
# \8 K; d. w5 S; b: A0 g6 {' ~6 l; i) x. ?, y; o
static struct platform_device da850_evm_tl_leds_device = {/ \: c! i5 s5 T- r/ j
.name = "leds-gpio",* K/ q9 \* [# n* L7 A8 Q* k0 S
.id = 1,
* x# K- x2 G, R& r8 ` .dev = {3 h* I' I: i- W: d
.platform_data = &da850_evm_tl_leds_pdata,
$ Q; u8 W5 w1 N# d) \ .release = led_dev_release,
5 q/ e4 P9 t7 w& x7 g$ x }( \5 ^5 I4 t% e9 t, k0 [
};# y T6 S( y& n) x6 L
: ]& q, B7 C- i. w p
static int __init led_platform_init(void)
5 c! R& l9 I1 [* H{' G" j8 @2 b$ { H7 P
int ret;
" l, [, n0 S- F& t2 t, m#if 0
0 {/ n, q/ n9 S5 n/ m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 m5 @* p' b) n+ O' X! s p4 G if (ret)
# I/ v) T6 m' c% \. `- j- S pr_warning("da850_evm_tl_leds_init : User LED mux failed :", ?$ E. S; w5 E6 X! r' I6 o- |
"%d\n", ret);
9 c4 g3 r/ f& Y#endif$ T9 F* I, X! ~7 D! ^! O
ret = platform_device_register(&da850_evm_tl_leds_device);" V7 M) C/ r0 ?- H! E
if (ret)
: ?4 i1 Z% Q1 q pr_warning("Could not register som GPIO expander LEDS");
3 h9 b2 }- ` P% x else2 i( G( v8 e( O4 u
printk(KERN_INFO "LED register sucessful!\n");$ i+ I1 w8 l: t
3 l" C* B# a# m! s
return ret;
8 @9 I# \- \; U, }}
9 T, H% v- C& y
9 e |( \, }9 `, astatic void __exit led_platform_exit(void)# Q" c' Z$ O6 U4 M6 f
{
2 X! x" H L: x platform_device_unregister(&da850_evm_tl_leds_device);+ x M: _/ M( G1 i; \
, `% \4 d9 y7 |* B+ T- ~
printk(KERN_INFO "LED unregister!\n");
2 l! `8 c+ r6 N7 U* l( w, s4 F}
, T- q4 s: z& q( D% o% P2 g* _7 y) H* U2 z, @& a
module_init(led_platform_init); v8 H8 M; j1 Q. e& O
module_exit(led_platform_exit);
# U& e3 x o* B5 r% X% S& M6 p& O; b4 Y8 U( Q' Q- C6 z8 D
MODULE_DESCRIPTION("Led platform driver");
- d% f' D e& a# {6 VMODULE_AUTHOR("Tronlong");
( s% g0 O7 b6 C! h. DMODULE_LICENSE("GPL");
3 ]5 s$ U; m0 K. k F' I2 ^9 {5 }: `% m2 `% E3 j1 \% h, z) {. z- B# V
|
|