Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp988038ybk; Sun, 10 May 2020 02:54:20 -0700 (PDT) X-Google-Smtp-Source: APiQypLlStVhRvBmcM+osAOG5MUgd+QgRySE+o4NXvbTMzS0P/VeCxG4gn96dGsam8dr1uNKJ230 X-Received: by 2002:a17:906:3709:: with SMTP id d9mr9172188ejc.94.1589104460800; Sun, 10 May 2020 02:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589104460; cv=none; d=google.com; s=arc-20160816; b=gF7aWw5NwUU1wrx5pkSFMw5rGc9lQNxf5RI6uwV0EFS3UUm+yXrvtIDxcx6eat1l7K EMKqXiieb72GOdJKpqRtmWwgaHxNY6LVOTqhtHKEVoH0T9Gp7gt7/CPRNw233JuubSAF tDrhdwLyi2RnHwH8oOjJfyFG3ytCgveUJOK0vbjK1548oPpn6VfBznv8W1augptAKVPJ NefieABA+BjQdASayWLugDhZEuGl+Rmu3MsZrtJp7pXbP+vXquSTpVIpJen9W8fJng/A irXYd2czMdbWiTUmOB9rQLTBhg3Vly7JaChnlw/SmdYWf4EOhkEVGu0+KhUI3rhbYlwY ZpQg== 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=Hrj19uRzPMyWV3HG1soEL+9fov6wQXQYn2d6d47v1NU=; b=FUzyCMhZ6+80ykYEvR3ScyRieYRdQ5vm9yyjCcckpUQRBg7FgG1JBw22ykRyDjEVY3 dVs3gzgJ0nJsKWJSrRYkS/A8EBi9FKSHnq/jKtmNWYNMc0ZbvVOkr6EstsORhMtQmazz G3de0v9ZtgYrvAg/vDq9mg5cLae+GrbqjlVLxz9jEIklZGSeoDSa7xyda6nCyPsoSCjk Wc+ZIIHPlsnX/AFJCdm/iKMUXlMERYrB1kccHRYDn6OMbVd22tFLUEqQ/ReUKtL0/ctD a/gSX6l26R/HWfomd4vNJeUSNEzETg2dtpnzuBn4JF8wVKYDwpTfZITV4s4OLFss+PGa 4/mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si3820754eds.168.2020.05.10.02.53.57; Sun, 10 May 2020 02:54:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729103AbgEJJvN (ORCPT + 99 others); Sun, 10 May 2020 05:51:13 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:46190 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729085AbgEJJvM (ORCPT ); Sun, 10 May 2020 05:51:12 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 905AB8000B82; Sun, 10 May 2020 09:51:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q51xkqzNECF2; Sun, 10 May 2020 12:51:09 +0300 (MSK) From: Serge Semin To: Jarkko Nikula , Andy Shevchenko , Mika Westerberg CC: Serge Semin , Serge Semin , Alexey Malahov , Thomas Bogendoerfer , Paul Burton , Ralf Baechle , Rob Herring , Frank Rowand , , , Wolfram Sang , "Rafael J. Wysocki" , Hans de Goede , Hanjun Guo , , Subject: [PATCH v2 11/12] i2c: designware: Use provided regmap instead of reg resource Date: Sun, 10 May 2020 12:50:17 +0300 Message-ID: <20200510095019.20981-12-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20200510095019.20981-1-Sergey.Semin@baikalelectronics.ru> References: <20200306132001.1B875803087C@mail.baikalelectronics.ru> <20200510095019.20981-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a preparation patch before adding a glue platform driver for the Baikal-T1 I2C controller. Since the i2c controller registers are indirectly accessed by means of the Baikal-T1 System Controller registers we need to have a way to disable the default registers mapping setup procedure and make the DW I2C core/platform code to use a provided by a glue driver regmap. Signed-off-by: Serge Semin Cc: Alexey Malahov Cc: Thomas Bogendoerfer Cc: Paul Burton Cc: Ralf Baechle Cc: Rob Herring Cc: Frank Rowand Cc: linux-mips@vger.kernel.org Cc: devicetree@vger.kernel.org --- drivers/i2c/busses/i2c-designware-common.c | 7 +++++++ drivers/i2c/busses/i2c-designware-platdrv.c | 14 ++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c index 35c5ad7e274e..141ea0651a8f 100644 --- a/drivers/i2c/busses/i2c-designware-common.c +++ b/drivers/i2c/busses/i2c-designware-common.c @@ -133,6 +133,13 @@ int i2c_dw_init_regmap(struct dw_i2c_dev *dev) u32 reg; int ret; + /* + * Skip detecting the registers map configuration if the regmap has + * already been provided by a higher code. + */ + if (dev->map) + return 0; + ret = i2c_dw_acquire_lock(dev); if (ret) return ret; diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index f577e2a92a4f..9d131a64ea81 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -212,10 +212,16 @@ int i2c_dw_plat_setup(struct dw_i2c_dev *dev) if (dev->irq < 0) return dev->irq; - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - dev->base = devm_ioremap_resource(&pdev->dev, mem); - if (IS_ERR(dev->base)) - return PTR_ERR(dev->base); + /* + * Don't try to get the controller registers MMIO space if regmap has + * been provided by a higher level code. + */ + if (!dev->map) { + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + dev->base = devm_ioremap_resource(&pdev->dev, mem); + if (IS_ERR(dev->base)) + return PTR_ERR(dev->base); + } dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); if (IS_ERR(dev->rst)) -- 2.25.1