Commit 3e494c80481653bbc810b4e67651097595ea0294

Authored by Stephen Rothwell
Committed by Paul Mackerras
1 parent 6020164499

[PATCH] ppc64: split iSeries specific parts out of vio.c

This patch splits the iSeries specific parts out of vio.c.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>

Showing 4 changed files with 166 additions and 125 deletions Side-by-side Diff

arch/ppc64/kernel/Makefile
... ... @@ -50,7 +50,9 @@
50 50 obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o
51 51 obj-$(CONFIG_BOOTX_TEXT) += btext.o
52 52 obj-$(CONFIG_HVCS) += hvcserver.o
53   -obj-$(CONFIG_IBMVIO) += vio.o
  53 +
  54 +vio-obj-$(CONFIG_PPC_ISERIES) += iSeries_vio.o
  55 +obj-$(CONFIG_IBMVIO) += vio.o $(vio-obj-y)
54 56 obj-$(CONFIG_XICS) += xics.o
55 57 obj-$(CONFIG_MPIC) += mpic.o
56 58  
arch/ppc64/kernel/iSeries_vio.c
  1 +/*
  2 + * IBM PowerPC iSeries Virtual I/O Infrastructure Support.
  3 + *
  4 + * Copyright (c) 2005 Stephen Rothwell, IBM Corp.
  5 + *
  6 + * This program is free software; you can redistribute it and/or
  7 + * modify it under the terms of the GNU General Public License
  8 + * as published by the Free Software Foundation; either version
  9 + * 2 of the License, or (at your option) any later version.
  10 + */
  11 +#include <linux/types.h>
  12 +#include <linux/device.h>
  13 +#include <linux/init.h>
  14 +
  15 +#include <asm/vio.h>
  16 +#include <asm/iommu.h>
  17 +#include <asm/abs_addr.h>
  18 +#include <asm/page.h>
  19 +#include <asm/iSeries/vio.h>
  20 +#include <asm/iSeries/HvTypes.h>
  21 +#include <asm/iSeries/HvLpConfig.h>
  22 +#include <asm/iSeries/HvCallXm.h>
  23 +
  24 +struct device *iSeries_vio_dev = &vio_bus_device.dev;
  25 +EXPORT_SYMBOL(iSeries_vio_dev);
  26 +
  27 +static struct iommu_table veth_iommu_table;
  28 +static struct iommu_table vio_iommu_table;
  29 +
  30 +void __init iommu_vio_init(void)
  31 +{
  32 + struct iommu_table *t;
  33 + struct iommu_table_cb cb;
  34 + unsigned long cbp;
  35 + unsigned long itc_entries;
  36 +
  37 + cb.itc_busno = 255; /* Bus 255 is the virtual bus */
  38 + cb.itc_virtbus = 0xff; /* Ask for virtual bus */
  39 +
  40 + cbp = virt_to_abs(&cb);
  41 + HvCallXm_getTceTableParms(cbp);
  42 +
  43 + itc_entries = cb.itc_size * PAGE_SIZE / sizeof(union tce_entry);
  44 + veth_iommu_table.it_size = itc_entries / 2;
  45 + veth_iommu_table.it_busno = cb.itc_busno;
  46 + veth_iommu_table.it_offset = cb.itc_offset;
  47 + veth_iommu_table.it_index = cb.itc_index;
  48 + veth_iommu_table.it_type = TCE_VB;
  49 + veth_iommu_table.it_blocksize = 1;
  50 +
  51 + t = iommu_init_table(&veth_iommu_table);
  52 +
  53 + if (!t)
  54 + printk("Virtual Bus VETH TCE table failed.\n");
  55 +
  56 + vio_iommu_table.it_size = itc_entries - veth_iommu_table.it_size;
  57 + vio_iommu_table.it_busno = cb.itc_busno;
  58 + vio_iommu_table.it_offset = cb.itc_offset +
  59 + veth_iommu_table.it_size;
  60 + vio_iommu_table.it_index = cb.itc_index;
  61 + vio_iommu_table.it_type = TCE_VB;
  62 + vio_iommu_table.it_blocksize = 1;
  63 +
  64 + t = iommu_init_table(&vio_iommu_table);
  65 +
  66 + if (!t)
  67 + printk("Virtual Bus VIO TCE table failed.\n");
  68 +}
  69 +
  70 +/**
  71 + * vio_register_device: - Register a new vio device.
  72 + * @voidev: The device to register.
  73 + */
  74 +static struct vio_dev *__init vio_register_device_iseries(char *type,
  75 + uint32_t unit_num)
  76 +{
  77 + struct vio_dev *viodev;
  78 +
  79 + /* allocate a vio_dev for this node */
  80 + viodev = kmalloc(sizeof(struct vio_dev), GFP_KERNEL);
  81 + if (!viodev)
  82 + return NULL;
  83 + memset(viodev, 0, sizeof(struct vio_dev));
  84 +
  85 + snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%s%d", type, unit_num);
  86 +
  87 + return vio_register_device_common(viodev, viodev->dev.bus_id, type,
  88 + unit_num, &vio_iommu_table);
  89 +}
  90 +
  91 +void __init probe_bus_iseries(void)
  92 +{
  93 + HvLpIndexMap vlan_map;
  94 + struct vio_dev *viodev;
  95 + int i;
  96 +
  97 + /* there is only one of each of these */
  98 + vio_register_device_iseries("viocons", 0);
  99 + vio_register_device_iseries("vscsi", 0);
  100 +
  101 + vlan_map = HvLpConfig_getVirtualLanIndexMap();
  102 + for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++) {
  103 + if ((vlan_map & (0x8000 >> i)) == 0)
  104 + continue;
  105 + viodev = vio_register_device_iseries("vlan", i);
  106 + /* veth is special and has it own iommu_table */
  107 + viodev->iommu_table = &veth_iommu_table;
  108 + }
  109 + for (i = 0; i < HVMAXARCHITECTEDVIRTUALDISKS; i++)
  110 + vio_register_device_iseries("viodasd", i);
  111 + for (i = 0; i < HVMAXARCHITECTEDVIRTUALCDROMS; i++)
  112 + vio_register_device_iseries("viocd", i);
  113 + for (i = 0; i < HVMAXARCHITECTEDVIRTUALTAPES; i++)
  114 + vio_register_device_iseries("viotape", i);
  115 +}
  116 +
  117 +/**
  118 + * vio_bus_init_iseries: - Initialize the iSeries virtual IO bus
  119 + */
  120 +static int __init vio_bus_init_iseries(void)
  121 +{
  122 + int err;
  123 +
  124 + err = vio_bus_init();
  125 + if (err == 0) {
  126 + vio_bus_device.iommu_table = &vio_iommu_table;
  127 + iSeries_vio_dev = &vio_bus_device.dev;
  128 + probe_bus_iseries();
  129 + }
  130 + return err;
  131 +}
  132 +
  133 +__initcall(vio_bus_init_iseries);
