summaryrefslogtreecommitdiffstats
path: root/drivers/dma/ioatdma_io.h
blob: c0b4bf66c9200a9f27954b7dd4adb83745d57ce1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called COPYING.
 */
#ifndef IOATDMA_IO_H
#define IOATDMA_IO_H

#include <asm/io.h>

/*
 * device and per-channel MMIO register read and write functions
 * this is a lot of anoying inline functions, but it's typesafe
 */

static inline u8 ioatdma_read8(struct ioat_device *device,
                               unsigned int offset)
{
	return readb(device->reg_base + offset);
}

static inline u16 ioatdma_read16(struct ioat_device *device,
                                 unsigned int offset)
{
	return readw(device->reg_base + offset);
}

static inline u32 ioatdma_read32(struct ioat_device *device,
                                 unsigned int offset)
{
	return readl(device->reg_base + offset);
}

static inline void ioatdma_write8(struct ioat_device *device,
                                  unsigned int offset, u8 value)
{
	writeb(value, device->reg_base + offset);
}

static inline void ioatdma_write16(struct ioat_device *device,
                                   unsigned int offset, u16 value)
{
	writew(value, device->reg_base + offset);
}

static inline void ioatdma_write32(struct ioat_device *device,
                                   unsigned int offset, u32 value)
{
	writel(value, device->reg_base + offset);
}

static inline u8 ioatdma_chan_read8(struct ioat_dma_chan *chan,
                                    unsigned int offset)
{
	return readb(chan->reg_base + offset);
}

static inline u16 ioatdma_chan_read16(struct ioat_dma_chan *chan,
                                      unsigned int offset)
{
	return readw(chan->reg_base + offset);
}

static inline u32 ioatdma_chan_read32(struct ioat_dma_chan *chan,
                                      unsigned int offset)
{
	return readl(chan->reg_base + offset);
}

static inline void ioatdma_chan_write8(struct ioat_dma_chan *chan,
                                       unsigned int offset, u8 value)
{
	writeb(value, chan->reg_base + offset);
}

static inline void ioatdma_chan_write16(struct ioat_dma_chan *chan,
                                        unsigned int offset, u16 value)
{
	writew(value, chan->reg_base + offset);
}

static inline void ioatdma_chan_write32(struct ioat_dma_chan *chan,
                                        unsigned int offset, u32 value)
{
	writel(value, chan->reg_base + offset);
}

#if (BITS_PER_LONG == 64)
static inline u64 ioatdma_chan_read64(struct ioat_dma_chan *chan,
                                      unsigned int offset)
{
	return readq(chan->reg_base + offset);
}

static inline void ioatdma_chan_write64(struct ioat_dma_chan *chan,
                                        unsigned int offset, u64 value)
{
	writeq(value, chan->reg_base + offset);
}
#endif

#endif /* IOATDMA_IO_H */

OpenPOWER on IntegriCloud