From patchwork Fri May 29 12:49:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 11578509 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B9B11744 for ; Fri, 29 May 2020 12:50:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03D802077D for ; Fri, 29 May 2020 12:50:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="tev7GWgH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726816AbgE2Mt7 (ORCPT ); Fri, 29 May 2020 08:49:59 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:54610 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727018AbgE2Mty (ORCPT ); Fri, 29 May 2020 08:49:54 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200529124952euoutp027df7dc4deb49c52fe51be5a0f68c2206~TgLFktjHV0940009400euoutp02a for ; Fri, 29 May 2020 12:49:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200529124952euoutp027df7dc4deb49c52fe51be5a0f68c2206~TgLFktjHV0940009400euoutp02a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1590756592; bh=GrxDA5iIgAOI8Alt9JYWIyF3cW/T6tYVEoUzcSu9Wto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tev7GWgHS3EGdhrO9ydDAZJJS9P8Gzbx5y1Kxy8SW/8LmyyMxIKYAYEzxRHLHbqpO 06EjMPbPMubuzVV8EK1sKFWUvqKxS9Rbh6i2S6KxXcAvXvHR4UgahTmQJVbq8YnwSF HUA/+CNRziSsuKSeblM+4SsG+ks0Q88IGSEcBx0c= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200529124952eucas1p2e2ae4295379ed6c62ddb39ebaf7d139b~TgLFOpYvt1904919049eucas1p29; Fri, 29 May 2020 12:49:52 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 54.74.60698.0F401DE5; Fri, 29 May 2020 13:49:52 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200529124952eucas1p2565c598c3c0164b5dec6ed83e19148b8~TgLE21sBi1701917019eucas1p2J; Fri, 29 May 2020 12:49:52 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200529124951eusmtrp146027ea796376930b651005eb6fd9990~TgLE2I6V61722217222eusmtrp1I; Fri, 29 May 2020 12:49:51 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-f4-5ed104f03e4f Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CB.CA.07950.FE401DE5; Fri, 29 May 2020 13:49:51 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200529124951eusmtip1002b54cd56840951beab382476cbf0bb~TgLEBYA4R1283312833eusmtip1v; Fri, 29 May 2020 12:49:51 +0000 (GMT) From: Marek Szyprowski To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Mark Brown , Dmitry Osipenko Cc: Marek Szyprowski , Liam Girdwood , Lucas Stach , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Viresh Kumar , peron.clem@gmail.com, Nishanth Menon , Stephen Boyd , Vincent Guittot , Rafael Wysocki , linux-samsung-soc@vger.kernel.org, Chanwoo Choi Subject: [PATCH 2/2] soc: samsung: Add simple voltage coupler for Exynos5800 Date: Fri, 29 May 2020 14:49:40 +0200 Message-Id: <20200529124940.10675-3-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529124940.10675-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSaUhUURjlznvz5jk1+hyFuWlkDRQkuGXBbVGyBR6l0L9ESnvpQ821eWoq BGpRNlouYbmjIqRj7kvu5ahNYjouNSopppmaSxoumKbV+Mz+nfOdc+75+LgkJq0TmpG+gSGs IpDxlxNivObtT63VIt7rbtt+X4bKU0uFKGVsgkADy1NCVPTjC0BabZkIfc4aEqDVD7EC1F+f SaClx20ApWqbBai4bUSE5ta6BOhTdj+O3nf2CdGWrhxHsW2rGCpfoc8a03XpIyK6QvWIoId1 jQSdsGlLV318iNNPqlSA1gy+EtBLFQeukG7iM16sv28Yq7BxvCH2iZkdEgWPHwzf2mzBo4Da XAlIElLHYUaJsRKISSlVAKCuIwrjyTKAGSotzpMlAFM0ZQIlMNhOjFdqRXospV4AuBB9dzeR 1TAj1AsEZQeV80pCL5hS0QBW5/RspzFqA4NNvYf02IRyhoW5i4R+D5w6DNcHcP1YQjnA6aYK wJdZwKKyN5geG1COUNenBvo3IdUtgnE1aoI3XYCDzWNCHpvAGU2ViMf7YefTeJwP3ANwrLtY xJN4APtjUncqTsPh7vXtLTDqKCytt+HHTnB2uQvjj2QIB+eN+f0NYXLN852xBMY+kPLuIzBd U7Jb29LTt2Oh4USBmL9PEoB1KZOCRGCR/r8rBwAVkLGhXIA3y9kHsnesOSaACw30tvYMCqgA fz9U55ZmpRY0/7qpBhQJ5HslZWlad6mQCeMiAtQAkpjcVHKuq9NdKvFiIiJZRZCHItSf5dTA nMTlMol93rfrUsqbCWH9WDaYVfxTBa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/sUCjctyP/qv 6Md0TF78/LDkpTW/tG7K7mxRYinOSDTUYi4qTgQAn1kQdrACAAA= X-CMS-MailID: 20200529124952eucas1p2565c598c3c0164b5dec6ed83e19148b8 X-Msg-Generator: CA X-RootMTR: 20200529124952eucas1p2565c598c3c0164b5dec6ed83e19148b8 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200529124952eucas1p2565c598c3c0164b5dec6ed83e19148b8 References: <20200529124940.10675-1-m.szyprowski@samsung.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add custom voltage regulator coupler for Exynos5800 SoCs, which require coupling between "vdd_arm" and "vdd_int" regulators. This coupler ensures that coupled regulators voltage balancing is done only when clients for each regulator (cpufreq for "vdd_arm" and devfreq for "vdd_int") apply their constraints, so the voltage values don't go beyond the bootloader-selected operation point during the boot process. This also ensures proper voltage balancing if any of those drivers is missing. Signed-off-by: Marek Szyprowski --- arch/arm/mach-exynos/Kconfig | 1 + drivers/soc/samsung/Kconfig | 3 + drivers/soc/samsung/Makefile | 1 + .../soc/samsung/exynos-regulator-coupler.c | 59 +++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 drivers/soc/samsung/exynos-regulator-coupler.c diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig index 76838255b5fa..f185cd3d4c62 100644 --- a/arch/arm/mach-exynos/Kconfig +++ b/arch/arm/mach-exynos/Kconfig @@ -118,6 +118,7 @@ config SOC_EXYNOS5800 bool "Samsung EXYNOS5800" default y depends on SOC_EXYNOS5420 + select EXYNOS_REGULATOR_COUPLER config EXYNOS_MCPM bool diff --git a/drivers/soc/samsung/Kconfig b/drivers/soc/samsung/Kconfig index c7a2003687c7..264185664594 100644 --- a/drivers/soc/samsung/Kconfig +++ b/drivers/soc/samsung/Kconfig @@ -37,4 +37,7 @@ config EXYNOS_PM_DOMAINS bool "Exynos PM domains" if COMPILE_TEST depends on PM_GENERIC_DOMAINS || COMPILE_TEST +config EXYNOS_REGULATOR_COUPLER + bool "Exynos SoC Regulator Coupler" if COMPILE_TEST + depends on ARCH_EXYNOS || COMPILE_TEST endif diff --git a/drivers/soc/samsung/Makefile b/drivers/soc/samsung/Makefile index edd1d6ea064d..ecc3a32f6406 100644 --- a/drivers/soc/samsung/Makefile +++ b/drivers/soc/samsung/Makefile @@ -9,3 +9,4 @@ obj-$(CONFIG_EXYNOS_PMU) += exynos-pmu.o obj-$(CONFIG_EXYNOS_PMU_ARM_DRIVERS) += exynos3250-pmu.o exynos4-pmu.o \ exynos5250-pmu.o exynos5420-pmu.o obj-$(CONFIG_EXYNOS_PM_DOMAINS) += pm_domains.o +obj-$(CONFIG_EXYNOS_REGULATOR_COUPLER) += exynos-regulator-coupler.o diff --git a/drivers/soc/samsung/exynos-regulator-coupler.c b/drivers/soc/samsung/exynos-regulator-coupler.c new file mode 100644 index 000000000000..54445918bd75 --- /dev/null +++ b/drivers/soc/samsung/exynos-regulator-coupler.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * http://www.samsung.com/ + * Author: Marek Szyprowski + * + * Samsung Exynos SoC voltage coupler + */ + +#include +#include +#include +#include +#include + +static int exynos_coupler_balance_voltage(struct regulator_coupler *coupler, + struct regulator_dev *rdev, + suspend_state_t state) +{ + struct coupling_desc *c_desc = &rdev->coupling_desc; + int ret, cons_uV = 0, cons_max_uV = INT_MAX; + bool skip_coupled = false; + + /* get coupled regulator constraints */ + ret = regulator_check_consumers(c_desc->coupled_rdevs[1], &cons_uV, + &cons_max_uV, state); + if (ret < 0) + return ret; + + /* skip adjusting coupled regulator if it has no constraints set yet */ + if (cons_uV == 0) + skip_coupled = true; + + return regulator_do_balance_voltage(rdev, state, skip_coupled); +} + +static int exynos_coupler_attach(struct regulator_coupler *coupler, + struct regulator_dev *rdev) +{ + if (strcmp(rdev_get_name(rdev), "vdd_arm") == 0 || + strcmp(rdev_get_name(rdev), "vdd_int") == 0) + return 0; + + return -EINVAL; +} + +static struct regulator_coupler exynos_coupler = { + .attach_regulator = exynos_coupler_attach, + .balance_voltage = exynos_coupler_balance_voltage, +}; + +static int __init exynos_coupler_init(void) +{ + if (!of_machine_is_compatible("samsung,exynos5800")) + return 0; + + return regulator_coupler_register(&exynos_coupler); +} +arch_initcall(exynos_coupler_init);