From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 46375433027 for ; Mon, 27 Jul 2026 18:25:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785176734; cv=none; b=Qn4FdwkxrUnmghAPsepvGPE3qU/GBXBkki4pcELVqbuMiK1l0/sg2Y/SCYxJ6G+hQgk2jqi7K0DrvG+mD/GBggoUneBe6vnkE4ZCCJB/eVIx+1HgdwVf0u0kxQRxtxprJWK/dZZMRJHb6dfldXSghwPlRlZQh7IsMU9vG9/76yM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785176734; c=relaxed/simple; bh=Z0YfX8jUsZUimRbbgNY9xw3prHCkWNC3qnu0Cc2fWXk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GfDq4BN44TM/VpZVpzbh5U9kMQMvaOVD2iIt9U4bXc5v5mI+Bd8hZ++Mf9yi9Kp5V9dAISWWIbm8a2y1S9uUzwJeVKnRE70p3N5/8IyHTgJr55g+2XmedmJwSijz0dP25Yz2bUAYQZCSBlGkMNPTRXAcAL0LwJbarP0bP7kEpxs= 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=K8JOA3Ut; arc=none smtp.client-ip=209.85.128.44 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="K8JOA3Ut" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4921eed3fa2so21065775e9.0 for ; Mon, 27 Jul 2026 11:25:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785176730; x=1785781530; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6MdKCtNkfinKWmrbT0g6/abtf3hr1i4RMWD/kXN9ElM=; b=K8JOA3UtuFz7wmY2QFY1LBuMBmeyqP9OmiCtx4j43oMi1Bv+XeYGVa2Ev/587/l//v 2uoGSszh11mermIhdypoJzrn7pLlIHidDZZHmLlwpDTwAOd7c2ErpvPjwiWeNKpSfUiU ceKOnIN7hmHD8Jbg31w0LndBuKQlAq/NwxITHrOhUn2eY8IEEP46h6f0LPIKKNSe5Ok7 vUj8RXNYsYN6URnK7OLO/mcH54JP/m8TJzvPrVMIwPS+Cph3RH4AdXopobYpJqOOhIdc yNQjoOqlZbBZvJdOHIHZSbpwVxNPALo7eP86QqaxOnJwYH572CbEHXIHHaTj+OTahY42 TaCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785176730; x=1785781530; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=6MdKCtNkfinKWmrbT0g6/abtf3hr1i4RMWD/kXN9ElM=; b=rNTvwz/pkwlsND8l3L/qzXZiXFc1NRTnrEB5XrgqzSoezyjvkOY0j9iXQLtcrQQYeZ usLyljoRtBKn30OMJrX4XlhTUbPGGxdDxYL1zGHDdOauBs1FKOmM2WY1WJcU3DTkUyxW V380bBONGqJEeURMiY/CrMfFGjIvntQBcILer45R9zuwGBFB2YOs49R6vCV4qHhlSj42 ZoE/UWzX9xq/hCK33XnmlpCf71LCllnaHADGm/RzbRHv7wKyaatJsg20shdpQ9ROg9Yr evy2n8UT5MYPKF1IwLyI5UdzgMkjzffNTNq1ayboIIDugmsVJgidQ130HUhFAIhVsEv4 OjKg== X-Forwarded-Encrypted: i=1; AHgh+RpVjIohbgbGRREEQXBx4NBZPdYbUVraWPw4cBDOKqf544IuGxmUX2Jx5goKfqyNqwnP71YEGyaPRsDnFhI=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4Ff2XEjMfkAorB9ju7daOdg+kNiBbgGX/0kBtmanwZvlTmj50 a6ERMvDCfvSJA7gyQrzvVb+zbbPrKnQK/Y6lJRB/asuZhWxXuGdb3rvQ X-Gm-Gg: AR+sD12hDuL5nAhCHW/BPDHcJkAL4YbfU9W2U3j/WxLKORV36dxVmWokpSauK9ih378 f5V+xx5FQIsiLAtHn3Ym1CSFXZTvXd8N3U/TVrAaRZCxgQBPbIk5fI+bzz5Vrb/s7eQqKZRwDdd CNIzrIG+aoR3SyK3gCQqYgUW5NVdjS9ZMVKaYNBKE2zkdev3Qd9LmEri/NuSikjDHXqOqsPSt9j JCJAR17naFHG6pN6f5jrxPqem4BuXOgbdkpFbg71XiYceVnf/nglOTrqK/I9xsnWKoMfw95GZH5 aW+udlmEudP6PuAeuR415aBzBGF+jGWT5wahLC891vc2H56EfNQHlLW7SR8a5v9m7kh7cBkBr18 BbUSMibcu7l6D4kgj/FJpUcaNESF28qqQcAJTKTgzIoJaKSFDaGwNSOiJJjd9TPAcY6U7qzXSX8 HFcURCrdXTreo/zVsRUka8kNk= X-Received: by 2002:a05:600d:6405:10b0:495:518a:d95a with SMTP id 5b1f17b1804b1-496c4fd961bmr1777965e9.29.1785176730336; Mon, 27 Jul 2026 11:25:30 -0700 (PDT) Received: from [192.168.0.2] ([197.250.51.166]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f85c53052sm50689288f8f.18.2026.07.27.11.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2026 11:25:29 -0700 (PDT) From: =?utf-8?q?Stefan_D=C3=B6singer?= Date: Mon, 27 Jul 2026 21:24:19 +0300 Subject: [PATCH v8 04/12] mfd: zx297520v3: Add a clock and reset MFD driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260727-zx29clk-v8-4-7a107b00f1dd@gmail.com> References: <20260727-zx29clk-v8-0-7a107b00f1dd@gmail.com> In-Reply-To: <20260727-zx29clk-v8-0-7a107b00f1dd@gmail.com> To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Brian Masney , Vinod Koul , Neil Armstrong , Russell King , Lee Jones Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-phy@lists.infradead.org, mfd@lists.linux.dev, =?utf-8?q?Stefan_D=C3=B6singer?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=7335; i=stefandoesinger@gmail.com; h=from:subject:message-id; bh=Z0YfX8jUsZUimRbbgNY9xw3prHCkWNC3qnu0Cc2fWXk=; b=owEBiQJ2/ZANAwAIAT0TvMhUTxoiAcsmYgBqZ6J6GBIxStOP2KyOvFMZI3ZqqqrsPUzMx3rxf SkqpfwB9OKJAk8EAAEIADkWIQRDFvS2qgVbJ5UyXWw9E7zIVE8aIgUCameiehsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMiwyLDIACgkQPRO8yFRPGiL6Rg/9HKudFEBi38W18LPvABhw8mKMW7IIpAl 0ILwg2qJQNrPOUHvHTotO9J0d73FuEL24iLg0pjmdx2nqQl4IMHfJkD5rwIwYP2OnL4X7J5s7DU E/0w72F4KOIHa2jvq5C+zgscFuOmvPGExZScfzTllSdBttx6LNnOtQaeBrXysVah9xEYy2ziNI8 vcLk5b5dkO0B/Dw+XNmT4EbzwnMW87Ifk4RmvS5y4ZWNg39liSUlUF+xH001Eev9MEsw1mVBD3j dJBTup4bk5lSkq0cUUjUoliB2525m7vIOofytPv3Jym7NfhxC5P9iCMBgkc+PW4HWNwoMvm35xb WWWuagQV1IHkjR9DppainyzbZqw41o7M+NNX8UYlmmWVlkYWsJFFgLE+SzWc1qbJSJ6UEYnXC5h EBO0Z4XzLT6hJOoCIMpVhfZy8NEXExFX7Qji1OuTUwJHVQdxVzWE4Z9h5nvxvTXIZXdFq6bMrUA 42k+ilf4pj2GcdfmcwWf7d+5YskRoEiUDlkLCbe2wrwLOsLMbWWhmCMbrAz31ltVMugVPnTVCKx MIIB/8AbIPvVInM3i8wRn49/syaaUTW9kbLbSEAcMB+eNNpFE/JpswhjY8LsJ9JhFQtZmjDd+Yd xk4ZdLBtk50Dj3SqPj26fmXeRWT58M+faR4fg2B+p5R45FAItZX0= X-Developer-Key: i=stefandoesinger@gmail.com; a=openpgp; fpr=4F9C2C8728019633893EBBB98CB81F9A72BBA155 This driver registers child devices for the zx297520v3 clock and reset controllers. The clk-zx297520v3 and reset-zte-zx297520v3 submitted in the next patches will drive the respective functionalities. Signed-off-by: Stefan Dösinger --- What I am still unsure about: How much sense does it make to have this module-capable and able to unbind: In practice, the board doesn't work without this driver and its clock and reset children. Changes v8: *) Remove .of_compatible from PHY mfd child *) Move to drivers/mfd (Sashiko) For me either soc/zte or mfd/ is fine. Note though that this MFD parent is very specific to the zx297520v3 SoC. I don't expect this to be reused anywhere else. There are two more MFD-ish devices in there: soc_sys at 0x140000, which I plan to handle in the same driver, and an i2c PMIC, which would get its own host driver. *) Use PLATFORM_DEVID_AUTO (Sashiko). NONE was intentional as I only ever expect one instance, but I don't see any harm in doing the standard thing and use AUTO *) On the suggestion not to put the link to mfd_cells[] into match data: I see that it is spelled out in Sashiko's mfd.md, written by Lee Jones, the MFD maintainer. I would appreciate some education on the rationale behind it: Putting a pointer into the void *data is a common pattern in the kernel. I don't understand in which situation this can possibly break? Both structs are static const in the same compilation unit. data is a const void *, not a uintptr_t or kernel_ulong_t, so it seems passing a pointer is the intended use. What am I missing? Changes v7: Add phy MFD child Changes v6: Make the ZTE SoC driver section depend on HAS_IOMEM (Sashiko). The entire MFD section, which contains MFD_CORE, depends on HAS_IOMEM even with COMPILE_TEST. Add a NULL ptr check for of_device_get_match_data (Sashiko). While not uniform, rave-sp, rohm-bd9576, atc260x, da9052-i2c protect against incorrect manual attachment that way. Add lspclk here as well in an attempt to satisfy both Conor Dooley, who asks for MFD for top and matrix, and Philipp Zabel, who prefers aux but at least wants the reset driver limited to one driver type. Changes v5: Use MFD instead of Aux bus for top and matrix crm because of extra functionality: Reboot in top, hwlock in Matrix. LSP clocks stay with the aux bus and are thus not handled in this driver. The clk driver will bind directly to the lspcrm node. --- MAINTAINERS | 1 + drivers/mfd/Kconfig | 11 +++++ drivers/mfd/Makefile | 2 + drivers/mfd/zte-zx297520v3-crm.c | 98 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 05322672b9b5..b04e9d43cfb0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3883,6 +3883,7 @@ F: Documentation/devicetree/bindings/clock/zte,zx297520v3-matrixcrm.yaml F: Documentation/devicetree/bindings/clock/zte,zx297520v3-topcrm.yaml F: arch/arm/boot/dts/zte/ F: arch/arm/mach-zte/ +F: drivers/mfd/zte-zx297520v3-crm.c F: include/dt-bindings/clock/zte,zx297520v3-clk.h F: include/dt-bindings/phy/zte,zx297520v3-topcrm.h F: include/dt-bindings/reset/zte,zx297520v3-reset.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 35f6e9b76d05..c0c7e83487f4 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -2572,5 +2572,16 @@ config MFD_MAX7360 additional drivers must be enabled in order to use the functionality of the device. +config MFD_ZTE_ZX297520V3_CRM + tristate "ZTE zx297520v3 Clock and Reset Manager" + select MFD_CORE + default SOC_ZX297520V3 + help + Say yes here to enable the driver for the ZTE zx297520v3 clock and + reset manager MFD driver. This driver provides the host device for + the clock and reset drivers and is required to boot the SoC. You + will also need to enable CLK_ZTE_ZX297520V3 and RESET_ZTE_ZX297520V3 + to build the actual clock and reset child drivers. + endmenu endif diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index dd4bb7e77c33..4f6a78170ac5 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -303,3 +303,5 @@ obj-$(CONFIG_MFD_RSMU_SPI) += rsmu_spi.o rsmu_core.o obj-$(CONFIG_MFD_UPBOARD_FPGA) += upboard-fpga.o obj-$(CONFIG_MFD_LOONGSON_SE) += loongson-se.o + +obj-$(CONFIG_MFD_ZTE_ZX297520V3_CRM) += zte-zx297520v3-crm.o diff --git a/drivers/mfd/zte-zx297520v3-crm.c b/drivers/mfd/zte-zx297520v3-crm.c new file mode 100644 index 000000000000..3a4f6cd0756e --- /dev/null +++ b/drivers/mfd/zte-zx297520v3-crm.c @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2026 Stefan Dösinger + */ + +#include +#include +#include +#include +#include + +struct zx297520v3_crm_data { + const struct mfd_cell *cells; + unsigned int num_cells; +}; + +static const struct mfd_cell zx297520v3_topcrm_devs[] = { + { + .name = "zx297520v3-topclk", + }, + { + .name = "zx297520v3-topreset", + }, + { + .name = "syscon-reboot", + .of_compatible = "syscon-reboot", + }, + { + .name = "zx297520v3-usb-phy", + }, +}; + +static const struct zx297520v3_crm_data zx297520v3_topcrm_data = { + .cells = zx297520v3_topcrm_devs, + .num_cells = ARRAY_SIZE(zx297520v3_topcrm_devs), +}; + +static const struct mfd_cell zx297520v3_matrixcrm_devs[] = { + { + .name = "zx297520v3-matrixclk", + }, + { + .name = "zx297520v3-matrixreset", + }, + /* A set of hwlock controllers is found here as well, but no driver is implemented yet */ +}; + +static const struct zx297520v3_crm_data zx297520v3_matrixcrm_data = { + .cells = zx297520v3_matrixcrm_devs, + .num_cells = ARRAY_SIZE(zx297520v3_matrixcrm_devs), +}; + +static const struct mfd_cell zx297520v3_lspcrm_devs[] = { + { + .name = "zx297520v3-lspclk", + }, + { + .name = "zx297520v3-lspreset", + }, +}; + +static const struct zx297520v3_crm_data zx297520v3_lspcrm_data = { + .cells = zx297520v3_lspcrm_devs, + .num_cells = ARRAY_SIZE(zx297520v3_lspcrm_devs), +}; + +static int zx297520v3_crm_probe(struct platform_device *pdev) +{ + const struct zx297520v3_crm_data *data; + + data = of_device_get_match_data(&pdev->dev); + if (!data) + return -ENODEV; + + return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO, data->cells, + data->num_cells, NULL, 0, NULL); +} + +static const struct of_device_id of_match_zx297520v3_crm[] = { + { .compatible = "zte,zx297520v3-topcrm", .data = &zx297520v3_topcrm_data }, + { .compatible = "zte,zx297520v3-matrixcrm", .data = &zx297520v3_matrixcrm_data }, + { .compatible = "zte,zx297520v3-lspcrm", .data = &zx297520v3_lspcrm_data }, + { } +}; +MODULE_DEVICE_TABLE(of, of_match_zx297520v3_crm); + +static struct platform_driver zx297520v3_crm = { + .probe = zx297520v3_crm_probe, + .driver = { + .name = "zx297520v3-crm", + .of_match_table = of_match_zx297520v3_crm, + }, +}; +module_platform_driver(zx297520v3_crm); + +MODULE_AUTHOR("Stefan Dösinger "); +MODULE_DESCRIPTION("ZTE zx297520v3 CRM MFD host driver"); +MODULE_LICENSE("GPL"); -- 2.54.0