From nobody Mon May 25 06:41:09 2026 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 1580137FF47 for ; Sun, 17 May 2026 13:04:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779023087; cv=none; b=mgKRUhv9UOvKcmz9GD/efA1Nl+/a08Abp4ytFOCYOeiDw0B3waM6MbBNPURb/qQbpxesO299kFPUJMPMqtA3yXK3dQlmva28Ib1YK6xHumyEyhwmWfVOXQ2l0NWFiGnR3qfYytUapacK5rXWPHVH43l1HqCZa/R9nxRvG8tpFsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779023087; c=relaxed/simple; bh=KshHTQQR+6mvIAComUFUue7CrlaSwdDDnxEiUrLUvHQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oDyKUmpzaumOE1fFGs025Hhu04/V7Jj+Ky+hV7abniCLNJ3xushsIggWTonTUSxI4GB0LAfazRtsV7YKRWXtSSFJG1gk/3mFBzjP8vh7eWgV+7f5zAGq3QMGxQmZPW/W9PmOC3cgZaFVCE9zeRnRYHUENE2jK98hpJ9cTjqbyYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cBFKjqP3; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cBFKjqP3" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-837b39eb078so938091b3a.2 for ; Sun, 17 May 2026 06:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779023066; x=1779627866; 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; bh=CbYK6zyjwjcKr/UaCrMnTnE/VprY/vEckd2yJv9TdQ8=; b=cBFKjqP3uvCQp4D4whhPenh+JHSL8UIvtISkpXMfb9SVrW9cCbKojzC5I7cwfTM71E z8h8b2BsXaMeu8jilWX+shwia2uG5epq2xoep/eof+O9XSCbN9QA231oqoc07c8eUadz crZy/cXQkvq2VmEqGdHKDzzrDa6m3GtGgPez0C9xu4PSVzemUjfD2cGncMExnEy/WJdF Lcneg0mulmPj5lKQOPFKTnIgd2pWRNEk+auJAt3IYoqEjIcPaMmQ4QZlPH6MD6NPv37G 4w6aqaxKkwrhL2iJoLTtmmUJgIjzaL30Gfv9RHq9MqeqBkcCWZ9CrkccgLiIDCL59DXL 4Bbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779023066; x=1779627866; 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; bh=CbYK6zyjwjcKr/UaCrMnTnE/VprY/vEckd2yJv9TdQ8=; b=b+eyDRCTcBBqgckvkl98KwMYaP0MrdxYSUvgGvfiSkicoN6aQ+2AsrzLaj5jM+2zco aWZlP3CH8hCC3u65dGfSWOk8XhoI020pRcGTkOFOEHDvQe6b2qjz03ahJkPnW/cCkFar ep9Vu0aGSjwCQSlbWEWRSErUw3Jag2GltpH4O3MOqN3Y7C3Py7lEkIpj3Xbqyl/Y/fte Og6yQpeAqK1TCkWTDvZZMbwzBOkEPkUWprIxlm5EkLtyyuom/m6vM9xEvviqa4KrnxPW AiT2NldTUb7eYVacLTUXVMPkR9RaREel33/lL3cFMKSp1C0r+49nbn1g+5RhTnVG3kCJ BL+g== X-Forwarded-Encrypted: i=1; AFNElJ/r6lxt8eKXoETSX1gN++fMM+u4z3Q2lFTMjHXAp3tac8c9WgYNcPyEgqpInNPEh+8ceoXXc5ZPau9k8Ns=@vger.kernel.org X-Gm-Message-State: AOJu0Yz52kl5C1CPGiUbUNKbDHykE4bG05iYJWfJTtfheENTeibDgdQl vpUskW95tqDyHRy2YCZCZWuDyVYaxzAzlTwJ5wwITR9GiMH8M/08oBzj7fjpSFoT X-Gm-Gg: Acq92OEr2XSDgx4LVLBoBoH9L+YyH2z25NYQBA/oqbp5v73Cjog+woLHpOPvmVj/kdY v+lgna3kDbPLS1dWdX8Er1upQeGlHh/OxtctCJKGf3OXwVDvFQIn0RW7EDiNQSOzdRoElgGvaad tMc7Llq+FfctScYVtfkowBUt+rsykLSZS41WTOqW/9KeC5zdlELRD4rr2vn0e7X8P5jd77sfMhK bwLL1z+sqF9/VR6poVroXANyzy1/dbJFVNixX3RHp3R0xn+KH5A4IyMPft9wtv6W1yQ/9AB6B3w dqY+WV1uYfjC1B9hCVBK2l6mT3TXVfCGP9BsoAklOdVmAwsJqfMgu6wBFFBMzMSwuAZp0Au2MO5 RI7KxwUtrg4+BpG0/ehftbkoOW6iobjcRpoqLZi5NoaD/PVTCNM6+kOu9qelJVtWCZBZloL5Yzq V0AcvsERskMi0dTH2sTyzvGw== X-Received: by 2002:a05:6a00:440e:b0:82f:3ecc:c42f with SMTP id d2e1a72fcca58-83f33c9d17amr11704313b3a.40.1779023066365; Sun, 17 May 2026 06:04:26 -0700 (PDT) Received: from mincom1 ([119.214.48.64]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f19c77822sm11712607b3a.41.2026.05.17.06.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2026 06:04:24 -0700 (PDT) From: Jihong Min To: Greg Kroah-Hartman , Mathias Nyman Cc: Guenter Roeck , Jonathan Corbet , Shuah Khan , Mario Limonciello , Basavaraj Natikar , linux-usb@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Jihong Min , "Mario Limonciello (AMD)" , Yaroslav Isakov Subject: [PATCH v6 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue Date: Sun, 17 May 2026 22:04:06 +0900 Message-ID: <20260517130407.795157-2-hurryman2212@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260517130407.795157-1-hurryman2212@gmail.com> References: <20260517130407.795157-1-hurryman2212@gmail.com> 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" AMD Promontory 21 (PROM21) xHCI controllers use generic xHCI operation, but the PCI function also exposes optional controller-specific sensor functionality. Add a small PROM21 PCI glue driver for AMD 1022:43fc and 1022:43fd controllers. The driver delegates USB host operation to the common xhci-pci core, collects the parent-provided MMIO resource data, and creates a "hwmon" auxiliary device for optional child drivers. Failure to create the auxiliary device is logged but does not fail the xHCI probe, since the auxiliary device is only needed for sensor support. Make the PROM21 PCI glue a hidden Kconfig tristate that follows USB_XHCI_PCI. This keeps the glue built in with a built-in xhci-pci core and builds it as a module with a modular xhci-pci core. A built-in xhci-pci core must not hand PROM21 controllers to a PROM21 glue driver that is only available as a module, otherwise USB behind those controllers can be unavailable during initramfs and PROM21 temperature sensor support may not appear until the controller is rebound after the module loads. Assisted-by: Codex:gpt-5.5 Signed-off-by: Jihong Min Reviewed-by: Mario Limonciello (AMD) Tested-by: Yaroslav Isakov --- drivers/usb/host/Kconfig | 7 + drivers/usb/host/Makefile | 1 + drivers/usb/host/xhci-pci-prom21.c | 136 ++++++++++++++++++ drivers/usb/host/xhci-pci.c | 11 ++ drivers/usb/host/xhci-pci.h | 3 + include/linux/platform_data/usb-xhci-prom21.h | 22 +++ 6 files changed, 180 insertions(+) create mode 100644 drivers/usb/host/xhci-pci-prom21.c create mode 100644 include/linux/platform_data/usb-xhci-prom21.h diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 0a277a07cf70..89bf262235e1 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -42,6 +42,13 @@ config USB_XHCI_PCI depends on USB_PCI default y =20 +config USB_XHCI_PCI_PROM21 + tristate + depends on X86 + depends on USB_XHCI_PCI + default USB_XHCI_PCI + select AUXILIARY_BUS + config USB_XHCI_PCI_RENESAS tristate "Support for additional Renesas xHCI controller with firmware" depends on USB_XHCI_PCI diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index a07e7ba9cd53..174580c1281a 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -71,6 +71,7 @@ obj-$(CONFIG_USB_UHCI_HCD) +=3D uhci-hcd.o obj-$(CONFIG_USB_FHCI_HCD) +=3D fhci.o obj-$(CONFIG_USB_XHCI_HCD) +=3D xhci-hcd.o obj-$(CONFIG_USB_XHCI_PCI) +=3D xhci-pci.o +obj-$(CONFIG_USB_XHCI_PCI_PROM21) +=3D xhci-pci-prom21.o obj-$(CONFIG_USB_XHCI_PCI_RENESAS) +=3D xhci-pci-renesas.o obj-$(CONFIG_USB_XHCI_PLATFORM) +=3D xhci-plat-hcd.o obj-$(CONFIG_USB_XHCI_HISTB) +=3D xhci-histb.o diff --git a/drivers/usb/host/xhci-pci-prom21.c b/drivers/usb/host/xhci-pci= -prom21.c new file mode 100644 index 000000000000..be0933ca5c62 --- /dev/null +++ b/drivers/usb/host/xhci-pci-prom21.c @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD Promontory 21 xHCI host controller PCI Bus Glue. + * + * This does not add any PROM21-specific USB or xHCI operation. It exists = only + * to publish an auxiliary device for integrated temperature sensor suppor= t. + * + * Copyright (C) 2026 Jihong Min + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xhci-pci.h" + +struct prom21_xhci_auxdev { + struct auxiliary_device *auxdev; + struct prom21_xhci_pdata pdata; + int id; +}; + +static DEFINE_IDA(prom21_xhci_auxdev_ida); + +static void prom21_xhci_auxdev_release(struct device *dev, void *res) +{ + struct prom21_xhci_auxdev *prom21_auxdev =3D res; + + auxiliary_device_destroy(prom21_auxdev->auxdev); + ida_free(&prom21_xhci_auxdev_ida, prom21_auxdev->id); +} + +static int prom21_xhci_create_auxdev(struct pci_dev *pdev) +{ + struct prom21_xhci_auxdev *prom21_auxdev; + struct usb_hcd *hcd =3D pci_get_drvdata(pdev); + + if (!hcd) + return -ENODEV; + + prom21_auxdev =3D devres_alloc(prom21_xhci_auxdev_release, + sizeof(*prom21_auxdev), GFP_KERNEL); + if (!prom21_auxdev) + return -ENOMEM; + + prom21_auxdev->pdata.pdev =3D pdev; + prom21_auxdev->pdata.regs =3D hcd->regs; + prom21_auxdev->pdata.rsrc_len =3D hcd->rsrc_len; + + prom21_auxdev->id =3D ida_alloc(&prom21_xhci_auxdev_ida, GFP_KERNEL); + if (prom21_auxdev->id < 0) { + int ret =3D prom21_auxdev->id; + + devres_free(prom21_auxdev); + return ret; + } + + prom21_auxdev->auxdev =3D auxiliary_device_create(&pdev->dev, + KBUILD_MODNAME, "hwmon", + &prom21_auxdev->pdata, + prom21_auxdev->id); + if (!prom21_auxdev->auxdev) { + ida_free(&prom21_xhci_auxdev_ida, prom21_auxdev->id); + devres_free(prom21_auxdev); + return -ENOMEM; + } + + devres_add(&pdev->dev, prom21_auxdev); + return 0; +} + +static void prom21_xhci_destroy_auxdev(struct pci_dev *pdev) +{ + devres_release(&pdev->dev, prom21_xhci_auxdev_release, NULL, NULL); +} + +static int prom21_xhci_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + int retval; + + retval =3D xhci_pci_common_probe(dev, id); + if (retval) + return retval; + + retval =3D prom21_xhci_create_auxdev(dev); + if (retval) { + /* + * The auxiliary device only provides optional temperature sensor + * support. Keep the xHCI controller usable if it fails. + */ + dev_err(&dev->dev, + "failed to create PROM21 hwmon auxiliary device: %d\n", + retval); + } + + return 0; +} + +static void prom21_xhci_remove(struct pci_dev *dev) +{ + prom21_xhci_destroy_auxdev(dev); + xhci_pci_remove(dev); +} + +static const struct pci_device_id pci_ids[] =3D { + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_PROM21_XHCI_43FC) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_PROM21_XHCI_43FD) }, + { /* end: all zeroes */ } +}; +MODULE_DEVICE_TABLE(pci, pci_ids); + +static struct pci_driver prom21_xhci_driver =3D { + .name =3D "xhci-pci-prom21", + .id_table =3D pci_ids, + + .probe =3D prom21_xhci_probe, + .remove =3D prom21_xhci_remove, + + .shutdown =3D usb_hcd_pci_shutdown, + .driver =3D { + .pm =3D pm_ptr(&usb_hcd_pci_pm_ops), + }, +}; +module_pci_driver(prom21_xhci_driver); + +MODULE_AUTHOR("Jihong Min "); +MODULE_DESCRIPTION("AMD Promontory 21 xHCI PCI Host Controller Driver"); +MODULE_IMPORT_NS("xhci"); +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 585b2f3117b0..039c26b241d0 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -696,12 +696,23 @@ static const struct pci_device_id pci_ids_renesas[] = =3D { { /* end: all zeroes */ } }; =20 +/* handled by xhci-pci-prom21 if enabled */ +static const struct pci_device_id pci_ids_prom21[] =3D { + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_PROM21_XHCI_43FC) }, + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_PROM21_XHCI_43FD) }, + { /* end: all zeroes */ } +}; + static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id = *id) { if (IS_ENABLED(CONFIG_USB_XHCI_PCI_RENESAS) && pci_match_id(pci_ids_renesas, dev)) return -ENODEV; =20 + if (IS_ENABLED(CONFIG_USB_XHCI_PCI_PROM21) && + pci_match_id(pci_ids_prom21, dev)) + return -ENODEV; + return xhci_pci_common_probe(dev, id); } =20 diff --git a/drivers/usb/host/xhci-pci.h b/drivers/usb/host/xhci-pci.h index e87c7d9d76b8..11f435f94322 100644 --- a/drivers/usb/host/xhci-pci.h +++ b/drivers/usb/host/xhci-pci.h @@ -4,6 +4,9 @@ #ifndef XHCI_PCI_H #define XHCI_PCI_H =20 +#define PCI_DEVICE_ID_AMD_PROM21_XHCI_43FC 0x43fc +#define PCI_DEVICE_ID_AMD_PROM21_XHCI_43FD 0x43fd + int xhci_pci_common_probe(struct pci_dev *dev, const struct pci_device_id = *id); void xhci_pci_remove(struct pci_dev *dev); =20 diff --git a/include/linux/platform_data/usb-xhci-prom21.h b/include/linux/= platform_data/usb-xhci-prom21.h new file mode 100644 index 000000000000..ee672ad452a8 --- /dev/null +++ b/include/linux/platform_data/usb-xhci-prom21.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * AMD Promontory 21 xHCI auxiliary device platform data. + * + * Copyright (C) 2026 Jihong Min + */ + +#ifndef _LINUX_PLATFORM_DATA_USB_XHCI_PROM21_H +#define _LINUX_PLATFORM_DATA_USB_XHCI_PROM21_H + +#include +#include + +struct pci_dev; + +struct prom21_xhci_pdata { + struct pci_dev *pdev; + void __iomem *regs; + resource_size_t rsrc_len; +}; + +#endif --=20 2.53.0 From nobody Mon May 25 06:41:09 2026 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 C66043803D0 for ; Sun, 17 May 2026 13:04:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779023088; cv=none; b=SQ5PZ9XXUDjOoOZZKYbmhslcn3N/QAOw/CJd5MOU3DIpxuQkTsCZpJPkWDX5F4xWRQEROIotbiHmMa8SRl5xkWy6LsCYCmB2zH7o24PVyyqn+zYjzD66Fuq6SO2E0NKaJZxodcGMY4EJwNSHbPp9b9MzNHp7/JNy0YzxCNRC6fU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779023088; c=relaxed/simple; bh=P9UUTz0KPjDaK36GdTPq2adIZXx1n07srA3bOyu4bAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b1g1Y0EPoZ3x504bpS1B2WJuu8rSD8d2KZwV3jBYXaXWaAeCiGqOfMPqkAt7VrAhGMnGGl9jy6SvFop5pgwH7cvL3uKKAz/4dWJdGfA/wFP8tahPx1ZgCo3Etjis7HEZZcupLgO1yCYIJNE928GHhUYU3iHnljd60YtyVxh5WRM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XzZgk5L8; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XzZgk5L8" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-8353ca0f1f1so539440b3a.1 for ; Sun, 17 May 2026 06:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779023069; x=1779627869; 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; bh=GkI4Tg8ZNhDS+JGp9hFJRIlTHUDV4Po0ZoBGx3Qld6I=; b=XzZgk5L8qO7nyd48/SHAS1+QQ97KWgMe5iufnHqtwHntFxNilG6n9v6tPb4TnTdDny 1X2Y4M9N07fBGYHu8yF4nKlkF0ys4COjqrVR25OFJPrX49Wcb89sWZf75VysnhV4yBpa tc8q+eRFGQ4QqI3wr0voq09NuvuoHG2FPE5mbGOB8P8xkEJHTHORnAgBXht/zsTD1qmb 8VmUZVvAjcTm9PKdaxoEsrIGynQVVThryaWoMBc6Aqa1xHrN/KpjGeXe3CWnp9o+bBgb HiVOAnJUIHQcnNCGxHsQVnsGlHhgiX5cB3kU8rWbr6Dh0iEtWQq91SvRHsoLlQA3o/iF CZ0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779023069; x=1779627869; 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; bh=GkI4Tg8ZNhDS+JGp9hFJRIlTHUDV4Po0ZoBGx3Qld6I=; b=Ht5ZR8M+VyNuTz5F5MC9c5CRdfjl1/uL034EcIqGpmuiHpqso/bdveTZIH5nF1WA8E ZcrVEwFSlHLV5hkayQt1Rn+7YvxdH4vqAsSx4n4KmSP/2NaaOC9DUs/jmc9u18qB09Vs SGeo4MURQBzvjU+nDH5r/CyV/LmOhu3H6hoZPF5uIeni3fGZ3Ghnl8LcYRkc0prwXqlh HNOsAwMUleHEGQsVDWOAbE2sfy76uFc4j10udAeoWdcskaNjXmeBloqt3k5xmuvs8jcO TUnLauhOQa6c+JkgcxPcnb1iU9+M2Zp2B4Mu0tXrniN4YKHQQX0dclosyAmlmHePb+Y1 2B7A== X-Forwarded-Encrypted: i=1; AFNElJ+lf90SEI4ucpFSRDv9rmWxZFDMXoDwx2uLyP65VTeViDr4ZQbjr5/hcrZe7M29Bldq4num/l2J3Gc14FE=@vger.kernel.org X-Gm-Message-State: AOJu0Yza1Lsa4UvwYrWdRxSwA1EJf83KCybzKi3D3/Ra25otrBGsEL4u TS+9VTVhzhEBUMFogIGtT/479EwwuomsWpqKxWAK/M4WYjQC8kmFAhdg X-Gm-Gg: Acq92OGr9+fD1ycgvPje10bF2KmgazXPHjC5SquZVStENV7+h09orjsIPdB8PlYkC6E d+FjSWB+YqyfD+ZbmT6hJP/HsZh0BpLCkxtPnmu/zyjYOHJczWIm0869fffjp/KPTRe4L46iNoh j4HnE0E+rK9YTg2JAbtvflaC/8ZcJzcL0mxgAnQHLDJJAlO7Mi2ZQUauSOTpIDk0XD7to0vYHWg 8oXyUo9eJ+lcKSQgfER46fIpaDJJyyDR/jbUJtwxHGJ21SOGpE/lhSYP1SVkzetVU+NYzUdif3h b9lMYRkpGieHLOSgXfIcp1YFTvXrBSx6cnkK5QPFTC62mOYIf4ut8G0JWg+Ype1kvYP4ZWREWHH H6FRDR4k1n1NRJc1l80Zt8EzjyvHsJZZ2E94yWmRaYTlHbiBIKVXs2GPA/1P5BcyIdTJgYKNtK6 +1A4MWIa1ZiyTTgdyxGx/g2g== X-Received: by 2002:a05:6a00:ace:b0:829:6f7d:3086 with SMTP id d2e1a72fcca58-83f33b62df1mr8585011b3a.11.1779023069330; Sun, 17 May 2026 06:04:29 -0700 (PDT) Received: from mincom1 ([119.214.48.64]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f19c77822sm11712607b3a.41.2026.05.17.06.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2026 06:04:28 -0700 (PDT) From: Jihong Min To: Greg Kroah-Hartman , Mathias Nyman Cc: Guenter Roeck , Jonathan Corbet , Shuah Khan , Mario Limonciello , Basavaraj Natikar , linux-usb@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Jihong Min , "Mario Limonciello (AMD)" , Yaroslav Isakov Subject: [PATCH v6 2/2] hwmon: add AMD Promontory 21 xHCI temperature sensor support Date: Sun, 17 May 2026 22:04:07 +0900 Message-ID: <20260517130407.795157-3-hurryman2212@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260517130407.795157-1-hurryman2212@gmail.com> References: <20260517130407.795157-1-hurryman2212@gmail.com> 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" Add an auxiliary-bus hwmon driver for the temperature sensor exposed by AMD Promontory 21 (PROM21) xHCI PCI functions. The driver binds to the "hwmon" auxiliary device published by the PROM21 xHCI PCI glue and exposes the sensor as temp1_input under the prom21_xhci hwmon device. The sensor is accessed through a PROM21 vendor index/data register pair in the xHCI PCI MMIO BAR. The driver consumes parent-provided MMIO data from the PROM21 PCI glue instead of inspecting the parent PCI driver's drvdata. The read path restores the previous vendor index value after sampling and does not runtime-resume the parent PCI device; reads from a suspended parent return -ENODATA. Document the supported device, register access, runtime PM behavior, and sysfs lookup method. The documentation also records the observation method used to identify the register pair and derive the conversion formula. Assisted-by: Codex:gpt-5.5 Signed-off-by: Jihong Min Reviewed-by: Mario Limonciello (AMD) Tested-by: Yaroslav Isakov Reviewed-by: Guenter Roeck --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/prom21-xhci.rst | 101 ++++++++++++ drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/prom21-xhci.c | 239 ++++++++++++++++++++++++++++ 5 files changed, 352 insertions(+) create mode 100644 Documentation/hwmon/prom21-xhci.rst create mode 100644 drivers/hwmon/prom21-xhci.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 8b655e5d6b68..324208f1faa2 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -216,6 +216,7 @@ Hardware Monitoring Kernel Drivers pmbus powerz powr1220 + prom21-xhci pt5161l pxe1610 pwm-fan diff --git a/Documentation/hwmon/prom21-xhci.rst b/Documentation/hwmon/prom= 21-xhci.rst new file mode 100644 index 000000000000..7984fb187bd8 --- /dev/null +++ b/Documentation/hwmon/prom21-xhci.rst @@ -0,0 +1,101 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver prom21-xhci +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +Supported chips: + + * AMD Promontory 21 (PROM21) xHCI USB host controller + + Prefix: 'prom21_xhci' + + PCI IDs: 1022:43fc, 1022:43fd + +Author: + + - Jihong Min + +Description +----------- + +This driver exposes the temperature sensor in AMD PROM21 xHCI controllers. + +The driver binds to an auxiliary device created by the xHCI PCI driver for +supported controllers. The sensor value is accessed through a vendor-speci= fic +index/data register pair in the controller's PCI MMIO BAR. +The auxiliary device is created by the ``xhci-pci-prom21`` PCI glue driver. +USB host operation is otherwise delegated to the common ``xhci-pci`` code. + +PROM21 is an AMD chipset IP used in single-chip or daisy-chained configura= tions +to build AMD 6xx/8xx series chipsets. Since the xHCI controllers are +integrated in PROM21, this temperature can also be used as a monitor for a +temperature close to the AMD chipset temperature. + +Register access +--------------- + +The temperature value is read through a vendor-specific index/data register +pair in the xHCI PCI MMIO BAR. The driver uses the following byte offsets = from +the MMIO BAR base: + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D +0x3000 Vendor index register +0x3008 Vendor data register +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +The driver saves the current vendor index register value, writes the +temperature selector ``0x0001e520`` to the vendor index register, reads the +vendor data register, and restores the previous vendor index value before +returning. The raw temperature value is the low 8 bits of the vendor data +register value. + +The hwmon core serializes this driver's callbacks, and the driver restores= the +previous index value after each read. This does not provide synchronization +with firmware, SMM, ACPI AML, or any other user outside this driver. + +No public AMD reference is available for the register pair or the raw valu= e. +The register pair was identified on an X870E system with two PROM21 xHCI +controllers. One controller was passed through to a Windows VM, and the sa= me +controller's PCI MMIO BAR was observed from the Linux host while HWiNFO64 = was +reporting the PROM21 xHCI temperature. In the test environment, the report= ed +temperature was very stable at idle and the displayed sensor resolution was +low, which made it possible to look for a consistently repeating MMIO resp= onse +for the same reported temperature. During observation, offset 0x3000 repea= tedly +contained selector ``0x0001e520``. Writing the same selector to offset 0x3= 000 +from Linux and then reading offset 0x3008 reproduced the same raw value, s= o the +offsets are treated as a vendor index/data register pair. + +The conversion formula was empirically inferred by matching observed raw +8-bit values against HWiNFO64's reported PROM21 xHCI temperature for the s= ame +controller. The observed mapping is: + + temp[C] =3D raw * 0.9066 - 78.624 + +Runtime PM +---------- + +The driver does not wake the xHCI PCI device for hwmon reads. It reads the +temperature only when the parent device is already active. A read from a +suspended device returns ``-ENODATA``. After a successful read, the driver +drops its active-only runtime PM reference and lets the PM core re-evaluat= e the +idle state. + +Sysfs entries +------------- + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D +temp1_input Temperature in millidegrees Celsius +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +The hwmon device name is ``prom21_xhci``. The sysfs path depends on the hw= mon +device number assigned by the kernel. Userspace can locate the device by +matching the ``name`` attribute: + +.. code-block:: sh + + for hwmon in /sys/class/hwmon/hwmon*; do + [ "$(cat "$hwmon/name")" =3D "prom21_xhci" ] || continue + cat "$hwmon/temp1_input" + done + +If the raw register value is invalid, ``temp1_input`` returns ``-ENODATA``. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 14e4cea48acc..fe0f14e247b5 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -951,6 +951,16 @@ config SENSORS_POWR1220 This driver can also be built as a module. If so, the module will be called powr1220. =20 +config SENSORS_PROM21_XHCI + tristate "AMD Promontory 21 xHCI temperature sensor" + depends on USB_XHCI_PCI_PROM21 + help + If you say yes here you get support for the AMD Promontory 21 + (PROM21) xHCI temperature sensor. + + This driver can also be built as a module. If so, the module + will be called prom21-xhci. + config SENSORS_LAN966X tristate "Microchip LAN966x Hardware Monitoring" depends on SOC_LAN966 || COMPILE_TEST diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 982ee2c6f9de..f833aed890d8 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -196,6 +196,7 @@ obj-$(CONFIG_SENSORS_PC87427) +=3D pc87427.o obj-$(CONFIG_SENSORS_PCF8591) +=3D pcf8591.o obj-$(CONFIG_SENSORS_POWERZ) +=3D powerz.o obj-$(CONFIG_SENSORS_POWR1220) +=3D powr1220.o +obj-$(CONFIG_SENSORS_PROM21_XHCI) +=3D prom21-xhci.o obj-$(CONFIG_SENSORS_PT5161L) +=3D pt5161l.o obj-$(CONFIG_SENSORS_PWM_FAN) +=3D pwm-fan.o obj-$(CONFIG_SENSORS_QNAP_MCU_HWMON) +=3D qnap-mcu-hwmon.o diff --git a/drivers/hwmon/prom21-xhci.c b/drivers/hwmon/prom21-xhci.c new file mode 100644 index 000000000000..d40d0c53ce45 --- /dev/null +++ b/drivers/hwmon/prom21-xhci.c @@ -0,0 +1,239 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD Promontory 21 xHCI Hwmon Implementation + * (only temperature monitoring is supported) + * + * This can be effectively used as the alternative chipset temperature mon= itor. + * + * Copyright (C) 2026 Jihong Min + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PROM21_XHCI_INDEX_OFFSET 0x3000 +#define PROM21_XHCI_DATA_OFFSET 0x3008 +#define PROM21_XHCI_TEMP_SELECTOR 0x0001e520 + +struct prom21_xhci { + struct pci_dev *pdev; + struct device *hwmon_dev; + void __iomem *regs; +}; + +static int prom21_xhci_pm_get(struct prom21_xhci *hwmon) +{ + struct device *dev =3D &hwmon->pdev->dev; + int ret; + + /* + * PROM21 temperature register access does not return a valid value while + * the parent xHCI PCI function is suspended. Do not wake the device from + * a hwmon read. On success, hold a usage reference without changing the + * runtime PM state; if runtime PM is disabled, allow the read unless the + * device is still marked suspended. + */ + ret =3D pm_runtime_get_if_active(dev); + if (ret > 0) + return 0; + + if (ret =3D=3D -EINVAL) { + if (pm_runtime_status_suspended(dev)) + return -ENODATA; + + pm_runtime_get_noresume(dev); + return 0; + } + + if (!ret) + return -ENODATA; + + return ret; +} + +/* + * This is not a pure MMIO read. The PROM21 vendor data register is select= ed + * by temporarily writing PROM21_XHCI_TEMP_SELECTOR to the vendor index + * register. + * The hwmon core already serializes this driver's callbacks, so this driv= er + * does not need an additional private lock. That does not synchronize with + * firmware, SMM, ACPI, or other possible users. Keep the sequence short a= nd + * restore the previous index before returning. + */ +static int prom21_xhci_read_temp_raw_restore_index(struct prom21_xhci *hwm= on, + u8 *raw) +{ + struct device *dev =3D &hwmon->pdev->dev; + u32 index; + u8 data; + int ret; + + ret =3D prom21_xhci_pm_get(hwmon); + if (ret) + return ret; + + index =3D readl(hwmon->regs + PROM21_XHCI_INDEX_OFFSET); + /* Select the PROM21 temperature register through the vendor index. */ + writel(PROM21_XHCI_TEMP_SELECTOR, + hwmon->regs + PROM21_XHCI_INDEX_OFFSET); + /* Use a 32-bit read for PCI MMIO register access. */ + data =3D readl(hwmon->regs + PROM21_XHCI_DATA_OFFSET) & 0xff; + /* Restore the previous vendor index register value. */ + writel(index, hwmon->regs + PROM21_XHCI_INDEX_OFFSET); + readl(hwmon->regs + PROM21_XHCI_INDEX_OFFSET); + + /* + * Drop the usage reference taken by prom21_xhci_pm_get(). This is + * enough because the read path never resumes the device; use the normal + * put path so the PM core can re-evaluate idle state after the read. + * Otherwise, a racing xHCI autosuspend attempt can see a nonzero + * runtime PM usage count and skip autosuspend, and a later + * pm_runtime_put_noidle(), which does not check for an idle device, + * would leave the device active. + */ + pm_runtime_put(dev); + + if (!data) + return -ENODATA; + + *raw =3D data; + return 0; +} + +static long prom21_xhci_raw_to_millicelsius(u8 raw) +{ + /* + * No public AMD reference is available for this value. + * The scale was derived from observed PROM21 xHCI temperature readings: + * temp[C] =3D raw * 0.9066 - 78.624 + */ + return DIV_ROUND_CLOSEST(raw * 9066, 10) - 78624; +} + +static umode_t prom21_xhci_is_visible(const void *drvdata, + enum hwmon_sensor_types type, u32 attr, + int channel) +{ + if (type !=3D hwmon_temp) + return 0; + + switch (attr) { + case hwmon_temp_input: + return 0444; + default: + return 0; + } +} + +static int prom21_xhci_read(struct device *dev, enum hwmon_sensor_types ty= pe, + u32 attr, int channel, long *val) +{ + struct prom21_xhci *hwmon =3D dev_get_drvdata(dev); + u8 raw; + int ret; + + if (type !=3D hwmon_temp || attr !=3D hwmon_temp_input) + return -EOPNOTSUPP; + + ret =3D prom21_xhci_read_temp_raw_restore_index(hwmon, &raw); + if (ret) + return ret; + + *val =3D prom21_xhci_raw_to_millicelsius(raw); + return 0; +} + +static const struct hwmon_ops prom21_xhci_ops =3D { + .is_visible =3D prom21_xhci_is_visible, + .read =3D prom21_xhci_read, +}; + +static const struct hwmon_channel_info *const prom21_xhci_info[] =3D { + HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), + NULL, +}; + +static const struct hwmon_chip_info prom21_xhci_chip_info =3D { + .ops =3D &prom21_xhci_ops, + .info =3D prom21_xhci_info, +}; + +static int prom21_xhci_probe(struct auxiliary_device *auxdev, + const struct auxiliary_device_id *id) +{ + struct device *dev =3D &auxdev->dev; + const struct prom21_xhci_pdata *pdata =3D dev_get_platdata(dev); + struct prom21_xhci *hwmon; + + if (!pdata) + return dev_err_probe(dev, -ENODEV, + "platform data unavailable\n"); + + if (!pdata->regs || + pdata->rsrc_len < PROM21_XHCI_DATA_OFFSET + sizeof(u32)) + return dev_err_probe(dev, -ENODEV, "invalid MMIO resource\n"); + + hwmon =3D devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL); + if (!hwmon) + return -ENOMEM; + + hwmon->pdev =3D pdata->pdev; + hwmon->regs =3D pdata->regs; + auxiliary_set_drvdata(auxdev, hwmon); + + /* + * Parent the hwmon device to the PCI function because the temperature + * value is read from that function's MMIO BAR, and systems may contain + * multiple PROM21 xHCI functions. This lets userspace identify the PCI + * endpoint for each reading. The auxiliary driver still owns the hwmon + * lifetime and unregisters it before HCD teardown. + */ + hwmon->hwmon_dev =3D + hwmon_device_register_with_info(&pdata->pdev->dev, "prom21_xhci", + hwmon, &prom21_xhci_chip_info, + NULL); + if (IS_ERR(hwmon->hwmon_dev)) + return PTR_ERR(hwmon->hwmon_dev); + + return 0; +} + +static void prom21_xhci_remove(struct auxiliary_device *auxdev) +{ + struct prom21_xhci *hwmon =3D auxiliary_get_drvdata(auxdev); + + /* + * The PROM21 PCI glue destroys the auxiliary device before HCD teardown. + * Unregister the hwmon device here so sysfs removes the attributes, + * stops new reads, and drains active hwmon callbacks before the xHCI + * MMIO mapping is released. + */ + hwmon_device_unregister(hwmon->hwmon_dev); +} + +static const struct auxiliary_device_id prom21_xhci_id_table[] =3D { + { .name =3D "xhci_pci_prom21.hwmon" }, + {} +}; +MODULE_DEVICE_TABLE(auxiliary, prom21_xhci_id_table); + +static struct auxiliary_driver prom21_xhci_driver =3D { + .name =3D "prom21-xhci", + .probe =3D prom21_xhci_probe, + .remove =3D prom21_xhci_remove, + .id_table =3D prom21_xhci_id_table, +}; +module_auxiliary_driver(prom21_xhci_driver); + +MODULE_AUTHOR("Jihong Min "); +MODULE_DESCRIPTION("AMD Promontory 21 xHCI temperature sensor driver"); +MODULE_LICENSE("GPL"); --=20 2.53.0