From patchwork Thu Jun 20 11:24:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 13705156 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 398B7C27C79 for ; Thu, 20 Jun 2024 11:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=gCJG0Ja4O3W5+n0BOGZ+62h9PoJVQnw5m6Ruy1ZerC8=; b=D49if0mWKU/N5O3/4hmKF2yPNn wmruH9DSv5ihqpj+sGRvFLqQOa5pc0XnQQ/a/fYyIQJl8DxjAzcGyJyIq1qdrjBl+w0CtKGTvr6hV 8frhdNQOO2VLTqMoi+GcU7EIzQVJaJJOlNFNPYIxFv7wssoT8TD0xEZ0P6IWMzlarTOx4AoYu5Q9K uvFRzCfmhnNp6+Cfwz42HQJiT63HvtxYMPYGYMh6lSv+UJZEuTK6SMVRh1ujkfCUPFrJeIFEQV6Ma vcRRXXRl5+s3R4HXHtPEFpMK6s4OR0e7ZEx/ZZvAU0tZkb/lxmUrTWAvrLwygq77Wit0L6sYPZxU4 iT1+Ztqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKFuR-00000004k6J-1gZE; Thu, 20 Jun 2024 11:24:55 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKFuO-00000004k4T-1iat for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2024 11:24:54 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2ebe3bac6c6so8858621fa.1 for ; Thu, 20 Jun 2024 04:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718882690; x=1719487490; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gCJG0Ja4O3W5+n0BOGZ+62h9PoJVQnw5m6Ruy1ZerC8=; b=LGlnPdUGuq7PojmOhCXRQ7GtQDaX+cVtapYFoGkq2BHqYtQ1sQUjhmjIy7/KU/ruKJ Rn4+/GTUdDlDU2E4PS7B7li0sqki/iUEkUCYwf8U+flhltspqprNHUetxtz1NmJsCk4K Nm+NM/sTr+v7vJGZosUVAXoZRlX2DPZqc648wI0rgTI64zpOSQrWzObTuVrl7YXfdNNG rHApAux0JiBzTMLQeYBkJpL3tAZ+l2cRd/08/qX8o2tdyETa9UiR1l7uefh5ySG3B3Mj mqHQMEQUc05uSGPOuOGd7up8Sk034Y/syD+ZS1B9QnnlSWMwLedbDaIMJ3ltkZm4tDDD Q+pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718882690; x=1719487490; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gCJG0Ja4O3W5+n0BOGZ+62h9PoJVQnw5m6Ruy1ZerC8=; b=esg34qtcUYHnFWtm9OJLq8XFk7SiZcQGnKYgmW0UjWiw3wjJURaEScxXlDoMnPwBlB XlKk1jGFMnljNJA6QxVBzf/YrFAbpc5E6C+tHEAOCmYUk0tXz66irf2lHlfZ8+dzJJcU UkpQjCs7jbYZP9LgJaR1NUDM7G6eSa32nhIDugPnzF81xeedOo/zhJMDat0K8sZ9vu9C T8Mzsg6XAHNCs3XNR4FgFzcSPtt/Wk1tMuCf+U6YZb1muUFcrTRmJ13vEQDeDdnQ/S8B dUp0fPuwn44YqkO2UzS88tXw/xQnyPVEn9OGn3jO/jLFC05HAVZHFjaldvMo8/LokwuK RSuA== X-Gm-Message-State: AOJu0YwWVn5cEKbVL9ktJExzXnkPIn3HdK/g+moAgLB3maI0ofT5ZVIa gmpuyE87w0n2/Q8ajYWgNddaUNMrS4tzZiGY7krWWRlsAOncOztUZnlVjpx+yy8= X-Google-Smtp-Source: AGHT+IFa6EadGkjUelwniOpcoV8wjGzlajwf0CUb0A6oVYtvqsnZs3ZgSbMRkdrUCg8xWmBN7N855g== X-Received: by 2002:a05:651c:20f:b0:2eb:f6bd:e4ec with SMTP id 38308e7fff4ca-2ec3cea1b44mr37772661fa.24.1718882689841; Thu, 20 Jun 2024 04:24:49 -0700 (PDT) Received: from gpeter-l.lan ([2a0d:3344:2e8:8510::3aa]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3647bf3092csm2025371f8f.97.2024.06.20.04.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 04:24:49 -0700 (PDT) From: Peter Griffin To: lee@kernel.org, arnd@arndb.de, krzk@kernel.org, alim.akhtar@samsung.com Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, tudor.ambarus@linaro.org, andre.draszik@linaro.org, saravanak@google.com, willmcvicker@google.com, semen.protsenko@linaro.org, kernel-team@android.com, Peter Griffin Subject: [PATCH v2 0/2] Add syscon of_syscon_register_regmap api Date: Thu, 20 Jun 2024 12:24:44 +0100 Message-ID: <20240620112446.1286223-1-peter.griffin@linaro.org> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240620_042452_530514_BDAC0420 X-CRM114-Status: GOOD ( 20.28 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Lee, Arnd, Krzysztof, all, This series adds support to syscon driver for a new of_syscon_register_regmap() api. Platforms such as gs101 require a special regmap to access PMU registers, which in the existing upstream client drivers are accessed via syscon regmap. This issue was partly solved in [1] whereby a custom regmap is created in exynos-pmu and a new API exynos_get_pmu_regmap_by_phandle() created. One issue with the approach in [1] is that it required client drivers to be updated from syscon_regmap_lookup_by_phandle() to exynos_get_pmu_regmap_by_phandle() when obtaining the regmap. Whilst updating to exynos_get_pmu_regmap_by_phandle() was OK for exynos specific drivers, it meant other drivers like syscon-reboot and syscon-poweroff which span multiple SoC architectures could not be easily re-used. In previous review feedback for USB phy and gs101 poweroff driver Krzysztof requested [2] that we take a more generic approach that other SoCs can also leverage. The new of_syscon_register_regmap() api overcomes this limitation by allowing a SoC driver like exynos-pmu to register it's SoC specific regmap with the syscon driver. This keeps the SoC complexity out of syscon driver, and allows client drivers to continue using syscon_regmap_lookup_by_phandle() as before. The solution allows more code re-use and can be used by other SoC archs. Notes on probe ordering exynos-pmu runs at postcore_initcall, so all but one of the client drivers (ufs phy, usb phy, watchdog) run after the regmap is created and registered. The one exception to this is pinctrl-samsung driver which is also postcore_initcall level. The exynos_get_pmu_regmap() and exynos_get_pmu_regmap_by_phandle() have been temporarily left to support -EPROBE_DEFER for pinctrl-samsung driver. The longer term plan to solve that probe ordering issue is to enable fw_devlink for syscon dt properties so they are correctly listed as suppliers in /sys/class/devlink. I tested a PoC patch (see below) for fw_devlink and that seemed to work fine. Once fw_devlink supports syscon I believe exynos_get_pmu_regmap_by_phandle() api could be removed. The main issue currently with fw_devlink syscon support is the wide diversity of dt property naming currently in use. That was discussed previously here [3] 1248a1256,1257 > DEFINE_SUFFIX_PROP(syscon_phandle, "syscon-phandle", NULL) > DEFINE_SUFFIX_PROP(pmu_syscon, "pmu-syscon", NULL) 1358a1368,1369 > { .parse_prop = parse_syscon_phandle, }, > { .parse_prop = parse_pmu_syscon, }, Note one previous concern from Saravana about syscon potentially probing before exynos-pmu driver and it relying on drivers/Makefile ordering. I tested this and even if mfd is listed before soc in drivers/Makefile exynos-pmu always probes first due to syscon driver not setting a .of_match_table entry. Once the syscon and exynos-pmu patchs are queued I will send patches for watchdog and ufs phy drivers to switch back to syscon_regmap_lookup_by_phandle() Many thanks, Peter. [1] https://lore.kernel.org/linux-arm-kernel/20240219204238.356942-1-peter.griffin@linaro.org/T/ [2] https://lore.kernel.org/lkml/06383015-51b2-4f4c-9fd8-e4f7ce12f44e@kernel.org/ [3] https://lore.kernel.org/all/CAGETcx-CCpaV7R0O0HpDpoX6KxQBuJiMmKdWA8nDE-5Qj2Sa7g@mail.gmail.com/ Changes since v1: - Collect by tags - Keep syscon lock held for check and adding entry (Krzysztof) - pass pmu_np not np to syscon_node_to_regmap() (William) Link to v1: - https://lore.kernel.org/linux-arm-kernel/20240614140421.3172674-1-peter.griffin@linaro.org/ Peter Griffin (2): mfd: syscon: add of_syscon_register_regmap() API soc: samsung: exynos-pmu: update to use of_syscon_register_regmap() drivers/mfd/syscon.c | 54 ++++++++++++++++++++++++++++++++ drivers/soc/samsung/exynos-pmu.c | 38 +++++++++------------- include/linux/mfd/syscon.h | 8 +++++ 3 files changed, 76 insertions(+), 24 deletions(-)