summaryrefslogtreecommitdiff
path: root/drivers/spi
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2017-08-16 05:38:30 (GMT)
committerBin Meng <bmeng.cn@gmail.com>2017-08-24 03:00:47 (GMT)
commitb42711f90c66d683b808cd78d9748ab38407413f (patch)
treed3032345edff668058babc925364840845b35d34 /drivers/spi
parent3e7914168413f7aa05a68a53ca16e84b14d6851b (diff)
downloadu-boot-b42711f90c66d683b808cd78d9748ab38407413f.tar.xz
x86: ich-spi: Move opcode registers configuration to another routine
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> Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/ich.c22
1 files 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;
}