From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61D33C982FF for ; Tue, 22 Sep 2026 10:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To: References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version: Subject:Date:From:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0Zym52JOfBPXrV1rY50LB5EBPcDp9VwOqgm30m1O+FY=; b=DQ6Kqt5DcJqUpqhwdppAQeg3pv rlDyrjwVCwPdSBQBj+MkmrhDjA2PXgqMIANGvzbJnzfONYQSZGptAv7zhpJ8IPCbzvaegwgEZ0W9e sDoriRVc80nIyJ8mD8A6YF7TgTmNPw1IdwslXLaTtSmD4jjKDU8k8iGfJCEn9PAgbtEVEOCnvSYUi kxQ2pHL5I7gO6/J5OLKOuWAuXOUVzYZz4YP30WVCpn83mUbzl5nHnIO1xPEJSpt2R0KzAwWp8tCrN x7JlabpMChkLYIDW4z+IFdXRRngdoq6th0udaJtxB+d/2FhLqS2kbksUl/2ffwbBpt8tzED9OqbPN BA5rYSjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x8xrg-0000000545P-2xKg; Tue, 22 Sep 2026 10:36:44 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x8xrf-0000000544e-27Sr; Tue, 22 Sep 2026 10:36:43 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id F1B3B448E2; Tue, 22 Sep 2026 10:36:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id C9EABC2BCFC; Tue, 22 Sep 2026 10:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1790073402; bh=0ui00qdYqGIqavaMCgWtVbPGeJpWwJ+VrrPOX5IcVo0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=F36bTwA+ob9kFmV4iydZyJzKTqPSNEjK+tLm+irTFR8s4mppO8/c8ZIsYy7kpveRZ doeuR6LGsKza+F5kmdzc1pqO3jQ9oJPSIuSsQ03zbCgz/xT+4xfDpFzRdQzNWQLLXo BXSR86+VEwUDul0KR/TxfziHpFVAQuhX7nJrRnCXfg6OFcD9fBNVekxOLNjD4IgMZG tBgOFpRYpcCt1exLdKuXTpEna9Q5CHZgGhHgPhtfu7PoCAbQBsqJ9Uw/I3n1n0j4lq xXamn6IkgR+iyqfHv/vGF5x9NJmaQevRgm5bl296CTr0UdNM9bErulbaWJKWTKnQz7 zIqFnejkMCGCA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB4EEC982F1; Tue, 22 Sep 2026 10:36:42 +0000 (UTC) From: Roman Vivchar via B4 Relay Date: Tue, 22 Sep 2026 13:36:41 +0300 Subject: [PATCH v2 2/3] usb: mtu3: add SoC platform data for FIFO quirk handling MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260922-6595-mtu3-v2-2-71203a362b36@protonmail.com> References: <20260922-6595-mtu3-v2-0-71203a362b36@protonmail.com> In-Reply-To: <20260922-6595-mtu3-v2-0-71203a362b36@protonmail.com> To: Chunfeng Yun , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno 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 X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1790073400; l=3783; i=rva333@protonmail.com; s=20260510; h=from:subject:message-id; bh=PeSYuhPfs9FYqWgAteG4UF+yJ7jUWVa+ILkv9Zw8AWk=; b=UNtHttnLwZMsvRPEU3t9LvSZ86hbB5MJFPwU4zkNlZ4JO2xLNtTaugjEPrxpBTUyyP30uXVui T5jVG/BHCwlC+0hld/Y/bjlvXK1adHefosMc/nm/JfNbzVayziQLNEw X-Developer-Key: i=rva333@protonmail.com; a=ed25519; pk=zww/nWjBGoQ4POXCG0BV6fx2iuXK6jx77rsKPA5YK5Y= X-Endpoint-Received: by B4 Relay for rva333@protonmail.com/20260510 with auth_id=777 X-Original-From: Roman Vivchar X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: rva333@protonmail.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Roman Vivchar 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 --- 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