Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3590479imu; Mon, 10 Dec 2018 04:53:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/WVI9ouUhQh1IFW/e+hikvzeWQbDib+p6fX7wzZPTRCuM7fDpmnNm1Wej74SVAlTyp+fxIn X-Received: by 2002:a17:902:ab84:: with SMTP id f4mr11764744plr.207.1544446387189; Mon, 10 Dec 2018 04:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544446387; cv=none; d=google.com; s=arc-20160816; b=nJxrcfJc/EFTHFS0vodIo1td+UVINcdI5wWnL6y4AKHEJiXiMxL1FOtSTcEmmwympq nSuZq/A4bjSbil4+3bCALvJ2yxsnRjWpU8jmWqgR2wy+pyFZOWe1maxbhqaTx0BiykH2 DHUxLL+VFd0eeQp25bnaM+pbQX+hUaer6Ba1RzoFife/UxG//ZO1gDdiYa30wmzVvlw8 6uvPkMlHxBiYEBma9966l+ge992Vg4nJYuxqiaWFQm/M8LFvQPrpnbQqxwok8IL+fUQk B0vCPcexqxA1LruVfbXIy4pe96PPdlfJ4D2dh/SPEq9TpqJ7ovlWB6ko+/l0pvmw09gW 7daA== 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:subject:cc:to:from:date; bh=UFMEWnAtpJyX7RgM1EXeXEYytf1bGnNzgsAG9DA3nyY=; b=bRE5RH0PYvodB6+cSBRPTAj2aWBI4cacmfgU0oZcsEY4KYX172ubs0yzvFOiy9WHFt TYyingWjL7Gqqv0mFb+nIL+Y4/U/x4hE1JgRYNRza7WK7w2tlWbFj5dLodsQ8n7xVfrV YAs+TiXdQq50CNqaaoyHPAW9tFqUY6FA8rgcia+rDKZa1jVH77b9GaGH8QaHSWgwgtwt jjgNuRwLQjGPcjISQ4zD2amFdZxmw8RuSc4GPH9lSGK6IO7wycJ3cP8lSeGf/rQNIGzM lVp5KLLhCxKJmXLb0iQfoUUl8635hOqHU+ltf8wN+UGmErDOE02tVfvmBdU99IkbfM7G JEHQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q25si9244416pgv.541.2018.12.10.04.52.51; Mon, 10 Dec 2018 04:53:07 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbeLJMNS (ORCPT + 99 others); Mon, 10 Dec 2018 07:13:18 -0500 Received: from mail.bootlin.com ([62.4.15.54]:60240 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726606AbeLJMNS (ORCPT ); Mon, 10 Dec 2018 07:13:18 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 04A5A20CEC; Mon, 10 Dec 2018 13:13:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from bbrezillon (aaubervilliers-681-1-79-44.w90-88.abo.wanadoo.fr [90.88.21.44]) by mail.bootlin.com (Postfix) with ESMTPSA id 9C81220CE8; Mon, 10 Dec 2018 13:13:15 +0100 (CET) Date: Mon, 10 Dec 2018 13:11:00 +0100 From: Boris Brezillon To: Yogesh Narayan Gaur Cc: Schrempf Frieder , "linux-mtd@lists.infradead.org" , "marek.vasut@gmail.com" , "broonie@kernel.org" , "linux-spi@vger.kernel.org" , "devicetree@vger.kernel.org" , "robh@kernel.org" , "mark.rutland@arm.com" , "shawnguo@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "computersforpeace@gmail.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v5 1/5] spi: spi-mem: Add driver for NXP FlexSPI controller Message-ID: <20181210131100.6e4801e2@bbrezillon> In-Reply-To: References: <1542366701-16065-1-git-send-email-yogeshnarayan.gaur@nxp.com> <1542366701-16065-2-git-send-email-yogeshnarayan.gaur@nxp.com> <20181210111909.35384eee@bbrezillon> <20181210115001.6c7af1d7@bbrezillon> <20181210120925.3c6336f6@bbrezillon> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 10 Dec 2018 11:25:55 +0000 Yogesh Narayan Gaur wrote: > Hi Boris, > > > -----Original Message----- > > From: Boris Brezillon [mailto:boris.brezillon@bootlin.com] > > Sent: Monday, December 10, 2018 4:39 PM > > To: Yogesh Narayan Gaur > > Cc: Schrempf Frieder ; linux- > > mtd@lists.infradead.org; marek.vasut@gmail.com; broonie@kernel.org; linux- > > spi@vger.kernel.org; devicetree@vger.kernel.org; robh@kernel.org; > > mark.rutland@arm.com; shawnguo@kernel.org; linux-arm- > > kernel@lists.infradead.org; computersforpeace@gmail.com; linux- > > kernel@vger.kernel.org > > Subject: Re: [PATCH v5 1/5] spi: spi-mem: Add driver for NXP FlexSPI controller > > > > On Mon, 10 Dec 2018 10:59:54 +0000 > > Yogesh Narayan Gaur wrote: > > > > > Hi Boris, > > > > > > > -----Original Message----- > > > > From: Boris Brezillon [mailto:boris.brezillon@bootlin.com] > > > > Sent: Monday, December 10, 2018 4:20 PM > > > > To: Yogesh Narayan Gaur > > > > Cc: Schrempf Frieder ; linux- > > > > mtd@lists.infradead.org; marek.vasut@gmail.com; broonie@kernel.org; > > > > linux- spi@vger.kernel.org; devicetree@vger.kernel.org; > > > > robh@kernel.org; mark.rutland@arm.com; shawnguo@kernel.org; > > > > linux-arm- kernel@lists.infradead.org; computersforpeace@gmail.com; > > > > linux- kernel@vger.kernel.org > > > > Subject: Re: [PATCH v5 1/5] spi: spi-mem: Add driver for NXP FlexSPI > > > > controller > > > > > > > > On Mon, 10 Dec 2018 10:43:56 +0000 > > > > Yogesh Narayan Gaur wrote: > > > > > > > > > > > Thus, in LUT preparation we have assigned only the base address. > > > > > > > Now if I have assigned ahb_buf_size to FSPI_FLSHXXCR0 register > > > > > > > then for > > > > > > read/write data beyond limit of ahb_buf_size offset I get data corruption. > > > > > > > > > > > > Why would you do that? We have the ->adjust_op_size() exactly > > > > > > for this reason, so, if someone tries to do a spi_mem_op with > > > > > > data.nbytes > ahb_buf_size you should return an error. > > > > > > > > > > > Let me explain my implementation with example. If I have to write > > > > > data of size > > > > 0x100 bytes at offset 0x1200 for CS1, I would program as below: > > > > > In func nxp_fspi_select_mem(), would set value of controller > > > > > address space > > > > size, memmap_phy_size, to FSPI_FLSHA2CR0 and rest all FSPI_FLSHXXCR0 as > > 0. > > > > > Value of memmap_phy_size is 0x10000000 i.e. 256 MB for my > > > > > LX2160ARDB > > > > target. > > > > > Then in nxp_fspi_prepare_lut(), I would prepare LUT ADDR with > > > > > address length > > > > requirement 3/4 byte for NOR or 1/2/3/4 bytes for NAND flash. > > > > > Also for LUT_NXP_WRITE would program data bytes as 0. > > > > > > > > > > Then inside func nxp_fspi_do_op(), set register FSPI_IPCR0 as the > > > > > address offset i.e. 0x1200 and in register FSPI_IPCR1 program the > > > > > data size to write i.e. 0x100 > > > > > > > > > > If, as suggested if I tries to mark value of register > > > > > FSPI_FLSHA2CR0 equal to > > > > ahb_buf_size (0x800), then access for address 0x1200 gives me wrong > > > > data. This is because as per the controller specification access to > > > > flash connected at CS1 can be performed under range of FSPI_ FLSHA1CR0 > > and FSPI_ FLSHA2CR0. > > > > > > > > Don't you have a way to set an offset to apply to the address > > > > accessed through the AHB? And if you don't, how will it work if your > > > > mapping is smaller than the flash size? > > > > > > Write operations are triggered using IP commands instead of AHB command. > > > For Read AHB command is used and in this we are adding the offset when > > performing memcpy_fromIO operation > > > memcpy_fromio(op->data.buf.in, (f->ahb_addr + op->addr.val), > > > len); > > > > > > AHB/IP operations are independent of the way how CS got selected. CS > > selection depends, e.g. CS1 on the value of register FSPI_FLSHA1CR0 and > > FSPI_FLSHA2CR0. > > > > > > Mapping can never going to be smaller than the connected flash size as per > > discussion with the Board design team and if it's possible by user manually > > changes the non-soldered part then flash area beyond complete mapping is not > > accessible. > > > On LX2160ARDB, with mapping of 256MB, for now we are having 4 flash > > devices connected with size as 64 MB. If user wants he can have only one single > > flash with flash size of 256MB. > > > > Given that the dirmap interface has now been merged and the MTD side of > > things is soon to be merged, I'd recommend you to implement it in your > > v6 and only use non-AHB accesses for the ->exec_op() implementation. > > This would going to be performance hit if I would use non-AHB accesses for ->exec_op(). Not if you implement the dirmap hooks.