.. | .. |
---|
3 | 3 | * Copyright (C) 2017 HiSilicon Limited, All Rights Reserved. |
---|
4 | 4 | * Author: Gabriele Paoloni <gabriele.paoloni@huawei.com> |
---|
5 | 5 | * Author: Zhichang Yuan <yuanzhichang@hisilicon.com> |
---|
| 6 | + * Author: John Garry <john.garry@huawei.com> |
---|
6 | 7 | */ |
---|
7 | 8 | |
---|
8 | 9 | #define pr_fmt(fmt) "LOGIC PIO: " fmt |
---|
.. | .. |
---|
41 | 42 | resource_size_t iio_sz = MMIO_UPPER_LIMIT; |
---|
42 | 43 | int ret = 0; |
---|
43 | 44 | |
---|
44 | | - if (!new_range || !new_range->fwnode || !new_range->size) |
---|
| 45 | + if (!new_range || !new_range->fwnode || !new_range->size || |
---|
| 46 | + (new_range->flags == LOGIC_PIO_INDIRECT && !new_range->ops)) |
---|
45 | 47 | return -EINVAL; |
---|
46 | 48 | |
---|
47 | 49 | start = new_range->hw_start; |
---|
.. | .. |
---|
230 | 232 | } |
---|
231 | 233 | |
---|
232 | 234 | #if defined(CONFIG_INDIRECT_PIO) && defined(PCI_IOBASE) |
---|
233 | | -#define BUILD_LOGIC_IO(bw, type) \ |
---|
234 | | -type logic_in##bw(unsigned long addr) \ |
---|
| 235 | +#define BUILD_LOGIC_IO(bwl, type) \ |
---|
| 236 | +type logic_in##bwl(unsigned long addr) \ |
---|
235 | 237 | { \ |
---|
236 | 238 | type ret = (type)~0; \ |
---|
237 | 239 | \ |
---|
238 | 240 | if (addr < MMIO_UPPER_LIMIT) { \ |
---|
239 | | - ret = read##bw(PCI_IOBASE + addr); \ |
---|
| 241 | + ret = _in##bwl(addr); \ |
---|
240 | 242 | } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ |
---|
241 | 243 | struct logic_pio_hwaddr *entry = find_io_range(addr); \ |
---|
242 | 244 | \ |
---|
243 | | - if (entry && entry->ops) \ |
---|
| 245 | + if (entry) \ |
---|
244 | 246 | ret = entry->ops->in(entry->hostdata, \ |
---|
245 | 247 | addr, sizeof(type)); \ |
---|
246 | 248 | else \ |
---|
.. | .. |
---|
249 | 251 | return ret; \ |
---|
250 | 252 | } \ |
---|
251 | 253 | \ |
---|
252 | | -void logic_out##bw(type value, unsigned long addr) \ |
---|
| 254 | +void logic_out##bwl(type value, unsigned long addr) \ |
---|
253 | 255 | { \ |
---|
254 | 256 | if (addr < MMIO_UPPER_LIMIT) { \ |
---|
255 | | - write##bw(value, PCI_IOBASE + addr); \ |
---|
| 257 | + _out##bwl(value, addr); \ |
---|
256 | 258 | } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ |
---|
257 | 259 | struct logic_pio_hwaddr *entry = find_io_range(addr); \ |
---|
258 | 260 | \ |
---|
259 | | - if (entry && entry->ops) \ |
---|
| 261 | + if (entry) \ |
---|
260 | 262 | entry->ops->out(entry->hostdata, \ |
---|
261 | 263 | addr, value, sizeof(type)); \ |
---|
262 | 264 | else \ |
---|
.. | .. |
---|
264 | 266 | } \ |
---|
265 | 267 | } \ |
---|
266 | 268 | \ |
---|
267 | | -void logic_ins##bw(unsigned long addr, void *buffer, \ |
---|
268 | | - unsigned int count) \ |
---|
| 269 | +void logic_ins##bwl(unsigned long addr, void *buffer, \ |
---|
| 270 | + unsigned int count) \ |
---|
269 | 271 | { \ |
---|
270 | 272 | if (addr < MMIO_UPPER_LIMIT) { \ |
---|
271 | | - reads##bw(PCI_IOBASE + addr, buffer, count); \ |
---|
| 273 | + reads##bwl(PCI_IOBASE + addr, buffer, count); \ |
---|
272 | 274 | } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ |
---|
273 | 275 | struct logic_pio_hwaddr *entry = find_io_range(addr); \ |
---|
274 | 276 | \ |
---|
275 | | - if (entry && entry->ops) \ |
---|
| 277 | + if (entry) \ |
---|
276 | 278 | entry->ops->ins(entry->hostdata, \ |
---|
277 | 279 | addr, buffer, sizeof(type), count); \ |
---|
278 | 280 | else \ |
---|
.. | .. |
---|
281 | 283 | \ |
---|
282 | 284 | } \ |
---|
283 | 285 | \ |
---|
284 | | -void logic_outs##bw(unsigned long addr, const void *buffer, \ |
---|
285 | | - unsigned int count) \ |
---|
| 286 | +void logic_outs##bwl(unsigned long addr, const void *buffer, \ |
---|
| 287 | + unsigned int count) \ |
---|
286 | 288 | { \ |
---|
287 | 289 | if (addr < MMIO_UPPER_LIMIT) { \ |
---|
288 | | - writes##bw(PCI_IOBASE + addr, buffer, count); \ |
---|
| 290 | + writes##bwl(PCI_IOBASE + addr, buffer, count); \ |
---|
289 | 291 | } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ |
---|
290 | 292 | struct logic_pio_hwaddr *entry = find_io_range(addr); \ |
---|
291 | 293 | \ |
---|
292 | | - if (entry && entry->ops) \ |
---|
| 294 | + if (entry) \ |
---|
293 | 295 | entry->ops->outs(entry->hostdata, \ |
---|
294 | 296 | addr, buffer, sizeof(type), count); \ |
---|
295 | 297 | else \ |
---|