|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. N" n- a2 {' s8 p& p* P j' t
#include <linux/init.h>
0 G' s4 q- V. t2 n#include <linux/module.h>1 ], x5 @) P. s( B; h
#include <linux/kernel.h>% P2 J P d7 M
#include <linux/types.h>: ?& n! w. F3 ?, G. m. a' q! b, b
#include <linux/gpio.h>
# q2 h, e6 `) C# N#include <linux/leds.h>6 A$ C ^9 W p2 j
#include <linux/platform_device.h>5 I2 U, b( y. H2 |) w0 b9 ~3 g" m
0 B/ L: N. I9 X#include <asm/mach-types.h>2 N( r- Z4 @4 S9 I4 w* B& J
#include <asm/mach/arch.h>3 R3 R" s4 Y! T6 u7 L- s
#include <mach/da8xx.h>
; [' c, S6 g& C5 ^6 L#include <mach/mux.h>1 ~- x% r' k- d7 W* C
: [- x1 f3 b9 n' L+ }6 p$ i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 y. d" h5 F9 k" n% p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): o- J# F4 `# J g* \5 P1 |, _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# d: k# q& ]/ T) F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- O" T4 J* K9 ?% n2 M, k
1 y2 f1 ^# S- F* @ h
/* assign the tl som board LED-GPIOs*/
* e! v- B9 \; y9 R3 p @static const short da850_evm_tl_user_led_pins[] = {
% h( q/ }9 d) F: J/ D /* These pins are definition at <mach/mux.h> file */
* ^' b) {& M- g+ x7 X/ l! r( N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, W: ^" F7 a/ p* [
-1
: ?+ T: Y0 ~- t7 z$ J+ N; E0 s6 D};
7 ]% k. `2 y* U5 y% o" i7 T
- z, E, ^* K J+ U& ?static struct gpio_led da850_evm_tl_leds[] = {( z* g$ s+ u) p& j
{' u% V: }; T* ^/ R$ z1 Z- M
.active_low = 0,
$ C2 [3 }4 _! @4 ~' c F8 w .gpio = DA850_USER_LED0,
& s- S; C8 U* K' H; n9 T* J P .name = "user_led0",4 F8 F+ C3 ~4 V3 u
.default_trigger = "default-on",. b0 Y" _# U' d V( G8 e9 t |" O
},
: G8 A- A0 C1 ~) S {9 y( {9 ?# D" x" R% W: F/ }
.active_low = 0,
8 X/ B, \) e, I& z/ P .gpio = DA850_USER_LED1,* g0 V; X N- j% _
.name = "user_led1",
" R3 j+ `6 B( \# p0 ? .default_trigger = "default-on",
4 n! W/ A) n: A- }6 r% H7 |& D },
" W- W, J H! u* n: |7 J {
! Z+ I2 l _9 f5 i( d5 r& |, B .active_low = 0,
5 X# T7 D) w' S7 E% d" Y .gpio = DA850_USER_LED2,9 e. R8 P2 R! |& Y% D' ]8 w
.name = "user_led2",
) I9 p6 H' n" c) b; A! ^2 F) m .default_trigger = "default-on",' Y2 t0 H& C! b% V: \, N
},2 n! f7 @# L+ v$ c% r1 }! H) V
{0 g5 y& N; W \0 ^* R
.active_low = 0,$ z+ R, @) u4 Z& _- \- B
.gpio = DA850_USER_LED3,
* V5 m5 l. y& _' [/ e% q .name = "user_led3",
/ M9 x0 |& [ s. d .default_trigger = "default-on",
) i: b0 ^/ K1 m& Y& {" g8 r2 i },
& g" J$ j/ w) h};
: O6 K# ]2 @2 V& M7 U' w# M
6 m8 m/ E; J- j, B lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! `6 D9 S9 P9 A" W1 I2 r E
.leds = da850_evm_tl_leds,* U4 `: j8 U) c' h" ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 n& C/ x# ?$ \; s0 R};% k% ~+ b- V6 {
6 b1 J4 m/ a& m' Zstatic void led_dev_release(struct device *dev): f7 s( S5 G9 j7 _& O
{' [3 V: v) v2 }. r5 M% L
};% l& z& ~( _- B' t% X
& G. h- ^ u( W# Hstatic struct platform_device da850_evm_tl_leds_device = {8 {5 R6 W; }; }, U% q/ w
.name = "leds-gpio",0 ?% m6 q3 ~) R* c, `2 B, R( }
.id = 1,
! t% ]" x/ @4 l9 t: w. Y6 G .dev = {" s5 J; Z* X! D' \* ^ Y6 @) i
.platform_data = &da850_evm_tl_leds_pdata,
# o9 x9 h ^* r6 y+ v+ Q a .release = led_dev_release,1 t% D( L8 p! b4 g% n# e& ?
}
1 Z- l, T# p0 d, {! m. J};
/ Y R3 [8 l1 x4 R: p
. r3 {( h: L! }3 b# l# estatic int __init led_platform_init(void)$ m( S( Q* _0 s& ?
{
# J: v5 `, q0 ? int ret;6 X9 v2 H& H! D1 e K
#if 0
; n' o% z3 d q/ |( J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! U1 C; D: H5 q4 Q) ^( f
if (ret)5 V" j! V3 i7 ?7 U4 K3 Z/ E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 P% x o. ?5 P' A0 X "%d\n", ret);# C; e. @- z R- s
#endif/ ?$ B/ ~/ v! P9 V2 `2 D8 D
ret = platform_device_register(&da850_evm_tl_leds_device);
* d! ^2 G+ t+ z) Z if (ret)
. W, G2 ~0 ~4 Z$ N! V% @7 z pr_warning("Could not register som GPIO expander LEDS");- V- C# _- _; Q% B: e
else8 ?- I1 o+ {& y; Y
printk(KERN_INFO "LED register sucessful!\n");
% a: @1 v4 l% O: ?" [* y J: u# t5 C7 ^& I
return ret;; K j! p4 r8 F9 |% v8 G
}
- G( ]* i. B7 m( M+ i) i+ `0 `, `" j+ ?
static void __exit led_platform_exit(void)
7 Z, U1 a \! w; G% c{5 v0 H- F5 t9 R
platform_device_unregister(&da850_evm_tl_leds_device);
- s9 t' H% D! _3 W+ I: O7 n) w6 r
5 v$ [( R8 J: W; R7 t, o printk(KERN_INFO "LED unregister!\n");
* @- i2 _+ G9 f1 p0 G6 r}
" p& J4 t- M4 L" r' N4 |, S* `7 @% p( \- v& S r9 J
module_init(led_platform_init);1 k4 F# C& c- R" K
module_exit(led_platform_exit);
$ \8 h, Z+ f9 A8 i q, e" G8 a& O
MODULE_DESCRIPTION("Led platform driver");
" V+ O0 p a: @. I. q" T: l/ ^MODULE_AUTHOR("Tronlong");
5 |- L ]) c; n2 I; X! ~9 ^MODULE_LICENSE("GPL");
- W' E4 x' b/ M( c5 T
' `( O% M' Q) m5 z" } |
|