|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 V4 J3 }* R' B4 {! o, F#include <linux/init.h>
) a& S4 _' g0 M' ^" T6 P; m#include <linux/module.h>
- D* `. i1 w/ ~1 S7 r9 ^# k#include <linux/kernel.h>
3 j+ G* S( q, q/ `/ U. B+ q* p( O#include <linux/types.h>( J5 e/ ?9 U4 q8 H
#include <linux/gpio.h>( H6 S! P& R: C' f) [
#include <linux/leds.h>
( s0 M1 t" q- i#include <linux/platform_device.h>$ c ~( y! M0 u5 p
/ m. {8 w! Q Q: V9 B
#include <asm/mach-types.h>" e0 J: z: Z" ~- a3 i" g1 S
#include <asm/mach/arch.h>
/ O0 Y, F: s% y& G" m' [9 v7 [#include <mach/da8xx.h>1 S4 | g& F/ k# r! d/ T* q
#include <mach/mux.h>
3 C, t' v. ]1 R# f) Z
: g3 k: L9 h: v1 v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 O: a8 ^6 B6 o8 t, u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 a6 N/ P" |% J8 ?3 R* t9 M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ S7 K- j! Z/ \! }$ @7 L
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 L; F3 g+ s2 q( h' ~ X
" {$ R/ ~. F7 P, v" q/* assign the tl som board LED-GPIOs*/
3 V6 U2 v3 T5 `$ p# U7 astatic const short da850_evm_tl_user_led_pins[] = {# Z& I: k/ g$ a6 B6 G# W- J& ~$ S
/* These pins are definition at <mach/mux.h> file */
: \0 A, q9 c7 \* n e- @# z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 l4 h; `4 W0 V0 R -1
) c' I/ P& T1 i) _0 E};' T. Q7 E1 _0 N" |0 v( a v
& P8 S6 ~4 a9 ?' d" t& X
static struct gpio_led da850_evm_tl_leds[] = {
& S; `# V, ?( z, A+ S7 J {
0 B3 v; I$ t: _. L& n3 g .active_low = 0,
2 E# M1 Q6 K3 f3 c# U# {* f$ ~ .gpio = DA850_USER_LED0,
- y N+ v6 i4 k( i# X .name = "user_led0",% ^7 d! S& P0 {
.default_trigger = "default-on",) M/ o$ W$ f% ]# o# \ H& U
},
2 A J' F" k% \5 q( j6 G. E {5 s- V( Q& R, b
.active_low = 0,
3 i) ^9 [1 I X .gpio = DA850_USER_LED1,, S4 N, Z& C( {6 _" E# N( j
.name = "user_led1",; d- m) ^8 e% i$ f8 {8 U+ e
.default_trigger = "default-on",
# B8 l A7 T( a- Z. \ },
5 g2 _/ R% W2 G! N/ L0 p* X5 ` {
C' M0 v( h' m .active_low = 0,
* _6 V F, x7 F6 |7 s5 W .gpio = DA850_USER_LED2,
) g" A4 i; _0 H6 o( x" K .name = "user_led2",
, T! T5 f7 ^* ~: ? .default_trigger = "default-on",8 g; V- \0 \* U q$ g5 H7 P
},
- A: L, b; F9 z( ? {5 z, m: H+ g0 r5 S- N
.active_low = 0,7 v" ]: ]* Q7 J9 G) p
.gpio = DA850_USER_LED3,, V' g' |9 m+ S: h/ V2 B+ S5 m; J
.name = "user_led3",4 z& e% r7 n! \! `
.default_trigger = "default-on",
1 R5 n. x0 \, u) ? },5 k' T* q' i) p8 p
};9 ~7 Z- X6 O, E
# R+ P# x. I$ ~. j) b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 z/ n6 [. L! v
.leds = da850_evm_tl_leds,
) ~2 i' N, _+ d* o& C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 w. e" ?* ?8 @' }8 h# J* g7 T' |};
0 H3 C" ~2 _0 a$ z9 G0 R# a9 M. M; m
/ a* K0 H" L( y: ?: _static void led_dev_release(struct device *dev)
' Z0 z! s8 ?2 x0 T- B* d{
1 E% y2 }+ y) @# {3 m/ ?};
) C; {" y0 {( m3 k( u
8 s+ @1 |. H6 V) mstatic struct platform_device da850_evm_tl_leds_device = {) f- y# X) P3 U+ A0 R% Z3 w
.name = "leds-gpio",9 p4 R- \* o$ U# C3 k
.id = 1," W: r @; z, R4 ]
.dev = {4 j8 u+ w8 i0 F, m7 P
.platform_data = &da850_evm_tl_leds_pdata,
$ ?- M4 T7 a6 }* T# x .release = led_dev_release,9 X* @( t- M* I7 Y9 c: t, b' u
}
7 L4 r) h- Q* i};
2 ~& {- C! y" s/ V; b# h( Y! s8 E; V$ C5 s% O* n
static int __init led_platform_init(void) B, w3 ?5 @6 |* }
{( A) n- x" q# s2 G u# |
int ret;( @' s0 I' n6 W
#if 0
, V) l$ B! F& C0 r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 c/ p' W: K' B! ]9 t
if (ret)" B: [1 h3 q+ t8 r6 ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! Z* X: T6 W! _* C "%d\n", ret);
- J' e |) }: E+ F- y" F#endif+ c) A) s# w! ?; L8 V
ret = platform_device_register(&da850_evm_tl_leds_device);4 J/ E* m) h7 J: |9 c
if (ret)
% a% }/ J8 {* T* G$ W9 z& l& |1 O pr_warning("Could not register som GPIO expander LEDS");
) U/ c4 n6 }2 u2 X4 i$ | else0 J! q, r$ I& P; ]& C+ U/ v8 S5 h
printk(KERN_INFO "LED register sucessful!\n");
+ W$ @. B0 G3 f7 B7 \9 q6 O9 S, D4 ]$ i I
return ret;2 c& |; A: Z& R3 |( l
}! u" F1 n: i1 N2 ?- g8 F
. P. y& S0 @9 {8 Vstatic void __exit led_platform_exit(void)
b% \8 N0 c, G3 H C{1 I( j6 g/ |3 G7 K0 G
platform_device_unregister(&da850_evm_tl_leds_device);
6 K3 ]$ k r0 \% |. J0 c; v5 ^
& {, f' [2 U& |2 D! p printk(KERN_INFO "LED unregister!\n");& A4 X: T0 j0 |2 _
}
! c# \4 p5 Y) ^- t: s5 d! v" S4 h3 E: s- r8 `
module_init(led_platform_init);. Q j& ^( F, c) n0 a2 O* v
module_exit(led_platform_exit);
/ u5 z2 |% }, j% y
7 V$ H3 W3 |( nMODULE_DESCRIPTION("Led platform driver");9 O2 u; P; q8 [: N: A
MODULE_AUTHOR("Tronlong");9 `( \# f( G$ T% T
MODULE_LICENSE("GPL"); U5 N, e" H5 H) M3 a
1 n0 l0 S7 V* N( b$ w& w, z
|
|