|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ J) \; ` f" {+ I3 X#include <linux/init.h>
# q" h7 {/ n* K5 I" L" F! I#include <linux/module.h>3 y/ W2 m1 D0 i4 L) ?$ ?8 H: K
#include <linux/kernel.h>
5 L; t5 `) _0 Q#include <linux/types.h>
2 ]. v" O( a7 k" O4 O$ _& }#include <linux/gpio.h>
4 K6 f$ k$ J e. Y: q9 U3 n#include <linux/leds.h>
! o& \2 o3 z T4 W) s#include <linux/platform_device.h>
' {5 b$ D5 B, Y6 E- b0 [6 d3 C
9 a$ n) H; p8 U) Y$ @#include <asm/mach-types.h>
0 a( K6 @) K5 l. [#include <asm/mach/arch.h>
4 g& q; \7 V7 G#include <mach/da8xx.h>
* B+ U) ^- k3 g# P* I5 t#include <mach/mux.h>
}1 i/ c8 X4 x0 |3 { c+ r1 j, R+ J0 I1 g# A8 a3 S) X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 T$ |, n, K) T' W' {* m( g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
J; {+ b" N5 i- ]% k+ ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( [* T8 T+ i$ n1 B( o) [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( }3 r( W/ w, y, t2 N; D- A' g, l0 H2 Q- K, x2 ]2 i
/* assign the tl som board LED-GPIOs*/! J& O* g$ ^8 Y% M. K/ s
static const short da850_evm_tl_user_led_pins[] = {
4 Q. \: @* V* O& Q: c( K2 G /* These pins are definition at <mach/mux.h> file */! Q$ @! p$ i' M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- h& T6 A9 E; r: j* X, a -10 H" e/ o% V+ w/ _) Z4 |
}; v3 j2 V! k' `: \
- B4 D7 D4 w6 M4 T* m E
static struct gpio_led da850_evm_tl_leds[] = {
% V! J. `$ Z2 c8 l& }# K {
2 `" q6 W! q/ J& J .active_low = 0,
! R$ A. A; ^( I! E .gpio = DA850_USER_LED0,) K/ z. M, ^# H4 s0 F* @
.name = "user_led0",
% C' x) f6 S6 Q .default_trigger = "default-on",
Y- d, L$ i5 X1 f0 C$ n" j# R* E! p },4 ~1 E" O, w/ q* L
{
/ Z, Q$ q+ b0 r* z+ q0 A .active_low = 0,
, f" O2 e# E) B# l, @' K6 k" Z: j .gpio = DA850_USER_LED1,
2 o) s: `7 W5 D, |$ y .name = "user_led1",! d4 i+ X& R) w) d, h% F
.default_trigger = "default-on",; m( o7 }# L0 J
},
; ^8 k2 F P# k# Y5 C9 ^0 t$ e {6 F3 ^ S! `2 }# i3 T
.active_low = 0,
. e8 f: Q% K1 B/ V .gpio = DA850_USER_LED2,8 I7 e2 _0 e9 [. H* s
.name = "user_led2",4 f! F! Q# q' M: N$ o8 o* }
.default_trigger = "default-on",+ {' m2 H t/ e9 F+ ?* ]! k
},
+ D: b8 R( c$ O1 g9 k {
% K2 ^6 G3 v6 h$ E" i* X .active_low = 0,% X! Q; h$ a# \7 U! z% t
.gpio = DA850_USER_LED3,# |5 K1 t4 ^3 L0 W! D m
.name = "user_led3",) U. _' P8 x5 K8 Q
.default_trigger = "default-on",* s5 b' E+ _0 z, n1 x9 n
},
* d2 M' R4 B) w};0 c3 U" M( M+ V( O* h! }
- y F" A/ c( k7 ?$ ~" fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { C: V4 b# c: r" R8 `; I
.leds = da850_evm_tl_leds,& [* M$ y3 o* o1 f& c; Y$ ?* t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 h9 T; C7 c, o& o* q2 N8 Y# ~};1 ?; x# U3 m2 u0 ]. C5 T! h
: G) W, W8 G1 M1 }7 O
static void led_dev_release(struct device *dev)
$ N$ ^/ |. ]2 m7 v6 O{0 r: k0 Z; a# ^$ k. {# k
};4 ?9 ]0 Y/ o& y8 d8 H# [9 @
; u) D5 w3 R, S E5 S4 Q) H: @: Fstatic struct platform_device da850_evm_tl_leds_device = {
4 ?( x+ I- j3 w .name = "leds-gpio",& v1 w: x$ i' \+ \ R8 x; P
.id = 1,8 B- _, u4 f) O
.dev = {8 D2 g. J1 ?/ h9 j. c ?4 x G
.platform_data = &da850_evm_tl_leds_pdata,
, w! F9 W7 C, J& S& r .release = led_dev_release,8 ?' [. k- D, W5 Z
}
: P& d* S& T# z5 f/ T" g6 ~! G# n7 W y};
4 N* [+ ]! [, j! S8 m2 p6 w/ O; L
4 A9 V$ F' d# `) ostatic int __init led_platform_init(void)
2 u& u6 |' j, Q9 o# i{: j1 r3 c8 h0 }6 B
int ret;
8 l7 d2 Q. ]9 k( L1 n, o8 j8 W# z#if 0
' R7 A- W, C/ ~/ e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 d* g9 h" i7 k- E1 k% [% l
if (ret)/ Z4 c1 H- w y% U6 x. I; g3 {9 G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") [3 H' B) Z/ ~/ r
"%d\n", ret);
; p7 _. a9 S3 W( g#endif% p: e+ F4 P6 G% I4 d
ret = platform_device_register(&da850_evm_tl_leds_device);
# [5 b9 `- z, Z5 C# @, o if (ret)7 h2 L# l& O/ Y( c+ R2 o& @
pr_warning("Could not register som GPIO expander LEDS");4 i- N0 i: R, F, O9 x# A
else, C0 P9 J* s' q
printk(KERN_INFO "LED register sucessful!\n");# N1 `, \& @% h/ C
' J( W7 V6 F. \; ^$ w return ret;9 P- e z. m/ m8 f& C) r3 }
}* ^$ N# E" Z' h4 [; W
* h$ E/ O5 W1 C8 P N
static void __exit led_platform_exit(void): v' h4 E" e* d
{
4 E; W* g3 [3 G% k: P platform_device_unregister(&da850_evm_tl_leds_device);
g2 t* G. @' R& P' d+ [% p5 H
printk(KERN_INFO "LED unregister!\n");5 b9 `3 V+ L5 h
}- H- ~- D, `" @& B
; H& Z, D6 b- {' @ ^/ t8 O4 c7 Y3 bmodule_init(led_platform_init);
9 r1 t$ T7 a2 s* E }module_exit(led_platform_exit);
2 h+ ~. C1 J- P4 O n+ e) g1 R# i
MODULE_DESCRIPTION("Led platform driver");
$ p' G. t6 F/ q1 r$ x1 V4 k3 XMODULE_AUTHOR("Tronlong");
7 V4 g& u( |$ a( m( a, XMODULE_LICENSE("GPL");
/ h z0 _* l- t" z6 J7 |; i8 }% i% f2 o. r' Q9 J
|
|