From patchwork Thu Sep 20 18:29:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 147120 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2331520ljw; Thu, 20 Sep 2018 11:29:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYxAEEGrIC8zXO3hAcMPDHQlS6lhogzv8N++LQ9BerZw/R/mWtZlOXebLA6VWvfBnuKYz6H X-Received: by 2002:a63:ec14:: with SMTP id j20-v6mr38130363pgh.28.1537468158096; Thu, 20 Sep 2018 11:29:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537468158; cv=none; d=google.com; s=arc-20160816; b=nWiB0yZxDlhh8rZul2vI0ccE4MC4aGt233DnrcgKICFxTS3422owBXiCtboNyp+QoT BWjCP/coiX8o6aVHY5JVNU6eA/Ww48sWDQSO17piEQWEiOlPOI+lBSCRRNMzTJ/BNUKX cRO5BU8rDDzSNSUiklAN/fp3xGorqtJ/rHVte4oaO4TxM7FlWwDGpu9qCl8rDhcs3YGC B1SJ+gRX7oRWatptg7hZtk2M+IEPIM4O/Whpv0+5kwslhNmb+jjNExCrvU9pvZMlNEfs cXspyb63QAz8PRdtHDOWXKI5V4J13IEX8Tw/+JMSATi9DlN40UDfPtyWQZ0q9QHrj9vZ Lssg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=la48aY5uXjq4A2lLegD6L3mL5JzWDz5xO/EKbSrcn5A=; b=J5mbmjBRHnH3KXFq7a418wJmTapuOUp/bgq1xaCj4u8zor37Y13ncP/97p78Vq4SM5 ltVHoorkcHdSDZmOrcAX2zai6/OoGlU0nQNmic9GF41Qi9qbORNrG39iRv3wd3DiRDMp juQzAX+Js5AY21RVEtsTGbrDu9LyXrluir4wa7qikujHdCc/+YRoifn2KGvO/pVKtH24 MqpQYUr0MTTKjcIh0rRDgatyIKHCAPoV0NiO74lg+/tfuEqMbm8rszjGa2MU0LMUVA2C M24EkvyVM86Mlc8gXYFA4z54BRc3DcKQwVodyS29pVlfRzgQrtsO0EsWGcsu5oad86ml v4PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bp1k9hS+; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (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 a33-v6si26035608pld.269.2018.09.20.11.29.17; Thu, 20 Sep 2018 11:29:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bp1k9hS+; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727029AbeIUAOC (ORCPT + 6 others); Thu, 20 Sep 2018 20:14:02 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:50539 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726781AbeIUAOC (ORCPT ); Thu, 20 Sep 2018 20:14:02 -0400 Received: by mail-wm1-f68.google.com with SMTP id s12-v6so533404wmc.0 for ; Thu, 20 Sep 2018 11:29:14 -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:mime-version :content-transfer-encoding; bh=la48aY5uXjq4A2lLegD6L3mL5JzWDz5xO/EKbSrcn5A=; b=Bp1k9hS+WXoheSAwak88WteD29XgAHfc1pRhzfPGE6JrKv5W8F16YFxZqW9UxzQwTs f6H1rdsXwIwbG3vnb+6uZLuUGqqN/jyTH7XFr/jk+IrPeatV8Qrj4hl+xtt7DubDRV/7 4/Cz9IXSXAmD+vl8rPxZA3tdDmaSip4ATS/9M= 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 :content-transfer-encoding; bh=la48aY5uXjq4A2lLegD6L3mL5JzWDz5xO/EKbSrcn5A=; b=pVxzB++IoOeR+ZK7XmZiikO/3fyT4uFPP+RNlGE377otKykgmeki4tZQ88Ll0ANPHb oN7uwRgD5YQ4Xv0+X+xP64xmf+lRQSYZLf/XOOFHv5akeChB8PrGWKF/Pypc55gfDeZr 3jNCS6YJj77Y8U8BjN6Z1rV4guhyPggOQR9Qioi+StcATEdVqZp3DnbRaVU5g+U89fCk WY7u7GLb9ZAw0PZr5zJhQ+Hyz7O+gP82OjJoOP6kEfhxWHRZutrHma663tLCz9HzzmKH RaZOV/ZaoAkDcxnyI6wxSwZpqb6zwCQ0ocCvItPoIwlwcRtSzLU+IrkXCSGVWIjsoUVm lt3A== X-Gm-Message-State: APzg51ATxC2IRgHHxy6kasPzR/osKpeIv5qhf6J7U3bu7/iuJs3pBCgN KfetMMidj2HMNW+BBRY9WhHfAg== X-Received: by 2002:a1c:b6d6:: with SMTP id g205-v6mr3896822wmf.17.1537468153322; Thu, 20 Sep 2018 11:29:13 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id 200-v6sm4783384wmv.6.2018.09.20.11.29.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Sep 2018 11:29:12 -0700 (PDT) From: Georgi Djakov To: linux-pm@vger.kernel.org Cc: gregkh@linuxfoundation.org, rjw@rjwysocki.net, robh+dt@kernel.org, mturquette@baylibre.com, khilman@baylibre.com, vincent.guittot@linaro.org, skannan@codeaurora.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, abailon@baylibre.com, maxime.ripard@bootlin.com, arnd@arndb.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, wsa@the-dreams.de, linux-i2c@vger.kernel.org, georgi.djakov@linaro.org Subject: [RFC] i2c: qup: Use the interconnect API Date: Thu, 20 Sep 2018 11:29:03 -0700 Message-Id: <20180920182903.19991-1-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The interconnect API provides an interface for consumer drivers to express their bandwidth needs in the SoC. This data is aggregated and the on-chip interconnect hardware is configured to the appropriate power/performance profile. Use the interconnect API to get() the path between the endpoints used for data transfers by the I2C QUP and report the needed bandwidth based on the i2c mode. Signed-off-by: Georgi Djakov --- This patch depends on the interconnect API: https://lkml.org/lkml/2018/8/31/444 TODO: Use a macro for converting and rounding to icc units instead of converting between kilobits, kilobytes etc. in the consumer drivers. drivers/i2c/busses/i2c-qup.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c index c86c3ae1318f..436747a74dc6 100644 --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -280,6 +281,11 @@ struct qup_i2c_dev { void (*read_rx_fifo)(struct qup_i2c_dev *qup); /* function to write tags in tx fifo for i2c read transfer */ void (*write_rx_tags)(struct qup_i2c_dev *qup); + + /* frequency mode standard */ + u32 clk_freq; + /* interconnect path to scale according to bandwidth needs */ + struct icc_path *path; }; static irqreturn_t qup_i2c_interrupt(int irq, void *dev) @@ -1657,6 +1663,16 @@ static void qup_i2c_disable_clocks(struct qup_i2c_dev *qup) clk_disable_unprepare(qup->pclk); } +static void qup_i2c_enable_icc(struct qup_i2c_dev *qup) +{ + icc_set(qup->path, 0, qup->clk_freq / 8000); +} + +static void qup_i2c_disable_icc(struct qup_i2c_dev *qup) +{ + icc_set(qup->path, 0, 0); +} + static const struct acpi_device_id qup_i2c_acpi_match[] = { { "QCOM8010"}, { }, @@ -1784,6 +1800,10 @@ static int qup_i2c_probe(struct platform_device *pdev) } ACPI_COMPANION_SET(&qup->adap.dev, ACPI_COMPANION(qup->dev)); } else { + qup->path = of_icc_get(qup->dev, "i2c-mem"); + if (IS_ERR(qup->path)) + return PTR_ERR(qup->path); + qup->clk = devm_clk_get(qup->dev, "core"); if (IS_ERR(qup->clk)) { dev_err(qup->dev, "Could not get core clock\n"); @@ -1795,6 +1815,8 @@ static int qup_i2c_probe(struct platform_device *pdev) dev_err(qup->dev, "Could not get iface clock\n"); return PTR_ERR(qup->pclk); } + qup->clk_freq = clk_freq; + qup_i2c_enable_icc(qup); qup_i2c_enable_clocks(qup); src_clk_freq = clk_get_rate(qup->clk); } @@ -1927,6 +1949,7 @@ static int qup_i2c_remove(struct platform_device *pdev) disable_irq(qup->irq); qup_i2c_disable_clocks(qup); + icc_put(qup->path); i2c_del_adapter(&qup->adap); pm_runtime_disable(qup->dev); pm_runtime_set_suspended(qup->dev); @@ -1939,6 +1962,7 @@ static int qup_i2c_pm_suspend_runtime(struct device *device) struct qup_i2c_dev *qup = dev_get_drvdata(device); dev_dbg(device, "pm_runtime: suspending...\n"); + qup_i2c_disable_icc(qup); qup_i2c_disable_clocks(qup); return 0; } @@ -1948,6 +1972,7 @@ static int qup_i2c_pm_resume_runtime(struct device *device) struct qup_i2c_dev *qup = dev_get_drvdata(device); dev_dbg(device, "pm_runtime: resuming...\n"); + qup_i2c_enable_icc(qup); qup_i2c_enable_clocks(qup); return 0; }