|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" t) G4 B7 h M1 u+ b; P#include <linux/init.h>
) r2 T4 q* T! j7 ]$ {* o2 n#include <linux/module.h>
+ w; X7 e& N5 h4 l( r% e$ r#include <linux/kernel.h>
8 R6 e9 Z; h# {5 k6 |0 }#include <linux/types.h>- K- r$ ]; Y, |) \4 r
#include <linux/gpio.h>& q/ T5 u7 {# l9 L2 q% E
#include <linux/leds.h>" b; U- u3 {3 P" `( o6 T% o
#include <linux/platform_device.h>
- Y7 j8 { Y/ n! Z! Q% u5 |! ]: h/ @. S0 c
#include <asm/mach-types.h>- S: F# F U9 Z( X: n
#include <asm/mach/arch.h> h+ R2 N% H1 C, J5 s, Q; d- O
#include <mach/da8xx.h>
- F- H. f$ j! j. D! ?, u' M- Q#include <mach/mux.h>
, b- j- U. k" G9 b. X
9 d+ f6 v( |# Z2 m6 N$ |+ I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% ]' w% O0 J# `/ ]+ D5 m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( J) Q( t: e/ I) h& V1 o; ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 n/ A; H" \3 L; ?' o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): f- ^7 S1 y4 G" M+ ^* a/ \6 w' j
! `) h/ i( o K' U; A5 q
/* assign the tl som board LED-GPIOs*/
! C' |: r1 }2 S7 pstatic const short da850_evm_tl_user_led_pins[] = {+ D# L) j4 D8 W, b' J2 S4 ]
/* These pins are definition at <mach/mux.h> file */
; z' E2 N3 ]& k/ Z" I5 H$ p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ G3 n) o! p# _! a# H -1
5 l+ F" N i" D# u$ i};4 m6 ^8 z6 u& C, H: l; O
( H4 M+ I8 x& u& cstatic struct gpio_led da850_evm_tl_leds[] = {
4 u5 Z3 [) h/ X. x/ G {$ E9 S# L* ?- X7 z* A! r* }
.active_low = 0," b. P1 A8 O; Y/ {4 a4 B! h* }
.gpio = DA850_USER_LED0,* B1 S5 M! U( `3 Y+ C3 [
.name = "user_led0",/ M1 A! h6 K i
.default_trigger = "default-on",/ {! E; x* [4 s5 h: V& E" @+ |
},
; ~) ^+ a+ e8 H- b8 P {
$ D/ h# F) A( h, e2 \" R3 ? .active_low = 0,
( {' X7 P# m' Z3 y3 P5 Z; m .gpio = DA850_USER_LED1,
$ }* t% _' z& T8 s6 } }& I6 ? .name = "user_led1",% U; u$ l$ [' l2 U) g7 M) ?
.default_trigger = "default-on",
7 l5 Z" x% b7 v9 q; u' F7 F j& _ },
( K3 s# h$ x, @7 ]" p {
# I$ f3 _, R7 O# G4 \ .active_low = 0,3 ]% _! y% T3 S
.gpio = DA850_USER_LED2,4 ~6 m+ [, W8 r7 U; O1 X8 G& _& D- b
.name = "user_led2",1 Z0 c0 ~% O, G( q: k0 C9 L
.default_trigger = "default-on",* Z( ]# M% F, K. F% ^, }: I8 o
},
1 Z; U7 ?; Y4 ~5 `& [0 s {
E7 \2 ^5 I. s3 G# \% h1 R9 n .active_low = 0, k/ e% ^- n7 N+ w* a
.gpio = DA850_USER_LED3,
- {8 N, l [; Q$ p. K2 |* a; | .name = "user_led3",
% Q8 D, @: E" s4 c& s .default_trigger = "default-on",
; R* L8 a. ?$ l9 I( { q, C },
/ k" H* W3 T6 O};% Y2 q3 l, s( A* ~5 @' U7 \* }8 X) p
) z0 h( q/ m7 Q1 I2 t9 g( _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ `( _) T! I& N2 H5 [
.leds = da850_evm_tl_leds,
2 N+ _$ f" _# o5 _# g: N9 W .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! O9 |. X. `# U: ^+ T' j7 x7 e
};6 R4 ]" x1 G3 O& z. ?
! T3 D; c: F' Q
static void led_dev_release(struct device *dev)
3 W/ F3 Q Z8 o# i' c5 d{
3 b9 }0 m$ f$ k};7 Q& A/ b$ f' |7 r o( Y
9 S3 Z# G1 b* f( ^2 t# pstatic struct platform_device da850_evm_tl_leds_device = {
5 e) R0 A( @! T) Y' n3 ^; d .name = "leds-gpio",
0 r3 y2 S# D6 P: i2 J/ L .id = 1,+ t5 I! p3 }; W/ a" @/ V1 L/ W
.dev = {
9 P+ u) t8 x" z% k5 P6 a: P .platform_data = &da850_evm_tl_leds_pdata,
' Z& ^; }, S- y .release = led_dev_release,) q' e. E$ v& j. t' w
}
2 R: [! p% K$ B* s# {};1 s5 o, I/ u- C8 F4 w7 j( r
7 q e. b. i( ?) n) [. X# q
static int __init led_platform_init(void)
9 a' f4 G+ w9 u# E{
, H; ~ e3 f3 i int ret;
* w) e9 C1 l( F1 p/ \#if 0- U( l1 j6 l' d% h4 T$ b1 \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- v1 s5 ^ z6 b+ S$ L& |( o1 Y$ d if (ret): \9 R2 `$ T. f3 @' u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", {$ t4 x7 U$ g: T2 B
"%d\n", ret);4 v* x5 l3 E: m) E
#endif7 x3 F0 ]3 T7 g+ B. a. \% R
ret = platform_device_register(&da850_evm_tl_leds_device);
" s" W! ]: Y. Y! I if (ret)
( Y/ w9 ]/ l- W6 C3 x pr_warning("Could not register som GPIO expander LEDS");1 W9 D, T) H V# H
else
+ M w9 G A! x5 l7 E printk(KERN_INFO "LED register sucessful!\n"); a0 z) u. a0 o. h4 n9 |* M
1 E5 \8 W5 P9 @$ q6 @
return ret;. g! C0 f2 z6 _2 Z
}
$ s% R- T9 k6 z
" @0 e6 \- l# V; e" L! Astatic void __exit led_platform_exit(void)' D% w2 Q* q9 B" l: O
{" D( d/ h/ O$ i8 O
platform_device_unregister(&da850_evm_tl_leds_device);8 a5 n. w6 f% ]5 o& i! |# {
7 W: w o5 s! g' d, a printk(KERN_INFO "LED unregister!\n");
; k5 Z4 U. L' m, u% {: @}: ]9 {4 k- `# q. I; t/ g T/ [
O+ _9 t7 ~8 b# ~3 }module_init(led_platform_init);
; J3 Z' {9 S+ Q6 D1 E) \$ G3 zmodule_exit(led_platform_exit);) m9 V6 p9 d% J+ x0 a, z& u6 K7 ?7 O' [; h
# i7 A# A4 o O; V
MODULE_DESCRIPTION("Led platform driver");2 x+ n/ ?* @7 g( h' c! u9 b8 S
MODULE_AUTHOR("Tronlong");
; f5 `6 o0 `/ S/ G. v* c+ m; ^" IMODULE_LICENSE("GPL");
1 z$ t# g, N3 b
$ y7 L9 F2 H5 g; q+ h1 u8 E |
|