arch/ppc64/kernel/vio.c
... ... @@ -25,10 +25,6 @@
25 25 #include <asm/ppcdebug.h>
26 26 #include <asm/vio.h>
27 27 #include <asm/hvcall.h>
28   -#include <asm/iSeries/vio.h>
29   -#include <asm/iSeries/HvTypes.h>
30   -#include <asm/iSeries/HvCallXm.h>
31   -#include <asm/iSeries/HvLpConfig.h>
32 28  
33 29 #define DBGENTER() pr_debug("%s entered\n", __FUNCTION__)
34 30  
35 31  
36 32  
37 33  
... ... @@ -41,27 +37,15 @@
41 37 static struct iommu_table *vio_build_iommu_table(struct vio_dev *);
42 38 static int vio_num_address_cells;
43 39 #endif
44   -#ifdef CONFIG_PPC_ISERIES
45   -static struct iommu_table veth_iommu_table;
46   -static struct iommu_table vio_iommu_table;
47   -#endif
48   -static struct vio_dev vio_bus_device = { /* fake "parent" device */
  40 +struct vio_dev vio_bus_device = { /* fake "parent" device */
49 41 .name = vio_bus_device.dev.bus_id,
50 42 .type = "",
51   -#ifdef CONFIG_PPC_ISERIES
52   - .iommu_table = &vio_iommu_table,
53   -#endif
54 43 .dev.bus_id = "vio",
55 44 .dev.bus = &vio_bus_type,
56 45 };
57 46  
58 47 #ifdef CONFIG_PPC_ISERIES
59   -static struct vio_dev *__init vio_register_device_iseries(char *type,
60   - uint32_t unit_num);
61 48  
62   -struct device *iSeries_vio_dev = &vio_bus_device.dev;
63   -EXPORT_SYMBOL(iSeries_vio_dev);
64   -
65 49 #define device_is_compatible(a, b) 1
66 50  
67 51 #endif
... ... @@ -157,48 +141,6 @@
157 141 return NULL;
158 142 }
159 143  
160   -#ifdef CONFIG_PPC_ISERIES
161   -void __init iommu_vio_init(void)
162   -{
163   - struct iommu_table *t;
164   - struct iommu_table_cb cb;
165   - unsigned long cbp;
166   - unsigned long itc_entries;
167   -
168   - cb.itc_busno = 255; /* Bus 255 is the virtual bus */
169   - cb.itc_virtbus = 0xff; /* Ask for virtual bus */
170   -
171   - cbp = virt_to_abs(&cb);
172   - HvCallXm_getTceTableParms(cbp);
173   -
174   - itc_entries = cb.itc_size * PAGE_SIZE / sizeof(union tce_entry);
175   - veth_iommu_table.it_size = itc_entries / 2;
176   - veth_iommu_table.it_busno = cb.itc_busno;
177   - veth_iommu_table.it_offset = cb.itc_offset;
178   - veth_iommu_table.it_index = cb.itc_index;
179   - veth_iommu_table.it_type = TCE_VB;
180   - veth_iommu_table.it_blocksize = 1;
181   -
182   - t = iommu_init_table(&veth_iommu_table);
183   -
184   - if (!t)
185   - printk("Virtual Bus VETH TCE table failed.\n");
186   -
187   - vio_iommu_table.it_size = itc_entries - veth_iommu_table.it_size;
188   - vio_iommu_table.it_busno = cb.itc_busno;
189   - vio_iommu_table.it_offset = cb.itc_offset +
190   - veth_iommu_table.it_size;
191   - vio_iommu_table.it_index = cb.itc_index;
192   - vio_iommu_table.it_type = TCE_VB;
193   - vio_iommu_table.it_blocksize = 1;
194   -
195   - t = iommu_init_table(&vio_iommu_table);
196   -
197   - if (!t)
198   - printk("Virtual Bus VIO TCE table failed.\n");
199   -}
200   -#endif
201   -
202 144 #ifdef CONFIG_PPC_PSERIES
203 145 static void probe_bus_pseries(void)
204 146 {
205 147  
... ... @@ -223,38 +165,10 @@
223 165 }
224 166 #endif
225 167  
226   -#ifdef CONFIG_PPC_ISERIES
227   -static void probe_bus_iseries(void)
228   -{
229   - HvLpIndexMap vlan_map = HvLpConfig_getVirtualLanIndexMap();
230   - struct vio_dev *viodev;
231   - int i;
232   -
233   - /* there is only one of each of these */
234   - vio_register_device_iseries("viocons", 0);
235   - vio_register_device_iseries("vscsi", 0);
236   -
237   - vlan_map = HvLpConfig_getVirtualLanIndexMap();
238   - for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++) {
239   - if ((vlan_map & (0x8000 >> i)) == 0)
240   - continue;
241   - viodev = vio_register_device_iseries("vlan", i);
242   - /* veth is special and has it own iommu_table */
243   - viodev->iommu_table = &veth_iommu_table;
244   - }
245   - for (i = 0; i < HVMAXARCHITECTEDVIRTUALDISKS; i++)
246   - vio_register_device_iseries("viodasd", i);
247   - for (i = 0; i < HVMAXARCHITECTEDVIRTUALCDROMS; i++)
248   - vio_register_device_iseries("viocd", i);
249   - for (i = 0; i < HVMAXARCHITECTEDVIRTUALTAPES; i++)
250   - vio_register_device_iseries("viotape", i);
251   -}
252   -#endif
253   -
254 168 /**
255 169 * vio_bus_init: - Initialize the virtual IO bus
256 170 */
257   -static int __init vio_bus_init(void)
  171 +int __init vio_bus_init(void)
