blob: 33c10864d2f773dc9bb265d8285db9fcabc9d7d7 [file] [log] [blame]
Chris Metcalff02cbbe2010-11-02 12:05:10 -04001/*
Chris Metcalf398fa5a2011-05-02 15:09:42 -04002 * Copyright 2011 Tilera Corporation. All Rights Reserved.
Chris Metcalff02cbbe2010-11-02 12:05:10 -04003 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15#include <linux/kernel.h>
16#include <linux/pci.h>
17#include <linux/delay.h>
18#include <linux/string.h>
19#include <linux/init.h>
20#include <linux/capability.h>
21#include <linux/sched.h>
22#include <linux/errno.h>
23#include <linux/bootmem.h>
24#include <linux/irq.h>
25#include <linux/io.h>
26#include <linux/uaccess.h>
Chris Metcalf3989efb2011-12-01 11:37:20 -050027#include <linux/export.h>
Chris Metcalff02cbbe2010-11-02 12:05:10 -040028
29#include <asm/processor.h>
30#include <asm/sections.h>
31#include <asm/byteorder.h>
32#include <asm/hv_driver.h>
33#include <hv/drv_pcie_rc_intf.h>
34
35
36/*
37 * Initialization flow and process
38 * -------------------------------
39 *
Lucas De Marchi25985ed2011-03-30 22:57:33 -030040 * This files contains the routines to search for PCI buses,
Chris Metcalff02cbbe2010-11-02 12:05:10 -040041 * enumerate the buses, and configure any attached devices.
42 *
43 * There are two entry points here:
44 * 1) tile_pci_init
45 * This sets up the pci_controller structs, and opens the
46 * FDs to the hypervisor. This is called from setup_arch() early
47 * in the boot process.
48 * 2) pcibios_init
49 * This probes the PCI bus(es) for any attached hardware. It's
50 * called by subsys_initcall. All of the real work is done by the
51 * generic Linux PCI layer.
52 *
53 */
54
55/*
56 * This flag tells if the platform is TILEmpower that needs
57 * special configuration for the PLX switch chip.
58 */
59int __write_once tile_plx_gen1;
60
61static struct pci_controller controllers[TILE_NUM_PCIE];
62static int num_controllers;
Chris Metcalf398fa5a2011-05-02 15:09:42 -040063static int pci_scan_flags[TILE_NUM_PCIE];
Chris Metcalff02cbbe2010-11-02 12:05:10 -040064
65static struct pci_ops tile_cfg_ops;
66
67
68/*
69 * We don't need to worry about the alignment of resources.
70 */
71resource_size_t pcibios_align_resource(void *data, const struct resource *res,
72 resource_size_t size, resource_size_t align)
73{
74 return res->start;
75}
76EXPORT_SYMBOL(pcibios_align_resource);
77
78/*
79 * Open a FD to the hypervisor PCI device.
80 *
81 * controller_id is the controller number, config type is 0 or 1 for
82 * config0 or config1 operations.
83 */
Chris Metcalf398fa5a2011-05-02 15:09:42 -040084static int __devinit tile_pcie_open(int controller_id, int config_type)
Chris Metcalff02cbbe2010-11-02 12:05:10 -040085{
86 char filename[32];
87 int fd;
88
89 sprintf(filename, "pcie/%d/config%d", controller_id, config_type);
90
91 fd = hv_dev_open((HV_VirtAddr)filename, 0);
92
93 return fd;
94}
95
96
97/*
98 * Get the IRQ numbers from the HV and set up the handlers for them.
99 */
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400100static int __devinit tile_init_irqs(int controller_id,
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400101 struct pci_controller *controller)
102{
103 char filename[32];
104 int fd;
105 int ret;
106 int x;
107 struct pcie_rc_config rc_config;
108
109 sprintf(filename, "pcie/%d/ctl", controller_id);
110 fd = hv_dev_open((HV_VirtAddr)filename, 0);
111 if (fd < 0) {
112 pr_err("PCI: hv_dev_open(%s) failed\n", filename);
113 return -1;
114 }
115 ret = hv_dev_pread(fd, 0, (HV_VirtAddr)(&rc_config),
116 sizeof(rc_config), PCIE_RC_CONFIG_MASK_OFF);
117 hv_dev_close(fd);
118 if (ret != sizeof(rc_config)) {
119 pr_err("PCI: wanted %zd bytes, got %d\n",
120 sizeof(rc_config), ret);
121 return -1;
122 }
123 /* Record irq_base so that we can map INTx to IRQ # later. */
124 controller->irq_base = rc_config.intr;
125
126 for (x = 0; x < 4; x++)
127 tile_irq_activate(rc_config.intr + x,
128 TILE_IRQ_HW_CLEAR);
129
130 if (rc_config.plx_gen1)
131 controller->plx_gen1 = 1;
132
133 return 0;
134}
135
136/*
137 * First initialization entry point, called from setup_arch().
138 *
139 * Find valid controllers and fill in pci_controller structs for each
140 * of them.
141 *
142 * Returns the number of controllers discovered.
143 */
Chris Metcalf05ef1b72012-04-25 12:45:26 -0400144int __init tile_pci_init(void)
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400145{
146 int i;
147
148 pr_info("PCI: Searching for controllers...\n");
149
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400150 /* Re-init number of PCIe controllers to support hot-plug feature. */
151 num_controllers = 0;
152
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400153 /* Do any configuration we need before using the PCIe */
154
155 for (i = 0; i < TILE_NUM_PCIE; i++) {
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400156 /*
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400157 * To see whether we need a real config op based on
158 * the results of pcibios_init(), to support PCIe hot-plug.
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400159 */
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400160 if (pci_scan_flags[i] == 0) {
161 int hv_cfg_fd0 = -1;
162 int hv_cfg_fd1 = -1;
163 int hv_mem_fd = -1;
164 char name[32];
165 struct pci_controller *controller;
166
167 /*
168 * Open the fd to the HV. If it fails then this
169 * device doesn't exist.
170 */
171 hv_cfg_fd0 = tile_pcie_open(i, 0);
172 if (hv_cfg_fd0 < 0)
173 continue;
174 hv_cfg_fd1 = tile_pcie_open(i, 1);
175 if (hv_cfg_fd1 < 0) {
176 pr_err("PCI: Couldn't open config fd to HV "
177 "for controller %d\n", i);
178 goto err_cont;
179 }
180
181 sprintf(name, "pcie/%d/mem", i);
182 hv_mem_fd = hv_dev_open((HV_VirtAddr)name, 0);
183 if (hv_mem_fd < 0) {
184 pr_err("PCI: Could not open mem fd to HV!\n");
185 goto err_cont;
186 }
187
188 pr_info("PCI: Found PCI controller #%d\n", i);
189
190 controller = &controllers[i];
191
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400192 controller->index = i;
193 controller->hv_cfg_fd[0] = hv_cfg_fd0;
194 controller->hv_cfg_fd[1] = hv_cfg_fd1;
195 controller->hv_mem_fd = hv_mem_fd;
196 controller->first_busno = 0;
197 controller->last_busno = 0xff;
198 controller->ops = &tile_cfg_ops;
199
200 num_controllers++;
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400201 continue;
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400202
203err_cont:
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400204 if (hv_cfg_fd0 >= 0)
205 hv_dev_close(hv_cfg_fd0);
206 if (hv_cfg_fd1 >= 0)
207 hv_dev_close(hv_cfg_fd1);
208 if (hv_mem_fd >= 0)
209 hv_dev_close(hv_mem_fd);
210 continue;
211 }
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400212 }
213
214 /*
215 * Before using the PCIe, see if we need to do any platform-specific
216 * configuration, such as the PLX switch Gen 1 issue on TILEmpower.
217 */
218 for (i = 0; i < num_controllers; i++) {
219 struct pci_controller *controller = &controllers[i];
220
221 if (controller->plx_gen1)
222 tile_plx_gen1 = 1;
223 }
224
225 return num_controllers;
226}
227
228/*
229 * (pin - 1) converts from the PCI standard's [1:4] convention to
230 * a normal [0:3] range.
231 */
Ralf Baechled5341942011-06-10 15:30:21 +0100232static int tile_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400233{
234 struct pci_controller *controller =
235 (struct pci_controller *)dev->sysdata;
236 return (pin - 1) + controller->irq_base;
237}
238
239
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400240static void __devinit fixup_read_and_payload_sizes(void)
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400241{
242 struct pci_dev *dev = NULL;
243 int smallest_max_payload = 0x1; /* Tile maxes out at 256 bytes. */
244 int max_read_size = 0x2; /* Limit to 512 byte reads. */
245 u16 new_values;
246
247 /* Scan for the smallest maximum payload size. */
248 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
249 int pcie_caps_offset;
250 u32 devcap;
251 int max_payload;
252
253 pcie_caps_offset = pci_find_capability(dev, PCI_CAP_ID_EXP);
254 if (pcie_caps_offset == 0)
255 continue;
256
257 pci_read_config_dword(dev, pcie_caps_offset + PCI_EXP_DEVCAP,
258 &devcap);
259 max_payload = devcap & PCI_EXP_DEVCAP_PAYLOAD;
260 if (max_payload < smallest_max_payload)
261 smallest_max_payload = max_payload;
262 }
263
264 /* Now, set the max_payload_size for all devices to that value. */
265 new_values = (max_read_size << 12) | (smallest_max_payload << 5);
266 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
267 int pcie_caps_offset;
268 u16 devctl;
269
270 pcie_caps_offset = pci_find_capability(dev, PCI_CAP_ID_EXP);
271 if (pcie_caps_offset == 0)
272 continue;
273
274 pci_read_config_word(dev, pcie_caps_offset + PCI_EXP_DEVCTL,
275 &devctl);
276 devctl &= ~(PCI_EXP_DEVCTL_PAYLOAD | PCI_EXP_DEVCTL_READRQ);
277 devctl |= new_values;
278 pci_write_config_word(dev, pcie_caps_offset + PCI_EXP_DEVCTL,
279 devctl);
280 }
281}
282
283
284/*
285 * Second PCI initialization entry point, called by subsys_initcall.
286 *
287 * The controllers have been set up by the time we get here, by a call to
288 * tile_pci_init.
289 */
Chris Metcalf05ef1b72012-04-25 12:45:26 -0400290int __init pcibios_init(void)
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400291{
292 int i;
293
294 pr_info("PCI: Probing PCI hardware\n");
295
296 /*
297 * Delay a bit in case devices aren't ready. Some devices are
298 * known to require at least 20ms here, but we use a more
299 * conservative value.
300 */
301 mdelay(250);
302
303 /* Scan all of the recorded PCI controllers. */
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400304 for (i = 0; i < TILE_NUM_PCIE; i++) {
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400305 /*
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400306 * Do real pcibios init ops if the controller is initialized
307 * by tile_pci_init() successfully and not initialized by
308 * pcibios_init() yet to support PCIe hot-plug.
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400309 */
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400310 if (pci_scan_flags[i] == 0 && controllers[i].ops != NULL) {
311 struct pci_controller *controller = &controllers[i];
312 struct pci_bus *bus;
Yinghai Lub17c0e62012-05-17 18:51:13 -0700313 LIST_HEAD(resources);
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400314
Chris Metcalff4de51d2011-05-17 15:25:21 -0400315 if (tile_init_irqs(i, controller)) {
316 pr_err("PCI: Could not initialize IRQs\n");
317 continue;
318 }
319
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400320 pr_info("PCI: initializing controller #%d\n", i);
321
322 /*
323 * This comes from the generic Linux PCI driver.
324 *
325 * It reads the PCI tree for this bus into the Linux
326 * data structures.
327 *
328 * This is inlined in linux/pci.h and calls into
329 * pci_scan_bus_parented() in probe.c.
330 */
Yinghai Lub17c0e62012-05-17 18:51:13 -0700331 pci_add_resource(&resources, &ioport_resource);
332 pci_add_resource(&resources, &iomem_resource);
333 bus = pci_scan_root_bus(NULL, 0, controller->ops, controller, &resources);
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400334 controller->root_bus = bus;
Yinghai Lub918c622012-05-17 18:51:11 -0700335 controller->last_busno = bus->busn_res.end;
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400336 }
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400337 }
338
339 /* Do machine dependent PCI interrupt routing */
340 pci_fixup_irqs(pci_common_swizzle, tile_map_irq);
341
342 /*
343 * This comes from the generic Linux PCI driver.
344 *
345 * It allocates all of the resources (I/O memory, etc)
346 * associated with the devices read in above.
347 */
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400348 pci_assign_unassigned_resources();
349
350 /* Configure the max_read_size and max_payload_size values. */
351 fixup_read_and_payload_sizes();
352
353 /* Record the I/O resources in the PCI controller structure. */
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400354 for (i = 0; i < TILE_NUM_PCIE; i++) {
355 /*
356 * Do real pcibios init ops if the controller is initialized
357 * by tile_pci_init() successfully and not initialized by
358 * pcibios_init() yet to support PCIe hot-plug.
359 */
360 if (pci_scan_flags[i] == 0 && controllers[i].ops != NULL) {
361 struct pci_bus *root_bus = controllers[i].root_bus;
362 struct pci_bus *next_bus;
363 struct pci_dev *dev;
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400364
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400365 list_for_each_entry(dev, &root_bus->devices, bus_list) {
366 /*
367 * Find the PCI host controller, ie. the 1st
368 * bridge.
369 */
370 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI &&
371 (PCI_SLOT(dev->devfn) == 0)) {
Chris Metcalf7f240b72012-07-25 15:49:23 -0400372 next_bus = dev->subordinate;
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400373 controllers[i].mem_resources[0] =
374 *next_bus->resource[0];
375 controllers[i].mem_resources[1] =
376 *next_bus->resource[1];
377 controllers[i].mem_resources[2] =
378 *next_bus->resource[2];
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400379
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400380 /* Setup flags. */
381 pci_scan_flags[i] = 1;
382
383 break;
384 }
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400385 }
386 }
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400387 }
388
389 return 0;
390}
391subsys_initcall(pcibios_init);
392
393/*
394 * No bus fixups needed.
395 */
396void __devinit pcibios_fixup_bus(struct pci_bus *bus)
397{
398 /* Nothing needs to be done. */
399}
400
Myron Stowecf1c5232011-10-28 15:48:17 -0600401void pcibios_set_master(struct pci_dev *dev)
402{
403 /* No special bus mastering setup handling. */
404}
405
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400406/*
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400407 * This is called from the generic Linux layer.
408 */
Chris Metcalf398fa5a2011-05-02 15:09:42 -0400409void __devinit pcibios_update_irq(struct pci_dev *dev, int irq)
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400410{
411 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
412}
413
414/*
415 * Enable memory and/or address decoding, as appropriate, for the
416 * device described by the 'dev' struct.
417 *
418 * This is called from the generic PCI layer, and can be called
419 * for bridges or endpoints.
420 */
421int pcibios_enable_device(struct pci_dev *dev, int mask)
422{
423 u16 cmd, old_cmd;
424 u8 header_type;
425 int i;
426 struct resource *r;
427
428 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
429
430 pci_read_config_word(dev, PCI_COMMAND, &cmd);
431 old_cmd = cmd;
432 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
433 /*
434 * For bridges, we enable both memory and I/O decoding
435 * in call cases.
436 */
437 cmd |= PCI_COMMAND_IO;
438 cmd |= PCI_COMMAND_MEMORY;
439 } else {
440 /*
441 * For endpoints, we enable memory and/or I/O decoding
442 * only if they have a memory resource of that type.
443 */
444 for (i = 0; i < 6; i++) {
445 r = &dev->resource[i];
446 if (r->flags & IORESOURCE_UNSET) {
447 pr_err("PCI: Device %s not available "
448 "because of resource collisions\n",
449 pci_name(dev));
450 return -EINVAL;
451 }
452 if (r->flags & IORESOURCE_IO)
453 cmd |= PCI_COMMAND_IO;
454 if (r->flags & IORESOURCE_MEM)
455 cmd |= PCI_COMMAND_MEMORY;
456 }
457 }
458
459 /*
460 * We only write the command if it changed.
461 */
462 if (cmd != old_cmd)
463 pci_write_config_word(dev, PCI_COMMAND, cmd);
464 return 0;
465}
466
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400467/****************************************************************
468 *
469 * Tile PCI config space read/write routines
470 *
471 ****************************************************************/
472
473/*
474 * These are the normal read and write ops
475 * These are expanded with macros from pci_bus_read_config_byte() etc.
476 *
477 * devfn is the combined PCI slot & function.
478 *
479 * offset is in bytes, from the start of config space for the
480 * specified bus & slot.
481 */
482
483static int __devinit tile_cfg_read(struct pci_bus *bus,
484 unsigned int devfn,
485 int offset,
486 int size,
487 u32 *val)
488{
489 struct pci_controller *controller = bus->sysdata;
490 int busnum = bus->number & 0xff;
491 int slot = (devfn >> 3) & 0x1f;
492 int function = devfn & 0x7;
493 u32 addr;
494 int config_mode = 1;
495
496 /*
497 * There is no bridge between the Tile and bus 0, so we
498 * use config0 to talk to bus 0.
499 *
500 * If we're talking to a bus other than zero then we
501 * must have found a bridge.
502 */
503 if (busnum == 0) {
504 /*
505 * We fake an empty slot for (busnum == 0) && (slot > 0),
506 * since there is only one slot on bus 0.
507 */
508 if (slot) {
509 *val = 0xFFFFFFFF;
510 return 0;
511 }
512 config_mode = 0;
513 }
514
515 addr = busnum << 20; /* Bus in 27:20 */
516 addr |= slot << 15; /* Slot (device) in 19:15 */
517 addr |= function << 12; /* Function is in 14:12 */
518 addr |= (offset & 0xFFF); /* byte address in 0:11 */
519
520 return hv_dev_pread(controller->hv_cfg_fd[config_mode], 0,
521 (HV_VirtAddr)(val), size, addr);
522}
523
524
525/*
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300526 * See tile_cfg_read() for relevant comments.
Chris Metcalff02cbbe2010-11-02 12:05:10 -0400527 * Note that "val" is the value to write, not a pointer to that value.
528 */
529static int __devinit tile_cfg_write(struct pci_bus *bus,
530 unsigned int devfn,
531 int offset,
532 int size,
533 u32 val)
534{
535 struct pci_controller *controller = bus->sysdata;
536 int busnum = bus->number & 0xff;
537 int slot = (devfn >> 3) & 0x1f;
538 int function = devfn & 0x7;
539 u32 addr;
540 int config_mode = 1;
541 HV_VirtAddr valp = (HV_VirtAddr)&val;
542
543 /*
544 * For bus 0 slot 0 we use config 0 accesses.
545 */
546 if (busnum == 0) {
547 /*
548 * We fake an empty slot for (busnum == 0) && (slot > 0),
549 * since there is only one slot on bus 0.
550 */
551 if (slot)
552 return 0;
553 config_mode = 0;
554 }
555
556 addr = busnum << 20; /* Bus in 27:20 */
557 addr |= slot << 15; /* Slot (device) in 19:15 */
558 addr |= function << 12; /* Function is in 14:12 */
559 addr |= (offset & 0xFFF); /* byte address in 0:11 */
560
561#ifdef __BIG_ENDIAN
562 /* Point to the correct part of the 32-bit "val". */
563 valp += 4 - size;
564#endif
565
566 return hv_dev_pwrite(controller->hv_cfg_fd[config_mode], 0,
567 valp, size, addr);
568}
569
570
571static struct pci_ops tile_cfg_ops = {
572 .read = tile_cfg_read,
573 .write = tile_cfg_write,
574};
575
576
577/*
578 * In the following, each PCI controller's mem_resources[1]
579 * represents its (non-prefetchable) PCI memory resource.
580 * mem_resources[0] and mem_resources[2] refer to its PCI I/O and
581 * prefetchable PCI memory resources, respectively.
582 * For more details, see pci_setup_bridge() in setup-bus.c.
583 * By comparing the target PCI memory address against the
584 * end address of controller 0, we can determine the controller
585 * that should accept the PCI memory access.
586 */
587#define TILE_READ(size, type) \
588type _tile_read##size(unsigned long addr) \
589{ \
590 type val; \
591 int idx = 0; \
592 if (addr > controllers[0].mem_resources[1].end && \
593 addr > controllers[0].mem_resources[2].end) \
594 idx = 1; \
595 if (hv_dev_pread(controllers[idx].hv_mem_fd, 0, \
596 (HV_VirtAddr)(&val), sizeof(type), addr)) \
597 pr_err("PCI: read %zd bytes at 0x%lX failed\n", \
598 sizeof(type), addr); \
599 return val; \
600} \
601EXPORT_SYMBOL(_tile_read##size)
602
603TILE_READ(b, u8);
604TILE_READ(w, u16);
605TILE_READ(l, u32);
606TILE_READ(q, u64);
607
608#define TILE_WRITE(size, type) \
609void _tile_write##size(type val, unsigned long addr) \
610{ \
611 int idx = 0; \
612 if (addr > controllers[0].mem_resources[1].end && \
613 addr > controllers[0].mem_resources[2].end) \
614 idx = 1; \
615 if (hv_dev_pwrite(controllers[idx].hv_mem_fd, 0, \
616 (HV_VirtAddr)(&val), sizeof(type), addr)) \
617 pr_err("PCI: write %zd bytes at 0x%lX failed\n", \
618 sizeof(type), addr); \
619} \
620EXPORT_SYMBOL(_tile_write##size)
621
622TILE_WRITE(b, u8);
623TILE_WRITE(w, u16);
624TILE_WRITE(l, u32);
625TILE_WRITE(q, u64);