|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ Q/ b! i& k' {; V$ A; Y# z7 Q#include <linux/init.h>
* p" G) M* d5 q$ N9 b0 s# x# ~1 q+ |#include <linux/module.h>
7 n2 X) {5 q. D/ C# r6 K3 j1 f#include <linux/kernel.h>
6 z- \1 }9 A% T b$ ~1 F#include <linux/types.h>
. u( {0 t$ a; M9 X) v#include <linux/gpio.h>
9 ]4 _, d [7 q- ^! u#include <linux/leds.h>+ r6 A+ _" x/ V" S
#include <linux/platform_device.h>, `7 C1 I) K4 G. {
$ h7 B K' W( \5 N3 K9 e
#include <asm/mach-types.h>5 }; E+ Z) o7 D8 D9 T6 D- v" s
#include <asm/mach/arch.h>
7 ~; V+ |5 }( k8 y. b#include <mach/da8xx.h>* I; l3 x# O& W6 c. o
#include <mach/mux.h>
- M) U D. M1 U: d) { P- G' v. s$ { J3 L1 p* f. ]
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' \' e+ c. U$ t4 h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) V8 {( z) d, p' X
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; l1 Q/ m. I, e/ o#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
}/ J* C) g5 n& m8 u4 Y; r7 D: g9 A, @' P2 e( O1 v
/* assign the tl som board LED-GPIOs*/) W3 M+ ~# b# l3 d, y( @7 p8 j
static const short da850_evm_tl_user_led_pins[] = {
3 x8 ]' y& K3 W" R7 M1 |1 s /* These pins are definition at <mach/mux.h> file */+ s2 X, T( Q9 V- c X2 l& B5 v0 a2 ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 S9 y% L$ m" @ u6 c -1
4 @ p& t/ |0 \7 z6 j};5 ?: m4 q' r$ F; q: |& o
5 Q. I: ~6 L/ O2 [; ?: u
static struct gpio_led da850_evm_tl_leds[] = {5 T C0 }9 H, Q9 L+ [7 p
{
5 L) [& \. k# }+ i9 e .active_low = 0,
. U3 O. w ^- o5 a6 H$ O .gpio = DA850_USER_LED0,9 c6 D* [$ o% B
.name = "user_led0",+ h6 c$ r* |, m; m0 v5 t' m
.default_trigger = "default-on",5 }0 K* z$ _! D7 o; t7 v6 m
},+ V! L9 H7 Z# b6 M5 z* u* q! O
{
' A9 N- b% K8 e+ z" W) `, E% b8 W .active_low = 0,- D' z9 S p3 b
.gpio = DA850_USER_LED1,# A! x: {" t, I9 p, m$ u$ E K
.name = "user_led1",1 C0 Z4 ~' u- q1 m
.default_trigger = "default-on",, E" ~6 Q' k( O- d l: i
},
}6 ^2 L, R$ [) K4 U+ S {" x; u4 |3 m# K' h! f0 L
.active_low = 0,
0 `4 f! H6 L$ W1 Q .gpio = DA850_USER_LED2,* z3 Y5 H) b" q% Q: l2 I
.name = "user_led2",
# [3 b$ Z# h. p& Z& m .default_trigger = "default-on",
% d1 I* h) R, E" a! } },
6 m! I: t l# f3 A {
8 F: ^$ V/ _6 S4 n .active_low = 0,2 R/ Q3 s+ Q* j: h
.gpio = DA850_USER_LED3,
. M5 S! y4 p! e2 s3 F4 ^ .name = "user_led3",
8 c* d$ K1 U2 k/ b8 v% m .default_trigger = "default-on",
6 h$ |& i8 L6 }( X },
. G# p! q# M5 H: M; Q};
4 a: A( ~+ h0 T7 |; ~$ p. Z2 [) ?" F: X, v2 k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" [- V2 Y( `0 A8 T L
.leds = da850_evm_tl_leds,
- z( E/ T$ D) ~; W9 a .num_leds = ARRAY_SIZE(da850_evm_tl_leds), I4 i# l1 \( O- V- I# [) b
};9 j5 n" Z! b# [6 l
' A. O4 r& P; t) Mstatic void led_dev_release(struct device *dev)0 J2 w- H9 l2 q& H
{
" W7 E1 r# x5 u};* ?3 h# _' V) `6 G
' i, x7 o/ S7 @4 s( gstatic struct platform_device da850_evm_tl_leds_device = {; b f( z& K% D8 ~1 n# ]
.name = "leds-gpio",
0 B) X. p- d. G7 ?, K .id = 1,
. M! l2 \2 d3 p# H. U .dev = {
$ p9 P2 m7 o4 ]+ A, w W7 C( e4 T .platform_data = &da850_evm_tl_leds_pdata,
# P3 F! S4 t( k .release = led_dev_release,
( @9 y; r; X% |1 S A8 y/ I( v }* m! b8 d9 K! I- L7 |1 A( ^
};1 q' ^1 v; X }4 }( U+ I
- k# ?6 p4 J# ?5 B; e
static int __init led_platform_init(void)$ Q' x- v' x. W# f& @
{
4 \( j+ l0 K3 f, H4 C0 } int ret;
/ |6 u5 t( t: T b1 F, l#if 0
2 ^/ Q9 O" g9 t. @. J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" h+ f' ?1 J/ v- L
if (ret)6 q- k- g" F8 b0 n& o) B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 A- ` L, R& _; Q* l
"%d\n", ret);
8 u$ t, L9 a3 p2 t3 Z& K#endif, u- ~6 D! D+ F8 X, v
ret = platform_device_register(&da850_evm_tl_leds_device);
8 C& Z& F# }0 q) F if (ret)% @4 G4 i w6 x- X6 s, B6 Y2 \; N4 A
pr_warning("Could not register som GPIO expander LEDS");
# z+ o; f G$ W f4 R+ @! x else
5 T9 n# ?' K! a; V! p printk(KERN_INFO "LED register sucessful!\n");& \5 H4 R) {, f, q2 Q7 ~
+ w; M4 o6 K! R/ B2 `- O' A i# ^6 w
return ret;
# @! r; o% {( ~" d& _}
9 O6 ^9 I, i: a1 k$ s* G) X% ^) K5 x( l* a
static void __exit led_platform_exit(void)
$ {' v' W# `2 t% w6 X# W' s' K{* \" o% k6 U, X0 o/ B! p4 m
platform_device_unregister(&da850_evm_tl_leds_device);
. `1 e2 x L' I O
+ w; v$ Z9 h8 z7 Z printk(KERN_INFO "LED unregister!\n");
/ D. ^% _ A: b) V}
7 h0 R0 F$ D' `
6 e. G; m" M, c/ f- _1 @* E% nmodule_init(led_platform_init);- ]* P7 O. s5 Z/ O
module_exit(led_platform_exit);
7 U/ i0 Y* S- ]8 L. g# } s9 i# F( B7 \. R+ k
MODULE_DESCRIPTION("Led platform driver");1 {: m, c3 [9 M
MODULE_AUTHOR("Tronlong");7 J! b3 }; r5 @2 X9 t e
MODULE_LICENSE("GPL");
( s9 z/ n8 u3 S
9 _1 \! r2 {) S3 ? |
|