{"id":812980,"url":"http://patchwork.ozlabs.org/api/patches/812980/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170912170931.29974-1-marek.vasut+renesas@gmail.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170912170931.29974-1-marek.vasut+renesas@gmail.com>","list_archive_url":null,"date":"2017-09-12T17:09:31","name":"[U-Boot] mtd: cfi: Add support for status register polling","commit_ref":"72443c7f7d2174903e73ee88dcb4364e0387bbb2","pull_url":null,"state":"accepted","archived":false,"hash":"65d9b24cd233dd400cdabda1469a448ef42d0e0c","submitter":{"id":1124,"url":"http://patchwork.ozlabs.org/api/people/1124/?format=json","name":"Marek Vasut","email":"marek.vasut@gmail.com"},"delegate":{"id":1696,"url":"http://patchwork.ozlabs.org/api/users/1696/?format=json","username":"stroese","first_name":"Stefan","last_name":"Roese","email":"sr@denx.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170912170931.29974-1-marek.vasut+renesas@gmail.com/mbox/","series":[{"id":2747,"url":"http://patchwork.ozlabs.org/api/series/2747/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=2747","date":"2017-09-12T17:09:31","name":"[U-Boot] mtd: cfi: Add support for status register polling","version":1,"mbox":"http://patchwork.ozlabs.org/series/2747/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/812980/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/812980/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"dlQW3y+e\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xsBFx4jGdz9s76\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 03:13:25 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 41E6EC21FE6; Tue, 12 Sep 2017 17:12:51 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 3744CC2203D;\n\tTue, 12 Sep 2017 17:12:49 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 45111C21D78; Tue, 12 Sep 2017 17:09:35 +0000 (UTC)","from mail-wr0-f195.google.com (mail-wr0-f195.google.com\n\t[209.85.128.195])\n\tby lists.denx.de (Postfix) with ESMTPS id 921E7C2207F\n\tfor <u-boot@lists.denx.de>; Tue, 12 Sep 2017 17:09:35 +0000 (UTC)","by mail-wr0-f195.google.com with SMTP id p37so6527614wrb.5\n\tfor <u-boot@lists.denx.de>; Tue, 12 Sep 2017 10:09:35 -0700 (PDT)","from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz.\n\t[86.49.107.50]) by smtp.gmail.com with ESMTPSA id\n\tw73sm5118132wmw.31.2017.09.12.10.09.34\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 12 Sep 2017 10:09:34 -0700 (PDT)"],"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=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,\n\tT_DKIM_INVALID autolearn=unavailable\n\tautolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id;\n\tbh=pkZI3s+0KFtcMzXTkLW6//TCiPHxbJApLROdN65OHMY=;\n\tb=dlQW3y+eF2ryTDHu5Y847a2o5BtaFIY/294kFwTa7tDbOTIoB5zUs5sWopZPT/tGtX\n\tzbLu78hV/Yq1AgPPnAesi+Rl8pt7x4yf8TgmTHiJMDpWCaaZJdiyg0tOPf6QvgtJBERM\n\t66rlmT2ZzGedZNuW1Ebw04X9ey1gU64wyfjnxMMViyXnj2k6bkqXCzTYrhM1WiDwgtEP\n\tvkFktbPX462UJ/NWdI+dfBOHDed/gj13m12Mljf5yPbPKUsX0w1y/g3E5hmmf1XZMZJZ\n\tyH9CofpKyHE3wZs67uGPK7qvZbMNbxg8Yu+qpd/xIvCe4Ru8Yc9b56OlluyLQIgYShcg\n\tR6DA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id;\n\tbh=pkZI3s+0KFtcMzXTkLW6//TCiPHxbJApLROdN65OHMY=;\n\tb=dLuVvxh2wseTNHlcG0V6/DGFN+5+qCdMB9siL1i7Iv+poxnJEqERQxwR6ZkGBzIuCz\n\t6yjMspofn79x09shw06b5ghdbbOZ9E6F812DzJblmW230qFYYcdNJ+SodGPOvnSBsufR\n\tBVZsBFgcQsmW5ekKCpc4FBj6Y6evsnCVd0eIcE9q+Jep3lj4SCui77bIE91Fxz+bmNZW\n\tnUGAcmWtCXImsBbCZmj/wChxiBQWMWb6sq3+nM+uOnRljXv9y+X5XslYfHHNRpfxu2Cj\n\tqoC6W5HAXTo8Fj3nxeVDu+fQVPPq+tM7ywo067QLotvkr2ScTSXdX6WJauynRmgVaV4j\n\tvDtw==","X-Gm-Message-State":"AHPjjUjWNc5bHapow3dEQNdbSISI1NjZ9peGZfIGW3Go4QW0Apw5x/tu\n\t5P1Re+pxf1M851Q/EfQ=","X-Google-Smtp-Source":"ADKCNb6mcbSQCv8lJjLneNU9LItl6nxcuBJWElbOKMZS64P5vQh4pfw1vor3WDx0SUrCvV/AXm+f8w==","X-Received":"by 10.223.130.116 with SMTP id\n\t107mr14083717wrb.240.1505236175050; \n\tTue, 12 Sep 2017 10:09:35 -0700 (PDT)","From":"Marek Vasut <marek.vasut@gmail.com>","X-Google-Original-From":"Marek Vasut <marek.vasut+renesas@gmail.com>","To":"u-boot@lists.denx.de","Date":"Tue, 12 Sep 2017 19:09:31 +0200","Message-Id":"<20170912170931.29974-1-marek.vasut+renesas@gmail.com>","X-Mailer":"git-send-email 2.11.0","Cc":"Marek Vasut <marek.vasut+renesas@gmail.com>","Subject":"[U-Boot] [PATCH] mtd: cfi: Add support for status register polling","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"The status register is optional in the AMD command sets, but it's\npresence can be checked by reading out CFI table entry 0xc bit 0.\nIf the register is present, prefer using it's bit 7 to determine\nif the flash is busy over reading the flash ; this is needed ie.\non Hyperflash memories.\n\nSigned-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>\n---\n drivers/mtd/cfi_flash.c | 15 ++++++++++++++-\n include/flash.h         |  1 +\n include/mtd/cfi_flash.h |  1 +\n 3 files changed, 16 insertions(+), 1 deletion(-)","diff":"diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c\nindex df04a425e2..8a5babea7b 100644\n--- a/drivers/mtd/cfi_flash.c\n+++ b/drivers/mtd/cfi_flash.c\n@@ -544,7 +544,16 @@ static int flash_is_busy (flash_info_t * info, flash_sect_t sect)\n #ifdef CONFIG_FLASH_CFI_LEGACY\n \tcase CFI_CMDSET_AMD_LEGACY:\n #endif\n-\t\tretval = flash_toggle (info, sect, 0, AMD_STATUS_TOGGLE);\n+\t\tif (info->sr_supported) {\n+\t\t\tflash_write_cmd (info, sect, info->addr_unlock1,\n+\t\t\t\t\t FLASH_CMD_READ_STATUS);\n+\t\t\tretval = !flash_isset (info, sect, 0,\n+\t\t\t\t\t       FLASH_STATUS_DONE);\n+\t\t} else {\n+\t\t\tretval = flash_toggle (info, sect, 0,\n+\t\t\t\t\t       AMD_STATUS_TOGGLE);\n+\t\t}\n+\n \t\tbreak;\n \tdefault:\n \t\tretval = 0;\n@@ -1685,6 +1694,7 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)\n {\n \tushort bankId = 0;\n \tuchar  manuId;\n+\tuchar  lsbits;\n \n \tflash_write_cmd(info, 0, 0, AMD_CMD_RESET);\n \tflash_unlock_seq(info, 0);\n@@ -1700,6 +1710,9 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)\n \t}\n \tinfo->manufacturer_id = manuId;\n \n+\tlsbits = flash_read_uchar(info, FLASH_OFFSET_LOWER_SW_BITS);\n+\tinfo->sr_supported = lsbits & BIT(0);\n+\n \tswitch (info->chipwidth){\n \tcase FLASH_CFI_8BIT:\n \t\tinfo->device_id = flash_read_uchar (info,\ndiff --git a/include/flash.h b/include/flash.h\nindex 0eedb1efa8..dc67cb2df6 100644\n--- a/include/flash.h\n+++ b/include/flash.h\n@@ -42,6 +42,7 @@ typedef struct {\n \tushort\tcfi_offset;\t\t/* offset for cfi query\t\t\t*/\n \tulong   addr_unlock1;\t\t/* unlock address 1 for AMD flash roms  */\n \tulong   addr_unlock2;\t\t/* unlock address 2 for AMD flash roms  */\n+\tuchar   sr_supported;\t\t/* status register supported            */\n \tconst char *name;\t\t/* human-readable name\t                */\n #endif\n #ifdef CONFIG_MTD\ndiff --git a/include/mtd/cfi_flash.h b/include/mtd/cfi_flash.h\nindex eade2b3614..095725a805 100644\n--- a/include/mtd/cfi_flash.h\n+++ b/include/mtd/cfi_flash.h\n@@ -62,6 +62,7 @@\n \n #define FLASH_OFFSET_MANUFACTURER_ID\t0x00\n #define FLASH_OFFSET_DEVICE_ID\t\t0x01\n+#define FLASH_OFFSET_LOWER_SW_BITS\t0x0C\n #define FLASH_OFFSET_DEVICE_ID2\t\t0x0E\n #define FLASH_OFFSET_DEVICE_ID3\t\t0x0F\n #define FLASH_OFFSET_CFI\t\t0x55\n","prefixes":["U-Boot"]}