From patchwork Sun Feb 2 12:59:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 205202 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9603C3524A for ; Sun, 2 Feb 2020 13:00:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75C2C20658 for ; Sun, 2 Feb 2020 13:00:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BcLLBaeo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726906AbgBBNAH (ORCPT ); Sun, 2 Feb 2020 08:00:07 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:36475 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726198AbgBBNAG (ORCPT ); Sun, 2 Feb 2020 08:00:06 -0500 Received: by mail-yw1-f65.google.com with SMTP id n184so10516379ywc.3; Sun, 02 Feb 2020 05:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e6rN6yJZ4eWmG/f569Zn9OH6A2Ob5WD1MTBuZuc6gi8=; b=BcLLBaeoTaZLKReT7xF4F380ZCod3MrDwYOq1eGTKZIqQMNmr/gbg7LiBc2mA2N0iG WFS59R7WRetlc/VIrBYgx7UAHtA5axveGDhJDGDTKfxjTZr5i8n9fTCYYGGiF1FsRTj/ 7g1c8UYiok0vKv/IDcAXqKagTPllBhPvvG40EgkYEABz+U0iGnZf/YwWnmQnzVGmNOqe oJVfDLUqkBD1frBo0JfA+4FYGgFai5IO5sAzpX6MdM46TgBXUIt5O1eYstP2Vq8FKf7i E2pvLkUffEnd4hICkRz/YirAScywfADg/ll1QZ0CXZoXVfHHPVhIHuJ25hWb4ms+mOsh ckRQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=e6rN6yJZ4eWmG/f569Zn9OH6A2Ob5WD1MTBuZuc6gi8=; b=kO6bt//qkML27/CIsr5X8eZVC/II3EJObnIrJl/aIAcBBHp7927WUTG6jM07Eb9g1q quMGWpxJocdvnjsy7MFUoqM7UaR843PEBSoDCAyxrWko2sg1wtnMuDdC4SneuEEifepZ dVZtlZVdFs/Qt+fOYZbFQYa0SkZrsheB1Y9IYE2+QilP8Im1RfJArm5oWAH1aAs4KO3c xKdDGV1CAYm7ITHRtn6df+Zc5rL0hSYNOOWxGVA/i1WpSzuMqnHeODxvPSidumxMRFzX /1JK3XG6dgAC+l2sMVc2g/r0pG+eOA5ByrPpFohb32hjV0KpRc64V32whfJhCYUb4hD6 Pbvw== X-Gm-Message-State: APjAAAVlfzHyjs+MFF5PPXqMRQ3HGg1J8nHk1vYaRG4Vfgm4dxv8IVI4 QnTkhb8EhHMZVf5uMGkLheGUr5QEmD8= X-Google-Smtp-Source: APXvYqx70kY7wgGOPXJWRZfeWiF9DHnZy7tefw85FuCVEcE9QFZkCaWdjfQvnlYHtM2j9I6yKoVLNA== X-Received: by 2002:a81:6055:: with SMTP id u82mr9702017ywb.35.1580648403893; Sun, 02 Feb 2020 05:00:03 -0800 (PST) Received: from localhost.localdomain (c-73-37-219-234.hsd1.mn.comcast.net. [73.37.219.234]) by smtp.gmail.com with ESMTPSA id m137sm7090013ywd.108.2020.02.02.05.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Feb 2020 05:00:03 -0800 (PST) From: Adam Ford To: linux-spi@vger.kernel.org Cc: Han Xu , Adam Ford , Yogesh Gaur , Ashish Kumar , Mark Brown , Rob Herring , Mark Rutland , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH V2 2/5] spi: fspi: dynamically alloc AHB memory Date: Sun, 2 Feb 2020 06:59:47 -0600 Message-Id: <20200202125950.1825013-2-aford173@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200202125950.1825013-1-aford173@gmail.com> References: <20200202125950.1825013-1-aford173@gmail.com> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Han Xu Apply patch from NXP upstream repo to dynamically allocate AHB memory as needed. Signed-off-by: Han Xu Signed-off-by: Adam Ford --- V2: Reorder s-o-b lines to give credit in proper order. diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c index 00c7899428a1..23abf5ae318e 100644 --- a/drivers/spi/spi-nxp-fspi.c +++ b/drivers/spi/spi-nxp-fspi.c @@ -307,6 +307,7 @@ #define POLL_TOUT 5000 #define NXP_FSPI_MAX_CHIPSELECT 4 +#define NXP_FSPI_MIN_IOMAP SZ_4M struct nxp_fspi_devtype_data { unsigned int rxfifo; @@ -345,6 +346,8 @@ struct nxp_fspi { void __iomem *ahb_addr; u32 memmap_phy; u32 memmap_phy_size; + u32 memmap_start; + u32 memmap_len; struct clk *clk, *clk_en; struct device *dev; struct completion c; @@ -657,12 +660,35 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi) f->selected = spi->chip_select; } -static void nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op) +static int nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op) { + u32 start = op->addr.val; u32 len = op->data.nbytes; + /* if necessary, ioremap before AHB read */ + if ((!f->ahb_addr) || start < f->memmap_start || + start + len > f->memmap_start + f->memmap_len) { + if (f->ahb_addr) + iounmap(f->ahb_addr); + + f->memmap_start = start; + f->memmap_len = len > NXP_FSPI_MIN_IOMAP ? + len : NXP_FSPI_MIN_IOMAP; + + f->ahb_addr = ioremap_wc(f->memmap_phy + f->memmap_start, + f->memmap_len); + + if (!f->ahb_addr) { + dev_err(f->dev, "failed to alloc memory\n"); + return -ENOMEM; + } + } + /* Read out the data directly from the AHB buffer. */ - memcpy_fromio(op->data.buf.in, (f->ahb_addr + op->addr.val), len); + memcpy_fromio(op->data.buf.in, + f->ahb_addr + start - f->memmap_start, len); + + return 0; } static void nxp_fspi_fill_txfifo(struct nxp_fspi *f, @@ -822,7 +848,7 @@ static int nxp_fspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) */ if (op->data.nbytes > (f->devtype_data->rxfifo - 4) && op->data.dir == SPI_MEM_DATA_IN) { - nxp_fspi_read_ahb(f, op); + err = nxp_fspi_read_ahb(f, op); } else { if (op->data.nbytes && op->data.dir == SPI_MEM_DATA_OUT) nxp_fspi_fill_txfifo(f, op); @@ -992,9 +1018,8 @@ static int nxp_fspi_probe(struct platform_device *pdev) /* find the resources - controller memory mapped space */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fspi_mmap"); - f->ahb_addr = devm_ioremap_resource(dev, res); - if (IS_ERR(f->ahb_addr)) { - ret = PTR_ERR(f->ahb_addr); + if (IS_ERR(res)) { + ret = PTR_ERR(res); goto err_put_ctrl; } @@ -1073,6 +1098,9 @@ static int nxp_fspi_remove(struct platform_device *pdev) mutex_destroy(&f->lock); + if (f->ahb_addr) + iounmap(f->ahb_addr); + return 0; } From patchwork Sun Feb 2 12:59:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 205201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42348C3524A for ; Sun, 2 Feb 2020 13:00:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 14A9B20658 for ; Sun, 2 Feb 2020 13:00:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WqHN4WNp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727024AbgBBNAN (ORCPT ); Sun, 2 Feb 2020 08:00:13 -0500 Received: from mail-yw1-f45.google.com ([209.85.161.45]:46809 "EHLO mail-yw1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726989AbgBBNAM (ORCPT ); Sun, 2 Feb 2020 08:00:12 -0500 Received: by mail-yw1-f45.google.com with SMTP id z141so10004339ywd.13; Sun, 02 Feb 2020 05:00:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g41y4TduYyE4Zq7XaNgfQZ1uBYpJA8BiIYoPp6mgrtE=; b=WqHN4WNpKRHbz5KbVH2wcfUM4s+eLtY9OB1l0MbE5xT7J+rxS0aIn+7YdN6npIGcj4 ufTxwcx8G+4HpLKqBnUZ+rvW2TGwx78OtAVlQOf7mjYPqIFlD7Us5llDzZ5gjQtPWhQ7 chCniMaQ6xBLI1Key30/9fisPEg9efhoDskNpki8mmFHbofIif5s1tgZyfgCuGTz75/V lszW4MSOXINJDGYfCFGrAflmi7s0zwSPrQhaHvJjCvpMpn1ePJ1NKK1T6L/GtoTOAkdr kmylhWwtX6Ed9iSE6LJNIQm8SX68upoP9DQz4m3rCCK3LEnZqXgCu2DhTf7l2SXfOky6 OxTg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=g41y4TduYyE4Zq7XaNgfQZ1uBYpJA8BiIYoPp6mgrtE=; b=mcPq6O/W+lXvAvZdMPA76FjeFDxrHyMGTF2POIBFObpVOuAJhUzRaCwOy4/zQC4eQh aKIu+O5nIb2q/gIFPlKBD3Sp4Jg+pbgCDnzGJLOvCj28J9BiY8CHrJDukADenuSHEY41 vp9qZjC5Z4EPWV0IXGw53JX1PHqv9gcaZqO9+VrOl6Lr/hpfZFO9iBMU2IKIp1rGDJYn AZmhG1rL3SBchCIskTtXGUptJFYh5XfEH53t5Rrl3Tlt16ASunxKlv8/saRnCaMVeNAI DYNAXeu05qpmgaguUOW67gELuye4e+jFA+KGoY3uM7eai7/dgbg/zyP3HsRCP17zIK68 vALA== X-Gm-Message-State: APjAAAVxB2rOphDB1yL0GisoMw9cAQDvZIXXupLc9qLCmNLEquhZ0TQU JCZR4prIR4fMrRW1nPDz246zb5P/3Wg= X-Google-Smtp-Source: APXvYqxESfjVSs4DtOWtMq7VLTeIVuSJZKG8ga+iAtfaG5fC/Sjp0XF06H7gjLbeQcvU/yBzLMS43Q== X-Received: by 2002:a81:a703:: with SMTP id e3mr15769631ywh.71.1580648408393; Sun, 02 Feb 2020 05:00:08 -0800 (PST) Received: from localhost.localdomain (c-73-37-219-234.hsd1.mn.comcast.net. [73.37.219.234]) by smtp.gmail.com with ESMTPSA id m137sm7090013ywd.108.2020.02.02.05.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Feb 2020 05:00:07 -0800 (PST) From: Adam Ford To: linux-spi@vger.kernel.org Cc: Adam Ford , Yogesh Gaur , Ashish Kumar , Mark Brown , Rob Herring , Mark Rutland , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH V2 4/5] dt-bindings: spi: spi-nxp-fspi: Add support for imx8mm, imx8qxp Date: Sun, 2 Feb 2020 06:59:49 -0600 Message-Id: <20200202125950.1825013-4-aford173@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200202125950.1825013-1-aford173@gmail.com> References: <20200202125950.1825013-1-aford173@gmail.com> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add support for nxp,imx8qxp-fspi and nxp,imx8mm-fspi do the bindings document. Signed-off-by: Adam Ford --- V2: No change diff --git a/Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt b/Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt index 2cd67eb727d4..7ac60d9fe357 100644 --- a/Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt +++ b/Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt @@ -2,6 +2,9 @@ Required properties: - compatible : Should be "nxp,lx2160a-fspi" + "nxp,imx8qxp-fspi" + "nxp,imx8mm-fspi" + - reg : First contains the register location and length, Second contains the memory mapping address and length - reg-names : Should contain the resource reg names: