hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/lib/logic_pio.c
....@@ -3,6 +3,7 @@
33 * Copyright (C) 2017 HiSilicon Limited, All Rights Reserved.
44 * Author: Gabriele Paoloni <gabriele.paoloni@huawei.com>
55 * Author: Zhichang Yuan <yuanzhichang@hisilicon.com>
6
+ * Author: John Garry <john.garry@huawei.com>
67 */
78
89 #define pr_fmt(fmt) "LOGIC PIO: " fmt
....@@ -41,7 +42,8 @@
4142 resource_size_t iio_sz = MMIO_UPPER_LIMIT;
4243 int ret = 0;
4344
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))
4547 return -EINVAL;
4648
4749 start = new_range->hw_start;
....@@ -230,17 +232,17 @@
230232 }
231233
232234 #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) \
235237 { \
236238 type ret = (type)~0; \
237239 \
238240 if (addr < MMIO_UPPER_LIMIT) { \
239
- ret = read##bw(PCI_IOBASE + addr); \
241
+ ret = _in##bwl(addr); \
240242 } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
241243 struct logic_pio_hwaddr *entry = find_io_range(addr); \
242244 \
243
- if (entry && entry->ops) \
245
+ if (entry) \
244246 ret = entry->ops->in(entry->hostdata, \
245247 addr, sizeof(type)); \
246248 else \
....@@ -249,14 +251,14 @@
249251 return ret; \
250252 } \
251253 \
252
-void logic_out##bw(type value, unsigned long addr) \
254
+void logic_out##bwl(type value, unsigned long addr) \
253255 { \
254256 if (addr < MMIO_UPPER_LIMIT) { \
255
- write##bw(value, PCI_IOBASE + addr); \
257
+ _out##bwl(value, addr); \
256258 } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
257259 struct logic_pio_hwaddr *entry = find_io_range(addr); \
258260 \
259
- if (entry && entry->ops) \
261
+ if (entry) \
260262 entry->ops->out(entry->hostdata, \
261263 addr, value, sizeof(type)); \
262264 else \
....@@ -264,15 +266,15 @@
264266 } \
265267 } \
266268 \
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) \
269271 { \
270272 if (addr < MMIO_UPPER_LIMIT) { \
271
- reads##bw(PCI_IOBASE + addr, buffer, count); \
273
+ reads##bwl(PCI_IOBASE + addr, buffer, count); \
272274 } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
273275 struct logic_pio_hwaddr *entry = find_io_range(addr); \
274276 \
275
- if (entry && entry->ops) \
277
+ if (entry) \
276278 entry->ops->ins(entry->hostdata, \
277279 addr, buffer, sizeof(type), count); \
278280 else \
....@@ -281,15 +283,15 @@
281283 \
282284 } \
283285 \
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) \
286288 { \
287289 if (addr < MMIO_UPPER_LIMIT) { \
288
- writes##bw(PCI_IOBASE + addr, buffer, count); \
290
+ writes##bwl(PCI_IOBASE + addr, buffer, count); \
289291 } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
290292 struct logic_pio_hwaddr *entry = find_io_range(addr); \
291293 \
292
- if (entry && entry->ops) \
294
+ if (entry) \
293295 entry->ops->outs(entry->hostdata, \
294296 addr, buffer, sizeof(type), count); \
295297 else \