diff options
author | Stefan Roese <sr@denx.de> | 2017-04-24 09:48:04 +0200 |
---|---|---|
committer | Bin Meng <bmeng.cn@gmail.com> | 2017-05-17 17:13:06 +0800 |
commit | 4759dffe23460d39d8e92c01013b00a3587e2112 (patch) | |
tree | 1431f4e513eafb21e025bd6fde397cd3d3014d8a /drivers/spi/ich.c | |
parent | 7025b05415ff97824266ce59b7f7915032ba6403 (diff) | |
download | u-boot-4759dffe23460d39d8e92c01013b00a3587e2112.tar.gz |
spi: ich: Configure SPI BIOS parameters for Linux upon U-Boot exit
This patch adds a remove function to the Intel ICH SPI driver, that will
be called upon U-Boot exit, directly before the OS (Linux) is started.
This function takes care of configuring the BIOS registers in the SPI
controller (similar to what a "standard" BIOS or coreboot does), so that
the Linux MTD device driver is able to correctly read/write to the SPI
NOR chip. Without this, the chip is not detected at all.
Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Jagan Teki <jteki@openedev.com>
Diffstat (limited to 'drivers/spi/ich.c')
-rw-r--r-- | drivers/spi/ich.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c index 893fe33b66f..bf2e99b5ccb 100644 --- a/drivers/spi/ich.c +++ b/drivers/spi/ich.c @@ -617,6 +617,22 @@ static int ich_spi_probe(struct udevice *dev) return 0; } +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)); + + return 0; +} + static int ich_spi_set_speed(struct udevice *bus, uint speed) { struct ich_spi_priv *priv = dev_get_priv(bus); @@ -700,4 +716,6 @@ U_BOOT_DRIVER(ich_spi) = { .priv_auto_alloc_size = sizeof(struct ich_spi_priv), .child_pre_probe = ich_spi_child_pre_probe, .probe = ich_spi_probe, + .remove = ich_spi_remove, + .flags = DM_FLAG_OS_PREPARE, }; |