258 172 {
259 173 int err;
260 174  
261 175  
262 176  
263 177  
264 178  
265 179  
... ... @@ -264,25 +178,35 @@
264 178 return err;
265 179 }
266 180  
267   - /* the fake parent of all vio devices, just to give us a nice directory */
  181 + /* the fake parent of all vio devices, just to give us
  182 + * a nice directory
  183 + */
268 184 err = device_register(&vio_bus_device.dev);
269 185 if (err) {
270   - printk(KERN_WARNING "%s: device_register returned %i\n", __FUNCTION__,
271   - err);
  186 + printk(KERN_WARNING "%s: device_register returned %i\n",
  187 + __FUNCTION__, err);
272 188 return err;
273 189 }
274 190  
  191 + return 0;
  192 +}
  193 +
275 194 #ifdef CONFIG_PPC_PSERIES
276   - probe_bus_pseries();
277   -#endif
278   -#ifdef CONFIG_PPC_ISERIES
279   - probe_bus_iseries();
280   -#endif
  195 +/**
  196 + * vio_bus_init_pseries: - Initialize the pSeries virtual IO bus
  197 + */
  198 +static int __init vio_bus_init_pseries(void)
  199 +{
  200 + int err;
281 201  
282   - return 0;
  202 + err = vio_bus_init();
  203 + if (err == 0)
  204 + probe_bus_pseries();
  205 + return err;
283 206 }
284 207  
285   -__initcall(vio_bus_init);
  208 +__initcall(vio_bus_init_pseries);
  209 +#endif
