From nobody Sat Jul 25 21:22:47 2026 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EF4F3F413E for ; Mon, 13 Jul 2026 12:22:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783945341; cv=none; b=Ad17q6VMU1KJwlIsQEkFEodXJ2NI9rTfVldHl8wEXw8ETKdvTBlfqlQj/eZbZF4J6izgofJOo2518PrNBWFdDAX+U303sg2K1IAHkfcfzMtH4+m1CAe7PM5Es3S63fhHsHtGyLCVOaPPFc6H0phqmbE6f7ovprNllxP7nCCrwjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783945341; c=relaxed/simple; bh=CC1I8A0g5ryeTNIPYNRkfYT1ctp/4W6LumSH2gdkO7E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jF5UevTn9/768eG9Lqut8bRr5jYcBnme9Ym9c3d2itQRq86pJoMypqPI6mu3OF9dXDbNO/BoijsFm2gnXMLVBAvY42HFfnP5HBsq64guxVp9snv6usVqOim9dBoDG9ANcWPocbEEC6qWVtfUAyx9821VsprOKGvcfY/sKfaNyQE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp; spf=pass smtp.mailfrom=0x0f.com; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b=Zb7i/LhY; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0x0f.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b="Zb7i/LhY" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-ca965de53baso1557302a12.0 for ; Mon, 13 Jul 2026 05:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1783945339; x=1784550139; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Q7vlwcyYZljM0igSykkOYX1j9W69gTakFBnqtWeMcKU=; b=Zb7i/LhY7m2Jyj0d6dOQao/k4S2lfxFRN7745PpW9CeEwevxqFUOpW9fmjCl/QdpY4 HqWXYvshxzFhy0aHtgGY133Ca+nxxZH2KFYTxqrF1gLIy8ERJHX5fSU+bF5HIr1oVNuq oZZL+iu0baTBUVnGFkKbVd0rAw3IcijJlFfxk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783945339; x=1784550139; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Q7vlwcyYZljM0igSykkOYX1j9W69gTakFBnqtWeMcKU=; b=S0SnFYePrMsKB3Ga5BfK33sDKlWhjXFD3l80fJ7xb7zPJQLlMaRBTDlwG61r6mTVJP 5jlY29NpQdtrBIJ8b5DiDshC5Y8189YkvSAOXgcpxQhLcIRo6iH/4jKeuxbewZ9EX/KR eSm0EgAykbn/Bs4Bj5FpdK8CHL5VmsSXPRCDGiYDrzEcp1so9l7VOyDJInTLBVQLFis+ 4skKQHpXuaOplOEAgqKwH6ac+c+87Ao7aAf6wgRZYj8HXMb2xzTDl++PcB7AuxQFIyus PXl4DgzVBS63ANkrrW8Ph7TY87kGROxjYvydYve+wH1Buy4ClZLQC4ZSlm39glaBUnVr 4NOA== X-Forwarded-Encrypted: i=1; AHgh+RruTV1AvlnNWp3o7tHtYrNxVQh5iGFc+ooOmGJDm3ajbWBzEsP6brnqoDPGhvCtCXueoho3NcGp2/jMf24=@vger.kernel.org X-Gm-Message-State: AOJu0YyLSX2GceVWFOaiWohgxHfAZ1CsFmgPWGS62yko/WxMUBolKd2H bx++bDAcWy66YMurwImeOj1pMPB9svcPHH9Fruy4HC+ZSfTo8jlBENzHQQFFndDR3Qs= X-Gm-Gg: AfdE7cmXhoD6Exq9C6xlC2ZSviuOrGhA3NXxRMrObkME3P52NYN/MaS78YDVUOByLYI OzEashyGTlSyclpaifLjEeg3Pv9TTG4eJgt2HQZ7TEYPKN5++a+sZKRK4NyXGZh0XuN5J1oUNG1 VAyFhnCgHckRpKKX48xU6V0IBKff4j8yyM4yqEPKirBQRXUk5jgBEmO7+z4ZOeVyguvGVQMyimf e3t6BJ6qRIPyluAkUV5qWCi5o020MtMECDSNW7WYplM9Y02ycSVi/pXAsAi+s19pFsH7ShnfSlg SuZh8kBbWKEzlLROqxngWVNLyY5HyHrHqXb2GEHbT1q51c01Kt5Q58ZZzLk9gjQRH75dnp7/oVr xel1FJ01jHVH74tVzSCQ0SiaPERSqdDYfEfWlCOMFYqIGT6k7FI17BfscJSldXrgyNSsPg6+/ZI R5IwC819UUa3qNCfTjfvaBo/QzlA== X-Received: by 2002:a05:6a20:9190:b0:3bf:79d6:f063 with SMTP id adf61e73a8af0-3c110b2642amr9523074637.43.1783945339191; Mon, 13 Jul 2026 05:22:19 -0700 (PDT) Received: from kinako.work.home.arpa ([2400:4162:2428:2ffe:a973:53e4:1a28:8545]) by smtp.googlemail.com with ESMTPSA id 41be03b00d2f7-ca5b3b251eesm8126216a12.31.2026.07.13.05.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 05:22:18 -0700 (PDT) From: Daniel Palmer To: peter.chen@kernel.org, gregkh@linuxfoundation.org, stern@rowland.harvard.edu Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Palmer Subject: [RFC PATCH 1/2] usb: ehci: Add option to override ehci_readl()/ehci_writel() Date: Mon, 13 Jul 2026 21:22:04 +0900 Message-ID: <20260713122205.1350933-2-daniel@thingy.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260713122205.1350933-1-daniel@thingy.jp> References: <20260713122205.1350933-1-daniel@thingy.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Palmer There are EHCI-like hosts, like fotg210, out there that should be able to use the shared ehci code but can't because they need to override some parts of the ehci code to work properly. Let ehci_readl() and ehci_writel() be overridden first. This allows the ehci code to be used with hosts that need to do special dances when accessing their registers. The change is hidden behind a boolean kconfig option so that the extra function pointer NULL check and call only happens when a broken controller is enabled. Signed-off-by: Daniel Palmer --- drivers/usb/host/Kconfig | 3 +++ drivers/usb/host/ehci.h | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index b3b1ec696bf5..8c88354e91e5 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -362,6 +362,9 @@ config USB_OCTEON_EHCI USB 2.0 device support. All CN6XXX based chips with USB are supported. =20 +config HAVE_BROKEN_EHCI_HCD + bool + endif # USB_EHCI_HCD =20 config USB_OXU210HP_HCD diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index d7a3c8d13f6b..f592cc26e494 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -258,6 +258,14 @@ struct ehci_hcd { /* one per controller */ /* us budgeted per uframe */ struct list_head tt_list; =20 +#ifdef CONFIG_HAVE_BROKEN_EHCI_HCD + /* Overrides to fix up broken implementations */ + /* Broken IO */ + void (*ehci_writel)(const struct ehci_hcd *ehci, + const unsigned int val, __u32 __iomem *regs); + unsigned int (*ehci_readl)(const struct ehci_hcd *ehci, __u32 __iomem *re= gs); +#endif + /* platform-specific data -- must come last */ unsigned long priv[] __aligned(sizeof(s64)); }; @@ -762,6 +770,10 @@ static inline unsigned int ehci_readl(const struct ehc= i_hcd *ehci, readl_be(regs) : readl(regs); #else +#ifdef CONFIG_HAVE_BROKEN_EHCI_HCD + if (ehci->ehci_readl) + return ehci->ehci_readl(ehci, regs); +#endif return readl(regs); #endif } @@ -788,6 +800,10 @@ static inline void ehci_writel(const struct ehci_hcd *= ehci, #else if (ehci->imx28_write_fix) imx28_ehci_writel(val, regs); +#ifdef CONFIG_HAVE_BROKEN_EHCI_HCD + else if (ehci->ehci_writel) + ehci->ehci_writel(ehci, val, regs); +#endif else writel(val, regs); #endif --=20 2.53.0 From nobody Sat Jul 25 21:22:47 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD41340929C for ; Mon, 13 Jul 2026 12:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783945343; cv=none; b=EyeKirdDw5lZlcODo2G1lDcIPpwTcB+VO097Y1F3DmmR7rN2OA3kVKBGwBZWZG72Zw0mc+oQ1oIk2EwiKCAXb5ZB/9wnzFNMiluSjLw0g1UPmw7m08R3G5NtbQOAf92DhrQjNyJjlU5cVK7Ma3WKxIVuxiAlz/W5MhoLXCq7AEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783945343; c=relaxed/simple; bh=eoJTAmX9AWXfkTF4kLIHT8w3C6GUQLelCr2YllhbyRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HlXKpL+3QYJQfJT4BXHYzYUvT+1u96/SpBzzYH3NEeTcW6rRvBjgLutBmKC7CLkraVeGmZbIpCMb0IhAVXYtPTbB612PWIkH9EerS6/qoAA3OdoqJ9n5jfUmC563m4yCnMHLnb2I/2r00P565/sH04RbP85IRhusxxDxapbzjsY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp; spf=pass smtp.mailfrom=0x0f.com; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b=JDSYCe1H; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0x0f.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b="JDSYCe1H" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2cacd69a9c0so31854005ad.1 for ; Mon, 13 Jul 2026 05:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1783945341; x=1784550141; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=kRr+JXgQmTo2U7vmzb7T4qvb4h5XSF+nEYAqLJoq5Zs=; b=JDSYCe1HPPzZAof3gDwkQtVU9wLKZBDRmLdX2k2MvtXAU9T37c9zOxZtgK+CD4AFo8 6OKtYrQT7TS9JvrK2LTB2iW2Bww6GSgTPom2CcVC9GlIKseJJ867eVr2OLmJm6dYfBuu vVUztEnj8n8JD/JLsi0UiCLZPYRXx14nP82v4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783945341; x=1784550141; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc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UrI 22SS/Pa9W++Obqsd36Mfp6c0BQfunfydIjqXRAkFLVtSETaI6eLhLyDi/a3sGoL+hWyBHWR/AZF jpfNWoC4cbpXYxg5PHUjBnEGdKZg== X-Received: by 2002:a05:6a20:9595:b0:3b4:7eb0:47aa with SMTP id adf61e73a8af0-3c1108c1ef5mr9418636637.25.1783945341167; Mon, 13 Jul 2026 05:22:21 -0700 (PDT) Received: from kinako.work.home.arpa ([2400:4162:2428:2ffe:a973:53e4:1a28:8545]) by smtp.googlemail.com with ESMTPSA id 41be03b00d2f7-ca5b3b251eesm8126216a12.31.2026.07.13.05.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 05:22:20 -0700 (PDT) From: Daniel Palmer To: peter.chen@kernel.org, gregkh@linuxfoundation.org, stern@rowland.harvard.edu Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Palmer Subject: [RFC PATCH 2/2] usb: chipidea: use the generic ehci_writel override for i.MX28 Date: Mon, 13 Jul 2026 21:22:05 +0900 Message-ID: <20260713122205.1350933-3-daniel@thingy.jp> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260713122205.1350933-1-daniel@thingy.jp> References: <20260713122205.1350933-1-daniel@thingy.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniel Palmer The EHCI core carries an imx28_write_fix flag baked into ehci_writel() that special-cases the i.MX28's need for a swp instruction when writing the EHCI registers. Now that the EHCI core provides a generic ehci_writel override hook, convert the chipidea host glue to install its own writel via that hook and drop the i.MX28 special case from the core, keeping ehci_writel() free of SoC-specific knowledge. Signed-off-by: Daniel Palmer --- drivers/usb/chipidea/Kconfig | 1 + drivers/usb/chipidea/host.c | 17 ++++++++++++++++- drivers/usb/host/ehci.h | 19 ++----------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig index bab45bc62361..5bada84943e2 100644 --- a/drivers/usb/chipidea/Kconfig +++ b/drivers/usb/chipidea/Kconfig @@ -29,6 +29,7 @@ config USB_CHIPIDEA_HOST bool "ChipIdea host controller" depends on USB_EHCI_HCD select USB_EHCI_ROOT_HUB_TT + select HAVE_BROKEN_EHCI_HCD if SOC_IMX28 help Say Y here to enable host controller functionality of the ChipIdea driver. diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index ced6076a8248..820bdea5da12 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -117,6 +117,18 @@ static irqreturn_t host_irq(struct ci_hdrc *ci) return usb_hcd_irq(ci->irq, ci->hcd); } =20 +#ifdef CONFIG_SOC_IMX28 +/* + * The i.MX28 needs a swp instruction rather than a normal write to the + * EHCI registers; provide it through the generic ehci_writel override. + */ +static void ci_hdrc_ehci_writel(const struct ehci_hcd *ehci, + const unsigned int val, __u32 __iomem *regs) +{ + asm("swp %0, %0, [%1]" : : "r"(val), "r"(regs)); +} +#endif + static int host_start(struct ci_hdrc *ci) { struct usb_hcd *hcd; @@ -150,7 +162,10 @@ static int host_start(struct ci_hdrc *ci) ehci->caps =3D ci->hw_bank.cap; ehci->has_hostpc =3D ci->hw_bank.lpm; ehci->has_tdi_phy_lpm =3D ci->hw_bank.lpm; - ehci->imx28_write_fix =3D ci->imx28_write_fix; +#ifdef CONFIG_SOC_IMX28 + if (ci->imx28_write_fix) + ehci->ehci_writel =3D ci_hdrc_ehci_writel; +#endif ehci->has_ci_pec_bug =3D ci->has_portsc_pec_bug; =20 priv =3D (struct ehci_ci_priv *)ehci->priv; diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index f592cc26e494..616b01314bfe 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -218,7 +218,6 @@ struct ehci_hcd { /* one per controller */ unsigned has_synopsys_hc_bug:1; /* Synopsys HC */ unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */ unsigned need_oc_pp_cycle:1; /* MPC834X port power */ - unsigned imx28_write_fix:1; /* For Freescale i.MX28 */ unsigned spurious_oc:1; unsigned is_aspeed:1; unsigned zx_wakeup_clear_needed:1; @@ -778,18 +777,6 @@ static inline unsigned int ehci_readl(const struct ehc= i_hcd *ehci, #endif } =20 -#ifdef CONFIG_SOC_IMX28 -static inline void imx28_ehci_writel(const unsigned int val, - volatile __u32 __iomem *addr) -{ - __asm__ ("swp %0, %0, [%1]" : : "r"(val), "r"(addr)); -} -#else -static inline void imx28_ehci_writel(const unsigned int val, - volatile __u32 __iomem *addr) -{ -} -#endif static inline void ehci_writel(const struct ehci_hcd *ehci, const unsigned int val, __u32 __iomem *regs) { @@ -798,13 +785,11 @@ static inline void ehci_writel(const struct ehci_hcd = *ehci, writel_be(val, regs) : writel(val, regs); #else - if (ehci->imx28_write_fix) - imx28_ehci_writel(val, regs); #ifdef CONFIG_HAVE_BROKEN_EHCI_HCD - else if (ehci->ehci_writel) + if (ehci->ehci_writel) ehci->ehci_writel(ehci, val, regs); -#endif else +#endif writel(val, regs); #endif } --=20 2.53.0