From patchwork Thu Jul 11 16:46:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812100 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp316878wrs; Thu, 11 Jul 2024 09:49:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/xG7CIfP/dyhP46hraAf4UuRTCruGNQkUz+AlEQtYpCZWKeSw8kJh3iG4lBsCWUq/h4keFLm3CSvSuYMycOYi X-Google-Smtp-Source: AGHT+IFuWjCWL/IK7Gq0K/JVBbeCnjCmn5bFqVEIQewY2JCz3Kyi4Xzp7ZdNG2zM7YJpRlSbxGU0 X-Received: by 2002:a05:6512:3a8f:b0:52e:6d71:e8f0 with SMTP id 2adb3069b0e04-52eb99911d2mr8483266e87.8.1720716582897; Thu, 11 Jul 2024 09:49:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720716582; cv=none; d=google.com; s=arc-20160816; b=quESMDvkbAZkw7/D/M4ev7aV4lzZF11/PIBTi8CAcQMJ3Hrn4n124xqvvNqU71x7rh h1E5mM2E4+dspEvxiQ198GMRm1qPr5VrtBqJ03/ploU3SO68C9yko4NQq2QL06VtVTl/ JzI6z2w+REIhlG1qL5rWplQm7KlCXm9CpAzt3Ush16vCZo0wFU1C4T7fld3MDp6ssFhp plmQekcYUWdEV3wEVpBfJ0mZ8WDKFgomDlcTMcDm3keB615QhY/1eCmW4hVuqYd05pTw KW/k8K5QlFTYGHB9wtc9HWify2V1nA2iVH751rpuurn0T+/UgC6YP+5vrN8tKCHtp8Bd /Yuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=N9IT/zALEh7mKodPKHns820h3aA7IvXfqWmQ85Fiq50=; fh=/XivWHF+vo8fEJZkIifbJJS5exQ4Pz1Cdxakj2MFy4s=; b=XBfxfDNsOnNyCXIduJ4yVqB3jviG34Wu8zOTDY7MTdjg0egDnpxVsruVLAMbrIyh71 IcOfonqQaka3oPivsHK76+wrdffWsc6+MbRvFtM7/91iI9BZe983Tn21Lf3AbJ9t+J1I 51T4EY82DE6kEZoAvNboYD6S98K+CNMJa2sLQ9kJqciCTLkDoIoQ7ZmJVpP1Mn3BNM6O xX36ox6xw0EO5n6KbKOmFJKpcxyR5NO6+EmmjCLtipEcXLqp/t72NBV3FaqdI+EjlMdM cLY30uUrbCpkxvkrdgcFW8lF+LodD1xhSMvPdEqBistavLzX5qFeP+wNAuRGUU5qeOD+ 0wVQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WAxOGHy6; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-594be54e480si3304148a12.600.2024.07.11.09.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:49:42 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WAxOGHy6; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4F562887D6; Thu, 11 Jul 2024 18:47:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="WAxOGHy6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 199B7887C3; Thu, 11 Jul 2024 18:47:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2D72888766 for ; Thu, 11 Jul 2024 18:47:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a77c7d3e8bcso149731466b.1 for ; Thu, 11 Jul 2024 09:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720716421; x=1721321221; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=N9IT/zALEh7mKodPKHns820h3aA7IvXfqWmQ85Fiq50=; b=WAxOGHy6lExpmM5lUDjAf6B6vNUR7eqyOdkxjQDAyB8M4aZ2Tnq0jW7RHIe1SbU0vI a7KAH0rmPPdQmCFY1hU8LAzPfMQDOghcEYHKIL3sy+JPB4Zy6jNe57KqpE0eP2bCFZmo KW+XUMjB9xOz2zyOTMk6IGmtV3if0e54crXaPzp6U2ws5xQ6tkscul29aWyhZlFOBCUT GyU5HvQlD9M2UkmYu+g19ZyN6QDW4u3HPhSBnKLoakGkA/+gxZHSWFfQjYb8Ej6qoLV3 U4aL2JIE9mueMRvAavNETpNFKvrKRfhA32FwwWTXamV2ev9oa2Hd+A96IVXVKFB6f05V bBRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720716421; x=1721321221; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N9IT/zALEh7mKodPKHns820h3aA7IvXfqWmQ85Fiq50=; b=Wx4imfHQebY8BU5sWm85HBqeq1FZBrKnXeUcjsX9HwAZNLKU7vgFNa9bwchfXkr5Do YAUY7Q4wZImSl8a6yRmLAsFE/1jYJ9apEG1cxY9+vahyvxCFD5CPaqanK9PjAuSegO+6 SQ8H6Zhy3IYsk0JNUFTdkGyXWeIkmRR8BiiNNrn5DBtPC8zMCr5/vjTKLtOaZvzsVMcM 9dXGXf4XA6GPVSNqdeNtaVXUo+hac0T0jL/lC03QuohIs+EXFjD1a7amMcUMno9lr3eC NStMaist8FMpXbv91ZrCMRcsCw/pbCwqJJt8CZHoFCpyWJj+SMOmtzVJHQ6ZbzJxV4UO ctjw== X-Gm-Message-State: AOJu0YwD3xP82WteSn0dcTZWNXLL6DzlKJxRdsB1Sd12AimoTiKGqD6c LubgiW2hdVUvQjJnQJbjavpSzlMiSF52PL13R39YTd9n0WUH7MdbhRcsM/fHeKY= X-Received: by 2002:a17:907:1759:b0:a6f:4bf2:daa2 with SMTP id a640c23a62f3a-a780b68a8a3mr590279366b.15.1720716421774; Thu, 11 Jul 2024 09:47:01 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a780a8545adsm268454166b.159.2024.07.11.09.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 09:47:01 -0700 (PDT) From: Caleb Connolly Date: Thu, 11 Jul 2024 18:46:49 +0200 Subject: [PATCH v5 17/23] power: regulator: qcom-rpmh-regulator: port over lineage_range helpers MIME-Version: 1.0 Message-Id: <20240711-b4-qcom-rpmh-v5-17-fbf04ce6a7e8@linaro.org> References: <20240711-b4-qcom-rpmh-v5-0-fbf04ce6a7e8@linaro.org> In-Reply-To: <20240711-b4-qcom-rpmh-v5-0-fbf04ce6a7e8@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Jaehoon Chung Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2125; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=T2PdM3mGDz1+DKxROesAPumWj6fK3RvayA6EpoqfUCo=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmkAxvtJ4nRMschO9VOI47KFaFgoXuS5I3P+S7p AmQI5PJ6c2JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZpAMbwAKCRAFgzErGV9k tiDLD/4qWdnhqwQWYpg2jlSQb7NCCMXwEiZzYQ+WXm0kZtqcurJMTuFgXVfQ63gNjQsy5vEHB4q FnURi6baFllTntjNwEMu/+iDZui9k6RhbgvjqGsK6vwDm6uYj4rfcd1Z4O/skJ/QzYMzG85FsOJ 1LL0aivoYUplzakMbi5F0a+Lb95mIIqCJtmHgOlBYwQxpNrCURAD6+UgAEsqAT7MDrKvIs6El01 o+Jzn9yi5xXIAZ85OWenxHQG+QttBGN0M18dpFPO+6+9YYBfsBf1O10L+MWhrqdnYhsyd24nfUp 9UcqOzHWqhCQylpZXuZLyk9FtOjMGOh2s7/yJbpsbRlnF2L2enLC6U2hsKBf10HcmsPFTAN2sdA /rjgOYwrCr8eZXWmU9vHSZJB/X6COrUGi3ebWXxooZVBFnfzv1NoS15/cDWc6vWGXiXRnY/73OA MnpFrNiXcCVtJnhJPl7OIFo5a9zPKPqF/4ExYeAWMmScKcUKm+ZLSCa5Ei5cyoHs+2P7xkAmRAb aKzXefPTOjrHdFt1NX2bdA5ifh0WUkYvEauYEYiHfWga3aDKxhBRxY+OFMZ4UDmVApj7IktJFNn qPCdouFDfAegAkc4+c5bHmX6Aw5Cxd5sluaYDdlEvhid9PkyIdw9B9CcBgb2wJWe5A2lm/pzrRZ q+Rdx8lg7CcEJsg== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Import struct linear_range() and builder macro from Linux regulator core. Acked-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/power/regulator/qcom-rpmh-regulator.c | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/power/regulator/qcom-rpmh-regulator.c b/drivers/power/regulator/qcom-rpmh-regulator.c index 5f522de44734..d0acee9f558e 100644 --- a/drivers/power/regulator/qcom-rpmh-regulator.c +++ b/drivers/power/regulator/qcom-rpmh-regulator.c @@ -28,8 +28,15 @@ enum rpmh_regulator_type { VRM, XOB, }; +enum rpmh_regulator_mode { + REGULATOR_MODE_RETENTION, + REGULATOR_MODE_LPM, + REGULATOR_MODE_AUTO, + REGULATOR_MODE_HPM, +}; + #define RPMH_REGULATOR_REG_VRM_VOLTAGE 0x0 #define RPMH_REGULATOR_REG_ENABLE 0x4 #define RPMH_REGULATOR_REG_VRM_MODE 0x8 @@ -60,8 +67,38 @@ enum rpmh_regulator_type { #define PMIC5_BOB_MODE_PFM 4 #define PMIC5_BOB_MODE_AUTO 6 #define PMIC5_BOB_MODE_PWM 7 + +/** + * struct linear_range - table of selector - value pairs + * + * Define a lookup-table for range of values. Intended to help when looking + * for a register value matching certaing physical measure (like voltage). + * Usable when increment of one in register always results a constant increment + * of the physical measure (like voltage). + * + * @min: Lowest value in range + * @min_sel: Lowest selector for range + * @max_sel: Highest selector for range + * @step: Value step size + */ +struct linear_range { + unsigned int min; + unsigned int min_sel; + unsigned int max_sel; + unsigned int step; +}; + +/* Initialize struct linear_range for regulators */ +#define REGULATOR_LINEAR_RANGE(_min_uV, _min_sel, _max_sel, _step_uV) \ +{ \ + .min = _min_uV, \ + .min_sel = _min_sel, \ + .max_sel = _max_sel, \ + .step = _step_uV, \ +} + /** * struct rpmh_vreg_hw_data - RPMh regulator hardware configurations * @regulator_type: RPMh accelerator type used to manage this * regulator