From patchwork Mon Sep 30 04:45:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13815370 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 D12FDCF6491 for ; Mon, 30 Sep 2024 04:51:35 +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:References:In-Reply-To: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:List-Owner; bh=qN+Z85uKhFcsA7I0FPVuQftO8kS+uCqLckN4FbzXu4E=; b=Rszt7ALYTg+sXoaCinNR281KSb FLM8oLSZ7xusqqB3n2fuF5pV2r2pML1hexkl6/TZvQJjwIPFxTnH19754D44uW8IfHg+19YZWQ01/ IbrSzn7fuvTkzt4BitVx0R7lBLWumbfdVitf6jSSfTTGVhEFsrA137E+LwZl1LwTgw9uzDr+D3+UT cIoOCvIqjoEiaVrPiERpXFHi00bRpETnuZuTSc11P0REeu7lKKJh90nlx1hjmzzylqojP8cJUV62H 3xQXbn6AIsHjq9SdtcDNOYNO4n0yECPgDz4AZd5y7Wkcym8SitZA6Lj7M6Dz4KZNhvaE1CsWE3K+L EUnuYOyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sv8Nb-0000000FvN2-0HKX; Mon, 30 Sep 2024 04:51:27 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sv8J1-0000000Fuk0-3tZT for linux-arm-kernel@lists.infradead.org; Mon, 30 Sep 2024 04:46:45 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-20b64584fd4so7518355ad.1 for ; Sun, 29 Sep 2024 21:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1727671603; x=1728276403; darn=lists.infradead.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=qN+Z85uKhFcsA7I0FPVuQftO8kS+uCqLckN4FbzXu4E=; b=ZIQ3SJQdJf3nb9FhRf/5YmAOg64ioDLIKOFIC54oU0xlxzSYawLW4W7VkWZKk56heU 78W7etcf+jiDN297kw+2O0d8Csn5aIyhCMBf1u2Huf0eo9OTULgr460N20fvREbPe++t ak+y8XYyD1i2T6v9ef+4jnmlmiYIw0lt4dBCA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727671603; x=1728276403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qN+Z85uKhFcsA7I0FPVuQftO8kS+uCqLckN4FbzXu4E=; b=vFpgmk8qax1q+lUNHjjIiwEmCNOHBIkgRxiqEh+Q8ll/crNklryMc/l9mYE1lnkd5p Tw6bTeN2ZTW3bRBWOFvu7JGUVW3AL8V2nkISyvwCxJ8Iz3Rs+ZvYz4ZJFg7mr3taFnDr EsETviXaHgxdJN2Bva0i3xwdDjCb71/2hcIDvynHs1TjYkAl1munUQRsJU6tcGcvDJEA H1DxBC+q5TfZv0aZ5tF5umMDac7EEtRuUoamJ9I2yiTmkLfXKzYe733wQX8+vlHMp/n6 sIdwqUvdsg0NwZrTQUCHgWDSvYTC1vt/lM3Q47TzZH+GRP+23TBKbZPkDjSlLm0uhmZ4 3YUw== X-Forwarded-Encrypted: i=1; AJvYcCUYKbr9NP8ktMv6IsCHb/0yM1RQXD/zvzjbyb1YDNK3qUpxepg8yHKinMrKVbSZJv2iMYCKWRdP081SR8yWrrFu@lists.infradead.org X-Gm-Message-State: AOJu0YznOjE3w4N9UGvXP+dE31Ct6C2Uv8RQ4RQA27KqIXDluojZhktC jjcADFbcVloD5BUapHbXVrorFq02O6rU/XP3sgpnBSt2EzRekhuYdEEzrrwwQA== X-Google-Smtp-Source: AGHT+IHsHQaIS+I9VX9gHEq3fHW0VJ8hm8miY4PsryP7g4DCTMesviF4MlhqkaQ76u1RTM6qq7VZ2g== X-Received: by 2002:a17:903:32c7:b0:20b:6458:ec83 with SMTP id d9443c01a7336-20b6458ef88mr67264665ad.4.1727671603389; Sun, 29 Sep 2024 21:46:43 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:659b:6caf:831b:3926]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37e0d65asm46236925ad.123.2024.09.29.21.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2024 21:46:43 -0700 (PDT) From: Chen-Yu Tsai To: Ulf Hansson , Matthias Brugger , AngeloGioacchino Del Regno , Mark Brown Cc: Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Douglas Anderson , Johan Hovold , Andy Shevchenko , Pablo Sun , Macpaul Lin , Sebastian Reichel Subject: [PATCH v9 3/3] pmdomain: mediatek: Use OF-specific regulator API to get power domain supply Date: Mon, 30 Sep 2024 12:45:23 +0800 Message-ID: <20240930044525.2043884-4-wenst@chromium.org> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog In-Reply-To: <20240930044525.2043884-1-wenst@chromium.org> References: <20240930044525.2043884-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240929_214643_999585_946B6977 X-CRM114-Status: GOOD ( 19.59 ) 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 The MediaTek power domain driver contains a hack that assigns the device node of the power domain to the struct device of the power domain controller in order to use the devres regulator API. Now that there is a proper OF-specific regulator API, and even a devres version, replace the hack with proper code. This change is incompatible with incomplete device trees. Instead of assigning the dummy regulator in cases where the power domain requires a supply but the device tree does not provide one, the driver will just error out. This will be seen on the MT8390 EVK, which is missing supplies for the IMG_VCORE and CAM_VCORE domains. And likely all the MediaTek EVBs, which have no power domain supplies specified. This is however the correct behavior. If the power domain's supply is missing, then it should not work. Relying on other parts of the system to keep the unattached regulator enabled is likely to break in ways less easier to understand. Signed-off-by: Chen-Yu Tsai Reviewed-by: AngeloGioacchino Del Regno --- Changes since v7: - New patch The other option is to follow what Rockchip will be doing: getting the regulator supply upon first use / enable [1]. This will result in less breakage: only the power domain that is missing its supplies will fail to be attached. [1] https://lore.kernel.org/all/20240919091834.83572-6-sebastian.reichel@collabora.com/ --- drivers/pmdomain/mediatek/mtk-pm-domains.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/pmdomain/mediatek/mtk-pm-domains.c b/drivers/pmdomain/mediatek/mtk-pm-domains.c index 88406e9ac63c..3580913f25d3 100644 --- a/drivers/pmdomain/mediatek/mtk-pm-domains.c +++ b/drivers/pmdomain/mediatek/mtk-pm-domains.c @@ -353,7 +353,6 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys *scpsys, struct device_no { const struct scpsys_domain_data *domain_data; struct scpsys_domain *pd; - struct device_node *root_node = scpsys->dev->of_node; struct device_node *smi_node; struct property *prop; const char *clk_name; @@ -388,16 +387,7 @@ generic_pm_domain *scpsys_add_one_domain(struct scpsys *scpsys, struct device_no pd->scpsys = scpsys; if (MTK_SCPD_CAPS(pd, MTK_SCPD_DOMAIN_SUPPLY)) { - /* - * Find regulator in current power domain node. - * devm_regulator_get() finds regulator in a node and its child - * node, so set of_node to current power domain node then change - * back to original node after regulator is found for current - * power domain node. - */ - scpsys->dev->of_node = node; - pd->supply = devm_regulator_get(scpsys->dev, "domain"); - scpsys->dev->of_node = root_node; + pd->supply = devm_of_regulator_get_optional(scpsys->dev, node, "domain"); if (IS_ERR(pd->supply)) return dev_err_cast_probe(scpsys->dev, pd->supply, "%pOF: failed to get power supply.\n",