mirror of
https://github.com/dwhinham/mt32-pi.git
synced 2026-10-27 06:21:59 +00:00
Add temporary Circle patch to fix Pi 4 USB issue
Temporary fix for rsta2/circle#209 until a new version is made available.
This commit is contained in:
1 parent
a216cfde9e
commit
b390fd59e3
2 files changed
+254
No files matched your search
@@ -17,6 +17,7 @@ $(CIRCLE_STDLIB_CONFIG) $(CIRCLE_CONFIG)&:
|
||||
|
||||
# Apply patches
|
||||
@patch -N -p1 --no-backup-if-mismatch -r - -d $(CIRCLEHOME) < patches/circle-43.3-minimal-usb-drivers.patch
|
||||
@patch -N -p1 --no-backup-if-mismatch -r - -d $(CIRCLEHOME) < patches/circle-43.3-pi4-usb-fix.patch
|
||||
|
||||
ifeq ($(strip $(GC_SECTIONS)),1)
|
||||
# Enable function/data sections for circle-stdlib
|
||||
@@ -116,6 +117,7 @@ clean:
|
||||
#
|
||||
veryclean: clean
|
||||
# Reverse patches
|
||||
@patch -R -N -p1 --no-backup-if-mismatch -r - -d $(CIRCLEHOME) < patches/circle-43.3-pi4-usb-fix.patch
|
||||
@patch -R -N -p1 --no-backup-if-mismatch -r - -d $(CIRCLEHOME) < patches/circle-43.3-minimal-usb-drivers.patch
|
||||
@patch -R -N -p1 --no-backup-if-mismatch -r - -d $(FLUIDSYNTHHOME) < patches/fluidsynth-2.1.7-circle.patch
|
||||
@patch -R -N -p1 --no-backup-if-mismatch -r - -d $(FLUIDSYNTHHOME) < patches/fluidsynth-2.1.7-pan-fix-2.patch
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
From 3a3bec6ec8a21abb63171af51b1333108aa2b28f Mon Sep 17 00:00:00 2001
|
||||
From: Rene Stange <rsta2@o2online.de>
|
||||
Date: Wed, 10 Mar 2021 20:40:05 +0100
|
||||
Subject: [PATCH] usb/xhci: Use PCIe INTA instead of MSI
|
||||
|
||||
* MSI did not work on RPi 4B v1.1 4GB any more for unknown reason
|
||||
* Results in a more unique interrupt handling for internal and
|
||||
external xHCI controller
|
||||
* bcmpciehostbridge: Do not enable MSI in enable_device() any more
|
||||
* bcmpciehostbridge: Enable INTX instead
|
||||
|
||||
Issue #209
|
||||
---
|
||||
include/circle/bcm2711int.h | 3 +-
|
||||
include/circle/usb/xhcidevice.h | 11 ++-----
|
||||
lib/bcmpciehostbridge.cpp | 7 +++--
|
||||
lib/usb/xhcidevice.cpp | 53 +++++++--------------------------
|
||||
4 files changed, 20 insertions(+), 54 deletions(-)
|
||||
|
||||
diff --git a/include/circle/bcm2711int.h b/include/circle/bcm2711int.h
|
||||
index c2237ce0..96e280d4 100644
|
||||
--- a/include/circle/bcm2711int.h
|
||||
+++ b/include/circle/bcm2711int.h
|
||||
@@ -2,7 +2,7 @@
|
||||
// bcm2711int.h
|
||||
//
|
||||
// Circle - A C++ bare metal environment for Raspberry Pi
|
||||
-// Copyright (C) 2019-2020 R. Stange <rsta2@o2online.de>
|
||||
+// Copyright (C) 2019-2021 R. Stange <rsta2@o2online.de>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -52,6 +52,7 @@
|
||||
#define ARM_IRQ_GPIO3 GIC_SPI (116)
|
||||
#define ARM_IRQ_UART GIC_SPI (121)
|
||||
#define ARM_IRQ_ARASANSDIO GIC_SPI (126)
|
||||
+#define ARM_IRQ_PCIE_HOST_INTA GIC_SPI (143)
|
||||
#define ARM_IRQ_PCIE_HOST_MSI GIC_SPI (148)
|
||||
#define ARM_IRQ_BCM54213_0 GIC_SPI (157)
|
||||
#define ARM_IRQ_BCM54213_1 GIC_SPI (158)
|
||||
diff --git a/include/circle/usb/xhcidevice.h b/include/circle/usb/xhcidevice.h
|
||||
index 2ca7bb30..bd9a416b 100644
|
||||
--- a/include/circle/usb/xhcidevice.h
|
||||
+++ b/include/circle/usb/xhcidevice.h
|
||||
@@ -2,7 +2,7 @@
|
||||
// xhcidevice.h
|
||||
//
|
||||
// Circle - A C++ bare metal environment for Raspberry Pi
|
||||
-// Copyright (C) 2019-2020 R. Stange <rsta2@o2online.de>
|
||||
+// Copyright (C) 2019-2021 R. Stange <rsta2@o2online.de>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -65,21 +65,16 @@ class CXHCIDevice : public CUSBHostController /// USB host controller interface
|
||||
#endif
|
||||
|
||||
private:
|
||||
-#ifdef USE_XHCI_INTERNAL
|
||||
void InterruptHandler (void);
|
||||
static void InterruptStub (void *pParam);
|
||||
-#else
|
||||
- void InterruptHandler (unsigned nVector);
|
||||
- static void InterruptStub (unsigned nVector, void *pParam);
|
||||
-#endif
|
||||
|
||||
boolean HWReset (void);
|
||||
|
||||
private:
|
||||
-#ifdef USE_XHCI_INTERNAL
|
||||
CInterruptSystem *m_pInterruptSystem;
|
||||
boolean m_bInterruptConnected;
|
||||
-#else
|
||||
+
|
||||
+#ifndef USE_XHCI_INTERNAL
|
||||
CBcmPCIeHostBridge m_PCIeHostBridge;
|
||||
#endif
|
||||
|
||||
diff --git a/lib/bcmpciehostbridge.cpp b/lib/bcmpciehostbridge.cpp
|
||||
index f7a41791..e64cebb0 100644
|
||||
--- a/lib/bcmpciehostbridge.cpp
|
||||
+++ b/lib/bcmpciehostbridge.cpp
|
||||
@@ -7,7 +7,7 @@
|
||||
// Licensed under GPL-2.0
|
||||
//
|
||||
// Circle - A C++ bare metal environment for Raspberry Pi
|
||||
-// Copyright (C) 2019-2020 R. Stange <rsta2@o2online.de>
|
||||
+// Copyright (C) 2019-2021 R. Stange <rsta2@o2online.de>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -550,6 +550,7 @@ int CBcmPCIeHostBridge::enable_device (u32 nClassCode, unsigned nSlot, unsigned
|
||||
| PCI_BASE_ADDRESS_MEM_TYPE_64);
|
||||
write32 (conf + PCI_BASE_ADDRESS_1, upper_32_bits (MEM_PCIE_RANGE_PCIE_START));
|
||||
|
||||
+#if 0
|
||||
uintptr msi_conf = find_pci_capability (conf, PCI_CAP_ID_MSI);
|
||||
if (!msi_conf)
|
||||
return -1;
|
||||
@@ -562,12 +563,14 @@ int CBcmPCIeHostBridge::enable_device (u32 nClassCode, unsigned nSlot, unsigned
|
||||
write8 (msi_conf + PCI_MSI_FLAGS, PCI_MSI_FLAGS_ENABLE
|
||||
| PCI_MSI_FLAGS_64BIT
|
||||
| uchQueueSize << 4);
|
||||
+#endif
|
||||
|
||||
write16 (conf + PCI_COMMAND, PCI_COMMAND_MEMORY
|
||||
| PCI_COMMAND_MASTER
|
||||
| PCI_COMMAND_PARITY
|
||||
| PCI_COMMAND_SERR
|
||||
- | PCI_COMMAND_INTX_DISABLE);
|
||||
+ //| PCI_COMMAND_INTX_DISABLE
|
||||
+ );
|
||||
|
||||
return 0;
|
||||
}
|
||||
diff --git a/lib/usb/xhcidevice.cpp b/lib/usb/xhcidevice.cpp
|
||||
index c5880f40..570251f2 100644
|
||||
--- a/lib/usb/xhcidevice.cpp
|
||||
+++ b/lib/usb/xhcidevice.cpp
|
||||
@@ -2,7 +2,7 @@
|
||||
// xhcidevice.cpp
|
||||
//
|
||||
// Circle - A C++ bare metal environment for Raspberry Pi
|
||||
-// Copyright (C) 2019-2020 R. Stange <rsta2@o2online.de>
|
||||
+// Copyright (C) 2019-2021 R. Stange <rsta2@o2online.de>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -27,14 +27,19 @@
|
||||
#include <circle/machineinfo.h>
|
||||
#include <assert.h>
|
||||
|
||||
+#ifdef USE_XHCI_INTERNAL
|
||||
+ #define ARM_IRQ_XHCI ARM_IRQ_XHCI_INTERNAL
|
||||
+#else
|
||||
+ #define ARM_IRQ_XHCI ARM_IRQ_PCIE_HOST_INTA
|
||||
+#endif
|
||||
+
|
||||
static const char From[] = "xhci";
|
||||
|
||||
CXHCIDevice::CXHCIDevice (CInterruptSystem *pInterruptSystem, CTimer *pTimer, boolean bPlugAndPlay)
|
||||
: CUSBHostController (bPlugAndPlay),
|
||||
-#ifdef USE_XHCI_INTERNAL
|
||||
m_pInterruptSystem (pInterruptSystem),
|
||||
m_bInterruptConnected (FALSE),
|
||||
-#else
|
||||
+#ifndef USE_XHCI_INTERNAL
|
||||
m_PCIeHostBridge (pInterruptSystem),
|
||||
#endif
|
||||
m_SharedMemAllocator (
|
||||
@@ -63,14 +68,12 @@ CXHCIDevice::~CXHCIDevice (void)
|
||||
HWReset ();
|
||||
}
|
||||
|
||||
-#ifdef USE_XHCI_INTERNAL
|
||||
if (m_bInterruptConnected)
|
||||
{
|
||||
assert (m_pInterruptSystem != 0);
|
||||
- m_pInterruptSystem->DisconnectIRQ (ARM_IRQ_XHCI_INTERNAL);
|
||||
+ m_pInterruptSystem->DisconnectIRQ (ARM_IRQ_XHCI);
|
||||
m_bInterruptConnected = FALSE;
|
||||
}
|
||||
-#endif
|
||||
|
||||
m_pScratchpadBufferArray = 0;
|
||||
m_pScratchpadBuffers = 0;
|
||||
@@ -126,13 +129,6 @@ boolean CXHCIDevice::Initialize (boolean bScanDevices)
|
||||
| XHCI_PCIE_FUNC << 12;
|
||||
Tags.GetTag (PROPTAG_NOTIFY_XHCI_RESET, &NotifyXHCIReset, sizeof NotifyXHCIReset, 4);
|
||||
|
||||
- if (!m_PCIeHostBridge.ConnectMSI (InterruptStub, this))
|
||||
- {
|
||||
- CLogger::Get ()->Write (From, LogError, "Cannot connect MSI");
|
||||
-
|
||||
- return FALSE;
|
||||
- }
|
||||
-
|
||||
if (!m_PCIeHostBridge.EnableDevice (XHCI_PCI_CLASS_CODE, XHCI_PCIE_SLOT, XHCI_PCIE_FUNC))
|
||||
{
|
||||
CLogger::Get ()->Write (From, LogError, "Cannot enable xHCI device");
|
||||
@@ -236,11 +232,9 @@ boolean CXHCIDevice::Initialize (boolean bScanDevices)
|
||||
m_pRootHub = new CXHCIRootHub (nMaxPorts, this);
|
||||
assert (m_pRootHub != 0);
|
||||
|
||||
-#ifdef USE_XHCI_INTERNAL
|
||||
assert (m_pInterruptSystem != 0);
|
||||
- m_pInterruptSystem->ConnectIRQ (ARM_IRQ_XHCI_INTERNAL, InterruptStub, this);
|
||||
+ m_pInterruptSystem->ConnectIRQ (ARM_IRQ_XHCI, InterruptStub, this);
|
||||
m_bInterruptConnected = TRUE;
|
||||
-#endif
|
||||
|
||||
// start controller
|
||||
m_pMMIO->op_write32 (XHCI_REG_OP_USBCMD, m_pMMIO->op_read32 (XHCI_REG_OP_USBCMD)
|
||||
@@ -346,31 +340,18 @@ void CXHCIDevice::FreeSharedMem (void *pBlock)
|
||||
m_SharedMemAllocator.Free (pBlock);
|
||||
}
|
||||
|
||||
-#ifdef USE_XHCI_INTERNAL
|
||||
void CXHCIDevice::InterruptHandler (void)
|
||||
-#else
|
||||
-void CXHCIDevice::InterruptHandler (unsigned nVector)
|
||||
-#endif
|
||||
{
|
||||
#ifdef XHCI_DEBUG2
|
||||
-#ifdef USE_XHCI_INTERNAL
|
||||
CLogger::Get ()->Write (From, LogDebug, "IRQ");
|
||||
-#else
|
||||
- CLogger::Get ()->Write (From, LogDebug, "MSI%u", nVector);
|
||||
-#endif
|
||||
-#endif
|
||||
-#ifndef USE_XHCI_INTERNAL
|
||||
- assert (nVector == 0);
|
||||
#endif
|
||||
|
||||
// acknowledge interrupt
|
||||
u32 nStatus = m_pMMIO->op_read32 (XHCI_REG_OP_USBSTS);
|
||||
m_pMMIO->op_write32 (XHCI_REG_OP_USBSTS, nStatus | XHCI_REG_OP_USBSTS_EINT);
|
||||
|
||||
-#ifdef USE_XHCI_INTERNAL
|
||||
m_pMMIO->rt_write32 (0, XHCI_REG_RT_IR_IMAN, m_pMMIO->rt_read32 (0, XHCI_REG_RT_IR_IMAN)
|
||||
| XHCI_REG_RT_IR_IMAN_IP);
|
||||
-#endif
|
||||
|
||||
if (nStatus & XHCI_REG_OP_USBSTS_HCH)
|
||||
{
|
||||
@@ -406,8 +387,6 @@ void CXHCIDevice::InterruptHandler (unsigned nVector)
|
||||
}
|
||||
}
|
||||
|
||||
-#ifdef USE_XHCI_INTERNAL
|
||||
-
|
||||
void CXHCIDevice::InterruptStub (void *pParam)
|
||||
{
|
||||
CXHCIDevice *pThis = (CXHCIDevice *) pParam;
|
||||
@@ -416,18 +395,6 @@ void CXHCIDevice::InterruptStub (void *pParam)
|
||||
pThis->InterruptHandler ();
|
||||
}
|
||||
|
||||
-#else
|
||||
-
|
||||
-void CXHCIDevice::InterruptStub (unsigned nVector, void *pParam)
|
||||
-{
|
||||
- CXHCIDevice *pThis = (CXHCIDevice *) pParam;
|
||||
- assert (pThis != 0);
|
||||
-
|
||||
- pThis->InterruptHandler (nVector);
|
||||
-}
|
||||
-
|
||||
-#endif
|
||||
-
|
||||
boolean CXHCIDevice::HWReset (void)
|
||||
{
|
||||
if ( !m_pMMIO->op_wait32 (XHCI_REG_OP_USBSTS, XHCI_REG_OP_USBSTS_CNR, 0, 100000)
|
||||
Reference in new issue
Block a user