From patchwork Fri May 19 08:56:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 100182 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp212307qge; Fri, 19 May 2017 01:57:22 -0700 (PDT) X-Received: by 10.99.148.17 with SMTP id m17mr9037567pge.187.1495184242236; Fri, 19 May 2017 01:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495184242; cv=none; d=google.com; s=arc-20160816; b=Cg2DAO71m6zCv6mkjyuetgAr7+x6vq5Iu0DLWWU4bpov1zkF94171z/M7RfIceFhAX w4em5IpCr2UW/H2sFvVc2L1P7gn4Gyz6tLsCevdvIsm58sZaUEAoHxhVY6Clhpzw2ipB wl00/jeZGF1BKYichJ3rs4Vg29UJ4HfROyUxQa50NiyK1Z442ld/sSGf8X4jgrgxj0Dc aRqk4+BPlzITcnw6jyNqWYUyxoLs8waro8FN/R3INmhjEt0CNX93sW56DWkYi1W+7ntN CQhKjFTJo1YCVo/vbn5WDT1k2GA7HyD2wxwN2u/muMsAAu2e2zQlCY8s5zEwCY95qS1D ahyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=F+F8wcOtjgPL8uUdYJdOgovc08CWiVauWhp+67LyIQ8=; b=nCJ0EEjW6KCeQtr59lnVbQxoJmlgoHezbmKhyZhD3qE/KCS8lV/cm2tqLZJdjhpOkF vJhG8eLXu6RNvnVebIJNqbYUUFuQMz871zLMqFJpnHTkovMCCpbHoe2Xs2Ul0zEy/wyE HLsBia2ROxtduVyLuoo8tUyvZWx1KCNh3ger6GJkmFOKEyJXihsvC11Viuijl0LMabls hVgfVwIL/TtOdNW6AOZWWbRqPNAf3C90MvMWIBhtGlR5xgLrP9GUuO1pv5P3O4nXJr3x gsJVnDDubnU7XtucQublMRruhYpvJmX54AKKwAyinVnV0JwwtYBQ7RUd6mbyvVk+RIxy Gtww== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si7685065pgr.213.2017.05.19.01.57.22; Fri, 19 May 2017 01:57:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753419AbdESI5N (ORCPT + 1 other); Fri, 19 May 2017 04:57:13 -0400 Received: from mail-wr0-f172.google.com ([209.85.128.172]:33048 "EHLO mail-wr0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752868AbdESI4v (ORCPT ); Fri, 19 May 2017 04:56:51 -0400 Received: by mail-wr0-f172.google.com with SMTP id w50so12579207wrc.0 for ; Fri, 19 May 2017 01:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=tCtPkSdCBwutjdYIT58OcddMYbEsiiO1pmaeIigrKNQ=; b=Amrbi2WSGibOMQMbs7+Z6tMrYBm5obb9arfKMGmSKeQR1VZy//7xX3X0l0d9zji0sz ZuKMVBBHb1eHskjuEapbCQt/Ohh3DyGliV7dl0uav4D4wJ0migRiNjdS8055HZ0oslA3 c6oVPj64KJppQrNciZOnKTFko2KgjCRRCjP8M= 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; bh=tCtPkSdCBwutjdYIT58OcddMYbEsiiO1pmaeIigrKNQ=; b=OVT06uR4RT6ju/rsuVKHZnSOcBEx35/JRmQRg8rVEGxwtf8Is95G8MJcGhixq1+BPB /3U1nKR9zRsFbCg14d4saNPyqiPhfBIqlizmZ1YQlY5meG2A7zzezaa3uTW0+ckmLelY 6sHphk2VvRypc/8DeIcPdGFwHDumTsfjW2MOCxFGMeRr2+bXgCXru0+rZseQtD5JR/pu ymQ+5tM/OAsVbiDhVqrL6WBrvtTmdcVQsntDXYFOFTzcmnbsKXZ5tpTKvASy7v9YciZZ KOBbtnmwo0NcHK7toLvhDGJXvh2L8DoFxbIovtBfKA+SOGJ+HqM7weudfWa+h5v9WdSM yKnQ== X-Gm-Message-State: AODbwcCpmeWCkWHMNAfRkUeFz5xNuuNh9JZVzPmig/T5hnNisa3b788x cCADucuR/d/pxotn X-Received: by 10.223.165.5 with SMTP id i5mr2506390wrb.197.1495184209880; Fri, 19 May 2017 01:56:49 -0700 (PDT) Received: from localhost.localdomain ([105.129.238.81]) by smtp.gmail.com with ESMTPSA id w68sm3573115wrb.49.2017.05.19.01.56.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 01:56:49 -0700 (PDT) From: Ard Biesheuvel To: jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, wsa@the-dreams.de, linux-i2c@vger.kernel.org, lorenzo.pieralisi@arm.com Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel Subject: [PATCH] i2c: designware: don't infer timings described by ACPI from clock rate Date: Fri, 19 May 2017 09:56:40 +0100 Message-Id: <20170519085640.15111-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Commit bd698d24b1b57 ("i2c: designware: Get selected speed mode sda-hold-time via ACPI") updated the logic that reads the timing parameters for various I2C bus rates from the DSDT, to only read the timing parameters for the currently selected mode. This causes a WARN_ON() splat on platforms that legally omit the clock frequency from the ACPI description, because in the new situation, the core I2C designware driver still accesses the fields in the driver struct that we no longer populate, and proceeds to calculate them from the clock frequency. Since the clock frequency is unspecified, the driver complains loudly using a WARN_ON(). So revert back to the old situation, where the struct fields for all timings are populated, but retain the new logic which chooses the SDA hold time from the timing mode that is currently in use. Fixes: bd698d24b1b57 ("i2c: designware: Get selected speed mode ...") Signed-off-by: Ard Biesheuvel --- drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reported-by: Lorenzo Pieralisi Acked-by: Jarkko Nikula Reviewed-by: Ard Biesheuvel Acked-by: Jarkko Nikula diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index f2acd4b6bf01..6283b99d2b17 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -96,6 +96,7 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev) struct dw_i2c_dev *dev = platform_get_drvdata(pdev); acpi_handle handle = ACPI_HANDLE(&pdev->dev); const struct acpi_device_id *id; + u32 ss_ht, fp_ht, hs_ht, fs_ht; struct acpi_device *adev; const char *uid; @@ -107,23 +108,24 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev) * Try to get SDA hold time and *CNT values from an ACPI method for * selected speed modes. */ + dw_i2c_acpi_params(pdev, "SSCN", &dev->ss_hcnt, &dev->ss_lcnt, &ss_ht); + dw_i2c_acpi_params(pdev, "FPCN", &dev->fp_hcnt, &dev->fp_lcnt, &fp_ht); + dw_i2c_acpi_params(pdev, "HSCN", &dev->hs_hcnt, &dev->hs_lcnt, &hs_ht); + dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt, &fs_ht); + switch (dev->clk_freq) { case 100000: - dw_i2c_acpi_params(pdev, "SSCN", &dev->ss_hcnt, &dev->ss_lcnt, - &dev->sda_hold_time); + dev->sda_hold_time = ss_ht; break; case 1000000: - dw_i2c_acpi_params(pdev, "FPCN", &dev->fp_hcnt, &dev->fp_lcnt, - &dev->sda_hold_time); + dev->sda_hold_time = fp_ht; break; case 3400000: - dw_i2c_acpi_params(pdev, "HSCN", &dev->hs_hcnt, &dev->hs_lcnt, - &dev->sda_hold_time); + dev->sda_hold_time = hs_ht; break; case 400000: default: - dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt, - &dev->sda_hold_time); + dev->sda_hold_time = fs_ht; break; }