|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! w% k5 H, [! P/ v2 L1 [" A: a#include <linux/init.h>
! d9 p. J( q& d' B7 r#include <linux/module.h>
2 v3 K; Z% j' z& u3 ]4 _#include <linux/kernel.h>7 ^) F5 O1 T" `* V9 g, p6 a5 L4 y, X
#include <linux/types.h>. ]) c2 W0 I. t4 f
#include <linux/gpio.h>
; @4 M" x/ Q1 ]8 u' b#include <linux/leds.h>5 p( U3 Y; X6 {" o3 J! o$ e
#include <linux/platform_device.h>
8 p1 m% _1 A; G9 x, p/ y& F8 O) x }
#include <asm/mach-types.h>5 Q1 U( P; B& b( c* \) E
#include <asm/mach/arch.h>
9 Z' M3 J6 p% K7 K8 o#include <mach/da8xx.h>
6 C1 w8 V4 Z! m& l#include <mach/mux.h>
6 H3 A6 p$ b8 e9 ~# d, i4 e: d4 T9 O+ O, P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 K& w( ] M2 Q- K p. u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 ^# z5 C1 O% \4 t; F
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 N$ s& i# T+ l8 s- u2 k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: R4 b/ U/ ]; `& ^% P2 `$ K
# c* \% C5 o* k3 o/* assign the tl som board LED-GPIOs*/; f6 d4 Q! g/ A: ^$ H
static const short da850_evm_tl_user_led_pins[] = {
- u; k) P( P; W6 ^ /* These pins are definition at <mach/mux.h> file */" |8 g6 W$ s- u3 a. Q% W2 E* I5 h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# k% X3 ~" R8 d% \3 W -1- o' I- [; I6 j& a, E8 n* } A
};1 L. o# J) B7 \6 [0 x
5 b' [" i! a0 d/ Vstatic struct gpio_led da850_evm_tl_leds[] = {
$ K. T0 f% q3 g2 h. c {3 S2 B) U: J4 ?( |
.active_low = 0,0 Y; b( J+ m4 l
.gpio = DA850_USER_LED0,9 T$ \+ E0 y3 O2 [
.name = "user_led0",- L) I% V! B w
.default_trigger = "default-on",$ _+ y- n0 O, {1 `
},
: ~9 \4 b1 b: K& b+ ]! m% F {
4 b4 H& Z5 G' Z9 L B2 r .active_low = 0,
" p7 X" g: F/ @6 F. V8 j1 ? t .gpio = DA850_USER_LED1,# v/ T& Y: E! j. a9 |& h
.name = "user_led1",
( k5 P$ G8 x7 `6 U .default_trigger = "default-on",
1 L# t3 R% C- |2 s/ W4 g8 o" R },0 |2 H& J# X/ \
{
- F, K) H" _, Q) L, O1 H .active_low = 0,
0 ]7 _' W3 x8 J- d! \ G .gpio = DA850_USER_LED2,& a/ o$ A/ C2 P4 Z* r: {! J
.name = "user_led2",4 l6 R4 ]( O& u# i! `8 J5 N& t
.default_trigger = "default-on",& G* }; y3 E, L1 k% B
},% L' ?- R R# Y C- u' _& r
{7 O0 x6 U- R. i, x8 D& @4 K
.active_low = 0,) a9 ~- O$ _( _2 W8 h4 n$ k% G. k
.gpio = DA850_USER_LED3,2 J/ R; `% p8 P7 F
.name = "user_led3",
! K. A% K/ _6 W; ?: ` .default_trigger = "default-on",) m" K2 @; g4 o1 d( F
},* l- i+ \0 ?2 ]* Z: K9 G
};
- f; h7 c3 J/ K j" ~% x: g% f' j9 \6 d' S0 z! n7 J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: X/ S. Z& I0 s. w" Z0 f .leds = da850_evm_tl_leds,
* I8 N3 X3 G8 d' T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# D r8 h! J& O" r ]. u
};
( B) _7 ^% w4 a% B7 s( o) E- l5 J P/ `, l) ]6 b9 C# S' v- l& }/ m
static void led_dev_release(struct device *dev)! V9 V# Y) ^' B( l2 U. Q6 i
{
: b Y: n0 l) _: h. O( f7 U};
9 s; Q1 ~' M2 n) ?6 q6 g7 B+ b! d
4 \" d* v- x& v8 K U7 j8 Vstatic struct platform_device da850_evm_tl_leds_device = {
, `! G. d4 Y; N9 C .name = "leds-gpio",, d' n3 ?3 ]2 X1 d# E$ J
.id = 1,
# r6 r2 d4 W" \0 m' O .dev = {& z- ^3 R J; W" b8 Q. K
.platform_data = &da850_evm_tl_leds_pdata,6 n0 \6 ]& u" H* L( S
.release = led_dev_release,
/ t5 V8 A* z4 Q3 S$ E& g }
4 Q+ o# P" Z7 ?! u};
- t: |# l U$ o1 h# g: C) K4 l" c1 j% m
static int __init led_platform_init(void)
6 N; y+ [( Y+ ~- E1 Y{* P2 g) x& e3 u H7 H( Y$ u4 U
int ret;8 F8 k2 n. ^9 V1 v: w! I
#if 0
" w! m+ w" f8 F- H4 p4 c9 W5 v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 N2 e# } C& B {$ w6 D if (ret)2 L5 [0 x/ _0 L+ ~% J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 i; U0 j9 r n+ c( n5 T
"%d\n", ret);9 b1 f1 S2 N- b9 y4 e9 n
#endif6 q& Y; T2 z* f& {2 [( M" ]
ret = platform_device_register(&da850_evm_tl_leds_device);- ~# K( W- h9 G" D0 ~# `0 y" n
if (ret)+ i6 |' F7 [& Z9 d; z2 c
pr_warning("Could not register som GPIO expander LEDS");
( P* L( Y- L5 K" o ?& ^ else
# T* p) j2 \, l: u4 K5 { printk(KERN_INFO "LED register sucessful!\n");
& M9 y3 q5 \5 A( n9 o4 r/ _2 r8 i# w$ Y: i: Q3 a* t
return ret; c1 u. u$ }0 l) b2 x+ z
}
" m1 B9 T" v0 X" N+ ]' r ~! [! f
static void __exit led_platform_exit(void), W3 s* q' z0 t+ o. _
{
4 \ N7 X9 D3 ~# o7 U platform_device_unregister(&da850_evm_tl_leds_device);
% V9 e( I8 c9 R- D, z* |' H; D- T% o6 w; {" N
printk(KERN_INFO "LED unregister!\n");
! b" g& {, V& z0 {& T, x}
! c( {* L* A5 H3 K2 y2 e4 w1 K8 Q. I" O0 k& O
module_init(led_platform_init);/ @$ O$ Z+ q4 @2 }9 k9 B/ m$ c- H- X
module_exit(led_platform_exit);1 l: W a, s( ^' j
4 ?3 N) T" L, L- i# t; X7 dMODULE_DESCRIPTION("Led platform driver");( O$ x' q% _4 J
MODULE_AUTHOR("Tronlong");
: T: S/ z S" [8 m9 E( LMODULE_LICENSE("GPL");
/ |+ X+ l* \" N1 T$ A! F# O4 n9 m5 X& s; G. T! j1 U
|
|