aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc64/kernel/vio.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/ppc64/kernel/vio.c')
-rw-r--r--arch/ppc64/kernel/vio.c147
1 files changed, 23 insertions, 124 deletions
diff --git a/arch/ppc64/kernel/vio.c b/arch/ppc64/kernel/vio.c
index 0c0ba71ac0e8..4b9e3712e384 100644
--- a/arch/ppc64/kernel/vio.c
+++ b/arch/ppc64/kernel/vio.c
@@ -25,10 +25,6 @@
25#include <asm/ppcdebug.h> 25#include <asm/ppcdebug.h>
26#include <asm/vio.h> 26#include <asm/vio.h>
27#include <asm/hvcall.h> 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#define DBGENTER() pr_debug("%s entered\n", __FUNCTION__) 29#define DBGENTER() pr_debug("%s entered\n", __FUNCTION__)
34 30
@@ -41,26 +37,14 @@ static const struct vio_device_id *vio_match_device(
41static struct iommu_table *vio_build_iommu_table(struct vio_dev *); 37static struct iommu_table *vio_build_iommu_table(struct vio_dev *);
42static int vio_num_address_cells; 38static int vio_num_address_cells;
43#endif 39#endif
44#ifdef CONFIG_PPC_ISERIES 40struct vio_dev vio_bus_device = { /* fake "parent" device */
45static struct iommu_table veth_iommu_table;
46static struct iommu_table vio_iommu_table;
47#endif
48static struct vio_dev vio_bus_device = { /* fake "parent" device */
49 .name = vio_bus_device.dev.bus_id, 41 .name = vio_bus_device.dev.bus_id,
50 .type = "", 42 .type = "",
51#ifdef CONFIG_PPC_ISERIES
52 .iommu_table = &vio_iommu_table,
53#endif
54 .dev.bus_id = "vio", 43 .dev.bus_id = "vio",
55 .dev.bus = &vio_bus_type, 44 .dev.bus = &vio_bus_type,
56}; 45};
57 46
58#ifdef CONFIG_PPC_ISERIES 47#ifdef CONFIG_PPC_ISERIES
59static struct vio_dev *__init vio_register_device_iseries(char *type,
60 uint32_t unit_num);
61
62struct device *iSeries_vio_dev = &vio_bus_device.dev;
63EXPORT_SYMBOL(iSeries_vio_dev);
64 48
65#define device_is_compatible(a, b) 1 49#define device_is_compatible(a, b) 1
66 50
@@ -157,48 +141,6 @@ static const struct vio_device_id * vio_match_device(const struct vio_device_id
157 return NULL; 141 return NULL;
158} 142}
159 143
160#ifdef CONFIG_PPC_ISERIES
161void __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#ifdef CONFIG_PPC_PSERIES 144#ifdef CONFIG_PPC_PSERIES
203static void probe_bus_pseries(void) 145static void probe_bus_pseries(void)
204{ 146{
@@ -223,38 +165,10 @@ static void probe_bus_pseries(void)
223} 165}
224#endif 166#endif
225 167
226#ifdef CONFIG_PPC_ISERIES
227static 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 * vio_bus_init: - Initialize the virtual IO bus 169 * vio_bus_init: - Initialize the virtual IO bus
256 */ 170 */
257static int __init vio_bus_init(void) 171int __init vio_bus_init(void)
258{ 172{
259 int err; 173 int err;
260 174
@@ -264,25 +178,35 @@ static int __init vio_bus_init(void)
264 return err; 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 err = device_register(&vio_bus_device.dev); 184 err = device_register(&vio_bus_device.dev);
269 if (err) { 185 if (err) {
270 printk(KERN_WARNING "%s: device_register returned %i\n", __FUNCTION__, 186 printk(KERN_WARNING "%s: device_register returned %i\n",
271 err); 187 __FUNCTION__, err);
272 return err; 188 return err;
273 } 189 }
274 190
191 return 0;
192}
193
275#ifdef CONFIG_PPC_PSERIES 194#ifdef CONFIG_PPC_PSERIES
276 probe_bus_pseries(); 195/**
277#endif 196 * vio_bus_init_pseries: - Initialize the pSeries virtual IO bus
278#ifdef CONFIG_PPC_ISERIES 197 */
279 probe_bus_iseries(); 198static int __init vio_bus_init_pseries(void)
280#endif 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/* vio_dev refcount hit 0 */ 211/* vio_dev refcount hit 0 */
288static void __devinit vio_dev_release(struct device *dev) 212static void __devinit vio_dev_release(struct device *dev)
@@ -312,7 +236,7 @@ static ssize_t viodev_show_name(struct device *dev, struct device_attribute *att
312} 236}
313DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_name, NULL); 237DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_name, NULL);
314 238
315static struct vio_dev * __devinit vio_register_device_common( 239struct vio_dev * __devinit vio_register_device_common(
316 struct vio_dev *viodev, char *name, char *type, 240 struct vio_dev *viodev, char *name, char *type,
317 uint32_t unit_address, struct iommu_table *iommu_table) 241 uint32_t unit_address, struct iommu_table *iommu_table)
318{ 242{
@@ -408,31 +332,6 @@ struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node)
408EXPORT_SYMBOL(vio_register_device_node); 332EXPORT_SYMBOL(vio_register_device_node);
409#endif 333#endif
410 334
411#ifdef CONFIG_PPC_ISERIES
412/**
413 * vio_register_device: - Register a new vio device.
414 * @voidev: The device to register.
415 */
416static 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#endif
435
436void __devinit vio_unregister_device(struct vio_dev *viodev) 335void __devinit vio_unregister_device(struct vio_dev *viodev)
437{ 336{
438 DBGENTER(); 337 DBGENTER();