From nobody Sat May 10 10:30:10 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=1610646534; cv=none; d=zohomail.com; s=zohoarc; b=d142xUiZubIUVbEDWwq0lIAHgIpx4lTgA/rYrI2yFFlUL+/0WUr2MCPHa/SXWhnVKzWwK68BmTPripr7IhKSaAKGyKz5uycsysWZbJoO6luMWUipa31X0n3P1vi6IkOJNJesKyXGJ9HV0qcJAt+6vWH/sNffaH0pyprI4Nj+SCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610646534; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Subject:To; bh=e0qzq5GFWJhIlfTRRTu2x5Ocj16Bkaz6W/a5NchpwUE=; b=K+i1THBQSngdrLi92n06Z/zgml5VLr9VNcLdM99eNkCXE4bEWC3v03Z+EkQ/MiAX8nHa79sJk7Of21fklP+OTEhUhQ+rbc8RxJfafNr8Sd4Pgn2y6gr/5djceighoHTT+dREgVkFCMYPKWbFwblIS6D1ho6g4Iux+4xljyQct4E= 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 1610646534138261.5573930384122; Thu, 14 Jan 2021 09:48:54 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728750AbhANRsj (ORCPT ); Thu, 14 Jan 2021 12:48:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726740AbhANRsi (ORCPT ); Thu, 14 Jan 2021 12:48:38 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4643CC0613D3; Thu, 14 Jan 2021 09:47:22 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id g10so5454476wmh.2; Thu, 14 Jan 2021 09:47:22 -0800 (PST) Received: from adgra-XPS-15-9570.home (2a01cb0008bd2700adae03a5d647a4d0.ipv6.abo.wanadoo.fr. [2a01:cb00:8bd:2700:adae:3a5:d647:a4d0]) by smtp.gmail.com with ESMTPSA id g18sm5120663wrw.61.2021.01.14.09.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 09:47:20 -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=e0qzq5GFWJhIlfTRRTu2x5Ocj16Bkaz6W/a5NchpwUE=; b=aw6mBerskmjus4D5dS1TmqusS5Ad5hokLJwa6BtO3TDb/F5+3XsCXBFZAjuM+DSrJL LH+iFoVnDuLnaCQdHRbCRbF3MDJXV9a4vKY3NA1PcnWtFntclU+9SgP5uqW8SCoe/E6W HciPjfYRaZtlbebMxCcueFCqECN6K9HQMiYnVuaymGMcsbofbcvMphXV5IZtTb2llha0 UXJ/LME5/iFFP61nT3Ipd8Ztrs4MzuUSGeXDY4KcnzqDufaKwNAEkMru2+4wyMttOu9m GrKTFNDUqlB2tHLNt8s9z3lpjG9iTJ6CCR7icTWw3o3hj9MnF3KPftCbVaI6DN+LLZIf W+tg== 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=e0qzq5GFWJhIlfTRRTu2x5Ocj16Bkaz6W/a5NchpwUE=; b=URtqyKaZ6zMACA85ZF2nI9ZnF5rNEgvK/ApElrl/JY0LV2awy59MC8eNbHRpyTPhgO sPaxreDRD1tiKfXF2iapN6vMTbP2qnSYWCcKt850fF0ur7FNPYN/bhR9KSg3klT0mNzq f3qHtXExcAW33yq2i92kcdwdmCtWzoFX/KbsOOflHKFbmVhQL3h8lWq5ckRdK/l4N/IZ Si5V5UUwrcsaS21RYV5XZj+3d0kbv3EeUBG6ai+g+6sDBqKwl16KnXJr4CHTCYPSWh9J nHAAehLVAwjLfKvKo6Dk18ynSlEhEoN/DBrYL7XbRi5yiIpMnFUFtVaIyEB+GqBpqVV8 VAdg== X-Gm-Message-State: AOAM530ZtfTvX75G8C/rjfBNd9EcoPLLP3hEfzJmTsc+ncNZ8pIeQNvD EI833gl0Exp795tU+w+anZw= X-Google-Smtp-Source: ABdhPJwNJV0yDU56qMZLEWWwLX84HCWerRUgnUYCDeLtI94GDJP7RO4yn7sDgWtlYb5kmy08Jel30w== X-Received: by 2002:a7b:cf30:: with SMTP id m16mr4885648wmg.145.1610646441032; Thu, 14 Jan 2021 09:47:21 -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 v5 5/6] regulator: pf8x00: use linear range for buck 1-6 Date: Thu, 14 Jan 2021 18:47:13 +0100 Message-Id: <20210114174714.122561-6-adrien.grassein@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210114174714.122561-1-adrien.grassein@gmail.com> References: <20210114174714.122561-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" Use a linear range to describe the voltages of the bucks 1-6 instead of listing it one by one (via a macro) Signed-off-by: Adrien Grassein --- drivers/regulator/pf8x00-regulator.c | 83 +++++++++++++++++----------- 1 file changed, 51 insertions(+), 32 deletions(-) diff --git a/drivers/regulator/pf8x00-regulator.c b/drivers/regulator/pf8x0= 0-regulator.c index 0c0f643b9c60..866162fddd07 100644 --- a/drivers/regulator/pf8x00-regulator.c +++ b/drivers/regulator/pf8x00-regulator.c @@ -154,35 +154,11 @@ static const unsigned int pf8x00_sw_current_table[] = =3D { 2100000, 2600000, 3000000, 4500000, }; =20 -#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) - /* Output: 0.4V to 1.8V */ -static const int pf8x00_sw1_to_6_voltages[] =3D { - SWV_LINE(0), - SWV_LINE(1), - SWV_LINE(2), - SWV_LINE(3), - SWV_LINE(4), - SWV_LINE(5), - SWV_LINE(6), - SWV_LINE(7), - SWV_LINE(8), - SWV_LINE(9), - SWV_LINE(10), - SWV_LINE(11), - SWV_LINE(12), - SWV_LINE(13), - SWV_LINE(14), - SWV_LINE(15), - SWV_LINE(16), - SWV_LINE(17), - SWV_LINE(18), - SWV_LINE(19), - SWV_LINE(20), - SWV_LINE(21), - 1500000, 1800000, +#define PF8XOO_SW1_6_VOLTAGE_NUM 0xB2 +static const struct linear_range pf8x00_sw1_to_6_voltages[] =3D { + REGULATOR_LINEAR_RANGE(400000, 0x00, 0xB0, 6250), + REGULATOR_LINEAR_RANGE(1800000, 0xB1, 0xB1, 0), }; =20 /* Output: 1.0V to 4.1V */ @@ -296,7 +272,19 @@ static const struct regulator_ops pf8x00_ldo_ops =3D { .get_voltage_sel =3D regulator_get_voltage_sel_regmap, }; =20 -static const struct regulator_ops pf8x00_buck_ops =3D { + +static const struct regulator_ops pf8x00_buck1_6_ops =3D { + .enable =3D regulator_enable_regmap, + .disable =3D regulator_disable_regmap, + .is_enabled =3D regulator_is_enabled_regmap, + .list_voltage =3D regulator_list_voltage_linear_range, + .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, +}; + +static const struct regulator_ops pf8x00_buck7_ops =3D { .enable =3D regulator_enable_regmap, .disable =3D regulator_disable_regmap, .is_enabled =3D regulator_is_enabled_regmap, @@ -345,11 +333,41 @@ static const struct regulator_ops pf8x00_vsnvs_ops = =3D { .of_match =3D _name, \ .regulators_node =3D "regulators", \ .of_parse_cb =3D pf8x00_of_parse_cb, \ - .n_voltages =3D ARRAY_SIZE(voltages), \ - .ops =3D &pf8x00_buck_ops, \ + .n_voltages =3D PF8XOO_SW1_6_VOLTAGE_NUM, \ + .ops =3D &pf8x00_buck1_6_ops, \ .type =3D REGULATOR_VOLTAGE, \ .id =3D PF8X00_BUCK ## _id, \ .owner =3D THIS_MODULE, \ + .linear_ranges =3D pf8x00_sw1_to_6_voltages, \ + .n_linear_ranges =3D \ + ARRAY_SIZE(pf8x00_sw1_to_6_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, \ + .enable_mask =3D 0x3, \ + .enable_time =3D 500, \ + }, \ + } + +#define PF8X00BUCK7(_name, base, voltages) \ + [PF8X00_BUCK7] =3D { \ + .desc =3D { \ + .name =3D _name, \ + .of_match =3D _name, \ + .regulators_node =3D "regulators", \ + .of_parse_cb =3D pf8x00_of_parse_cb, \ + .n_voltages =3D ARRAY_SIZE(voltages), \ + .ops =3D &pf8x00_buck7_ops, \ + .type =3D REGULATOR_VOLTAGE, \ + .id =3D PF8X00_BUCK7, \ + .owner =3D THIS_MODULE, \ .volt_table =3D voltages, \ .vsel_reg =3D (base) + SW_RUN_VOLT, \ .vsel_mask =3D 0xff, \ @@ -366,6 +384,7 @@ static const struct regulator_ops pf8x00_vsnvs_ops =3D { }, \ } =20 + #define PF8X00VSNVS(_name, base, voltages) \ [PF8X00_VSNVS] =3D { \ .desc =3D { \ @@ -394,7 +413,7 @@ static struct pf8x00_regulator pf8x00_regulators_data[P= F8X00_MAX_REGULATORS] =3D { PF8X00BUCK(4, "buck4", PF8X00_SW_BASE(PF8X00_BUCK4), pf8x00_sw1_to_6_volt= ages), PF8X00BUCK(5, "buck5", PF8X00_SW_BASE(PF8X00_BUCK5), pf8x00_sw1_to_6_volt= ages), PF8X00BUCK(6, "buck6", PF8X00_SW_BASE(PF8X00_BUCK6), pf8x00_sw1_to_6_volt= ages), - PF8X00BUCK(7, "buck7", PF8X00_SW_BASE(PF8X00_BUCK7), pf8x00_sw7_voltages), + PF8X00BUCK7("buck7", PF8X00_SW_BASE(PF8X00_BUCK7), pf8x00_sw7_voltages), PF8X00VSNVS("vsnvs", PF8X00_VSNVS_CONFIG1, pf8x00_vsnvs_voltages), }; =20 --=20 2.25.1