simba.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * QEMU Simba PCI bridge
  3. *
  4. * Copyright (c) 2006 Fabrice Bellard
  5. * Copyright (c) 2012,2013 Artyom Tarasenko
  6. * Copyright (c) 2018 Mark Cave-Ayland
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  21. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. #include "qemu/osdep.h"
  27. #include "hw/pci/pci.h"
  28. #include "hw/pci/pci_bridge.h"
  29. #include "hw/pci/pci_bus.h"
  30. #include "qemu/module.h"
  31. #include "hw/pci-bridge/simba.h"
  32. /*
  33. * Chipset docs:
  34. * APB: "Advanced PCI Bridge (APB) User's Manual",
  35. * http://www.sun.com/processors/manuals/805-1251.pdf
  36. */
  37. static void simba_pci_bridge_realize(PCIDevice *dev, Error **errp)
  38. {
  39. /*
  40. * command register:
  41. * According to PCI bridge spec, after reset
  42. * bus master bit is off
  43. * memory space enable bit is off
  44. * According to manual (805-1251.pdf).
  45. * the reset value should be zero unless the boot pin is tied high
  46. * (which is true) and thus it should be PCI_COMMAND_MEMORY.
  47. */
  48. SimbaPCIBridge *br = SIMBA_PCI_BRIDGE(dev);
  49. pci_bridge_initfn(dev, TYPE_PCI_BUS);
  50. pci_set_word(dev->config + PCI_COMMAND, PCI_COMMAND_MEMORY);
  51. pci_set_word(dev->config + PCI_STATUS,
  52. PCI_STATUS_FAST_BACK | PCI_STATUS_66MHZ |
  53. PCI_STATUS_DEVSEL_MEDIUM);
  54. /* Allow 32-bit IO addresses */
  55. pci_set_word(dev->config + PCI_IO_BASE, PCI_IO_RANGE_TYPE_32);
  56. pci_set_word(dev->config + PCI_IO_LIMIT, PCI_IO_RANGE_TYPE_32);
  57. pci_set_word(dev->wmask + PCI_IO_BASE_UPPER16, 0xffff);
  58. pci_set_word(dev->wmask + PCI_IO_LIMIT_UPPER16, 0xffff);
  59. pci_bridge_update_mappings(PCI_BRIDGE(br));
  60. }
  61. static void simba_pci_bridge_class_init(ObjectClass *klass, void *data)
  62. {
  63. DeviceClass *dc = DEVICE_CLASS(klass);
  64. PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
  65. k->realize = simba_pci_bridge_realize;
  66. k->exit = pci_bridge_exitfn;
  67. k->vendor_id = PCI_VENDOR_ID_SUN;
  68. k->device_id = PCI_DEVICE_ID_SUN_SIMBA;
  69. k->revision = 0x11;
  70. k->config_write = pci_bridge_write_config;
  71. set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
  72. device_class_set_legacy_reset(dc, pci_bridge_reset);
  73. dc->vmsd = &vmstate_pci_device;
  74. }
  75. static const TypeInfo simba_pci_bridge_info = {
  76. .name = TYPE_SIMBA_PCI_BRIDGE,
  77. .parent = TYPE_PCI_BRIDGE,
  78. .class_init = simba_pci_bridge_class_init,
  79. .instance_size = sizeof(SimbaPCIBridge),
  80. .interfaces = (InterfaceInfo[]) {
  81. { INTERFACE_CONVENTIONAL_PCI_DEVICE },
  82. { },
  83. },
  84. };
  85. static void simba_register_types(void)
  86. {
  87. type_register_static(&simba_pci_bridge_info);
  88. }
  89. type_init(simba_register_types)