From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/5] x86: ich-spi: Move opcode registers configuration to another routine
Date: Tue, 15 Aug 2017 22:38:30 -0700 [thread overview]
Message-ID: <1502861911-14366-4-git-send-email-bmeng.cn@gmail.com> (raw)
In-Reply-To: <1502861911-14366-1-git-send-email-bmeng.cn@gmail.com>
At present the ICH SPI opcode registers configuration is done in the
ich_spi_remove() routine, a little bit weird but that's how current.
Linux MTD driver works. This changes to move the opcode registers
configuration to a separate routine ich_spi_config_opcode() which
might be called by U-Boot itself as well.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---
drivers/spi/ich.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index d4888f5..373bc26 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -338,6 +338,21 @@ static int ich_status_poll(struct ich_spi_priv *ctlr, u16 bitmask,
return -ETIMEDOUT;
}
+void ich_spi_config_opcode(struct udevice *dev)
+{
+ struct ich_spi_priv *ctlr = dev_get_priv(dev);
+
+ /*
+ * PREOP, OPTYPE, OPMENU1/OPMENU2 registers can be locked down
+ * to prevent accidental or intentional writes. Before they get
+ * locked down, these registers should be initialized properly.
+ */
+ ich_writew(ctlr, SPI_OPPREFIX, ctlr->preop);
+ ich_writew(ctlr, SPI_OPTYPE, ctlr->optype);
+ ich_writel(ctlr, SPI_OPMENU_LOWER, ctlr->opmenu);
+ ich_writel(ctlr, SPI_OPMENU_UPPER, ctlr->opmenu + sizeof(u32));
+}
+
static int ich_spi_xfer(struct udevice *dev, unsigned int bitlen,
const void *dout, void *din, unsigned long flags)
{
@@ -585,16 +600,11 @@ static int ich_spi_probe(struct udevice *dev)
static int ich_spi_remove(struct udevice *bus)
{
- struct ich_spi_priv *ctlr = dev_get_priv(bus);
-
/*
* Configure SPI controller so that the Linux MTD driver can fully
* access the SPI NOR chip
*/
- ich_writew(ctlr, SPI_OPPREFIX, ctlr->preop);
- ich_writew(ctlr, SPI_OPTYPE, ctlr->optype);
- ich_writel(ctlr, SPI_OPMENU_LOWER, ctlr->opmenu);
- ich_writel(ctlr, SPI_OPMENU_UPPER, ctlr->opmenu + sizeof(u32));
+ ich_spi_config_opcode(bus);
return 0;
}
--
2.9.2
next prev parent reply other threads:[~2017-08-16 5:38 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 5:38 [U-Boot] [PATCH 1/5] x86: ich-spi: Remove spi_write_protect_region() Bin Meng
2017-08-16 5:38 ` [U-Boot] [PATCH 2/5] x86: ich-spi: Remove unnecessary assignment in ich_init_controller() Bin Meng
2017-08-16 6:18 ` Stefan Roese
2017-08-24 3:17 ` Bin Meng
2017-08-16 5:38 ` [U-Boot] [PATCH 3/5] x86: ich-spi: Don't read cached lock status Bin Meng
2017-08-16 6:19 ` Stefan Roese
2017-08-24 3:17 ` Bin Meng
2017-08-16 5:38 ` Bin Meng [this message]
2017-08-16 6:19 ` [U-Boot] [PATCH 4/5] x86: ich-spi: Move opcode registers configuration to another routine Stefan Roese
2017-08-24 3:17 ` Bin Meng
2017-08-16 5:38 ` [U-Boot] [PATCH 5/5] x86: fsp: Configure SPI opcode registers before SPI is locked down Bin Meng
2017-08-16 6:21 ` Stefan Roese
2017-08-24 3:17 ` Bin Meng
2017-08-26 13:39 ` Simon Glass
2017-08-26 13:58 ` Bin Meng
2017-08-26 22:40 ` Simon Glass
2017-08-27 0:12 ` Bin Meng
2017-09-06 1:39 ` Simon Glass
2017-09-12 13:53 ` Bin Meng
2017-09-13 2:31 ` Simon Glass
2017-08-16 6:18 ` [U-Boot] [PATCH 1/5] x86: ich-spi: Remove spi_write_protect_region() Stefan Roese
2017-08-24 3:17 ` Bin Meng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1502861911-14366-4-git-send-email-bmeng.cn@gmail.com \
--to=bmeng.cn@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox