drivers: spi: sifive: remove CONFIG_SIFIVE_SPI_0_ROM

CONFIG_SIFIVE_SPI_0_ROM (default y) was an option to disable spi0 if
used to access SPI Flash ROM. However, its design had a problem: it
relied on instance numbers. You had to set status okay for spi0 to make
it work (incongruent with the purpose of the option itself). This patch
makes things simpler: if such SPI0 is not available, simply keep it
disabled in DT. Bindings have been updated to mention this case.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-07-11 12:30:52 +02:00 committed by Carles Cufí
commit c2d699ec2d
3 changed files with 9 additions and 34 deletions

View file

@ -3,20 +3,8 @@
# Copyright (c) 2018 SiFive Inc.
# SPDX-License-Identifier: Apache-2.0
menuconfig SPI_SIFIVE
config SPI_SIFIVE
bool "SiFive SPI controller driver"
depends on SOC_SERIES_RISCV_SIFIVE_FREEDOM
help
Enable the SPI peripherals on SiFive Freedom processors
config SIFIVE_SPI_0_ROM
bool "SPI 0 is used to access SPI Flash ROM"
default y
depends on SPI_SIFIVE
help
If enabled, SPI 0 is reserved for accessing the SPI flash ROM and a
driver interface won't be instantiated for SPI 0.
Beware disabling this option on HiFive 1! The SPI flash ROM is where the
program is stored, and if this driver initializes the interface for
peripheral control the FE310 will crash on boot.

View file

@ -296,24 +296,6 @@ static struct spi_driver_api spi_sifive_api = {
&spi_sifive_cfg_##n, \
POST_KERNEL, \
CONFIG_SPI_INIT_PRIORITY, \
&spi_sifive_api)
&spi_sifive_api);
#ifndef CONFIG_SIFIVE_SPI_0_ROM
#if DT_INST_NODE_HAS_PROP(0, label)
SPI_INIT(0);
#endif /* DT_INST_NODE_HAS_PROP(0, label) */
#endif /* !CONFIG_SIFIVE_SPI_0_ROM */
#if DT_INST_NODE_HAS_PROP(1, label)
SPI_INIT(1);
#endif /* DT_INST_NODE_HAS_PROP(1, label) */
#if DT_INST_NODE_HAS_PROP(2, label)
SPI_INIT(2);
#endif /* DT_INST_NODE_HAS_PROP(2, label) */
DT_INST_FOREACH_STATUS_OKAY(SPI_INIT)

View file

@ -1,7 +1,12 @@
# Copyright (c) 2018, SiFive Inc.
# SPDX-License-Identifier: Apache-2.0
description: Sifive SPI controller
description: |
Sifive SPI controller.
Note: First instance of the Sifive SPI controller (spi0) must be kept
disabled if used to access SPI Flash ROM. Failing to do so could result in
crashes during boot time.
compatible: "sifive,spi0"