286 210  
287 211 /* vio_dev refcount hit 0 */
288 212 static void __devinit vio_dev_release(struct device *dev)
... ... @@ -312,7 +236,7 @@
312 236 }
313 237 DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_name, NULL);
314 238  
315   -static struct vio_dev * __devinit vio_register_device_common(
  239 +struct vio_dev * __devinit vio_register_device_common(
316 240 struct vio_dev *viodev, char *name, char *type,
317 241 uint32_t unit_address, struct iommu_table *iommu_table)
318 242 {
... ... @@ -406,31 +330,6 @@
406 330 return viodev;
407 331 }
408 332 EXPORT_SYMBOL(vio_register_device_node);
409   -#endif
410   -
411   -#ifdef CONFIG_PPC_ISERIES
412   -/**
413   - * vio_register_device: - Register a new vio device.
414   - * @voidev: The device to register.
415   - */
416   -static struct vio_dev *__init vio_register_device_iseries(char *type,
417   - uint32_t unit_num)
418   -{
419   - struct vio_dev *viodev;
420   -
421   - DBGENTER();
422   -
423   - /* allocate a vio_dev for this node */
424   - viodev = kmalloc(sizeof(struct vio_dev), GFP_KERNEL);
425   - if (!viodev)
426   - return NULL;
427   - memset(viodev, 0, sizeof(struct vio_dev));
428   -
429   - snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%s%d", type, unit_num);
430   -
431   - return vio_register_device_common(viodev, viodev->dev.bus_id, type,
432   - unit_num, &vio_iommu_table);
433   -}
434 333 #endif
435 334  
436 335 void __devinit vio_unregister_device(struct vio_dev *viodev)
include/asm-ppc64/vio.h
... ... @@ -56,6 +56,9 @@
56 56 int vio_get_irq(struct vio_dev *dev);
57 57 int vio_enable_interrupts(struct vio_dev *dev);
58 58 int vio_disable_interrupts(struct vio_dev *dev);
  59 +extern struct vio_dev * __devinit vio_register_device_common(
  60 + struct vio_dev *viodev, char *name, char *type,
  61 + uint32_t unit_address, struct iommu_table *iommu_table);
59 62  
60 63 extern struct dma_mapping_ops vio_dma_ops;
61 64  
62 65  
... ... @@ -95,10 +98,14 @@
95 98 struct device dev;
96 99 };
97 100  
  101 +extern struct vio_dev vio_bus_device;
  102 +
98 103 static inline struct vio_dev *to_vio_dev(struct device *dev)
99 104 {
100 105 return container_of(dev, struct vio_dev, dev);
101 106 }
  107 +
  108 +extern int vio_bus_init(void);
102 109  
103 110 #endif /* _ASM_VIO_H */