From patchwork Mon Mar 28 00:54:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 8677671 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 904FB9F44D for ; Mon, 28 Mar 2016 00:55:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9B07D2021B for ; Mon, 28 Mar 2016 00:55:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D2D420211 for ; Mon, 28 Mar 2016 00:55:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659AbcC1AzO (ORCPT ); Sun, 27 Mar 2016 20:55:14 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:25827 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752627AbcC1AzN (ORCPT ); Sun, 27 Mar 2016 20:55:13 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O4Q0024557WSU60@mailout2.w1.samsung.com>; Mon, 28 Mar 2016 01:55:09 +0100 (BST) X-AuditID: cbfec7f5-f792a6d000001302-71-56f880ecdd8c Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id A4.99.04866.CE088F65; Mon, 28 Mar 2016 01:55:08 +0100 (BST) Received: from localhost.localdomain ([10.113.63.52]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O4Q0085957KU110@eusync2.samsung.com>; Mon, 28 Mar 2016 01:55:08 +0100 (BST) From: Krzysztof Kozlowski To: Sangbeom Kim , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , Lee Jones , linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: linux-mmc@vger.kernel.org, Javier Martinez Canillas , Ivaylo Dimitrov , stable@vger.kernel.org Subject: [PATCH] regulator: s2mps11: Fix invalid minimal selector for buck9 supplying SD card Date: Mon, 28 Mar 2016 09:54:49 +0900 Message-id: <1459126489-18311-1-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 2.5.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKLMWRmVeSWpSXmKPExsVy+t/xK7pvGn6EGXw8q2ox9eETNoslVw6x W7x5u4bJ4vULQ4v7X48yWny70sFkcXnXHDaLI//7GS1mnN/HZHFxxRcmiwUbHzE6cHvsnHWX 3WPTqk42jzvX9rB5bOkHcvu2rGL0+LxJLoAtissmJTUnsyy1SN8ugSvj2ORdjAW3ZSom7jjO 1sDYLNHFyMkhIWAi8Wn2PFYIW0ziwr31bF2MXBxCAksZJW5tvQjl/GeUuNk/HayKTcBYYvPy JWAJEYE2JomJfQcYQRxmgdmMEldud7KAVAkLxEvM6ZgN1sEioCqxZOtJNhCbV8Bd4trkY0A2 B9A+OYkFF9InMHIvYGRYxSiaWppcUJyUnmukV5yYW1yal66XnJ+7iRESWF93MC49ZnWIUYCD UYmHN8PyR5gQa2JZcWXuIUYJDmYlEd6qNKAQb0piZVVqUX58UWlOavEhRmkOFiVx3pm73ocI CaQnlqRmp6YWpBbBZJk4OKUaGNN28c8/cjtKJWaSWLtwgQ3zhdtiU/j2JPUtWxI7Ucgi/c6K RffTFp+bbOa02TamcXNcjTaf4P9vV99ry17+tOhk44Yzp+oYPqR2/fY/a7LrvH5u7qe7k9Su JUxM+Pd02b+ofM61ize8DVwdsps51PS+K2vJ7TdbTlxclJnqXPO7LWsiu9Dih9+VWIozEg21 mIuKEwGEqG+fKAIAAA== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The buck9 regulator of S2MPS11 PMIC lacked minimal selector for linear mapping. The mapping starts from 0x40 (3 V). This buck9 provides power to other regulators, including LDO13 and LDO19 which supply the MMC2 (SD card). Bootloader initializes the regulator with value of 0xff (5 V) which is outside of supported voltage range. When (during boot) constraints to buck9 were applied, the driver wrote value counting from 0x00, not 0x40. Effectively driver set lower voltage than required leading to SD card detection errors on Odroid XU3/XU4: mmc1: card never left busy state mmc1: error -110 whilst initialising SD card Fixes: cb74685ecb39 ("regulator: s2mps11: Add samsung s2mps11 regulator driver") Cc: Signed-off-by: Krzysztof Kozlowski Reviewed-by: Javier Martinez Canillas Tested-by: Javier Martinez Canillas --- The issue can be reproduced on next-20160324 with bae4fdc88d7f7dda1 (regulator: core: Ensure we are at least in bounds for our constraints). --- drivers/regulator/s2mps11.c | 19 ++++++++++++++++++- include/linux/mfd/samsung/s2mps11.h | 9 +++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index d24e2c783dc5..caeefc38ac47 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -324,6 +324,23 @@ static struct regulator_ops s2mps11_buck_ops = { .enable_mask = S2MPS11_ENABLE_MASK \ } +#define regulator_desc_s2mps11_buck9 { \ + .name = "BUCK9", \ + .id = S2MPS11_BUCK9, \ + .ops = &s2mps11_buck_ops, \ + .type = REGULATOR_VOLTAGE, \ + .owner = THIS_MODULE, \ + .min_uV = MIN_3000_MV, \ + .uV_step = STEP_25_MV, \ + .linear_min_sel = S2MPS11_BUCK9_MIN_VSEL, \ + .n_voltages = S2MPS11_BUCK9_N_VOLTAGES, \ + .ramp_delay = S2MPS11_RAMP_DELAY, \ + .vsel_reg = S2MPS11_REG_B9CTRL2, \ + .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \ + .enable_reg = S2MPS11_REG_B9CTRL1, \ + .enable_mask = S2MPS11_ENABLE_MASK \ +} + static const struct regulator_desc s2mps11_regulators[] = { regulator_desc_s2mps11_ldo(1, STEP_25_MV), regulator_desc_s2mps11_ldo(2, STEP_50_MV), @@ -371,7 +388,7 @@ static const struct regulator_desc s2mps11_regulators[] = { regulator_desc_s2mps11_buck6_10(6, MIN_600_MV, STEP_6_25_MV), regulator_desc_s2mps11_buck6_10(7, MIN_600_MV, STEP_6_25_MV), regulator_desc_s2mps11_buck6_10(8, MIN_600_MV, STEP_6_25_MV), - regulator_desc_s2mps11_buck6_10(9, MIN_3000_MV, STEP_25_MV), + regulator_desc_s2mps11_buck9, regulator_desc_s2mps11_buck6_10(10, MIN_750_MV, STEP_12_5_MV), }; diff --git a/include/linux/mfd/samsung/s2mps11.h b/include/linux/mfd/samsung/s2mps11.h index b288965e8101..3937a932bfe0 100644 --- a/include/linux/mfd/samsung/s2mps11.h +++ b/include/linux/mfd/samsung/s2mps11.h @@ -173,10 +173,19 @@ enum s2mps11_regulators { #define S2MPS11_LDO_VSEL_MASK 0x3F #define S2MPS11_BUCK_VSEL_MASK 0xFF +#define S2MPS11_BUCK9_MIN_VSEL 0x40 #define S2MPS11_ENABLE_MASK (0x03 << S2MPS11_ENABLE_SHIFT) #define S2MPS11_ENABLE_SHIFT 0x06 #define S2MPS11_LDO_N_VOLTAGES (S2MPS11_LDO_VSEL_MASK + 1) #define S2MPS11_BUCK_N_VOLTAGES (S2MPS11_BUCK_VSEL_MASK + 1) +/* + * Buck9 supports only 32 voltages (values from 0x40 to 0x5F) but bootloader + * initializes the register with value of 0xff so when probing this would + * cause a failure (Odroid XU3): + * vdd_2.8v_ldo: failed to get the current voltage(-22) + * Instead pretend we support up to 0xff (5 V). + */ +#define S2MPS11_BUCK9_N_VOLTAGES 192 #define S2MPS11_RAMP_DELAY 25000 /* uV/us */ #define S2MPS11_CTRL1_PWRHOLD_MASK BIT(4)