From: Roman Vivchar via B4 Relay <devnull+rva333.protonmail.com@kernel.org>
To: Chunfeng Yun <chunfeng.yun@mediatek.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Cc: linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Roman Vivchar <rva333@protonmail.com>
Subject: [PATCH v2 2/3] usb: mtu3: add SoC platform data for FIFO quirk handling
Date: Tue, 22 Sep 2026 13:36:41 +0300 [thread overview]
Message-ID: <20260922-6595-mtu3-v2-2-71203a362b36@protonmail.com> (raw)
In-Reply-To: <20260922-6595-mtu3-v2-0-71203a362b36@protonmail.com>
From: Roman Vivchar <rva333@protonmail.com>
Some SoCs, such as mt6595, require specific quirks for the MTU3 to
function properly.
The mt6595 IP block doesn't support multiple slots for the FIFO,
resulting FIFO wrap.
Fix this by adding platform data with a field to handle FIFO limitation.
No functional changes for existing SoCs.
Assisted-by: LLM (debugging)
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/usb/mtu3/mtu3.h | 9 +++++++++
drivers/usb/mtu3/mtu3_core.c | 3 +++
drivers/usb/mtu3/mtu3_gadget.c | 8 ++++++--
drivers/usb/mtu3/mtu3_plat.c | 8 ++++++--
4 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
index ba5a63669e5f..349e5b20f285 100644
--- a/drivers/usb/mtu3/mtu3.h
+++ b/drivers/usb/mtu3/mtu3.h
@@ -315,6 +315,14 @@ static inline struct ssusb_mtk *dev_to_ssusb(struct device *dev)
return dev_get_drvdata(dev);
}
+/**
+ * struct mtu3_platform_data - platform data for the driver.
+ * @fifo_single_slot: the IP can handle only one buffer for bulk transfers
+ */
+struct mtu3_platform_data {
+ bool fifo_single_slot;
+};
+
/**
* struct mtu3 - device driver instance data.
* @slot: MTU3_U2_IP_SLOT_DEFAULT for U2 IP only,
@@ -369,6 +377,7 @@ struct mtu3 {
unsigned connected:1;
unsigned async_callbacks:1;
unsigned separate_fifo:1;
+ unsigned fifo_single_slot:1;
u8 address;
u8 test_mode_nr;
diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
index 66dbfe1705d5..15f1b80fd0e2 100644
--- a/drivers/usb/mtu3/mtu3_core.c
+++ b/drivers/usb/mtu3/mtu3_core.c
@@ -922,6 +922,7 @@ static int mtu3_set_dma_mask(struct mtu3 *mtu)
int ssusb_gadget_init(struct ssusb_mtk *ssusb)
{
struct device *dev = ssusb->dev;
+ const struct mtu3_platform_data *pdata = device_get_match_data(dev);
struct platform_device *pdev = to_platform_device(dev);
struct mtu3 *mtu = NULL;
int ret = -ENOMEM;
@@ -930,6 +931,8 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
if (mtu == NULL)
return -ENOMEM;
+ mtu->fifo_single_slot = pdata->fifo_single_slot;
+
mtu->irq = platform_get_irq_byname_optional(pdev, "device");
if (mtu->irq < 0) {
if (mtu->irq == -EPROBE_DEFER)
diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c
index f224f2ee379a..8ac244d40afd 100644
--- a/drivers/usb/mtu3/mtu3_gadget.c
+++ b/drivers/usb/mtu3/mtu3_gadget.c
@@ -112,8 +112,12 @@ static int mtu3_ep_enable(struct mtu3_ep *mep)
mep->ep.desc = desc;
mep->ep.comp_desc = comp_desc;
- /* slot mainly affects bulk/isoc transfer, so ignore int */
- mep->slot = usb_endpoint_xfer_int(desc) ? 0 : mtu->slot;
+ if (mtu->fifo_single_slot)
+ /* older IPs can handle only one slot reliably */
+ mep->slot = 0;
+ else
+ /* slot mainly affects bulk/isoc transfer, so ignore int */
+ mep->slot = usb_endpoint_xfer_int(desc) ? 0 : mtu->slot;
ret = mtu3_config_ep(mtu, mep, interval, burst, mult);
if (ret < 0)
diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
index cc8a864dbd63..bb67da4704b2 100644
--- a/drivers/usb/mtu3/mtu3_plat.c
+++ b/drivers/usb/mtu3/mtu3_plat.c
@@ -611,9 +611,13 @@ static const struct dev_pm_ops mtu3_pm_ops = {
#define DEV_PM_OPS (IS_ENABLED(CONFIG_PM) ? &mtu3_pm_ops : NULL)
+static const struct mtu3_platform_data mt8173_platform_data = {
+ .fifo_single_slot = false,
+};
+
static const struct of_device_id mtu3_of_match[] = {
- {.compatible = "mediatek,mt8173-mtu3",},
- {.compatible = "mediatek,mtu3",},
+ { .compatible = "mediatek,mt8173-mtu3", .data = &mt8173_platform_data },
+ { .compatible = "mediatek,mtu3", .data = &mt8173_platform_data },
{},
};
MODULE_DEVICE_TABLE(of, mtu3_of_match);
--
2.55.0
next prev parent reply other threads:[~2026-09-22 10:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 10:36 [PATCH v2 0/3] usb: mtu3: add mt6595 support Roman Vivchar via B4 Relay
2026-09-22 10:36 ` [PATCH v2 1/3] dt-bindings: usb: mtu3: add mt6595 Roman Vivchar via B4 Relay
2026-09-22 10:44 ` sashiko-bot
2026-09-28 7:51 ` Krzysztof Kozlowski
2026-09-22 10:36 ` Roman Vivchar via B4 Relay [this message]
2026-09-22 11:46 ` [PATCH v2 2/3] usb: mtu3: add SoC platform data for FIFO quirk handling AngeloGioacchino Del Regno
2026-09-22 10:36 ` [PATCH v2 3/3] usb: mtu3: add mt6595 support Roman Vivchar via B4 Relay
2026-09-22 10:50 ` sashiko-bot
2026-09-22 11:46 ` AngeloGioacchino Del Regno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260922-6595-mtu3-v2-2-71203a362b36@protonmail.com \
--to=devnull+rva333.protonmail.com@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunfeng.yun@mediatek.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=robh@kernel.org \
--cc=rva333@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox