[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>

authored by

Stephen Rothwell and committed by
Paul Mackerras
3e494c80 60201644

+167 -126
+3 -1
arch/ppc64/kernel/Makefile
··· 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
+133
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);
+24 -125
arch/ppc64/kernel/vio.c
··· 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 ··· 37 41 static struct iommu_table *vio_build_iommu_table(struct vio_dev *); 38 42 static int vio_num_address_cells; 39 43 #endif 40 - #ifdef CONFIG_PPC_ISERIES 41 - static struct iommu_table veth_iommu_table; 42 - static struct iommu_table vio_iommu_table; 43 - #endif 44 - static struct vio_dev vio_bus_device = { /* fake "parent" device */ 44 + struct vio_dev vio_bus_device = { /* fake "parent" device */ 45 45 .name = vio_bus_device.dev.bus_id, 46 46 .type = "", 47 - #ifdef CONFIG_PPC_ISERIES 48 - .iommu_table = &vio_iommu_table, 49 - #endif 50 47 .dev.bus_id = "vio", 51 48 .dev.bus = &vio_bus_type, 52 49 }; 53 50 54 51 #ifdef CONFIG_PPC_ISERIES 55 - static struct vio_dev *__init vio_register_device_iseries(char *type, 56 - uint32_t unit_num); 57 - 58 - struct device *iSeries_vio_dev = &vio_bus_device.dev; 59 - EXPORT_SYMBOL(iSeries_vio_dev); 60 52 61 53 #define device_is_compatible(a, b) 1 62 54 ··· 141 157 return NULL; 142 158 } 143 159 144 - #ifdef CONFIG_PPC_ISERIES 145 - void __init iommu_vio_init(void) 146 - { 147 - struct iommu_table *t; 148 - struct iommu_table_cb cb; 149 - unsigned long cbp; 150 - unsigned long itc_entries; 151 - 152 - cb.itc_busno = 255; /* Bus 255 is the virtual bus */ 153 - cb.itc_virtbus = 0xff; /* Ask for virtual bus */ 154 - 155 - cbp = virt_to_abs(&cb); 156 - HvCallXm_getTceTableParms(cbp); 157 - 158 - itc_entries = cb.itc_size * PAGE_SIZE / sizeof(union tce_entry); 159 - veth_iommu_table.it_size = itc_entries / 2; 160 - veth_iommu_table.it_busno = cb.itc_busno; 161 - veth_iommu_table.it_offset = cb.itc_offset; 162 - veth_iommu_table.it_index = cb.itc_index; 163 - veth_iommu_table.it_type = TCE_VB; 164 - veth_iommu_table.it_blocksize = 1; 165 - 166 - t = iommu_init_table(&veth_iommu_table); 167 - 168 - if (!t) 169 - printk("Virtual Bus VETH TCE table failed.\n"); 170 - 171 - vio_iommu_table.it_size = itc_entries - veth_iommu_table.it_size; 172 - vio_iommu_table.it_busno = cb.itc_busno; 173 - vio_iommu_table.it_offset = cb.itc_offset + 174 - veth_iommu_table.it_size; 175 - vio_iommu_table.it_index = cb.itc_index; 176 - vio_iommu_table.it_type = TCE_VB; 177 - vio_iommu_table.it_blocksize = 1; 178 - 179 - t = iommu_init_table(&vio_iommu_table); 180 - 181 - if (!t) 182 - printk("Virtual Bus VIO TCE table failed.\n"); 183 - } 184 - #endif 185 - 186 160 #ifdef CONFIG_PPC_PSERIES 187 161 static void probe_bus_pseries(void) 188 162 { ··· 165 223 } 166 224 #endif 167 225 168 - #ifdef CONFIG_PPC_ISERIES 169 - static void probe_bus_iseries(void) 170 - { 171 - HvLpIndexMap vlan_map = HvLpConfig_getVirtualLanIndexMap(); 172 - struct vio_dev *viodev; 173 - int i; 174 - 175 - /* there is only one of each of these */ 176 - vio_register_device_iseries("viocons", 0); 177 - vio_register_device_iseries("vscsi", 0); 178 - 179 - vlan_map = HvLpConfig_getVirtualLanIndexMap(); 180 - for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++) { 181 - if ((vlan_map & (0x8000 >> i)) == 0) 182 - continue; 183 - viodev = vio_register_device_iseries("vlan", i); 184 - /* veth is special and has it own iommu_table */ 185 - viodev->iommu_table = &veth_iommu_table; 186 - } 187 - for (i = 0; i < HVMAXARCHITECTEDVIRTUALDISKS; i++) 188 - vio_register_device_iseries("viodasd", i); 189 - for (i = 0; i < HVMAXARCHITECTEDVIRTUALCDROMS; i++) 190 - vio_register_device_iseries("viocd", i); 191 - for (i = 0; i < HVMAXARCHITECTEDVIRTUALTAPES; i++) 192 - vio_register_device_iseries("viotape", i); 193 - } 194 - #endif 195 - 196 226 /** 197 227 * vio_bus_init: - Initialize the virtual IO bus 198 228 */ 199 - static int __init vio_bus_init(void) 229 + int __init vio_bus_init(void) 200 230 { 201 231 int err; 202 232 ··· 178 264 return err; 179 265 } 180 266 181 - /* the fake parent of all vio devices, just to give us a nice directory */ 267 + /* the fake parent of all vio devices, just to give us 268 + * a nice directory 269 + */ 182 270 err = device_register(&vio_bus_device.dev); 183 271 if (err) { 184 - printk(KERN_WARNING "%s: device_register returned %i\n", __FUNCTION__, 185 - err); 272 + printk(KERN_WARNING "%s: device_register returned %i\n", 273 + __FUNCTION__, err); 186 274 return err; 187 275 } 188 - 189 - #ifdef CONFIG_PPC_PSERIES 190 - probe_bus_pseries(); 191 - #endif 192 - #ifdef CONFIG_PPC_ISERIES 193 - probe_bus_iseries(); 194 - #endif 195 276 196 277 return 0; 197 278 } 198 279 199 - __initcall(vio_bus_init); 280 + #ifdef CONFIG_PPC_PSERIES 281 + /** 282 + * vio_bus_init_pseries: - Initialize the pSeries virtual IO bus 283 + */ 284 + static int __init vio_bus_init_pseries(void) 285 + { 286 + int err; 287 + 288 + err = vio_bus_init(); 289 + if (err == 0) 290 + probe_bus_pseries(); 291 + return err; 292 + } 293 + 294 + __initcall(vio_bus_init_pseries); 295 + #endif 200 296 201 297 /* vio_dev refcount hit 0 */ 202 298 static void __devinit vio_dev_release(struct device *dev) ··· 236 312 } 237 313 DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_name, NULL); 238 314 239 - static struct vio_dev * __devinit vio_register_device_common( 315 + struct vio_dev * __devinit vio_register_device_common( 240 316 struct vio_dev *viodev, char *name, char *type, 241 317 uint32_t unit_address, struct iommu_table *iommu_table) 242 318 { ··· 330 406 return viodev; 331 407 } 332 408 EXPORT_SYMBOL(vio_register_device_node); 333 - #endif 334 - 335 - #ifdef CONFIG_PPC_ISERIES 336 - /** 337 - * vio_register_device: - Register a new vio device. 338 - * @voidev: The device to register. 339 - */ 340 - static struct vio_dev *__init vio_register_device_iseries(char *type, 341 - uint32_t unit_num) 342 - { 343 - struct vio_dev *viodev; 344 - 345 - DBGENTER(); 346 - 347 - /* allocate a vio_dev for this node */ 348 - viodev = kmalloc(sizeof(struct vio_dev), GFP_KERNEL); 349 - if (!viodev) 350 - return NULL; 351 - memset(viodev, 0, sizeof(struct vio_dev)); 352 - 353 - snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%s%d", type, unit_num); 354 - 355 - return vio_register_device_common(viodev, viodev->dev.bus_id, type, 356 - unit_num, &vio_iommu_table); 357 - } 358 409 #endif 359 410 360 411 void __devinit vio_unregister_device(struct vio_dev *viodev)
+7
include/asm-ppc64/vio.h
··· 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 ··· 98 95 struct device dev; 99 96 }; 100 97 98 + extern struct vio_dev vio_bus_device; 99 + 101 100 static inline struct vio_dev *to_vio_dev(struct device *dev) 102 101 { 103 102 return container_of(dev, struct vio_dev, dev); 104 103 } 104 + 105 + extern int vio_bus_init(void); 105 106 106 107 #endif /* _ASM_VIO_H */