From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit 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. +config HAVE_BROKEN_EHCI_HCD + bool + endif # USB_EHCI_HCD 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; +#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 *regs); +#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 ehci_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 -- 2.53.0