From patchwork Tue Dec 24 00:58:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 182422 Delivered-To: patch@linaro.org Received: by 2002:a92:a146:0:0:0:0:0 with SMTP id v67csp1083131ili; Mon, 23 Dec 2019 16:58:51 -0800 (PST) X-Google-Smtp-Source: APXvYqzAvfFqDc1qkkd4/yU/KnDH+zW/bLzoMlwvUMAO7hve6HZzl59WYmgBCcdYVfJ9vWX/8ay3 X-Received: by 2002:a9d:630d:: with SMTP id q13mr33606233otk.31.1577149131536; Mon, 23 Dec 2019 16:58:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577149131; cv=none; d=google.com; s=arc-20160816; b=sJEaUNpXGHRtucb1ASEfCQ3PxxnfzN2JkzZIaSUgYK8G2IOOQthBaL/0dX0/+gWZz1 KUTGsNmJACi8AzJYfdwHlRqCwpqSuA8wibea/up5t2TOsGVJ72OWbGAsCli1r4gbIY6v CXZjtwfTMS7KrH9OkAzj+VQNkkrx0OFg1V8bCux6Tqh8cntkY5ROnsfXqEnq4mN8+nrA hXQXEXLIOw1wYkjeVXgerw2KiAutuexs3Esb0pPhxfDlMv9xfvVteO6i3pvs436jCiWR YSQE/87d1vGtn23WSFGACTC1T6ViPpwcxXuYUKn/TqlkLCbKY4j4wqyhmd1tFSV3E6pA 7u9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ptvB2VDB24XgjGGsapMHLcxkUeAkQ2BNrHSJcT9wJnA=; b=v6n2K/MgjI6zuv3jACZ7VlJEAzcOUbLTTNLMrzTLurZAfN3XHs8Fqp/tA8T3jn/k3W UcREL2GgMjOPGHa7+JmmsAg1BEPJnO1XM3Y0tlaEIHkgc0BcEjcbvSm3Civ5ZWPoxRfn 2Vs9dfTyjRp77CZwca55FmxgTubzrZkpc9JeJ5Lx1b+s8kblgN/I7ONXc8ZOtb+fHmyk GF2j/ktopzTmcQUiy8AlBJ+pl2/z3yZGdY2ObUXBXkDeGzbIkITXU7oEi+dV3d0FgyYU hdZj1kBqHcVws3laB8BwHpSctJrWpR6wvKzQUfO5DWniodLZUC+fSZkW6Jv5TsMI2Ege ygHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17si2797245oth.149.2019.12.23.16.58.51; Mon, 23 Dec 2019 16:58:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-spi-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-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726877AbfLXA6t (ORCPT + 2 others); Mon, 23 Dec 2019 19:58:49 -0500 Received: from mx.socionext.com ([202.248.49.38]:23638 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726833AbfLXA6t (ORCPT ); Mon, 23 Dec 2019 19:58:49 -0500 Received: from unknown (HELO iyokan-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 24 Dec 2019 09:58:47 +0900 Received: from mail.mfilter.local (m-filter-1 [10.213.24.61]) by iyokan-ex.css.socionext.com (Postfix) with ESMTP id BD1AF603AB; Tue, 24 Dec 2019 09:58:47 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Tue, 24 Dec 2019 09:59:27 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id 29E371A01CF; Tue, 24 Dec 2019 09:58:47 +0900 (JST) From: Kunihiko Hayashi To: Mark Brown , linux-spi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Masahiro Yamada , Keiji Hayashibara , Masami Hiramatsu , Jassi Brar , Kunihiko Hayashi Subject: [PATCH 2/5] spi: uniphier: Change argument of irq functions to private structure Date: Tue, 24 Dec 2019 09:58:24 +0900 Message-Id: <1577149107-30670-3-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1577149107-30670-1-git-send-email-hayashi.kunihiko@socionext.com> References: <1577149107-30670-1-git-send-email-hayashi.kunihiko@socionext.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This changes each argument of functions uniphier_irq_{enable,disable}() to uniphier_spi_priv because these functions are used not only for spi_device but also for the entire controller. Signed-off-by: Kunihiko Hayashi --- drivers/spi/spi-uniphier.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/spi/spi-uniphier.c b/drivers/spi/spi-uniphier.c index ce9b301..3859649 100644 --- a/drivers/spi/spi-uniphier.c +++ b/drivers/spi/spi-uniphier.c @@ -93,9 +93,9 @@ static inline unsigned int bytes_per_word(unsigned int bits) return bits <= 8 ? 1 : (bits <= 16 ? 2 : 4); } -static inline void uniphier_spi_irq_enable(struct spi_device *spi, u32 mask) +static inline void uniphier_spi_irq_enable(struct uniphier_spi_priv *priv, + u32 mask) { - struct uniphier_spi_priv *priv = spi_master_get_devdata(spi->master); u32 val; val = readl(priv->base + SSI_IE); @@ -103,9 +103,9 @@ static inline void uniphier_spi_irq_enable(struct spi_device *spi, u32 mask) writel(val, priv->base + SSI_IE); } -static inline void uniphier_spi_irq_disable(struct spi_device *spi, u32 mask) +static inline void uniphier_spi_irq_disable(struct uniphier_spi_priv *priv, + u32 mask) { - struct uniphier_spi_priv *priv = spi_master_get_devdata(spi->master); u32 val; val = readl(priv->base + SSI_IE); @@ -346,12 +346,12 @@ static int uniphier_spi_transfer_one_irq(struct spi_master *master, uniphier_spi_fill_tx_fifo(priv); - uniphier_spi_irq_enable(spi, SSI_IE_RCIE | SSI_IE_RORIE); + uniphier_spi_irq_enable(priv, SSI_IE_RCIE | SSI_IE_RORIE); time_left = wait_for_completion_timeout(&priv->xfer_done, msecs_to_jiffies(SSI_TIMEOUT_MS)); - uniphier_spi_irq_disable(spi, SSI_IE_RCIE | SSI_IE_RORIE); + uniphier_spi_irq_disable(priv, SSI_IE_RCIE | SSI_IE_RORIE); if (!time_left) { dev_err(dev, "transfer timeout.\n"); From patchwork Tue Dec 24 00:58:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 182426 Delivered-To: patch@linaro.org Received: by 2002:a92:a146:0:0:0:0:0 with SMTP id v67csp1083297ili; Mon, 23 Dec 2019 16:59:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwwIBXpoUtl5Bge/YvCQ+J1Abf5Huy6Xk/KUFe4ybeswzZaKZcsdnpnU/MtrQYLWU+Aw4WE X-Received: by 2002:a9d:6d06:: with SMTP id o6mr36240362otp.239.1577149143066; Mon, 23 Dec 2019 16:59:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577149143; cv=none; d=google.com; s=arc-20160816; b=JFMaujSjlB+EcLHrSAZb+qsXlexE6tN9HtogfdVnzdPHeaTDK6a2NiIJ0tOxax+mwN B/AtK4ZKDYJDmDeCMl7x66pLk4LWq++isVVgak6+F/JTdObCuG5BByKmJcnuL1Tv27C9 vYzPktB90Dy4Fvte/1PccQgfC6fxXne+e1OEcE2cM6t2Pt66S99xh6+QlRzuY2wp0KiK 692OwKW4J9smmAykizUNqTlLY0DqU63I409V+uCBhFQdiCcrom0GZbPdDso9TejGk4LZ 5LrX59cgqePV/bVX8bmT0wlh2Vwc4kJkzZdLlp9rjbjo6ITew31/lIvGD0y7EEGtGEP9 L0sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=gaUknwGtgEirjGjxjp9lGlT8cAC3dFZC3L/OkyydUIQ=; b=zWB1LtNfNa0M6wRNHAz20BtDykqSi8M0abbTxM4UJiY8eAjScztg5bLX9oL4LCI8eE 858kCkjxTsrl+Zte08qN7B6zf2jtYI6ZMf8T6Lwkf6gOYRiA+K7iJrmqt7x+wg7LZ+HI 5euDGAMbcQXB+gCxXLee2oEseisczUqzQ2aZX4URWa/pgUns1zhrAeQhi6QdRw0+dlZN XRZxUYiZyPiS1TYHL6949XOv7pWAklLCtav9/I8PVRHBUaMdQwhMGJ5kiAHeYlIGCQdm 4dGKMJNbiEGkfgGBxIWeixlyixfZlazMvAc6nzaRKjXKM9HgxiPBhGQ/ERLZiht16FVm ROMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i20si5744006oie.119.2019.12.23.16.59.02; Mon, 23 Dec 2019 16:59:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-spi-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-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727071AbfLXA67 (ORCPT + 2 others); Mon, 23 Dec 2019 19:58:59 -0500 Received: from mx.socionext.com ([202.248.49.38]:23640 "EHLO mx.socionext.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727030AbfLXA6u (ORCPT ); Mon, 23 Dec 2019 19:58:50 -0500 Received: from unknown (HELO iyokan-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 24 Dec 2019 09:58:48 +0900 Received: from mail.mfilter.local (m-filter-1 [10.213.24.61]) by iyokan-ex.css.socionext.com (Postfix) with ESMTP id C4C45603AB; Tue, 24 Dec 2019 09:58:48 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Tue, 24 Dec 2019 09:59:28 +0900 Received: from plum.e01.socionext.com (unknown [10.213.132.32]) by kinkan.css.socionext.com (Postfix) with ESMTP id 4149E1A01CF; Tue, 24 Dec 2019 09:58:48 +0900 (JST) From: Kunihiko Hayashi To: Mark Brown , linux-spi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Masahiro Yamada , Keiji Hayashibara , Masami Hiramatsu , Jassi Brar , Kunihiko Hayashi Subject: [PATCH 3/5] spi: uniphier: Add handle_err callback function Date: Tue, 24 Dec 2019 09:58:25 +0900 Message-Id: <1577149107-30670-4-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1577149107-30670-1-git-send-email-hayashi.kunihiko@socionext.com> References: <1577149107-30670-1-git-send-email-hayashi.kunihiko@socionext.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This adds master->handle_err() callback function to stop transfer due to error. The function also resets FIFOs and disables interrupt. Signed-off-by: Kunihiko Hayashi --- drivers/spi/spi-uniphier.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) -- 2.7.4 diff --git a/drivers/spi/spi-uniphier.c b/drivers/spi/spi-uniphier.c index 3859649..c4e3b96 100644 --- a/drivers/spi/spi-uniphier.c +++ b/drivers/spi/spi-uniphier.c @@ -432,6 +432,22 @@ static int uniphier_spi_unprepare_transfer_hardware(struct spi_master *master) return 0; } +static void uniphier_spi_handle_err(struct spi_master *master, + struct spi_message *msg) +{ + struct uniphier_spi_priv *priv = spi_master_get_devdata(master); + u32 val; + + /* stop running spi transfer */ + writel(0, priv->base + SSI_CTL); + + /* reset FIFOs */ + val = SSI_FC_TXFFL | SSI_FC_RXFFL; + writel(val, priv->base + SSI_FC); + + uniphier_spi_irq_disable(priv, SSI_IE_RCIE | SSI_IE_RORIE); +} + static irqreturn_t uniphier_spi_handler(int irq, void *dev_id) { struct uniphier_spi_priv *priv = dev_id; @@ -538,6 +554,7 @@ static int uniphier_spi_probe(struct platform_device *pdev) = uniphier_spi_prepare_transfer_hardware; master->unprepare_transfer_hardware = uniphier_spi_unprepare_transfer_hardware; + master->handle_err = uniphier_spi_handle_err; master->num_chipselect = 1; ret = devm_spi_register_master(&pdev->dev, master);