vio.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #include <asm/vio.h>
  15. #include <asm/iommu.h>
  16. #include <asm/tce.h>
  17. #include <asm/abs_addr.h>
  18. #include <asm/page.h>
  19. #include <asm/iseries/vio.h>
  20. #include <asm/iseries/hv_types.h>
  21. #include <asm/iseries/hv_lp_config.h>
  22. #include <asm/iseries/hv_call_xm.h>
  23. #include "iommu.h"
  24. struct device *iSeries_vio_dev = &vio_bus_device.dev;
  25. EXPORT_SYMBOL(iSeries_vio_dev);
  26. static struct iommu_table veth_iommu_table;
  27. static struct iommu_table vio_iommu_table;
  28. static void __init iommu_vio_init(void)
  29. {
  30. iommu_table_getparms_iSeries(255, 0, 0xff, &veth_iommu_table);
  31. veth_iommu_table.it_size /= 2;
  32. vio_iommu_table = veth_iommu_table;
  33. vio_iommu_table.it_offset += veth_iommu_table.it_size;
  34. if (!iommu_init_table(&veth_iommu_table))
  35. printk("Virtual Bus VETH TCE table failed.\n");
  36. if (!iommu_init_table(&vio_iommu_table))
  37. printk("Virtual Bus VIO TCE table failed.\n");
  38. }
  39. static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
  40. {
  41. if (strcmp(dev->type, "vlan") == 0)
  42. return &veth_iommu_table;
  43. return &vio_iommu_table;
  44. }
  45. static struct vio_bus_ops vio_bus_ops_iseries = {
  46. .build_iommu_table = vio_build_iommu_table,
  47. };
  48. /**
  49. * vio_bus_init_iseries: - Initialize the iSeries virtual IO bus
  50. */
  51. static int __init vio_bus_init_iseries(void)
  52. {
  53. iommu_vio_init();
  54. vio_bus_device.iommu_table = &vio_iommu_table;
  55. iSeries_vio_dev = &vio_bus_device.dev;
  56. return vio_bus_init(&vio_bus_ops_iseries);
  57. }
  58. __initcall(vio_bus_init_iseries);