From patchwork Thu Apr 23 17:00:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1102 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 38BB041496 for ; Thu, 23 Apr 2020 19:01:15 +0200 (CEST) Received: by mail-pl1-f199.google.com with SMTP id y12sf5093658plk.23 for ; Thu, 23 Apr 2020 10:01:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587661273; cv=pass; d=google.com; s=arc-20160816; b=Lxk2uG0c4KT/YipyaLn+P0kfnq1dvlXUia+2Mw+fTMJbemJOSXcZyZOBAeoVsaq0Cm 7+pO8hkh/CtfhsLlj8UD5DEagoNwd1FbsdWawWm4DLT6Al+szzBpiRgOhDwCr3h20VnK udTA+E8CzKD8f4FM/dUfT0IIOUflWWhjdeQT8j5LIqXedN9FcIskvY1tosiUkXGnPFDU S4pglTwzXOG0Tdy/SrDPOR1loZ5yUUuNLY4ubZe3ToGtgj2GMycwdBIlWFN694ipgSqX DBhKgAHqmpt+ICFQSlDJiDr/pP4DoBm2pv/CXit6vJrijuM2WMCHCLns1waDh282uoqb BKHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=q42jL4TAc4RtezyiarqHT/9v+VzcKjQCRHZ8mrDgUBI=; b=0oHYUrPcXUC54+k+oqwP2XZIo6npLFgldZtqnP8NzLVUfzuEES7E8nfFUilB5IDILh lvSITYBQtAQvnhXeMhWe7gqNmjvB3k4cm3OTs1oxTS7fzbfHZ9YtmAz4YROEZ3Ti6xZm dGJM7gAvEPdozU7SwnO2LqHPpYqaUC/P90c/B7Ra1bI5fxb4lIv40QUSEq9kqF1W8+20 dlHLPPWJzLsJUBGkpRN9dbfwhyLwaMV+vhky7/zYbfgIBOmVKYFW86qyhacGiGuj8xaD Rn8a29bRwbwjY7+VJasMf2pguy/KaKweAtybkJAr5uqiQVtC3OMNxmrUEX8gQAGwBnGX wEJA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=U1qF3hFm; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=q42jL4TAc4RtezyiarqHT/9v+VzcKjQCRHZ8mrDgUBI=; b=pbhFzOJjxvF/KJ0K5JCPUDqfYfUKfrUtMEpwkHehLwaFMoCZdVDNgS1J4rkxEvc3qg 4Az9ju8IECQdHrz3l6nvsIO8nDwYeksA48EvtshyAv8DmRYV+MotVH//o/u/xDcyOLwi 6qpCjRyPHsSIDUndRcPRiTpQqEhy00DgYHuVE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=q42jL4TAc4RtezyiarqHT/9v+VzcKjQCRHZ8mrDgUBI=; b=FiQ/VhNc/hpwv5i+5KGoL4VmpTqSTq6fSBxwTS7DPk/TGRHdbZsM7kulTYO6pGexg/ Ch5fKsF1oL9btH2HOQikc1YbdYdbFjwIy+FD6UCiB27x9fUD7B5IMcwchnKypsbmFpdM /tt4eiyOODE3aloARs0CYECpfoHuNmCvoskCfxxyL+QZjgUhk3+TFQ2woqJIzW4ghAC4 R1qdRaluP2kCwAWZEqZ4KZbbo6BzUGnPzi7Le2bEpyla/G0twMrcTNlxElGtDq3x9dI0 yPwMC9X0JnuQ4T2s2ZOgIx8sSlU/A0QyyM/BqQCWEXFVlK6QMMAPEns2caVQAaARXUFs nRug== X-Gm-Message-State: AGi0Pua48QMysW3mNEGD7T+X8IgsZGJ+SUU/PqkLBBCCw/Lq050zVy6S 5Bw+lSbZ0cKRbk/wkTYYm+vBEvM7 X-Google-Smtp-Source: APiQypIZXsrYrlzlvqPr9pjlRAfodEk6DbMMsjh8vU2KA277wVLTdhjI2DCxuuG7jFSvrH8JA08kbQ== X-Received: by 2002:a17:90a:a113:: with SMTP id s19mr1698293pjp.161.1587661272991; Thu, 23 Apr 2020 10:01:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:b58d:: with SMTP id a13ls3634086pls.0.gmail; Thu, 23 Apr 2020 10:01:12 -0700 (PDT) X-Received: by 2002:a17:902:7886:: with SMTP id q6mr4682012pll.237.1587661272302; Thu, 23 Apr 2020 10:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587661272; cv=none; d=google.com; s=arc-20160816; b=SYd+3Y15L9rB4Gv/nXunsFDKZPYmR2T7f/CIQ6Cy62iKESk1/2U1iXu9bAsy5FPVcY tt4NKN2/ltzwSunhkrhSXSW0NR/FSpuvmKOi9h6bfdILVmIgBYzq3sKvVQL+BwQ1D0De iH0oabTGn3BibyjlTpu8yZ3mzaYXqPpy5EvTQJnXh4tny0UGrIPWQSBq0F8VrZ08zeuS 6aLbQ143tFrAOyuz6a1q8XW3G23AqewzUDvFPmRGFj65GtqBpWi+lHX3ryty16m9oULD WHocp5usNbPcTikbm4uYNNDMD7cqKTlSqlIQ1RqKSs6KR+jAUGPg6iImH7F4W+qfNm6b J28A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LcwJfM3Q1vrrYUHu5ApI5aVGmdOtHzLucx1YE7tfUB4=; b=b3/YKDoEgwUv71NO9U3I5YvzAY7J699SjvmXnQ7zSvijU1m39MaCvRlmfWZcKkzC9T 4hkrCQQYD8toIVIR2b63cDWj9QMs83bgHNS9ksvkSnw4wAIaR9xiVtOX3fYmnxLrIpb2 mO31pMhMqqSPXj5T2mT1R0iUm9UZy0a7yg1TkgFIzC50UgPoMUtxx7SaM1FMlxOqXHZF TN36UjGVfr91uR8FZXEtwmuhUSYW7qxXYs90gcFCInJPoaLwwCv3jeTXGQI/1rlo9VYG MR/4IQvzOWRvEhu+lKRmf9L/auiAZK9XN00/fuZFfE3rghHjHvL80VsYHGWpc5PiNdH1 Ct2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=U1qF3hFm; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z21sor4022114pjr.26.2020.04.23.10.01.11 for (Google Transport Security); Thu, 23 Apr 2020 10:01:11 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:90a:1503:: with SMTP id l3mr1610964pja.87.1587661271121; Thu, 23 Apr 2020 10:01:11 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:587e:69d7:8a4e:a122]) by smtp.gmail.com with ESMTPSA id w2sm3084146pfc.194.2020.04.23.10.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 10:01:10 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Cc: Rick Chen , Bin Meng , Bhargav Shah , Sagar Shrikant Kadam , linux-amarula@amarulasolutions.com, Jagan Teki , Vignesh R Subject: [PATCH v4 1/5] spi: sifive: Add spi-mem exec op Date: Thu, 23 Apr 2020 22:30:53 +0530 Message-Id: <20200423170057.1976-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200423170057.1976-1-jagan@amarulasolutions.com> References: <20200423170057.1976-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=U1qF3hFm; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , SiFive SPI controller is responsible to handle the slave devices like mmc spi and spi nor flash. The controller is designed such a way that it would handle the slave transactions based on the I/O protocol numbers, example if spi nor slave send quad write opcode it has to send alone with I/O protocol number of 4 and if it try to send data it has to send I/O protocol number along with 4 line data. But the current spi-xfer code from spi-mem is combining the opcode and address in a single transaction, so the SPI controller will be unable to identify the I/O protocol number of opcode vs address. So, add the spi-mem exec_op with spi-xfer of opcode, address and data as a separate transaction. This doesn't remove the .xfer of dm_spi_ops since mmc spi will make use of it. Note: This code might have moved to the spi-mem core area once we have done the dedicated tests on other controllers and have real reason to move. Cc: Vignesh R Signed-off-by: Jagan Teki --- Changes for v4: - new patch drivers/spi/spi-sifive.c | 75 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c index 8f5efb51a3..5e612edcff 100644 --- a/drivers/spi/spi-sifive.c +++ b/drivers/spi/spi-sifive.c @@ -8,8 +8,9 @@ #include #include +#include #include -#include +#include #include #include #include @@ -241,6 +242,73 @@ static int sifive_spi_xfer(struct udevice *dev, unsigned int bitlen, return 0; } +static int sifive_spi_exec_op(struct spi_slave *slave, + const struct spi_mem_op *op) +{ + struct udevice *dev = slave->dev; + unsigned long flags = SPI_XFER_BEGIN; + u8 opcode = op->cmd.opcode; + unsigned int pos = 0; + const void *tx_buf = NULL; + void *rx_buf = NULL; + int op_len, i; + int ret; + + if (!op->addr.nbytes && !op->dummy.nbytes && !op->data.nbytes) + flags |= SPI_XFER_END; + + /* send the opcode */ + ret = sifive_spi_xfer(dev, 8, (void *)&opcode, NULL, flags); + if (ret < 0) { + dev_err(dev, "failed to xfer opcode\n"); + return ret; + } + + op_len = op->addr.nbytes + op->dummy.nbytes; + u8 op_buf[op_len]; + + /* send the addr + dummy */ + if (op->addr.nbytes) { + /* fill address */ + for (i = 0; i < op->addr.nbytes; i++) + op_buf[pos + i] = op->addr.val >> + (8 * (op->addr.nbytes - i - 1)); + + pos += op->addr.nbytes; + + /* fill dummy */ + if (op->dummy.nbytes) + memset(op_buf + pos, 0xff, op->dummy.nbytes); + + /* make sure to set end flag, if no data bytes */ + if (!op->data.nbytes) + flags |= SPI_XFER_END; + + ret = sifive_spi_xfer(dev, op_len * 8, op_buf, NULL, flags); + if (ret < 0) { + dev_err(dev, "failed to xfer addr + dummy\n"); + return ret; + } + } + + /* send/received the data */ + if (op->data.nbytes) { + if (op->data.dir == SPI_MEM_DATA_IN) + rx_buf = op->data.buf.in; + else + tx_buf = op->data.buf.out; + + ret = sifive_spi_xfer(dev, op->data.nbytes * 8, + tx_buf, rx_buf, SPI_XFER_END); + if (ret) { + dev_err(dev, "failed to xfer data\n"); + return ret; + } + } + + return 0; +} + static int sifive_spi_set_speed(struct udevice *bus, uint speed) { struct sifive_spi *spi = dev_get_priv(bus); @@ -348,11 +416,16 @@ static int sifive_spi_probe(struct udevice *bus) return 0; } +static const struct spi_controller_mem_ops sifive_spi_mem_ops = { + .exec_op = sifive_spi_exec_op, +}; + static const struct dm_spi_ops sifive_spi_ops = { .xfer = sifive_spi_xfer, .set_speed = sifive_spi_set_speed, .set_mode = sifive_spi_set_mode, .cs_info = sifive_spi_cs_info, + .mem_ops = &sifive_spi_mem_ops, }; static const struct udevice_id sifive_spi_ids[] = { From patchwork Thu Apr 23 17:00:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1103 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D692541496 for ; Thu, 23 Apr 2020 19:01:17 +0200 (CEST) Received: by mail-vk1-f198.google.com with SMTP id m76sf3119097vke.4 for ; Thu, 23 Apr 2020 10:01:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587661276; cv=pass; d=google.com; s=arc-20160816; b=Z9y7mtU001k6RqvqwAF0N5+SB4+wsqT4KG5v0EPlS29FoXqOE3SwP9kuKwHXWWQC3X 76yhPCJ7PoaZfW4nJ1OLcxbRfJLgGEwplQ1BCOrK+n+7eDB1F//hVYRa7FisggMn+4WZ yiACD2BF0RUGhJ+3Ukgqh6J4CJNEq23vlvRPnCXId4rqeew0lJlZ6FEuQKYx1qyOnlQ1 LeJkxBGt29RkE1XDeygH3ZJ3JS4EkGmEqHrTIk8QZfW+mDo6O+v8LibeteAtq+qewN6b g0rM0iF7dUjosmd0WEFECKib9H8IQtKKhCglZgOharmNm47ScdCA6WWYRB2KK/vcUOFf Zn0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7SlTWew0TF3iag0/N7v+xESCPRbLzQPDVc8yNx5sgTU=; b=BhgpVK95AKlBJxNr+WG/uymaJiYuZzW4EQcSVUP4KhMrbJ/dOBBzspxLn0/btd9JLE IW7yIL2Sj8jEctjEZYjUWYXRPd7CgTf0Z0/+QOMgAsFc4SXM8I9x3syA0BTkhng7WJc4 fKUKTK0jzZt0BMnhw4Fh1dMwaUgjTpZNNoGgwJVSACXFGbuArHrGZsPfHpqvt6zKrJh1 9uF1/nIhgTKAQ3zD0lbDMDMZx8mSzbycgTPq89JklmZAkAwRxVhYSl4H/hTQCZDBJn2S U9Q907ajpVAAgi8oRgswvV/qRp97QdHWQINDuhKVcwlDmzWW2aWJpblVHS9clRyPTIjS eAgQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jVxQJTEw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=7SlTWew0TF3iag0/N7v+xESCPRbLzQPDVc8yNx5sgTU=; b=S+p9oubVUdfUllj9W3zapBTESe8wUIK4GfYxd6GwyqLruYNhRpSUlNmxjt6rhkfpf4 to2iWiyrL5pBWDK3h+sjAZk052aWe/PayNKCPaOEMsToMvXXf1IiDlXiBYtfyTJdg21j Vol+wfGaWXGwb8Y/Uz4ce3KQElPBwOWSZV2Ps= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=7SlTWew0TF3iag0/N7v+xESCPRbLzQPDVc8yNx5sgTU=; b=P7OAg3Tt7ewrwO02S/eh86CdINZGjRwIDUO8MOIza/+Q2cw/TbiGEw9efyOA9XRoHt qvk/aBl1jA2+D2TpAVuKHwWUxIf6xTasgxhGbuPg6tiUvbChQuTkrkCOWdMNUPNld1XX vtjOSFevpGszRwSoylqSG+9EMX0q5KeGl6BP9Szpcfq1wCXFZJB1tl71SrEMnk/hF1iT Ij0FBUYeX5UN2R6NiBiBetw39M7543tw/wE0tTxyinCWZrt1Zt+YanFkTld5qsPP/8G+ IZGhIP/dRiUnR/b08+VGF/c9Mq6TZv9OfiucSWsEDM5smUUycHzvARFFIVJ3SbdefazB qtzA== X-Gm-Message-State: AGi0PuYSIpflO8gr0z8xjDmGQ6WWCrjY+HBvW406QllRzD5voulqgJmy CahksTd+5vPDt2JOXDTfC1386rzt X-Google-Smtp-Source: APiQypIPs2udK4PYO8+P52EvuKiE9oEGp3yoTi9pBg5VgtOfFkKzbhfNo0KcFWInM58TgpbrvEm0Lg== X-Received: by 2002:a1f:9148:: with SMTP id t69mr4137305vkd.83.1587661276434; Thu, 23 Apr 2020 10:01:16 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a67:f605:: with SMTP id k5ls963823vso.2.gmail; Thu, 23 Apr 2020 10:01:16 -0700 (PDT) X-Received: by 2002:a05:6102:409:: with SMTP id d9mr4135136vsq.220.1587661275915; Thu, 23 Apr 2020 10:01:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587661275; cv=none; d=google.com; s=arc-20160816; b=uiV0NVcCpZ+PUYzU4LriWyDvkcj98/x5HKhzQY3XhXmrSOzQPPfaEXhu2FdHswVKns 3NrZdGjQAGKPZrXw/viffBKbh+21AcFgkgO8e4yT5dahh4QEbtUsVppqLe2sXDpl5XjR MHqxLvLUICyUpM/tLB6voPuoY9RqNtgDF2+F6AaUBxThuwB+5bPuiczSA+VnxiN3RDpC O7HDcjmmDL1W5DBCjTtIwqnFrt+ZBwhP45/VsNM9Coa4pweQ1iuWYhVGw6eYdegwprD3 NEiEJSNM0vxMDHs5DiFSkSiF3dyFmxlQq2W5ImqNkt6WN2kxn24/M1oohjUqr8G4942v 2gCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=qd9a9Bpe2vulcb7CflNsSS2kb1zWBFdJUqbqnTGph44=; b=BVklzKB+M8VjZR/Umkji9tS8c1h6rb+fp6dii9y+FOtsHX3x6Lwsa17P21HzIcMjvM P9zYKeGGJgnDWBDz4KP/oiW5H3Sy3FRXIVo6u0h4ETKlRRyivtT/xdXGGt0n9fMYx85a 7E6fGcjgvhIL6o8CnX5iLhbPtiNRDrnoIq4TsKxbAoJNhtXhVK6JpAJyPdSYYTaYlQPm agyc7EJQwpFfXsuSojjzFvzzRRssAp/6eEe8OPBK1VJ0LeOLJK1eSjVaxp7wioEiePtN jZ9D5+1nZsRs9x4QFQi9kqwgL/OiZsfduhH93lsb6IlebRKoN54HzlMbwsMM2X9sqzc4 cpSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jVxQJTEw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r143sor1840200vke.25.2020.04.23.10.01.15 for (Google Transport Security); Thu, 23 Apr 2020 10:01:15 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:6a82:: with SMTP id n2mr2585644plk.159.1587661274661; Thu, 23 Apr 2020 10:01:14 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:587e:69d7:8a4e:a122]) by smtp.gmail.com with ESMTPSA id w2sm3084146pfc.194.2020.04.23.10.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 10:01:13 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Cc: Rick Chen , Bin Meng , Bhargav Shah , Sagar Shrikant Kadam , linux-amarula@amarulasolutions.com, Jagan Teki , Vignesh R Subject: [PATCH v4 2/5] spi: sifive: Fix format register proto field Date: Thu, 23 Apr 2020 22:30:54 +0530 Message-Id: <20200423170057.1976-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200423170057.1976-1-jagan@amarulasolutions.com> References: <20200423170057.1976-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=jVxQJTEw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , SiFive SPI controller has a proto bit field in frame format register which would be used to configure the SPI I/O protocol lines used on specific transfer.  Right now the driver is configuring this proto using slave->mode, for all types of transctions. This makes the driver unable to function since the proto needs to configure dynamically for each and every transaction separately at runtime. Now, the controller driver supports per transfer via spi-mem exec_opo, so add the fmt_proto flag and fill the per transfer buswidth so that the controller configures the proto bit at runtime. This patch fixes the SPI controller works with SPI NOR flash on quad read with page program. Cc: Vignesh R Signed-off-by: Jagan Teki --- Changes for v4: - new patch drivers/spi/spi-sifive.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c index 5e612edcff..0ea4930a0a 100644 --- a/drivers/spi/spi-sifive.c +++ b/drivers/spi/spi-sifive.c @@ -86,6 +86,11 @@ #define SIFIVE_SPI_IP_TXWM BIT(0) #define SIFIVE_SPI_IP_RXWM BIT(1) +/* format protocol */ +#define SIFIVE_SPI_PROTO_QUAD 4 /* 4 lines I/O protocol transfer */ +#define SIFIVE_SPI_PROTO_DUAL 2 /* 2 lines I/O protocol transfer */ +#define SIFIVE_SPI_PROTO_SINGLE 1 /* 1 line I/O protocol transfer */ + struct sifive_spi { void *regs; /* base address of the registers */ u32 fifo_depth; @@ -93,6 +98,7 @@ struct sifive_spi { u32 cs_inactive; /* Level of the CS pins when inactive*/ u32 freq; u32 num_cs; + u8 fmt_proto; }; static void sifive_spi_prep_device(struct sifive_spi *spi, @@ -147,12 +153,17 @@ static void sifive_spi_prep_transfer(struct sifive_spi *spi, /* Number of wires ? */ cr &= ~SIFIVE_SPI_FMT_PROTO_MASK; - if ((slave_plat->mode & SPI_TX_QUAD) || (slave_plat->mode & SPI_RX_QUAD)) + switch (spi->fmt_proto) { + case SIFIVE_SPI_PROTO_QUAD: cr |= SIFIVE_SPI_FMT_PROTO_QUAD; - else if ((slave_plat->mode & SPI_TX_DUAL) || (slave_plat->mode & SPI_RX_DUAL)) + break; + case SIFIVE_SPI_PROTO_DUAL: cr |= SIFIVE_SPI_FMT_PROTO_DUAL; - else + break; + default: cr |= SIFIVE_SPI_FMT_PROTO_SINGLE; + break; + } /* SPI direction in/out ? */ cr &= ~SIFIVE_SPI_FMT_DIR; @@ -246,6 +257,7 @@ static int sifive_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) { struct udevice *dev = slave->dev; + struct sifive_spi *spi = dev_get_priv(dev->parent); unsigned long flags = SPI_XFER_BEGIN; u8 opcode = op->cmd.opcode; unsigned int pos = 0; @@ -257,6 +269,8 @@ static int sifive_spi_exec_op(struct spi_slave *slave, if (!op->addr.nbytes && !op->dummy.nbytes && !op->data.nbytes) flags |= SPI_XFER_END; + spi->fmt_proto = op->cmd.buswidth; + /* send the opcode */ ret = sifive_spi_xfer(dev, 8, (void *)&opcode, NULL, flags); if (ret < 0) { @@ -284,6 +298,8 @@ static int sifive_spi_exec_op(struct spi_slave *slave, if (!op->data.nbytes) flags |= SPI_XFER_END; + spi->fmt_proto = op->addr.buswidth; + ret = sifive_spi_xfer(dev, op_len * 8, op_buf, NULL, flags); if (ret < 0) { dev_err(dev, "failed to xfer addr + dummy\n"); @@ -298,6 +314,8 @@ static int sifive_spi_exec_op(struct spi_slave *slave, else tx_buf = op->data.buf.out; + spi->fmt_proto = op->data.buswidth; + ret = sifive_spi_xfer(dev, op->data.nbytes * 8, tx_buf, rx_buf, SPI_XFER_END); if (ret) { From patchwork Thu Apr 23 17:00:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1104 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 7204841496 for ; Thu, 23 Apr 2020 19:01:22 +0200 (CEST) Received: by mail-pg1-f198.google.com with SMTP id 189sf5133243pgb.10 for ; Thu, 23 Apr 2020 10:01:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587661280; cv=pass; d=google.com; s=arc-20160816; b=OjNgkA4nA3ChvaZrnUtsIhR2NH578FikH+GtvsYUMSVPaq39sXZXfRBJ2O/Pb4LVa4 1/H0/uFppk/SGBXodyleYBQgVbECeTKIG2JmOVmM9K172Yhv+XRa8XgF5vAW7eTrwEco uI30YMVGJJPJCn96l2Dr4WUL2VUFmF72fY2VV6vKUKWkNYymIpSMfbDCTvoHEnyUGas1 1zYkajUVSQYZzTXq6Iggjr45ywdlXlTopxP/4xorjIW5TWKa3EMZqsk0Csmz/EUg36Lc gOLmGjn9Gn2hZRP0LSnXAnl8ngm15LWe6/nrxjyDPORoL+sDcitYR0unpvsgRTKRwIa2 Pr7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t6LAJVkpAaL0ZXpeRN3ytdpQJwB4DCSgldy+Oaubg2A=; b=b24CnlYEuxifPnwNQGms6JQKyI3GUhpdGrHYjwYCZ/CmTQSiemvCVwHyS/laVBtXN3 lwJNvGEazI9yIDa/Bey2BhvYEdM0BwSbYc5cGIx5uuYVFe8soFf1LdT3Ef0b+0qYW7RH xNuqazNjzQqqHqHENhFn+JQkNnEJQ3EogqU+y0ewqjRW256Ojz57eo06bOVlNUDypQ+g gnsJRarNaWe02PEyhK9gw939E5VqdVcuicPYVDqFuCJCoUe9Qw6KyRheljm6v/oaTXbm yW4Md4E4VZu+no1E48JAQYOmzIFQNvuiVxKoHexJdcT8hn84BPgtQ6upsrLSe496ZixN aYnA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RGyc7OiE; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=t6LAJVkpAaL0ZXpeRN3ytdpQJwB4DCSgldy+Oaubg2A=; b=Gl5l9j9uH9JJtiN4CB29d3d3MWRF7GFRyxFcwMfHBByAl+42916mER1SVq10qcPx88 qd3qbX8n/TlDz4dFUi0NI9hlJ6guITFglbrkdLTmUpCJG26VCVEiLoAlfZ9xOwXg3tNn f9VJsOFOyE94kEvnVB7+7vh395XDZpg3+aIzc= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=t6LAJVkpAaL0ZXpeRN3ytdpQJwB4DCSgldy+Oaubg2A=; b=p3/xwtjyIaEbsNoWsu9X60u9PLAQOwoZzSkJCgssJAEuYlXzSTXWUtYEYeqIPykrmR Grj8n/JIRcCTRbb1PG2VkoU0THncj001gehPkoCrKD24qsoFPdGYJAQIt4+G2ks6DJlM EO4jpt0IGmxSBirIiRyTwF2D4J7CKwzvzKDCSjZrsIG2tjx41TSYMo6UQzHjoJrBjc9o VdC5EE1P189W9LGTO1GxqBRg9+pbQIOeFARfeHfYxddjpH29I37SPJaxBUevJmjHbL3T XxjyIIQGaOlY87EZ0CEbEA3gCb7gt35pc7bcOqqKno1nlHWVlpXHpVm5SVzJJA2YnuOl IBdw== X-Gm-Message-State: AGi0PuYBXET7NMuZX0zk4qKFhqjohnWIHuCRG0nj/6vqVC9wNy9Uz4fc d6v9iduTIObO3rEyXvoM+oapbOiM X-Google-Smtp-Source: APiQypIaAImu0z69qbQJwRclIqWwUFav/xbNAMjJFvqQdmpW6OtUg8524AbIlm4+VF562OsPnUiMaw== X-Received: by 2002:aa7:8bc8:: with SMTP id s8mr4765257pfd.252.1587661279461; Thu, 23 Apr 2020 10:01:19 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:7203:: with SMTP id ba3ls692831plb.4.gmail; Thu, 23 Apr 2020 10:01:19 -0700 (PDT) X-Received: by 2002:a17:90a:dd45:: with SMTP id u5mr1615008pjv.19.1587661278900; Thu, 23 Apr 2020 10:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587661278; cv=none; d=google.com; s=arc-20160816; b=wfvPaI7G9L3pMo/O678cMi4y2C4v7BDKavTAsgFUMqcCEOHPU/8RYETBLE7/vIffnT A4Nu1a5oQHpqH+ih0kwtF5mDixvxTSP9i4UQs9TpL6XxUzPO4Biy90GfExaCDVYp4mzo bnLeXCtRDewMsA6mSXQjwaDaSSEq9sk9qjb4POs6XD+wATsPjQq2pnifw4fOKZhZlKq3 7thq4NYNL5pAqTkUC/gwGRMcTgeRNWOVSzs8FnlHwp86g/pWM2BEt5teUXOl5yOTp+hk pGw4uX3OtOvZFvbeyZe3dwn060gEg3mzrafrhv7tTG6xkuY+4njgELhzRJ3oQzCopEh6 lLOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=TaI2O8vgjlonnoHlMX0+YV2RvJ2UJQpboIKrb8XT2P4=; b=pktWVaWKLzjJfri/5NKnBCQOgpd4tYwmWNwDvK3SFiOiQPSgmm+zoGwxbyAqNnFkYZ EKk8YdqcIgaI0eIMOTEVpLrbcJ5gGEjXWWcykBT8wMW50z91voUk8KHKImEJiDEmDJyz uoW0ANcwVcpS2dph3RuyKNgB+Dnswnc/9C9c0TujPF9dp/HPTcplyu5fwtEwIAuRsNWT uCGnvSOcW6JogvfmGicE1dLjmGc69MQ+TJl/qIoYWKdus5nNYzTdc3h7S9XVSq6pSZAB FOHVH1OBr2Z+efk3SYsIimCuOUTP7oYbAsn6CufksxkxFD4aWc3p1YebpXKGyR13imUc AeUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RGyc7OiE; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id fz9sor4192611pjb.22.2020.04.23.10.01.18 for (Google Transport Security); Thu, 23 Apr 2020 10:01:18 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:90a:2526:: with SMTP id j35mr1626704pje.98.1587661278463; Thu, 23 Apr 2020 10:01:18 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:587e:69d7:8a4e:a122]) by smtp.gmail.com with ESMTPSA id w2sm3084146pfc.194.2020.04.23.10.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 10:01:17 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Cc: Rick Chen , Bin Meng , Bhargav Shah , Sagar Shrikant Kadam , linux-amarula@amarulasolutions.com, Jagan Teki , Vignesh R Subject: [PATCH v4 3/5] spi: sifive: Fix QPP transfer Date: Thu, 23 Apr 2020 22:30:55 +0530 Message-Id: <20200423170057.1976-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200423170057.1976-1-jagan@amarulasolutions.com> References: <20200423170057.1976-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RGyc7OiE; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The guessed reason is that the existing logic of filling tx fifo with data, rx fifo with NULL for tx transfer and filling rx fifo with data, tx fifo with NULL for rx transfer is not clear enough to support the Quad Page Program.     SiFive SPI controllers have specific sets of watermark registers and SPI I/O directions bits in order to program SPI controllers clear enough to support all sets of operating modes.     Here is the exact programing sequence that would follow on this patch and tested via SPI-NOR and MMC_SPI.     - set the frame format proto, endian - set the frame format dir, set it for tx and clear it for rx - TX transfer:   fill tx fifo with data.   wait for TX watermark bit to clear. - RX transfer:   fill tx fifo with 0xff.   write nbytes to rx watermark register   wait for rx watermark bit to clear.   read the rx fifo data. So, this patch adopts this program sequence and fixes the existing I/O direction bit. Cc: Vignesh R Signed-off-by: Jagan Teki --- Changes for v4: - update commit message drivers/spi/spi-sifive.c | 57 ++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c index 0ea4930a0a..4cab0391f7 100644 --- a/drivers/spi/spi-sifive.c +++ b/drivers/spi/spi-sifive.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -134,8 +135,8 @@ static void sifive_spi_clear_cs(struct sifive_spi *spi) } static void sifive_spi_prep_transfer(struct sifive_spi *spi, - bool is_rx_xfer, - struct dm_spi_slave_platdata *slave_plat) + struct dm_spi_slave_platdata *slave_plat, + u8 *rx_ptr) { u32 cr; @@ -167,7 +168,7 @@ static void sifive_spi_prep_transfer(struct sifive_spi *spi, /* SPI direction in/out ? */ cr &= ~SIFIVE_SPI_FMT_DIR; - if (!is_rx_xfer) + if (!rx_ptr) cr |= SIFIVE_SPI_FMT_DIR; writel(cr, spi->regs + SIFIVE_SPI_REG_FMT); @@ -198,13 +199,19 @@ static void sifive_spi_tx(struct sifive_spi *spi, const u8 *tx_ptr) writel(tx_data, spi->regs + SIFIVE_SPI_REG_TXDATA); } +static int sifive_spi_wait(struct sifive_spi *spi, u32 bit) +{ + return wait_for_bit_le32(spi->regs + SIFIVE_SPI_REG_IP, + bit, true, 100, false); +} + static int sifive_spi_xfer(struct udevice *dev, unsigned int bitlen, const void *dout, void *din, unsigned long flags) { struct udevice *bus = dev->parent; struct sifive_spi *spi = dev_get_priv(bus); struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); - const unsigned char *tx_ptr = dout; + const u8 *tx_ptr = dout; u8 *rx_ptr = din; u32 remaining_len; int ret; @@ -217,31 +224,37 @@ static int sifive_spi_xfer(struct udevice *dev, unsigned int bitlen, return ret; } - sifive_spi_prep_transfer(spi, true, slave_plat); + sifive_spi_prep_transfer(spi, slave_plat, rx_ptr); remaining_len = bitlen / 8; while (remaining_len) { - int n_words, tx_words, rx_words; - - n_words = min(remaining_len, spi->fifo_depth); + unsigned int n_words = min(remaining_len, spi->fifo_depth); + unsigned int tx_words, rx_words; /* Enqueue n_words for transmission */ - if (tx_ptr) { - for (tx_words = 0; tx_words < n_words; ++tx_words) { - sifive_spi_tx(spi, tx_ptr); - sifive_spi_rx(spi, NULL); - tx_ptr++; - } + for (tx_words = 0; tx_words < n_words; tx_words++) { + if (!tx_ptr) + sifive_spi_tx(spi, NULL); + else + sifive_spi_tx(spi, tx_ptr++); } - /* Read out all the data from the RX FIFO */ if (rx_ptr) { - for (rx_words = 0; rx_words < n_words; ++rx_words) { - sifive_spi_tx(spi, NULL); - sifive_spi_rx(spi, rx_ptr); - rx_ptr++; - } + /* Wait for transmission + reception to complete */ + writel(n_words - 1, spi->regs + SIFIVE_SPI_REG_RXMARK); + ret = sifive_spi_wait(spi, SIFIVE_SPI_IP_RXWM); + if (ret) + return ret; + + /* Read out all the data from the RX FIFO */ + for (rx_words = 0; rx_words < n_words; rx_words++) + sifive_spi_rx(spi, rx_ptr++); + } else { + /* Wait for transmission to complete */ + ret = sifive_spi_wait(spi, SIFIVE_SPI_IP_TXWM); + if (ret) + return ret; } remaining_len -= n_words; @@ -395,6 +408,10 @@ static void sifive_spi_init_hw(struct sifive_spi *spi) /* Watermark interrupts are disabled by default */ writel(0, spi->regs + SIFIVE_SPI_REG_IE); + /* Default watermark FIFO threshold values */ + writel(1, spi->regs + SIFIVE_SPI_REG_TXMARK); + writel(0, spi->regs + SIFIVE_SPI_REG_RXMARK); + /* Set CS/SCK Delays and Inactive Time to defaults */ writel(SIFIVE_SPI_DELAY0_CSSCK(1) | SIFIVE_SPI_DELAY0_SCKCS(1), spi->regs + SIFIVE_SPI_REG_DELAY0); From patchwork Thu Apr 23 17:00:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1106 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 0DDA641496 for ; Thu, 23 Apr 2020 19:01:36 +0200 (CEST) Received: by mail-oo1-f69.google.com with SMTP id j4sf4461479oot.10 for ; Thu, 23 Apr 2020 10:01:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587661294; cv=pass; d=google.com; s=arc-20160816; b=R7ZHfIJIxfF/ndgMba60x+NdiaxvvEyLhlMGGgD9NogKxoWdinWxKie7xVKtxyupq/ ta2dPTWZm2MDMgA9b3MTLQ/P0iWtecnNCSy6qV/dwWL33VbEh32UFo1Vch1/gdMWYry2 aZt3ymhKAfMnPJR1l2So2m9P91dflxQZL1AHJ+iYU6fiDGkxjw9jwoeWr/8ERKCHXwYj tQ342+Pb0XNNwndlCNnGweJYQDipi85mINjz3E8iP7dqca2q3WfJ08TfEQtTArU8WtJV N+09ZYzLDXGhUeq+q6GLbVCffWT7QDf6K01+xhfOtnI3Y3lTnXXbLAt4WlcTwcFyaUOz hrxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=gm0UxkOf+X2YUs4bozzJAMCRBNvGmtg1o3PBV/6lGl4=; b=TJ6xtXJQgF5hqzkmcidxMhD2JiJS6Z0EoT3N5g+NsbA9QAJVJLmX9Q2mjlzjM5lASI Y5+PhfhBNcAmew3dzTqVHZBLh5TvB4Kb55I6GUASPbTMtiJIK1i3jOwKST5Hbcs5MsD3 xMkkrXBrb4HaiO1dOjdrbu4S0usGUwnwEcZ5RdSJ0RJTj+lvig7LL40v86KrrtBICTki /pH1GZK1gjZOMqNWgaoOZjUSqcqKX0vD4VjvSeGd+wVgWJS8XPNvrKlubtJ98Ze3ea1w Tp7ij7dvGRrcz50Q176p3TUR0Ke9TWdUyuGZwrkCvVZw2gffao29uDqixriCysdOeIbD xDOw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Svq4CLnb; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=gm0UxkOf+X2YUs4bozzJAMCRBNvGmtg1o3PBV/6lGl4=; b=j39lq2qzukZQC46kiqXk5udP10dKzsuV6BTZ2BfRVRDYuWdauPvbE9VpWYXFYs3aOW g/iyTSkQTg7wqJEWqnOfrpfpZd5SHYrh+gPQcS9AxmC6M4IJi7pkdAe96kAIbmHIv58+ sJRh+z1yctWWhYGALL6f90/xbUhmesAYGJcsY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=gm0UxkOf+X2YUs4bozzJAMCRBNvGmtg1o3PBV/6lGl4=; b=JnwUHBuDlS7AOSceOhbKAO0XRNK5koDzpLLyzgQZ1kdRwAasYCLT6v2Hcnhz+fP4CN sdLcp5VD46mosAySeHOUdBz/cI6uSeI9aJekTVSTivys+hwH+5gP+IDRaNPcUjr/rZTt 6wc70vo3TOBcLbVTIvzotVQnygNAtg8szuAv2w35knqyoLXOdmHr4niKfSe5p18/u/if 90T4QORfOKeEhfLNa31paiMZ6un986iIqgMkT2Y4+PImwZWU/7rVAQocIofjPQUKAfa1 HdACAbAKK5ebLxBi71+4gaCC9yEW0sZQBIECzjqPeNt5lfZ5p3zQ+3QM4SJzVO/mnpq9 ViMA== X-Gm-Message-State: AGi0PuamFdDBrziONsGWLl3/kftlPY2QU2rLnuAZtzhUd7XSFDEkTk1q 0LvPaQ8Lzw+7go0HgbuntQ7IT7ML X-Google-Smtp-Source: APiQypLNT6igUQVOxY5gcLQBKmie6ppjqeSpbduLGanXamLRYPiME15O2OfSNfqZamzY4yDhaN7tzg== X-Received: by 2002:a9d:876:: with SMTP id 109mr4275362oty.327.1587661283768; Thu, 23 Apr 2020 10:01:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:aca:3104:: with SMTP id x4ls1004953oix.0.gmail; Thu, 23 Apr 2020 10:01:23 -0700 (PDT) X-Received: by 2002:aca:ccc6:: with SMTP id c189mr3777878oig.161.1587661283357; Thu, 23 Apr 2020 10:01:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587661283; cv=none; d=google.com; s=arc-20160816; b=TWbgvLYAN3tbyN4QKDsfvQbgF7vrJbWgjRx3QnY/WvHT/ipwTPFCjg90W58iHcRMM0 ev1LR5e0OJvMQpdzkBvmrAoA5WGLidSRaIG4EaSKb/zBMINITxqw9fpJ0/ruRM4FIRHG O4qqigVYt/lSHBYdKakkW92hbj4VxbY1PkWz/ufr0AlGTru1endQAGwMG9CeKDWNVlit hOXeAm//EYM+SVbJzvsDdloACDnA8YZ43WJaAFNs5hlYP3MZtMlDn+LaJpnH9dHBdisd rXlVn2vuzWOQR/NDuTDafqzVL0qMPU22D5ryRjRohFC0Mjw1sRUmi498sxrmeIAAczQG MWAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k0YrpQC+91MUPCn2k+GzSyEGhNt99n6//iMaa6hZSTc=; b=nEzdoRbb+cKNaTK5GiEcYFvhBisO1qPXy+NZoIK+gHFqMsi2bAtd40SE1Nu9zAAf84 Uwm8YiVuqwwzT+UjoaK79pezZfETnkZ9oT/XGegE2wupY46Nc+JrVSBCCf5LQz1/ASjB 0ViRgmr42jVO4+Hfo/EDJi8qyqqQNYHlBWx+u01hpwK5dS0RvxS1R+EHP5x/9NtyV1Zw lW/DeJn8FhX6aql3hFl0wkhnhVvJVVSet/v1sJEY359Nh5Rt6tlgsH9VZAByzIliD5c1 zCSBaFmsxxIdS04fXnpNudU5smi1X//zOSIxPte4wQMRvyKc2ZSiqGvJ78qRQNdeN429 N+UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Svq4CLnb; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id o4sor2444088ota.139.2020.04.23.10.01.22 for (Google Transport Security); Thu, 23 Apr 2020 10:01:22 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a63:b958:: with SMTP id v24mr4834629pgo.138.1587661282062; Thu, 23 Apr 2020 10:01:22 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:587e:69d7:8a4e:a122]) by smtp.gmail.com with ESMTPSA id w2sm3084146pfc.194.2020.04.23.10.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 10:01:21 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Cc: Rick Chen , Bin Meng , Bhargav Shah , Sagar Shrikant Kadam , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v4 4/5] riscv: dts: hifive-unleashed-a00: Add -u-boot.dtsi Date: Thu, 23 Apr 2020 22:30:56 +0530 Message-Id: <20200423170057.1976-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200423170057.1976-1-jagan@amarulasolutions.com> References: <20200423170057.1976-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Svq4CLnb; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add U-Boot specific dts file for hifive-unleashed-a00, this would help to add u-boot specific properties and other node changes without touching the base dts(i) files which are easy to sync from Linux. Added spi2 alias for qspi2 as an initial u-boot specific property change. spi probing in current dm model is very much rely on aliases numbering. Even though the qspi2 can't come under any associated spi nor flash it would require to specify the same to make proper binding happen for other spi slaves. Signed-off-by: Jagan Teki Reviewed-by: Bin Meng Acked-by: Rick Chen --- Changes for v4: - update licence arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi new file mode 100644 index 0000000000..8a784b5661 --- /dev/null +++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Copyright (C) 2019 Jagan Teki + */ + +/ { + aliases { + spi2 = &qspi2; + }; +}; From patchwork Thu Apr 23 17:00:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1105 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 83D4C41496 for ; Thu, 23 Apr 2020 19:01:27 +0200 (CEST) Received: by mail-lf1-f72.google.com with SMTP id t194sf2568736lff.20 for ; Thu, 23 Apr 2020 10:01:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587661286; cv=pass; d=google.com; s=arc-20160816; b=YbVCQ+CIBSi6ijCkOeRpT6T2n74nq3PUbWzE6+jgPTt2k/9Pr3kzTdrNjhhTYU5w6L uHtCAQQfa5thGClT66owXSH8f9w9qy4JYH6v8DsbKF8EZKjiEU4AwiS0I4aJlqesUuNq mf91Z+lg+S4+cgHZbuY0lhCvNuhnmdCw2HcaAB7CudlDXg8IcPAidVRg2cFyX0ndSCT5 xOA7f/DCLwuLD+BatE+tD98Hotn1FGhlT/E6EgPHDHPAu51SdEq7gJXdjA3w7O+Mfg12 CFyM/sjGlDKh1L0cZ98xSmuRyqjwgbvXjWVRuZmVzYbwIohd2nfhQKZ/cw26KHyfMrrc ykVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=td/0XIJTun5DlX/1Ork8IgcGLlWQt7TS1gMh0q8Lwpk=; b=Q6C0Zf0Kz2Nabd+3phK7RxkQT8ZlJ8fyLZ1UHEjm9Y984ouAMBdnVuJbn2UYvHj247 FEd/VB0WKCvTs7Rl21ujDJ861jhReyFLl8U4qjoyfQIRF0PWv3dtXoY7uTunVXB43vfk Vx+kfUdfQZ/Bokh0PrZUBBqRqnLExtrkB00hZLZ+22bjv/orbjQLevnUF2Y2+OYGi/jE icxyI4nsIY7tUerPp2WBbGUZBCpJTf1EvsilWaNfUjMOytvJGzNkhCLMeU0dsFmtpKWm JijPYLUcIlC0sZW3m8mQ9OSheCMl9nOZW1WatKhl9eLD5cvcWrJL/6v8pl1jV203GRlZ YWqA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PfE+vYEL; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=td/0XIJTun5DlX/1Ork8IgcGLlWQt7TS1gMh0q8Lwpk=; b=earKTMruy6OvB60L4LSwX8YHaPmWI1PjbjFtKU9I/Zp/GBlhzgTUzRVZIei66s+GMF nUYIcnVP0rHx41tv4RSGs4Oz3P6eaqTsuTs+fnFzbIgQTXyDKXTSeNjFrm0sLGQKu5Kt KY49P0ipJxe89qwvv4Ty6AkKHswyz79meBLEc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=td/0XIJTun5DlX/1Ork8IgcGLlWQt7TS1gMh0q8Lwpk=; b=cKPHEQ5nn59uH/nt/HFJKP/HDhC4b/u+u4E4fFPf5m8BcWy90bZc3RZxNYlIjtczgr jPnpiaC+SlTkhWxP8wvHPV7kRNu8+iz+6VfFuI46CdofXZmKpCBWqTPgwSZGigatBbfk f4TQ6Um1behahpoG/6IeDtryww3NhCYZA/hdPZof5F8sw7KMZTLaL/WjnvhyT8W+YuX4 q7Z9jNhtznVzWWBrqgjdTQgE/cBnaCAdDgWtRAr9fZ3kHAOP/mvcLrNHsgT8GvrMW6Ei iz1BmWwUB9v0zPPoSJdCRYLtST/a2NVK4ikPDEy8FZPc3eIkPL/0B4NNUCmmTHICIy4q MKIw== X-Gm-Message-State: AGi0PuYKoXDyvVMCIEtPqpE5bXj+W7hl4XCdAuoGjGoadZrVA+UlMJAy SPTfu4eKXbmd6cHGaW/PvlBFBTRf X-Google-Smtp-Source: APiQypK5YXrlaSFTetjThs0GWyIn28piDcR1jEvNCQqPYZfv4FH4sDWXVtYXaNHqIqFtpnetEWMvRw== X-Received: by 2002:ac2:515d:: with SMTP id q29mr3005343lfd.210.1587661286678; Thu, 23 Apr 2020 10:01:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a2e:9ad6:: with SMTP id p22ls1836242ljj.9.gmail; Thu, 23 Apr 2020 10:01:26 -0700 (PDT) X-Received: by 2002:a2e:b0d4:: with SMTP id g20mr3024187ljl.18.1587661285912; Thu, 23 Apr 2020 10:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587661285; cv=none; d=google.com; s=arc-20160816; b=yY/aRrFGNBGblrXCDmC1k39joU47T/ySPectKK6+eDB1itOTb4rjr+zGhego3NGOvG 65gGLfmoflbZVsm47Z7s2vwJfS6WW8I9pIl8xPOQvD2/QDKiYRsd3FEwnQp6mIHwFYLc XetCrXXrnoUj5yw7CXkT6SrI3uY7Gmt81xZMMJVzSPuoVpyyvWVB8X6A6aEfFyWfOuiA RGZox+MxChT1b+q/DTxze70if8uCh9SliiR3x9iz2aSj/aVz8WHBIGR0KUk16sgrmUW/ sZVlh+Cplvw9MyjwQvJXll4sHfOB1xDksRli0GozVTEKcn1RQUh76TOqAhlj0ItR1xDy vYKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4DJ8blU0pKMEwm2LZNMw134WzspD8GP8ZufWnbni/pk=; b=MjFSUP0/z8afbdsrmW2e34XW2CwfFYI1B7WbwdhbgK2do/f4JJDvHlOoi9FrzVV1J+ KWiu9WY0ePr2VxRhMVz90eNSXSYxS/aSF6ol5ARXamaOCSzAdp0XYG/f5dfVHr1H0ajy VcHvUsebAvQFu2HD0wKHELDasgnql+i7FoDPLndnIleB4l+/TFnKElHQj7gPxMa8SGYH bqRfpFBiHR0GQY/WtbKEF0XWeI4nRR++9ZfAj/4UJM+K3ciqsg4RRHTeaDuu0QEn46zn NlV2J9mNxXiEkHR4qxzOKiTHq6xUEFSJXB6A87wAfegpmmYn5gvEaaLCHdC4CO1rAaTb vWyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PfE+vYEL; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y29sor1308299lfb.5.2020.04.23.10.01.25 for (Google Transport Security); Thu, 23 Apr 2020 10:01:25 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:ac8d:: with SMTP id h13mr4669835plr.267.1587661285415; Thu, 23 Apr 2020 10:01:25 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:587e:69d7:8a4e:a122]) by smtp.gmail.com with ESMTPSA id w2sm3084146pfc.194.2020.04.23.10.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 10:01:24 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Cc: Rick Chen , Bin Meng , Bhargav Shah , Sagar Shrikant Kadam , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v4 5/5] sifive: fu540: Enable spi-nor flash support Date: Thu, 23 Apr 2020 22:30:57 +0530 Message-Id: <20200423170057.1976-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200423170057.1976-1-jagan@amarulasolutions.com> References: <20200423170057.1976-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=PfE+vYEL; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , HiFive Unleashed A00 support is25wp256 spi-nor flash, So enable the same and add test result log for future reference. Tested on SiFive FU540 board. Signed-off-by: Jagan Teki Reviewed-by: Bin Meng Acked-by: Rick Chen --- Changes for v4: - none arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi | 1 + board/sifive/fu540/Kconfig | 3 +++ 2 files changed, 4 insertions(+) diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi index 8a784b5661..2aebfab646 100644 --- a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi @@ -5,6 +5,7 @@ / { aliases { + spi0 = &qspi0; spi2 = &qspi2; }; }; diff --git a/board/sifive/fu540/Kconfig b/board/sifive/fu540/Kconfig index 5ca21474de..75661f35f8 100644 --- a/board/sifive/fu540/Kconfig +++ b/board/sifive/fu540/Kconfig @@ -26,6 +26,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply CMD_FS_GENERIC imply CMD_NET imply CMD_PING + imply CMD_SF imply CLK_SIFIVE imply CLK_SIFIVE_FU540_PRCI imply DOS_PARTITION @@ -40,6 +41,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply SIFIVE_SERIAL imply SPI imply SPI_SIFIVE + imply SPI_FLASH + imply SPI_FLASH_ISSI imply MMC imply MMC_SPI imply MMC_BROKEN_CD