From nobody Sat May 10 11:30:36 2025 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610589974; cv=none; d=zohomail.com; s=zohoarc; b=S/OJJCRFvU832mDoxq1z9B4nnVg4aKQfBfZTAHXmYIUCNrHUP6/PnUPqKKYkD/YGV6PzYAktEhhgBiK8IuQb8hiUc/GG4neAjbpyEGoDso6xdqEXtvW8rjop6E82WWc0fzJ5vL87eT5yhriPUzl4ZdAR7tBs3CIyg4n4KZZNnQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610589974; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=ga6RWsMGRnOBRU223li1MY5FtCYIzdzZznWAiBLHlds=; b=b6deR5c5h86N/vJtBDgvth2KKyoVjyI0yQorA0hA89s0YyupE7vKujz9XvupzzW4FpxstwgaBKRyQ73nuWx3znlJ7/7gn9/c4xmzvohL+65EqSTynVPHvbr8FJKwirKY0dUOb5PgCNPr8hQVJNYY4yffSupPanrOmqXX/7DmX4E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1610589974240403.63047607742635; Wed, 13 Jan 2021 18:06:14 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729343AbhAMW2D (ORCPT ); Wed, 13 Jan 2021 17:28:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbhAMWVE (ORCPT ); Wed, 13 Jan 2021 17:21:04 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA03FC06179F; Wed, 13 Jan 2021 14:20:23 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id y187so3031113wmd.3; Wed, 13 Jan 2021 14:20:23 -0800 (PST) Received: from localhost.localdomain (2a01cb0008bd27000d88c7723353ad1a.ipv6.abo.wanadoo.fr. [2a01:cb00:8bd:2700:d88:c772:3353:ad1a]) by smtp.gmail.com with ESMTPSA id t1sm5594929wro.27.2021.01.13.14.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 14:20:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ga6RWsMGRnOBRU223li1MY5FtCYIzdzZznWAiBLHlds=; b=Zpi12CjpqLZABzoMsmC6r+DkHWv0xviygQSlCiD/ji3x1lBfhlzvJCMSvjBqdNPp8M Ctx4JMZExpKXPkva4YsUHZN2/whYRoTK1VmS1Q1q4X/GdprHN8w1r+cUfKzSEs9HiZPt yc+0u2oVmPb4hr+3BP8h+QQr4loJRXuQ2zQXFi3iiAW6otp1TJpynBDf/xG3SVWCbI4H pNMIQFwwdWukgGDBlcZlUjUOAJGC+lm4rZMXlbDAEj6cvzjAlUYzYdwit+xZoSgawSK7 P6fGe7Q9K63TMvZIxZUiV69BSqVZ6tifI4/TttMXECpJOQJBkR9y+WIHtiB/LJQyszW+ fW5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ga6RWsMGRnOBRU223li1MY5FtCYIzdzZznWAiBLHlds=; b=QDFR/DYn6MmQF8rWzTa4785ncxzI5U6fRnKUhlYwh96tLgQ52R+Bn/lffGzpHm+Z/m VqIY2gU1OiRX3QW0Sel16hVjgU4U1S+r0O3OYY2hm7ljJ5tnETnrzO4y7zOKaiCt0d+9 slm+RxCGJHV0C0+Z+uX/MfFzBO2YdTFYJFrSp1hJFZ8agopxtuigRNJo/OTNKjI6+6+I D8DzOAAw3g8veWqhxUqR0XdBCy7P7HLmum6VN6TqyewSGWUFzfKxzLES7gS9hkE6PhmU GcbU58WmKU2cVW12Q/Dha8En8dDqytmSoUB4y0tvlM8LjBlcIopj3Ourx/9jc2JIdVQN qZJA== X-Gm-Message-State: AOAM530SNeQvtdUde2dy6vbCrkEFKu8ZOb/KTJWDPBrcsPOAtesEJH0w xk7S4iEQkP/lUGI5pNYaKCoKIc65j+I= X-Google-Smtp-Source: ABdhPJzsYRZPxVIafNK7x1L9j61Dj9sqOobrkbxo3nsO5xzaEs0vM4CqzPVy08X64pJPSeEzvDwyfA== X-Received: by 2002:a1c:2d8a:: with SMTP id t132mr1081182wmt.119.1610576422600; Wed, 13 Jan 2021 14:20:22 -0800 (PST) From: Adrien Grassein Cc: broonie@kernel.org, jagan@amarulasolutions.com, lgirdwood@gmail.com, robh+dt@kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Adrien Grassein Subject: [PATCH v4 4/6] regulator: pf8x00: mark nxp,ilim-ma property as deprecated Date: Wed, 13 Jan 2021 23:20:14 +0100 Message-Id: <20210113222016.1915993-5-adrien.grassein@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210113222016.1915993-1-adrien.grassein@gmail.com> References: <20210113222016.1915993-1-adrien.grassein@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This property seems useless because we can use the regulator-max-microamp generic property to do the same and using generic code. As this property was already released in a kernel version, we can't remove it, just mark it as deprecated. Signed-off-by: Adrien Grassein --- drivers/regulator/pf8x00-regulator.c | 55 +++++++++++++++++++++------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/drivers/regulator/pf8x00-regulator.c b/drivers/regulator/pf8x0= 0-regulator.c index af9918cd27aa..0c0f643b9c60 100644 --- a/drivers/regulator/pf8x00-regulator.c +++ b/drivers/regulator/pf8x00-regulator.c @@ -128,7 +128,6 @@ enum pf8x00_devid { =20 struct pf8x00_regulator { struct regulator_desc desc; - u8 ilim; u8 phase_shift; }; =20 @@ -150,6 +149,11 @@ static const int pf8x00_ldo_voltages[] =3D { 3100000, 3150000, 3200000, 3300000, 3350000, 1650000, 1700000, 5000000, }; =20 +/* Output: 2.1A to 4.5A */ +static const unsigned int pf8x00_sw_current_table[] =3D { + 2100000, 2600000, 3000000, 4500000, +}; + #define SWV(i) (6250 * i + 400000) #define SWV_LINE(i) SWV(i*8+0), SWV(i*8+1), SWV(i*8+2), SWV(i*8+3), \ SWV(i*8+4), SWV(i*8+5), SWV(i*8+6), SWV(i*8+7) @@ -199,10 +203,10 @@ static struct pf8x00_regulator *desc_to_regulator(con= st struct regulator_desc *d return container_of(desc, struct pf8x00_regulator, desc); } =20 -static void swxilim_select(const struct regulator_desc *desc, int ilim) +static void swxilim_select(struct pf8x00_chip *chip, int id, int ilim) { - struct pf8x00_regulator *data =3D desc_to_regulator(desc); u8 ilim_sel; + u8 reg =3D PF8X00_SW_BASE(id) + SW_CONFIG2; =20 switch (ilim) { case 2100: @@ -222,7 +226,32 @@ static void swxilim_select(const struct regulator_desc= *desc, int ilim) break; } =20 - data->ilim =3D ilim_sel; + regmap_update_bits(chip->regmap, reg, + PF8X00_SWXILIM_MASK, + ilim_sel << PF8X00_SWXILIM_SHIFT); +} + +static void handle_ilim_property(struct device_node *np, + const struct regulator_desc *desc, + struct regulator_config *config) +{ + struct pf8x00_chip *chip =3D config->driver_data; + int ret; + int val; + + if ((desc->id >=3D PF8X00_BUCK1) && (desc->id <=3D PF8X00_BUCK7)) { + ret =3D of_property_read_u32(np, "nxp,ilim-ma", &val); + if (ret) { + dev_dbg(chip->dev, "unspecified ilim for BUCK%d, use value stored in OT= P\n", + desc->id - PF8X00_LDO4); + return; + } + + dev_warn(chip->dev, "nxp,ilim-ma is deprecated, please use regulator-max= -microamp\n"); + swxilim_select(chip, desc->id, val); + + } else + dev_warn(chip->dev, "nxp,ilim-ma used with incorrect regulator (%d)\n", = desc->id); } =20 static int pf8x00_of_parse_cb(struct device_node *np, @@ -235,12 +264,7 @@ static int pf8x00_of_parse_cb(struct device_node *np, int val; int ret; =20 - ret =3D of_property_read_u32(np, "nxp,ilim-ma", &val); - if (ret) - dev_dbg(chip->dev, "unspecified ilim for BUCK%d, use 2100 mA\n", - desc->id - PF8X00_LDO4); - - swxilim_select(desc, val); + handle_ilim_property(np, desc, config); =20 ret =3D of_property_read_u32(np, "nxp,phase-shift", &val); if (ret) { @@ -279,6 +303,8 @@ static const struct regulator_ops pf8x00_buck_ops =3D { .list_voltage =3D regulator_list_voltage_table, .set_voltage_sel =3D regulator_set_voltage_sel_regmap, .get_voltage_sel =3D regulator_get_voltage_sel_regmap, + .get_current_limit =3D regulator_get_current_limit_regmap, + .set_current_limit =3D regulator_set_current_limit_regmap, }; =20 static const struct regulator_ops pf8x00_vsnvs_ops =3D { @@ -327,6 +353,11 @@ static const struct regulator_ops pf8x00_vsnvs_ops =3D= { .volt_table =3D voltages, \ .vsel_reg =3D (base) + SW_RUN_VOLT, \ .vsel_mask =3D 0xff, \ + .curr_table =3D pf8x00_sw_current_table, \ + .n_current_limits =3D \ + ARRAY_SIZE(pf8x00_sw_current_table), \ + .csel_reg =3D (base) + SW_CONFIG2, \ + .csel_mask =3D PF8X00_SWXILIM_MASK, \ .enable_reg =3D (base) + SW_MODE1, \ .enable_val =3D 0x3, \ .disable_val =3D 0x0, \ @@ -458,10 +489,6 @@ static int pf8x00_i2c_probe(struct i2c_client *client) regmap_update_bits(chip->regmap, reg, PF8X00_SWXPHASE_MASK, data->phase_shift); - - regmap_update_bits(chip->regmap, reg, - PF8X00_SWXILIM_MASK, - data->ilim << PF8X00_SWXILIM_SHIFT); } } =20 --=20 2.25.1