From patchwork Tue Jan 29 19:54:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Otavio Salvador X-Patchwork-Id: 1032986 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ossystems.com.br Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jl7Y8WIT"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43pxzZ3gYgz9s9G for ; Wed, 30 Jan 2019 06:54:46 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=oyDQiOR7z0b5R9HaaPEkw4lMn3eGoazKznLfnwiwScs=; b=jl7Y8WITRlhWOC JVjNICl/JqS+dZY5G4FoqjhcADABrpnHgBnMn7ZpTVQZfPU/+oYPRdL0QatSSBOz9E4xFJn8WDX5e KTpDzxmIcY7o0BwLaWJocK6p9UVLiaFfR4GcYqnEei5d/+Kw0X1ckjDbzP1F9H+L/fvjqBbM0mWA0 QLheG/H6WzPlJBX7hXjxvNLjvwUGTaHbricb9PEkpe34d3tmfuCawZ1dnc1gtuidqoMq9tVZuOCV4 bK5Cfsw7w5B6Y3ekW+wh7IiRniclDEy6w5jWumsCP2Uuv9EIICir7RnPqSQmF3a/AC0wfLDXT/ngo fVH9w2SVontt37IxYwLw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1goZSy-00083h-Hy; Tue, 29 Jan 2019 19:54:40 +0000 Received: from mail-qt1-f195.google.com ([209.85.160.195]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1goZSu-00083J-Dd for linux-arm-kernel@lists.infradead.org; Tue, 29 Jan 2019 19:54:38 +0000 Received: by mail-qt1-f195.google.com with SMTP id r14so23758745qtp.1 for ; Tue, 29 Jan 2019 11:54:35 -0800 (PST) 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:mime-version :organization:content-transfer-encoding; bh=EioVinHT2X6yqjwgWHj6uKTZ7lv2NlLmkKjuJFYrDpk=; b=ovW8hKfZtKA1fZZJBuk0a15Ruup9hRAPxlwV+rT96lye36X1Op8HpnqdPtK7wrfhUv 63+L7voleAa1NXgTg94sijeBBPyU4Y3MXQBgi3lhfznzN/f/ahIoi7v2LH1WA+KlN2/t o68CXswRr2EN7fNZyK1xSyq616TAqFg+/UIC33YFd95Np0moTSbdlngyLSNES/OX1ukT UN392oxhcAN0ZVqyX73hC+Ptw7hwH5gmHPLNj3/oqnp7xraA/YnKn6bKOYiCc6eYIUFX CE88MrmJeGAHiupB9zxEyoGBLs96BmJziBI7kcau5NlO16VFeM9hjgePi9IkjyQQ7qm1 F7Qw== X-Gm-Message-State: AJcUukeERBaEacfcavPzRXNkE9BPT9neVtydFyseQCh9bVvrY4KXfTtL zKMuNDyXMIjpe+icgmNgq5DFoIqG X-Google-Smtp-Source: ALg8bN5sTmRmSJKe/pdaO3EBrE0tcG1zl6fJwd5HndR5E3KyLKn0qIrg6Qs3vcLOuvSsjCCFvyC9lQ== X-Received: by 2002:ac8:270d:: with SMTP id g13mr27836759qtg.168.1548791674554; Tue, 29 Jan 2019 11:54:34 -0800 (PST) Received: from localhost.localdomain ([181.220.86.121]) by smtp.gmail.com with ESMTPSA id k62sm66134794qte.86.2019.01.29.11.54.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 11:54:33 -0800 (PST) Received: by localhost.localdomain (sSMTP sendmail emulation); Tue, 29 Jan 2019 17:54:27 -0200 From: Otavio Salvador To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/4] regulator: rk808: Fix BUCK1/2 voltages on rk805 Date: Tue, 29 Jan 2019 17:54:21 -0200 Message-Id: <20190129195424.10161-1-otavio@ossystems.com.br> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Organization: O.S. Systems Software LTDA. X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190129_115436_460298_40468273 X-CRM114-Status: GOOD ( 14.63 ) X-Spam-Score: 0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.160.195 listed in wl.mailspike.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (otavio.salvador[at]gmail.com) 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.160.195 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Zhu , Otavio Salvador , Mark Brown , Liam Girdwood , linux-kernel@vger.kernel.org, Tony Xie , Vicent Chi , Andy Yan , Philipp Tomsic Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org RK805 has the following voltage range for the BUCK1 and BUCK2 regulators: From 0.7125V to 1.45V in 12.5mV steps, 1.8V, 2V, 2.2V and 2.3V , which corresponds to the following values as per the RK805 datasheet: 000 000: 0.7125V 000 001: 0.725V …… 111 011: 1.45V 111 100: 1.8V 111 101: 2.0V 111 110: 2.2V 111 111: 2.3V This means that the voltage range is not linear and so RK805 can not reuse the same regulator_ops structure from RK808. Fix it by creating a list with the correct supported voltage values for RK805 BUCK1 and BUCK2 regulators. Tested on a rv1108-elgin-r1 board that now correctly reports a BUCK2 voltage of 2.2V instead of the unsupported value of 1.4875V. Signed-off-by: Otavio Salvador --- drivers/regulator/rk808-regulator.c | 53 ++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index 213b68743cc8..1463c65c85db 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c @@ -289,6 +289,21 @@ static int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) RK808_RAMP_RATE_MASK, ramp_value); } +static int rk805_set_suspend_voltage(struct regulator_dev *rdev, int uv) +{ + unsigned int reg; + int sel = regulator_map_voltage_ascend(rdev, uv, uv); + + if (sel < 0) + return -EINVAL; + + reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET; + + return regmap_update_bits(rdev->regmap, reg, + rdev->desc->vsel_mask, + sel); +} + static int rk808_set_suspend_voltage(struct regulator_dev *rdev, int uv) { unsigned int reg; @@ -376,6 +391,19 @@ static struct regulator_ops rk805_reg_ops = { .set_suspend_disable = rk805_set_suspend_disable, }; +static struct regulator_ops rk805_buck1_2_ops = { + .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, + .set_suspend_voltage = rk805_set_suspend_voltage, + .set_suspend_enable = rk805_set_suspend_enable, + .set_suspend_disable = rk805_set_suspend_disable, +}; + static struct regulator_ops rk805_switch_ops = { .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, @@ -433,6 +461,17 @@ static struct regulator_ops rk808_switch_ops = { .set_suspend_disable = rk808_set_suspend_disable, }; +static const int rk805_buck_1_2_voltages[] = { + 712500, 725000, 737500, 750000, 762500, 775000, 787500, 800000, + 812500, 825000, 837500, 850000, 862500, 875000, 887500, 900000, + 912500, 925000, 937500, 950000, 962500, 975000, 987500, 1000000, + 1012500, 1025000, 1037500, 1050000, 1062500, 1075000, 1087500, 1100000, + 1112500, 1125000, 1137500, 1150000, 1162500, 1175000, 1187500, 1200000, + 1212500, 1225000, 1237500, 1250000, 1262500, 1275000, 1287500, 1300000, + 1312500, 1325000, 1337500, 1350000, 1362500, 1375000, 1387500, 1400000, + 1412500, 1425000, 1437500, 1450000, 1800000, 2000000, 2200000, 2300000, +}; + static const struct regulator_desc rk805_reg[] = { { .name = "DCDC_REG1", @@ -440,11 +479,10 @@ static const struct regulator_desc rk805_reg[] = { .of_match = of_match_ptr("DCDC_REG1"), .regulators_node = of_match_ptr("regulators"), .id = RK805_ID_DCDC1, - .ops = &rk805_reg_ops, + .ops = &rk805_buck1_2_ops, .type = REGULATOR_VOLTAGE, - .min_uV = 712500, - .uV_step = 12500, - .n_voltages = 64, + .n_voltages = ARRAY_SIZE(rk805_buck_1_2_voltages), + .volt_table = rk805_buck_1_2_voltages, .vsel_reg = RK805_BUCK1_ON_VSEL_REG, .vsel_mask = RK818_BUCK_VSEL_MASK, .enable_reg = RK805_DCDC_EN_REG, @@ -456,11 +494,10 @@ static const struct regulator_desc rk805_reg[] = { .of_match = of_match_ptr("DCDC_REG2"), .regulators_node = of_match_ptr("regulators"), .id = RK805_ID_DCDC2, - .ops = &rk805_reg_ops, + .ops = &rk805_buck1_2_ops, .type = REGULATOR_VOLTAGE, - .min_uV = 712500, - .uV_step = 12500, - .n_voltages = 64, + .n_voltages = ARRAY_SIZE(rk805_buck_1_2_voltages), + .volt_table = rk805_buck_1_2_voltages, .vsel_reg = RK805_BUCK2_ON_VSEL_REG, .vsel_mask = RK818_BUCK_VSEL_MASK, .enable_reg = RK805_DCDC_EN_REG,