Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1000845imc; Mon, 11 Mar 2019 04:24:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqznzXmIzcZRo6oU/6lmIXf8pmiTgKxkeLOQyNNHPdosV5puc/7uJwXOc8Msq+KjQKxcGDKp X-Received: by 2002:a17:902:a413:: with SMTP id p19mr34205695plq.337.1552303449234; Mon, 11 Mar 2019 04:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552303449; cv=none; d=google.com; s=arc-20160816; b=Nmh+ihHupiEsjqDckrYiun/Qs1Zsn+yoNxu2Rop+IiFL0YD8mV7MvEGb5L62HfJE6n izlPLPrueTXJyg7AjOE6L6hWtgPuTi43oYu77JHQKnQ5XbctsRYKuIAgWzITZ/wj2hWC H6LJz4WCOn0fV4ZyiI1K5JlPjAlX+P8+45uA673TOf9dXi/2u00ZDftqadXMXzdjWSlE iTyzN5xn4JZTc/3a8rAg0JWpWH8fWpVZ4lsPwq2A2QgD9ZGcVsqUd5jRQwSU4NYswBZF qv4Z/ECfRr9hVMZSArfD9092a3eNt6oalfSHO4B7ntxjY3awZ5qczMsyes8KJ0h3Sm3g lK4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3p+dlc9mmw/q4fvFNKlvib8IuX0knT2Z2H/fWGHNmKw=; b=bHFOrLK862DqIz/ndKlHxH2NuUu+qYv8kDsMipjDU5PlIuVEeeQdgPugvdI7KyO+rz NVFE8HPY7ySxpTyKkKFEdJe98xJB2SzrdpcBGQS3FV3JU4YhGWF6XDuXp14Cszz9V9T+ TA1b/D5xJL7lZgOOIbgU0K8GJVeS8y5YKVhci6Z23EQ5r5NjHarm0pcWHUDvYRr84ndV F1DSlmLaI7mtCDTcwsXzqfKKy/DKqNtZzN0a/na4ngJtz5FiwJ1K72xs1phAHgI9pNBi Si60d5wnEfcf6LzPAnM4Da/FjiEwcCdThdGNvxD2GH34aq/zfR7OkMOqfpaJqWFkTBBv Y4gg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 24si4958005pgl.359.2019.03.11.04.23.54; Mon, 11 Mar 2019 04:24:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727435AbfCKLWW (ORCPT + 99 others); Mon, 11 Mar 2019 07:22:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50972 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727239AbfCKLWV (ORCPT ); Mon, 11 Mar 2019 07:22:21 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB16C81F25; Mon, 11 Mar 2019 11:22:20 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-37.ams2.redhat.com [10.36.117.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 435725C579; Mon, 11 Mar 2019 11:22:19 +0000 (UTC) From: Hans de Goede To: Jarkko Nikula , Wolfram Sang , Andy Shevchenko , Mika Westerberg , Lee Jones Cc: Hans de Goede , linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] i2c: i2c-designware-platdrv: Allow a dynamic adap. nr without an ACPI fwnode Date: Mon, 11 Mar 2019 12:22:15 +0100 Message-Id: <20190311112216.31391-2-hdegoede@redhat.com> In-Reply-To: <20190311112216.31391-1-hdegoede@redhat.com> References: <20190311112216.31391-1-hdegoede@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 11 Mar 2019 11:22:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before this commit the i2c-designware-platdrv assumes that if the pdev has an apci-companion it should use a dynamic adapter-nr and otherwise it will use pdev->id as adapter-nr. On some devices e.g. the Apollo Lake using Acer TravelMate Spin B118, some of the LPSS i2c-adapters are enumerated through PCI and do not have an ACPI fwnode. These devices are handled as mfd devices so they end up using the i2c-designware-platdrv driver. This results in the i2c-adapter being registered with the mfd generated pdev->id as adapter-nr, which conflicts with existing adapters, triggering a WARN(id < 0, "couldn't get idr") in i2c-core-base.c and causing the adapter registration to fail. This commit adds support for setting a "linux,use-dynamic-adapter-nr" device property on the device to make i2c-designware-platdrv use dynamic adapter-nrs on devices without an ACPI fwnode, together with changes to drivers/mfd/intel-lpss-pci.c to set this, this fixes the WARN. Before this commit the setting of the adapter.nr was somewhat convoluted, in the acpi_companion case it was set from dw_i2c_acpi_configure, in the non acpi_companion case it was set from dw_i2c_set_fifo_size() based on tx_fifo_depth not being set yet. This commit also cleans this up. Note the "linux,use-dynamic-adapter-nr" is meant for kernel internal use only, therefor it is NOT documented under Documents/devicetree/bindings. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1687065 Signed-off-by: Hans de Goede --- drivers/i2c/busses/i2c-designware-platdrv.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index ead5e7de3e4d..9f28159efdb2 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -86,7 +86,6 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev) struct i2c_timings *t = &dev->timings; u32 ss_ht = 0, fp_ht = 0, hs_ht = 0, fs_ht = 0; - dev->adapter.nr = -1; dev->tx_fifo_depth = 32; dev->rx_fifo_depth = 32; @@ -219,7 +218,7 @@ static void i2c_dw_configure_slave(struct dw_i2c_dev *dev) dev->mode = DW_IC_SLAVE; } -static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev, int id) +static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev) { u32 param, tx_fifo_depth, rx_fifo_depth; @@ -233,7 +232,6 @@ static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev, int id) if (!dev->tx_fifo_depth) { dev->tx_fifo_depth = tx_fifo_depth; dev->rx_fifo_depth = rx_fifo_depth; - dev->adapter.nr = id; } else if (tx_fifo_depth >= 2) { dev->tx_fifo_depth = min_t(u32, dev->tx_fifo_depth, tx_fifo_depth); @@ -324,6 +322,13 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) if (has_acpi_companion(&pdev->dev)) dw_i2c_acpi_configure(pdev); + if (has_acpi_companion(&pdev->dev) || + device_property_read_bool(&pdev->dev, + "linux,use-dynamic-adapter-nr")) + dev->adapter.nr = -1; + else + dev->adapter.nr = pdev->id; + /* * Only standard mode at 100kHz, fast mode at 400kHz, * fast mode plus at 1MHz and high speed mode at 3.4MHz are supported. @@ -358,7 +363,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) div_u64(clk_khz * t->sda_hold_ns + 500000, 1000000); } - dw_i2c_set_fifo_size(dev, pdev->id); + dw_i2c_set_fifo_size(dev); adap = &dev->adapter; adap->owner = THIS_MODULE; -- 2.20.1