|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 }9 h4 k1 v. l! Q#include <linux/init.h>
$ w, ~; ~4 o& @' ~4 @#include <linux/module.h>* {" F" E; r; q
#include <linux/kernel.h>
, `- {; {' ?3 X#include <linux/types.h>
# G" ^: D: Z, A#include <linux/gpio.h>3 G+ D5 l. R9 r7 Z- k4 b- I8 P- z
#include <linux/leds.h>
$ ?: V, {1 z5 X$ I" v2 R7 R+ A#include <linux/platform_device.h>
9 \ j/ m* q/ `2 y2 t+ ^& i5 Z0 c. u, O' Q; t& g6 @/ m" F
#include <asm/mach-types.h>
8 b8 D" l8 Z# o#include <asm/mach/arch.h>, Z, A( Z z+ Z: U) l6 J: i* v- C K
#include <mach/da8xx.h>
8 `# K3 \9 B C1 \; R#include <mach/mux.h>! N' l* _' N) p8 Q7 |% {( e ]: K
1 g" n4 J4 {" d$ s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ s3 g0 L: J" |% q8 X! O' I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ f! p( o0 v; b1 Q3 L+ D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& M' ~( _- b- _+ v* }/ {
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, s( I: X- O! G6 }* |6 ^
" \% c- [5 b) H5 q; t" d" G/* assign the tl som board LED-GPIOs*/
. j2 S4 C# z$ Q* F4 K! d/ }static const short da850_evm_tl_user_led_pins[] = {
0 M/ c7 X. r2 O6 n$ s e' A8 Y1 W /* These pins are definition at <mach/mux.h> file */
- i$ g4 t& P# Y4 b$ X: o. e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. o8 a- r9 x1 L -1
0 w4 t( x! K. G- d};" r7 \: C0 @0 R0 }2 ~
7 W9 r3 t) A4 {3 M% W4 ?5 o
static struct gpio_led da850_evm_tl_leds[] = {2 L+ W0 {' v0 W' f. U9 ?6 P4 j( K
{$ C6 \' w% \4 V! G2 c: S0 ~, Q
.active_low = 0,
! C' e F) R7 W2 _$ |2 E .gpio = DA850_USER_LED0,
$ T# [7 S0 t/ X) X3 { .name = "user_led0",
' \) ~2 s7 h+ B7 \7 u' T. W .default_trigger = "default-on",
. m" h( X: N+ F% } },
' Y, {0 p: S" B, m4 M0 ?6 } {
& [2 z- U$ f% w8 S9 G% C .active_low = 0,: ^( n3 r' f$ o7 x
.gpio = DA850_USER_LED1,
8 Y+ q* @" X& l0 x9 m ]' d .name = "user_led1",' a, F( q* ~, Z+ Q7 r+ c' p" E7 ?- F
.default_trigger = "default-on",
1 E3 t. c- n4 N+ h },
5 Q/ ]" \8 S6 z6 _1 i {
7 _. \6 }! G8 l .active_low = 0,$ g2 p/ ?( K' L1 n* b, Q3 f
.gpio = DA850_USER_LED2,2 q- y) y( L. M( o8 b2 C9 y2 l, h
.name = "user_led2",* \0 q5 T- G& r7 ^5 n
.default_trigger = "default-on",
+ \/ m) L, T7 K) }, _ },/ j' X# [- P5 S
{
# [0 a7 O% d6 |7 D; m2 Z# [ .active_low = 0,
3 a' o0 z' G2 p5 f- a+ f7 c .gpio = DA850_USER_LED3,
5 U& `- H. E3 q6 H- V .name = "user_led3",
& `, [1 y- }( D% F" n; ]* W4 Y* L5 S .default_trigger = "default-on",8 u* S @) \: L: ` S
},& s0 N) ]' B' @) k* T
};% H' _0 n% e- b0 k" y6 E
/ P; n; H$ O" y5 i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 c, D8 J+ I; D. I! ]2 P
.leds = da850_evm_tl_leds,
# R) ~/ V7 g% c# ~( F6 X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 t6 z* w g' L p5 u/ f l. e# Q
};3 {! P6 P$ k, M2 P' k6 c6 }* }/ D6 z
/ _1 b" T$ E8 G5 a& J5 x, E
static void led_dev_release(struct device *dev)9 F+ `0 y% {+ z% {! N
{
7 t& W# k+ H6 g' Z2 T, D% k};+ K( a. M0 F7 z/ E+ t, a
7 s$ q9 W2 D# D9 q, l
static struct platform_device da850_evm_tl_leds_device = {
2 s! a: d( s+ I; h .name = "leds-gpio",
" c: ~; ]" W6 D. M0 L .id = 1,
2 E: W7 h4 J# e, L/ h% g7 f .dev = {
( C% n; F* w. E9 c- T .platform_data = &da850_evm_tl_leds_pdata,4 k. a) u- m2 z: T. h2 i7 Y: t- C
.release = led_dev_release,
; L7 @: J3 q$ D4 X/ x }
/ `. B* A! E* | `};
' P, G" v$ r% y+ N6 j
V8 I5 h: r$ J9 T8 V Q3 ystatic int __init led_platform_init(void); h8 H7 |. C# z: b
{3 @0 p" \' j( \2 ^3 U
int ret;
, w, q5 ~* F% i/ r6 o% d#if 0* }6 ~' ~" A) w/ m. G/ d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- Q9 c- V/ T# O) ]2 H! i' U+ ~ if (ret)
: c# x# {) a- ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! e6 g5 {% s3 U" _# Y' U' v1 ]6 O
"%d\n", ret);
. o" G5 L8 ?& h0 r) T0 n) @#endif7 h2 b6 p5 O; H0 O- K$ H
ret = platform_device_register(&da850_evm_tl_leds_device);
V) y0 n. O! L& t3 `' \9 N& r if (ret) r- K1 P4 `8 M; P$ R7 S
pr_warning("Could not register som GPIO expander LEDS");
: N6 E/ {# U. E e% K2 g- ~ else
6 f1 z2 S& o8 t printk(KERN_INFO "LED register sucessful!\n");5 l# D$ a3 a4 } i2 R
& ^+ w% e# Q. ?9 M3 B8 D2 B4 s- ]
return ret;
3 f" d+ _, d# \5 L}
& T- S0 P8 `% H
8 D: f2 t1 `5 }5 @& k, Qstatic void __exit led_platform_exit(void)
9 u* u$ o7 M* t: F& u. M. x{
$ s2 K& C. R# K1 x platform_device_unregister(&da850_evm_tl_leds_device);% m8 D6 e" H: s$ |- V0 n/ d
3 a$ P6 F; C3 z% y% b
printk(KERN_INFO "LED unregister!\n");8 p. ~; U) i1 L8 w+ a7 D! Q
}
; \: ?1 v n+ L2 W" i) A5 O9 C& i- P( k% E! a8 w+ _
module_init(led_platform_init);8 {; X" ^4 T) E* y4 @
module_exit(led_platform_exit);
' i% S1 P. P/ o' E* B& q
$ n! t4 ]9 Q* T% vMODULE_DESCRIPTION("Led platform driver");
0 h7 y" h/ c+ S. t* j( iMODULE_AUTHOR("Tronlong");" ]. f, n: i/ k' J
MODULE_LICENSE("GPL");
6 M1 M% a2 ~# O; S6 ?# r
* p0 {# R" e3 ^ |
|