Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2559262pxb; Mon, 18 Jan 2021 23:31:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0kgWLKesCioLAF5f8md/cZddpq7VYUlNIsXvJu0c16OFMnvv3rpjkdr11kkB+fDOLLHpF X-Received: by 2002:aa7:c88a:: with SMTP id p10mr2328425eds.204.1611041482571; Mon, 18 Jan 2021 23:31:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611041482; cv=none; d=google.com; s=arc-20160816; b=oo/YXCkkLdMvQs36rebD4Xf2XQKIhpVlbbeNf/5Fb6vErhq/QvPhrx/YCYMndX3EBZ AEt0yZxGRwqHUdGQYCWmEDX+Zmc7iQkiiNf48y8pb5O9S6ETSSH8u5jRq1CpNfgKONai 0RNqb1oFVJ6frNCBwj3VarBnvsC2tVQWyfwtTrNW67LeA7zaug0bD9KqI/ltTR+mh7hb qw3jYZ+ZXiKdhbAaCvBsSWtYYD1cBvtw7HjL7Nal1ubf5gOVCrqxUc/oOlK23UM5MY6o JLOcsKlsSLy4tsWUYaQqxYe01IO2l1vyHavGSFJrwyUY456Ne2Chqn73Ct87Xap7L1tp fhxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=SGDZocYTMRwn3rHznDVoOYGXMuXKuTLqJcjZTlDcqTY=; b=IlvwH4mdOGbdkDN00hp1tZ8WEElCwEJwU7q1+3lTvMnuD1YaTjdmBc3Pzr1v++ocK6 PXo0hQxA5VLdMnM0zsj1ibWb/MnKJRMwzyoh/1T5eTJqGJbbhk3YFXkDnHgSmZ2G15dQ w2JOsk+AwL6QJDhwhJ24adHa3VwslQp8HWItWS0V1bQrLXNWFBiglom/WeF91OUcQF4b j60CRZs2ZMlqrAC62oVdtR+lUtpWNHnb7/i2Mt59j5QAaOhhAClBuAwO+80cvVbeMbXb AWHujOI7I0OyDXUfq3jiLGP29fbzPaK3+QcInbY3STYaFQwmE4DT+MXLZlOGFO8hrG+V v4JQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f26si8678609edq.200.2021.01.18.23.30.57; Mon, 18 Jan 2021 23:31:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730757AbhASH3O (ORCPT + 99 others); Tue, 19 Jan 2021 02:29:14 -0500 Received: from mail-lf1-f41.google.com ([209.85.167.41]:45346 "EHLO mail-lf1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726134AbhASH1Z (ORCPT ); Tue, 19 Jan 2021 02:27:25 -0500 Received: by mail-lf1-f41.google.com with SMTP id q12so636943lfo.12 for ; Mon, 18 Jan 2021 23:27:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SGDZocYTMRwn3rHznDVoOYGXMuXKuTLqJcjZTlDcqTY=; b=jullFCgGvUDSuFT8BF9KL6wHEMfj1mUtUQoSkU0PXs3/i1A8itRbpmvp376T5v1c6E t7nLMVm2kFvBPAD1BVsiuXyd535nPZf2P3XN70DFwDlT7k3gUaEBIOeY4MjjRH+BVPJb 08TF8fWy2tUIY/C5ah9wCDKcOi2kOVehGMEq1W3m5MJGtRI0W4d9J8mN4YjAtA9qS0/Z Yzlp7kFjbCB2BC6wYmmNF/L81djm0CyczVjDlv/f7i+52du/GzZ0Rvx7c87SOTUgBFME Z43+knVhNrO3IETmqRUWFYYIszzjDfZf967EwqxjvNudViljefFwyTS5l91QY9MzhE/1 5/VQ== X-Gm-Message-State: AOAM532VlW1dC1GcIktozpvk+Z7RVHJtTBIhldtvnxlkim/VNvRcZl+F wq2KU/paqc8KQ1g8EL5Fur0= X-Received: by 2002:a19:c30e:: with SMTP id t14mr1226433lff.521.1611041200314; Mon, 18 Jan 2021 23:26:40 -0800 (PST) Received: from localhost.localdomain (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id i27sm2189016lfc.31.2021.01.18.23.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 23:26:39 -0800 (PST) Date: Tue, 19 Jan 2021 09:26:33 +0200 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Lee Jones , Liam Girdwood , Mark Brown , Matti Vaittinen , linux-kernel@vger.kernel.org, linux-power@fi.rohmeurope.com Subject: [PATCH v2 12/17] regulator: rohm-regulator: linear voltage support Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The helper for obtaining HW-state based DVS voltage levels currently only works for regulators using linear-ranges. Extend support to regulators with simple linear mappings and add also proper error path if pickable-ranges regulators call this. Signed-off-by: Matti Vaittinen --- Changes since v1: - moved SNVS level adding to own patch drivers/regulator/rohm-regulator.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/rohm-regulator.c b/drivers/regulator/rohm-regulator.c index 5c558b153d55..63aabb8c7786 100644 --- a/drivers/regulator/rohm-regulator.c +++ b/drivers/regulator/rohm-regulator.c @@ -22,13 +22,26 @@ static int set_dvs_level(const struct regulator_desc *desc, return ret; return 0; } - + /* If voltage is set to 0 => disable */ if (uv == 0) { if (omask) return regmap_update_bits(regmap, oreg, omask, 0); } + /* Some setups don't allow setting own voltage but do allow enabling */ + if (!mask) { + if (omask) + return regmap_update_bits(regmap, oreg, omask, omask); + + return -EINVAL; + } for (i = 0; i < desc->n_voltages; i++) { - ret = regulator_desc_list_voltage_linear_range(desc, i); + /* NOTE to next hacker - Does not support pickable ranges */ + if (desc->linear_range_selectors) + return -EINVAL; + if (desc->n_linear_ranges) + ret = regulator_desc_list_voltage_linear_range(desc, i); + else + ret = regulator_desc_list_voltage_linear(desc, i); if (ret < 0) continue; if (ret == uv) { -- 2.25.4 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]