From patchwork Mon Aug 6 15:12:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 953951 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41kh8v0n7Qz9s0n for ; Tue, 7 Aug 2018 01:17:35 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id D48D9C21EBB; Mon, 6 Aug 2018 15:14:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 34CA2C21E26; Mon, 6 Aug 2018 15:13:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D1700C21E5B; Mon, 6 Aug 2018 15:13:02 +0000 (UTC) Received: from mx2.mailbox.org (mx2.mailbox.org [80.241.60.215]) by lists.denx.de (Postfix) with ESMTPS id A5928C21E42 for ; Mon, 6 Aug 2018 15:12:56 +0000 (UTC) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 6D8C44154F; Mon, 6 Aug 2018 17:12:56 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id Dmuc1EhF3eTp; Mon, 6 Aug 2018 17:12:54 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Date: Mon, 6 Aug 2018 17:12:50 +0200 Message-Id: <20180806151253.31205-1-sr@denx.de> Cc: Boris Brezillon , Jagan Teki , Miquel Raynal Subject: [U-Boot] [PATCH 1/4] spi: spi-mem: Add optional half-duplex SPI transfer mode X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Some SPI controller might now support full-duplex SPI transfers. This option can be enabled to use half-duplex operation mode for such SPI controllers. Signed-off-by: Stefan Roese Cc: Miquel Raynal Cc: Boris Brezillon Cc: Jagan Teki --- drivers/spi/Kconfig | 8 ++++++++ drivers/spi/spi-mem.c | 31 ++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 9fbd26740d..5bd8289284 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -25,6 +25,14 @@ config SPI_MEM This extension is meant to simplify interaction with SPI memories by providing an high-level interface to send memory-like commands. +config SPI_MEM_HALF_DUPLEX + bool "Use half-duplex SPI transfer" + depends on SPI_MEM + help + Some SPI controller might not support full-duplex SPI transfers. + This option can be enabled to use half-duplex operation mode for + such SPI controllers. + config ALTERA_SPI bool "Altera SPI driver" help diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index 07ce799170..617fbbfe09 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -202,6 +202,10 @@ int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) struct dm_spi_ops *ops = spi_get_ops(bus); unsigned int xfer_len, pos = 0; u8 *tx_buf, *rx_buf = NULL; + unsigned int pos2; + int tx_len; + int rx_len; + u32 flag; int ret; int i; @@ -370,8 +374,29 @@ int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) if (tx_data) memcpy(tx_buf + pos, op->data.buf.out, op->data.nbytes); - ret = spi_xfer(slave, xfer_len * 8, tx_buf, rx_buf, - SPI_XFER_BEGIN | SPI_XFER_END); + pos2 = pos; + if (CONFIG_IS_ENABLED(SPI_MEM_HALF_DUPLEX)) { + if (rx_data) { + tx_len = (sizeof(op->cmd.opcode) + + op->addr.nbytes + op->dummy.nbytes); + rx_len = op->data.nbytes; + flag = SPI_XFER_BEGIN; + pos2 = 0; + } else { + tx_len = xfer_len; + rx_len = 0; + flag = SPI_XFER_BEGIN | SPI_XFER_END; + } + ret = spi_xfer(slave, tx_len * 8, tx_buf, NULL, flag); + if (rx_data) { + ret = spi_xfer(slave, rx_len * 8, NULL, + rx_buf, SPI_XFER_END); + } + } else { + ret = spi_xfer(slave, xfer_len * 8, tx_buf, rx_buf, + SPI_XFER_BEGIN | SPI_XFER_END); + } + spi_release_bus(slave); for (i = 0; i < pos; i++) @@ -387,7 +412,7 @@ int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) return ret; if (rx_data) - memcpy(op->data.buf.in, rx_buf + pos, op->data.nbytes); + memcpy(op->data.buf.in, rx_buf + pos2, op->data.nbytes); kfree(tx_buf); kfree(rx_buf); From patchwork Mon Aug 6 15:12:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 953947 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41kh5q56S3z9s0n for ; Tue, 7 Aug 2018 01:14:55 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5C40AC21DED; Mon, 6 Aug 2018 15:13:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 557F9C21E76; Mon, 6 Aug 2018 15:13:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 585BAC21E4E; Mon, 6 Aug 2018 15:13:03 +0000 (UTC) Received: from mx1.mailbox.org (mx1.mailbox.org [80.241.60.212]) by lists.denx.de (Postfix) with ESMTPS id 8D087C21E47 for ; Mon, 6 Aug 2018 15:12:58 +0000 (UTC) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 6226D48BD6; Mon, 6 Aug 2018 17:12:58 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id CNp00BKtt-mM; Mon, 6 Aug 2018 17:12:55 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Date: Mon, 6 Aug 2018 17:12:51 +0200 Message-Id: <20180806151253.31205-2-sr@denx.de> In-Reply-To: <20180806151253.31205-1-sr@denx.de> References: <20180806151253.31205-1-sr@denx.de> Cc: Boris Brezillon , Jagan Teki , Miquel Raynal Subject: [U-Boot] [PATCH 2/4] mtd: nand: Don't abort erase operation when a bad block is detected X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" It was noticed, that the erase command (mtd erase spi-nand0) aborts upon the first bad block. With this change, bad blocks are now skipped and the erase operation will continue. Signed-off-by: Stefan Roese Cc: Miquel Raynal Cc: Boris Brezillon Cc: Jagan Teki --- drivers/mtd/nand/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/core.c b/drivers/mtd/nand/core.c index 0b793695cc..888f765b90 100644 --- a/drivers/mtd/nand/core.c +++ b/drivers/mtd/nand/core.c @@ -162,7 +162,7 @@ int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo) nanddev_offs_to_pos(nand, einfo->addr + einfo->len - 1, &last); while (nanddev_pos_cmp(&pos, &last) <= 0) { ret = nanddev_erase(nand, &pos); - if (ret) { + if (ret && ret != -EIO) { einfo->fail_addr = nanddev_pos_to_offs(nand, &pos); return ret; From patchwork Mon Aug 6 15:12:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 953946 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41kh4c5NGMz9s0n for ; Tue, 7 Aug 2018 01:13:52 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 6F5C3C21DB6; Mon, 6 Aug 2018 15:13:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 940CBC21E7D; Mon, 6 Aug 2018 15:13:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 785C5C21E8A; Mon, 6 Aug 2018 15:13:02 +0000 (UTC) Received: from mx1.mailbox.org (mx1.mailbox.org [80.241.60.212]) by lists.denx.de (Postfix) with ESMTPS id 48F80C21E56 for ; Mon, 6 Aug 2018 15:12:57 +0000 (UTC) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 2067248C5C; Mon, 6 Aug 2018 17:12:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id TP3TiW1_Mx9A; Mon, 6 Aug 2018 17:12:55 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Date: Mon, 6 Aug 2018 17:12:52 +0200 Message-Id: <20180806151253.31205-3-sr@denx.de> In-Reply-To: <20180806151253.31205-1-sr@denx.de> References: <20180806151253.31205-1-sr@denx.de> Cc: Boris Brezillon , Jagan Teki , Miquel Raynal Subject: [U-Boot] [PATCH 3/4] cmd: mtd: Don't use with negative return codes for shell commands X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When negative return codes are used in commands (do_foo()), the shell prints these messages: exit not allowed from main input shell. Change the return codes in the new mtd commands to use only positive values and these annoying warnings are gone. Signed-off-by: Stefan Roese Cc: Miquel Raynal Cc: Boris Brezillon Cc: Jagan Teki --- cmd/mtd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/mtd.c b/cmd/mtd.c index 221b12500f..38a89736cf 100644 --- a/cmd/mtd.c +++ b/cmd/mtd.c @@ -188,7 +188,7 @@ static int do_mtd_list(void) if (!dev_nb) { printf("No MTD device found\n"); - return -EINVAL; + return EINVAL; } return 0; @@ -269,13 +269,13 @@ static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (mtd_is_aligned_with_min_io_size(mtd, off)) { printf("Offset not aligned with a page (0x%x)\n", mtd->writesize); - return -EINVAL; + return EINVAL; } if (mtd_is_aligned_with_min_io_size(mtd, len)) { printf("Size not a multiple of a page (0x%x)\n", mtd->writesize); - return -EINVAL; + return EINVAL; } if (dump) @@ -285,7 +285,7 @@ static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (!buf) { printf("Could not map/allocate the user buffer\n"); - return -ENOMEM; + return ENOMEM; } printf("%s %lldB (%d page(s)) at offset 0x%08llx%s%s\n", @@ -306,7 +306,7 @@ static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (ret) { printf("%s on %s failed with error %d\n", read ? "Read" : "Write", mtd->name, ret); - return ret; + return -ret; } if (dump) { @@ -346,13 +346,13 @@ static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (mtd_is_aligned_with_block_size(mtd, off)) { printf("Offset not aligned with a block (0x%x)\n", mtd->erasesize); - return -EINVAL; + return EINVAL; } if (mtd_is_aligned_with_block_size(mtd, len)) { printf("Size not a multiple of a block (0x%x)\n", mtd->erasesize); - return -EINVAL; + return EINVAL; } erase_op.mtd = mtd; From patchwork Mon Aug 6 15:12:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 953949 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41kh7s2ZMjz9s3q for ; Tue, 7 Aug 2018 01:16:41 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1D17EC21E4E; Mon, 6 Aug 2018 15:14:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8D25CC21E4E; Mon, 6 Aug 2018 15:13:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 85AF3C21E7D; Mon, 6 Aug 2018 15:13:02 +0000 (UTC) Received: from mx2.mailbox.org (mx2.mailbox.org [80.241.60.215]) by lists.denx.de (Postfix) with ESMTPS id 22F55C21E96 for ; Mon, 6 Aug 2018 15:12:57 +0000 (UTC) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id E278541103; Mon, 6 Aug 2018 17:12:56 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id 6_GTuJ-TC5Lm; Mon, 6 Aug 2018 17:12:55 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Date: Mon, 6 Aug 2018 17:12:53 +0200 Message-Id: <20180806151253.31205-4-sr@denx.de> In-Reply-To: <20180806151253.31205-1-sr@denx.de> References: <20180806151253.31205-1-sr@denx.de> Cc: Boris Brezillon , Jagan Teki , Miquel Raynal Subject: [U-Boot] [PATCH 4/4] cmd: mtd: Add info text to mtd erase subcommand X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Adding this info helps seeing, what really is being erased - especially if no arguments are passed for offset and size. Now this is the output: => mtd erase spi-nand0 Erasing 0x00000000 ... 0x07ffffff (65536 page(s)) nand: attempt to erase a bad/reserved block @6000000 nand: attempt to erase a bad/reserved block @7fe0000 Signed-off-by: Stefan Roese Cc: Miquel Raynal Cc: Boris Brezillon Cc: Jagan Teki --- cmd/mtd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/mtd.c b/cmd/mtd.c index 38a89736cf..6d27698d1e 100644 --- a/cmd/mtd.c +++ b/cmd/mtd.c @@ -355,6 +355,9 @@ static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return EINVAL; } + printf("Erasing 0x%08llx ... 0x%08llx (%d page(s))\n", + off, off + len - 1, mtd_len_to_pages(mtd, len)); + erase_op.mtd = mtd; erase_op.addr = off; erase_op.len = len;