From nobody Tue Feb 10 02:30:05 2026 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 392FC1A23A1 for ; Wed, 8 Jan 2025 01:28:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736299740; cv=none; b=jBnGA6MiXB+cA8NQnpDNrCme8as7PLfkPWww8xGQ3eBNXKz86Ve4dLrvJo0WokSU9dZqKA+7+eb0pmVoBiP4ZSNx24+ceVfvqDkWcfhv7uACbVnlC9TJN5gEoZxXUiN1dZIU+Mt6R/EJ8d2ncL+4ODAbIcRn/ZEPShmyqRJQnbw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736299740; c=relaxed/simple; bh=ZPZ1RvYh2kO8gp/HE4ITCITiJwPeiYCbTgy1PyW8+MI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Px6q4ZpEqAmcvmPNBJwx2+wrcfMYQvkqj44DwR5i8fAzVuYDwa+WzkLVYLKlclxCMeDVFuOJEi/uxpx06gFlKZUll7W45vGuiqf52Z60dat/aAYjdB4+nUUg2mUEd071hGf88s2dbs3UBFHLHxfI82Vm6xa0wBYQr2SpCvnpwus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=HVHkSb7G; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="HVHkSb7G" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-21619108a6bso223784565ad.3 for ; Tue, 07 Jan 2025 17:28:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736299736; x=1736904536; 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=h2PH+YeR0bEBhGOmEQodK+uTa/B+QOdEM0hw2aypokE=; b=HVHkSb7GCWVl72WAHK0yvON8bJx6LRgWGgSl/8iNsxIFwVoUasyEFUf2PxNRDedGeQ FosZRJFn201HaCn4RV7sRL+GU9fs52Oj8Bdhpq5sjYtUFPlRcKc5JeZdPLoOM1LbICCf 94R2xCJ8OCC0qKKJ3Biu4oPr+nYQHg2AT9TOE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736299736; x=1736904536; 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=h2PH+YeR0bEBhGOmEQodK+uTa/B+QOdEM0hw2aypokE=; b=Lz9AdYIQpbni4yLXdhvBYlL15wBntQq9Euy1umx5owuJjl0a+LU+91JUp6fAtddR9v XakbAQZyOvSpgQYkgy8FVAaG6kOVa3D29bd1bJwz+nEDPCXex/B4frSk8BXuj8UhO8lS tNUZvN0fAWlFY5QhPxvVSxY3I0dCmnZWtzJw5tIg1tCgXPZTowsycFe/vOxatEUQSJND JqMsjOjY+BzEUvIzG9y8JTd7+DtUBflHSCdAVtr4b+aVB+F+ArZUh9Ty5ulodZEE6d32 yCEh/cXF0b779VJhwiGYx8XkNScR8NfkpucmMw+hEGX8xEzZ53m5S0xW2NmatuIQxbIJ wKSA== X-Gm-Message-State: AOJu0YyJaAuU9IZazgqclnAa2cVJ7gTQWakHclitwd5kWbsni0eiWOie wzZ3q/SEbcVuapsRrTF5annbZMA1Kx2x6US+wzMrOxg+529X1QQCQgg7qnEtlw== X-Gm-Gg: ASbGncvtRiMgY9wmePLd8GbEH6UcF/3cGDJeZ/CRpfbcS1A37ssG9Cjz2m3hiqxkQmm pn13a3NwQTZo3m0pSpzQ8XZqsef9C2gqYAw1xxn1u+HmTHvaCDcLrflxVniedKi3gZcsyWlE8BK k1+IGIp5SlSWfJrNFlDu42Kwndw8PSE4r7t0Wv/S8up8JuQdG29yXxMvUkLOSNVu1k7VFqKjbj7 d3zzSmg/cmJqXnR/fhtiCUlkA/RyoqmsMJWY3xzBsALmTga5Mem3/PVxAf6iAxEbng4f2TA6zyo W75DtPHnI+MlLjvSxV3E X-Google-Smtp-Source: AGHT+IEPnKUCG2gblLZlLZNHyLGaKfpBR0RoXfdx9u2gcf5pTAWqsgbyihyLPhCZcWcNvOkJsoUDRw== X-Received: by 2002:a17:903:2311:b0:215:a2e2:53ff with SMTP id d9443c01a7336-21a83f36e1dmr16501155ad.11.1736299736529; Tue, 07 Jan 2025 17:28:56 -0800 (PST) Received: from localhost (129.135.125.34.bc.googleusercontent.com. [34.125.135.129]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-219dc962cf4sm316325925ad.25.2025.01.07.17.28.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Jan 2025 17:28:56 -0800 (PST) From: Stephen Boyd To: Bjorn Andersson , Konrad Dybcio Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, devicetree@vger.kernel.org, Dmitry Baryshkov , Krzysztof Kozlowski , Rob Herring , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Arnd Bergmann , Conor Dooley , Saravana Kannan , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Subject: [RFC PATCH 5/6] bus: qcom-sc7180: Attach pm domain to watchdog device Date: Tue, 7 Jan 2025 17:28:42 -0800 Message-ID: <20250108012846.3275443-6-swboyd@chromium.org> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog In-Reply-To: <20250108012846.3275443-1-swboyd@chromium.org> References: <20250108012846.3275443-1-swboyd@chromium.org> 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" Find the watchdog device described as a child node of the sc7180 SoC node and attach a generic pm domain to the device before registering the device with the platform bus. The domain simply gets the clk and turns it on when the pm domain is powered on and turns it off when the pm domain is powered off. Cc: Rob Herring Cc: Bjorn Andersson Cc: Konrad Dybcio Cc: Signed-off-by: Stephen Boyd --- drivers/bus/qcom/qcom-sc7180.c | 122 +++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/drivers/bus/qcom/qcom-sc7180.c b/drivers/bus/qcom/qcom-sc7180.c index a615cf5a2129..7dfe6b32efef 100644 --- a/drivers/bus/qcom/qcom-sc7180.c +++ b/drivers/bus/qcom/qcom-sc7180.c @@ -3,18 +3,140 @@ * SoC bus driver for Qualcomm SC7180 SoCs */ =20 +#include +#include #include +#include #include #include #include #include #include #include +#include +#include + +struct qcom_soc_pm_domain { + struct clk *clk; + struct generic_pm_domain pd; +}; + +static struct qcom_soc_pm_domain * +gpd_to_qcom_soc_pm_domain(struct generic_pm_domain *gpd) +{ + return container_of(gpd, struct qcom_soc_pm_domain, pd); +} + +static struct qcom_soc_pm_domain *pd_to_qcom_soc_pm_domain(struct dev_pm_d= omain *pd) +{ + struct generic_pm_domain *gpd; + + gpd =3D container_of(pd, struct generic_pm_domain, domain); + + return gpd_to_qcom_soc_pm_domain(gpd); +} + +static struct qcom_soc_pm_domain *dev_to_qcom_soc_pm_domain(struct device = *dev) +{ + struct dev_pm_domain *pd; + + pd =3D dev->pm_domain; + if (!pd) + return NULL; + + return pd_to_qcom_soc_pm_domain(pd); +} + +static struct platform_device * +qcom_soc_alloc_device(struct platform_device *socdev, const char *compatib= le) +{ + struct device_node *np __free(device_node); + + np =3D of_get_compatible_child(socdev->dev.of_node, compatible); + + return of_platform_device_alloc(np, NULL, &socdev->dev); +} + +static int qcom_soc_domain_activate(struct device *dev) +{ + struct qcom_soc_pm_domain *soc_domain; + + dev_info(dev, "Activating device\n"); + soc_domain =3D dev_to_qcom_soc_pm_domain(dev); + + soc_domain->clk =3D devm_clk_get(dev, NULL); + + return PTR_ERR_OR_ZERO(soc_domain->clk); +} + +static int qcom_soc_domain_power_on(struct generic_pm_domain *domain) +{ + struct qcom_soc_pm_domain *soc_domain; + + pr_info("Powering on device\n"); + soc_domain =3D gpd_to_qcom_soc_pm_domain(domain); + + return clk_prepare_enable(soc_domain->clk); +} + +static int qcom_soc_domain_power_off(struct generic_pm_domain *domain) +{ + struct qcom_soc_pm_domain *soc_domain; + + pr_info("Powering off device\n"); + soc_domain =3D gpd_to_qcom_soc_pm_domain(domain); + + clk_disable_unprepare(soc_domain->clk); + + return 0; +} + +static int qcom_soc_add_clk_domain(struct platform_device *socdev, + struct platform_device *pdev) +{ + struct qcom_soc_pm_domain *domain; + struct generic_pm_domain *pd; + int ret; + + domain =3D devm_kzalloc(&socdev->dev, sizeof(*domain), GFP_KERNEL); + if (!domain) + return -ENOMEM; + + pd =3D &domain->pd; + pd->name =3D "wdog"; + ret =3D pm_genpd_init(pd, NULL, false); + if (ret) + return ret; + + /* TODO: Wrap this in a generic_pm_domain function similar to power_on() = */ + pd->domain.activate =3D qcom_soc_domain_activate; + pd->power_on =3D qcom_soc_domain_power_on; + pd->power_off =3D qcom_soc_domain_power_off; + + dev_info(&socdev->dev, "adding pm domain for %s\n", dev_name(&pdev->dev)); + dev_pm_domain_set(&pdev->dev, &pd->domain); + + return 0; +} =20 static int qcom_soc_sc7180_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; struct device_node *np =3D dev->of_node; + struct platform_device *sdev; + int ret; + + sdev =3D qcom_soc_alloc_device(pdev, "qcom,apss-wdt-sc7180"); + if (!sdev) + return dev_err_probe(dev, -ENODEV, "Failed to alloc sdev\n"); + + ret =3D qcom_soc_add_clk_domain(pdev, sdev); + if (ret) + return dev_err_probe(dev, ret, "Failed to add clk domain to sdev\n"); + + ret =3D of_platform_device_add(sdev); + if (ret) + return dev_err_probe(dev, ret, "Failed to add sdev to bus\n"); =20 return of_platform_populate(np, NULL, NULL, dev); } --=20 https://chromeos.dev