summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Angelo Salese <angelosa@users.noreply.github.com>2024-01-17 02:47:07 +0100
committer GitHub <noreply@github.com>2024-01-16 20:47:07 -0500
commit81a6a18e47954194c028045c538c35a131d53812 (patch)
tree763d9c6ad80349f77f1037bd41b4a615e119a8db
parent8d4b2e2916a9a42c6ef0aac65e451d7e480f8e95 (diff)
bus/pci: convert opti82c861 to a pci_slot, add basic OpenHCI values (#11940)
-rw-r--r--scripts/src/bus.lua2
-rw-r--r--scripts/src/machine.lua12
-rw-r--r--src/devices/bus/pci/opti82c861.cpp81
-rw-r--r--src/devices/bus/pci/opti82c861.h (renamed from src/devices/machine/opti82c861.h)6
-rw-r--r--src/devices/bus/pci/pci_slot.cpp3
-rw-r--r--src/devices/machine/opti82c861.cpp52
-rw-r--r--src/mame/apple/imacg3.cpp2
7 files changed, 91 insertions, 67 deletions
diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua
index b0b6a8e71ff..e853aaedcfb 100644
--- a/scripts/src/bus.lua
+++ b/scripts/src/bus.lua
@@ -5442,5 +5442,7 @@ if (BUSES["PCI"]~=null) then
MAME_DIR .. "src/devices/bus/pci/sonicvibes.h",
MAME_DIR .. "src/devices/bus/pci/rtl8029as_pci.cpp",
MAME_DIR .. "src/devices/bus/pci/rtl8029as_pci.h",
+ MAME_DIR .. "src/devices/bus/pci/opti82c861.cpp",
+ MAME_DIR .. "src/devices/bus/pci/opti82c861.h",
}
end
diff --git a/scripts/src/machine.lua b/scripts/src/machine.lua
index f17010c82f0..af09e563671 100644
--- a/scripts/src/machine.lua
+++ b/scripts/src/machine.lua
@@ -4642,18 +4642,6 @@ end
---------------------------------------------------
--
---@src/devices/machine/opti82c861.h,MACHINES["OPTI82C861"] = true
----------------------------------------------------
-
-if (MACHINES["OPTI82C861"]~=null) then
- files {
- MAME_DIR .. "src/devices/machine/opti82c861.cpp",
- MAME_DIR .. "src/devices/machine/opti82c861.h",
- }
-end
-
----------------------------------------------------
---
--@src/devices/machine/output_latch.h,MACHINES["OUTPUT_LATCH"] = true
---------------------------------------------------
diff --git a/src/devices/bus/pci/opti82c861.cpp b/src/devices/bus/pci/opti82c861.cpp
new file mode 100644
index 00000000000..c70aeafdf37
--- /dev/null
+++ b/src/devices/bus/pci/opti82c861.cpp
@@ -0,0 +1,81 @@
+// license:BSD-3-Clause
+// copyright-holders: R. Belmont
+/*
+ OPTi 82C861 "FireLink" USB 1.1 OHCI controller
+ Skeleton by R. Belmont
+*/
+
+#include "emu.h"
+#include "opti82c861.h"
+
+#define LOG_REGISTERS (1U << 1)
+
+#define VERBOSE (LOG_GENERAL)
+#include "logmacro.h"
+
+DEFINE_DEVICE_TYPE(OPTI_82C861, opti_82c861_device, "opti82c861", "OPTi 82C861 \"FireLink\" USB OHCI controller")
+
+opti_82c861_device::opti_82c861_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
+ : pci_card_device(mconfig, type, tag, owner, clock)
+{
+}
+
+opti_82c861_device::opti_82c861_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : opti_82c861_device(mconfig, OPTI_82C861, tag, owner, clock)
+{
+}
+
+void opti_82c861_device::mem_map(address_map& map)
+{
+ // HcRevision: OpenHCI v1.0 with legacy support
+ map(0x000, 0x003).lr32(NAME([]() { return 0x00000110; }));
+ map(0x048, 0x04b).lrw32(
+ NAME([this] () {
+ // 2 downstream ports (always?)
+ return (m_HcRhDescriptorA & 0xff001b00) | 0x02;
+ }),
+ NAME([this] (offs_t offset, u32 data, u32 mem_mask) {
+ COMBINE_DATA(&m_HcRhDescriptorA);
+ if (ACCESSING_BITS_24_31)
+ LOG("HcRhDescriptorA: set Power-On to Power-Good Time %d msec\n", (m_HcRhDescriptorA >> 24) * 2);
+ if (ACCESSING_BITS_8_15)
+ LOG("HcRhDescriptorA: set status %02x\n", (m_HcRhDescriptorA & 0x1b00) >> 8);
+ })
+ );
+}
+
+void opti_82c861_device::config_map(address_map &map)
+{
+ pci_card_device::config_map(map);
+// map(0x4e, 0x4e) i2c Control Register
+// map(0x50, 0x50) PCI Host Feature Control Register
+// map(0x51, 0x51) Interrupt Assignment Register
+// map(0x52, 0x52) Strap Option Enable
+// map(0x54, 0x57) IRQ Driveback Address Register
+// map(0x6c, 0x6f) Test Mode Enable Register
+}
+
+void opti_82c861_device::device_start()
+{
+ pci_card_device::device_start();
+ set_ids(0x1045c861, 0x10, 0x0c0310, 0);
+ revision = 0x10;
+ add_map(0x1000, M_MEM, FUNC(opti_82c861_device::mem_map)); // 4KiB memory map
+
+ command = 0;
+ // fast back-to-back, medium DEVSEL#
+ status = 0x0280;
+ intr_pin = 1;
+ intr_line = 0;
+}
+
+void opti_82c861_device::device_reset()
+{
+ pci_card_device::device_reset();
+ m_HcRhDescriptorA = 0x01000000;
+}
+
+void opti_82c861_device::map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space,
+ uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space)
+{
+}
diff --git a/src/devices/machine/opti82c861.h b/src/devices/bus/pci/opti82c861.h
index 41ee4c480e9..d13a33a6d35 100644
--- a/src/devices/machine/opti82c861.h
+++ b/src/devices/bus/pci/opti82c861.h
@@ -6,9 +6,9 @@
#pragma once
-#include "machine/pci.h"
+#include "pci_slot.h"
-class opti_82c861_device : public pci_device
+class opti_82c861_device : public pci_card_device
{
public:
opti_82c861_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
@@ -18,12 +18,14 @@ public:
protected:
virtual void device_start() override;
+ virtual void device_reset() override;
void map_extra(u64 memory_window_start, u64 memory_window_end, u64 memory_offset, address_space *memory_space,
u64 io_window_start, u64 io_window_end, u64 io_offset, address_space *io_space) override;
void config_map(address_map &map) override;
private:
+ u32 m_HcRhDescriptorA = 0;
};
DECLARE_DEVICE_TYPE(OPTI_82C861, opti_82c861_device)
diff --git a/src/devices/bus/pci/pci_slot.cpp b/src/devices/bus/pci/pci_slot.cpp
index 84290f2283d..fb84862b0b0 100644
--- a/src/devices/bus/pci/pci_slot.cpp
+++ b/src/devices/bus/pci/pci_slot.cpp
@@ -15,6 +15,7 @@
#include "sonicvibes.h"
#include "sw1000xg.h"
#include "rtl8029as_pci.h"
+#include "opti82c861.h"
DEFINE_DEVICE_TYPE(PCI_SLOT, pci_slot_device, "pci_slot", "PCI extension motherboard port")
@@ -103,6 +104,8 @@ void pci_cards(device_slot_interface &device)
// 0x0a - docking stations
// 0x0b - processors
// 0x0c - Serial Bus controllers
+ device.option_add("opti82c861", OPTI_82C861);
+
// 0x0d - wireless controllers
// 0x0e - Intelligent I/O controllers
// 0x0f - Satellite Communication controllers
diff --git a/src/devices/machine/opti82c861.cpp b/src/devices/machine/opti82c861.cpp
deleted file mode 100644
index 715e498baa8..00000000000
--- a/src/devices/machine/opti82c861.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders: R. Belmont
-/*
- OPTi 82C861 "FireLink" USB 1.1 OHCI controller
- Skeleton by R. Belmont
-*/
-
-#include "emu.h"
-#include "opti82c861.h"
-
-#define LOG_REGISTERS (1U << 1)
-
-#define VERBOSE (0)
-#include "logmacro.h"
-
-DEFINE_DEVICE_TYPE(OPTI_82C861, opti_82c861_device, "opti82c861", "OPTi 82C861 USB OHCI controller")
-
-opti_82c861_device::opti_82c861_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
- : pci_device(mconfig, type, tag, owner, clock)
-{
-}
-
-opti_82c861_device::opti_82c861_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : opti_82c861_device(mconfig, OPTI_82C861, tag, owner, clock)
-{
-}
-
-void opti_82c861_device::mem_map(address_map& map)
-{
-}
-
-void opti_82c861_device::config_map(address_map &map)
-{
- pci_device::config_map(map);
-}
-
-void opti_82c861_device::device_start()
-{
- pci_device::device_start();
- set_ids(0x1045c861, 0x10, 0x0c0310, 0);
- revision = 0x10;
- add_map(0x1000, M_MEM, FUNC(opti_82c861_device::mem_map)); // 4KiB memory map
-
- command = 0;
- intr_pin = 1;
- intr_line = 0;
-}
-
-void opti_82c861_device::map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space,
- uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space)
-{
-}
diff --git a/src/mame/apple/imacg3.cpp b/src/mame/apple/imacg3.cpp
index a31f4192487..8169a8786a2 100644
--- a/src/mame/apple/imacg3.cpp
+++ b/src/mame/apple/imacg3.cpp
@@ -20,12 +20,12 @@
****************************************************************************/
#include "emu.h"
+#include "bus/pci/opti82c861.h"
#include "cpu/powerpc/ppc.h"
#include "machine/dimm_spd.h"
#include "machine/i2cmem.h"
#include "machine/input_merger.h"
#include "machine/mpc106.h"
-#include "machine/opti82c861.h"
#include "machine/pci.h"
#include "machine/pci-ide.h"
#include "machine/ram.h"