diff --git a/boards/arc/arduino_101_sss/Kconfig.defconfig b/boards/arc/arduino_101_sss/Kconfig.defconfig index 063d1eb7f99..488bdcdc79e 100644 --- a/boards/arc/arduino_101_sss/Kconfig.defconfig +++ b/boards/arc/arduino_101_sss/Kconfig.defconfig @@ -4,17 +4,4 @@ if BOARD_ARDUINO_101_SSS config BOARD default "arduino_101_sss" -if FLASH && SPI - -config SPI_FLASH_W25QXXDV - default y - -config SPI_FLASH_W25QXXDV_SPI_NAME - default "SPI_2" - -config SPI_FLASH_W25QXXDV_SPI_SLAVE - default 1 - -endif # FLASH && SPI - endif # BOARD_ARDUINO_101_SSS diff --git a/boards/x86/arduino_101/Kconfig.defconfig b/boards/x86/arduino_101/Kconfig.defconfig index adaed44eca8..5f8c9430343 100644 --- a/boards/x86/arduino_101/Kconfig.defconfig +++ b/boards/x86/arduino_101/Kconfig.defconfig @@ -20,16 +20,8 @@ config GPIO if SPI_FLASH_W25QXXDV -config SPI_FLASH_W25QXXDV_SPI_NAME - default "SPI_0" -config SPI_FLASH_W25QXXDV_SPI_SLAVE - default 1 config SPI_FLASH_W25QXXDV_GPIO_SPI_CS default y -config SPI_FLASH_W25QXXDV_GPIO_SPI_CS_DRV_NAME - default "GPIO_0" -config SPI_FLASH_W25QXXDV_GPIO_SPI_CS_PIN - default 24 if DISK_ACCESS_FLASH diff --git a/boards/x86/arduino_101/arduino_101.dts b/boards/x86/arduino_101/arduino_101.dts index 6140b3eca38..b14add5fe9c 100644 --- a/boards/x86/arduino_101/arduino_101.dts +++ b/boards/x86/arduino_101/arduino_101.dts @@ -58,6 +58,15 @@ &spi0 { status = "ok"; + cs-gpios = <&gpio0 24 0>; + + spi-flash@1 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "winbond,w25q16", "jedec,spi-nor"; + reg = <1>; + spi-max-frequency = <8000000>; + }; }; &spi1 { diff --git a/boards/x86/arduino_101/dts_fixup.h b/boards/x86/arduino_101/dts_fixup.h new file mode 100644 index 00000000000..e9bd8741268 --- /dev/null +++ b/boards/x86/arduino_101/dts_fixup.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Linaro Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Board level DTS fixup file */ + +#define DT_SPI_FLASH_W25QXXDV_SPI_SLAVE DT_SNPS_DESIGNWARE_SPI_B0001000_WINBOND_W25Q16_1_BASE_ADDRESS +#define DT_SPI_FLASH_W25QXXDV_SPI_NAME DT_SNPS_DESIGNWARE_SPI_B0001000_WINBOND_W25Q16_1_BUS_NAME +#define DT_SPI_FLASH_W25QXXDV_SPI_FREQ DT_SNPS_DESIGNWARE_SPI_B0001000_WINBOND_W25Q16_1_SPI_MAX_FREQUENCY + +#define DT_SPI_FLASH_W25QXXDV_GPIO_SPI_CS_DRV_NAME DT_SNPS_DESIGNWARE_SPI_B0001000_CS_GPIOS_CONTROLLER +#define DT_SPI_FLASH_W25QXXDV_GPIO_SPI_CS_PIN DT_SNPS_DESIGNWARE_SPI_B0001000_CS_GPIOS_PIN + + +/* End of Board Level DTS fixup file */ diff --git a/drivers/flash/Kconfig.w25qxxdv b/drivers/flash/Kconfig.w25qxxdv index 43a6c5421b7..063985a6648 100644 --- a/drivers/flash/Kconfig.w25qxxdv +++ b/drivers/flash/Kconfig.w25qxxdv @@ -12,9 +12,6 @@ menuconfig SPI_FLASH_W25QXXDV if SPI_FLASH_W25QXXDV -config SPI_FLASH_W25QXXDV_SPI_NAME - string "SPI controller device name" - config SPI_FLASH_W25QXXDV_DRV_NAME string "SPI flash device name" default "W25QXXDV" @@ -27,41 +24,12 @@ config SPI_FLASH_W25QXXDV_INIT_PRIORITY Device is connected to SPI bus, it has to be initialized after SPI driver. -config SPI_FLASH_W25QXXDV_SPI_FREQ_0 - int "SPI system frequency" - default 8000000 - help - This option sets the SPI controller's frequency. Beware this value - depends on the SPI controller being used and also on the system - clock. - -config SPI_FLASH_W25QXXDV_SPI_SLAVE - int "SPI slave linked to SPI flash" - help - This option sets the SPI slave number the SPI controller has to switch - to when dealing with WinBond SPI flash chip. - config SPI_FLASH_W25QXXDV_GPIO_SPI_CS bool "Manage SPI CS through a GPIO pin" help This option is useful if one needs to manage SPI CS through a GPIO pin to by-pass the SPI controller's CS logic. -config SPI_FLASH_W25QXXDV_GPIO_SPI_CS_DRV_NAME - string "GPIO driver's name to use to drive SPI CS through" - depends on SPI_FLASH_W25QXXDV_GPIO_SPI_CS - help - This option is mandatory to set which GPIO controller to use in order - to actually emulate the SPI CS. - -config SPI_FLASH_W25QXXDV_GPIO_SPI_CS_PIN - int "GPIO PIN to use to drive SPI CS through" - default 0 - depends on SPI_FLASH_W25QXXDV_GPIO_SPI_CS - help - This option is mandatory to set which GPIO pin to use in order - to actually emulate the SPI CS. - config SPI_FLASH_W25QXXDV_GPIO_CS_WAIT_DELAY int "Delay time in us" default 0 diff --git a/drivers/flash/spi_flash_w25qxxdv.c b/drivers/flash/spi_flash_w25qxxdv.c index 47a985f3480..538a1e96c46 100644 --- a/drivers/flash/spi_flash_w25qxxdv.c +++ b/drivers/flash/spi_flash_w25qxxdv.c @@ -399,23 +399,23 @@ static int spi_flash_wb_configure(struct device *dev) { struct spi_flash_data *data = dev->driver_data; - data->spi = device_get_binding(CONFIG_SPI_FLASH_W25QXXDV_SPI_NAME); + data->spi = device_get_binding(DT_SPI_FLASH_W25QXXDV_SPI_NAME); if (!data->spi) { return -EINVAL; } - data->spi_cfg.frequency = CONFIG_SPI_FLASH_W25QXXDV_SPI_FREQ_0; + data->spi_cfg.frequency = DT_SPI_FLASH_W25QXXDV_SPI_FREQ; data->spi_cfg.operation = SPI_WORD_SET(8); - data->spi_cfg.slave = CONFIG_SPI_FLASH_W25QXXDV_SPI_SLAVE; + data->spi_cfg.slave = DT_SPI_FLASH_W25QXXDV_SPI_SLAVE; #if defined(CONFIG_SPI_FLASH_W25QXXDV_GPIO_SPI_CS) data->cs_ctrl.gpio_dev = device_get_binding( - CONFIG_SPI_FLASH_W25QXXDV_GPIO_SPI_CS_DRV_NAME); + DT_SPI_FLASH_W25QXXDV_GPIO_SPI_CS_DRV_NAME); if (!data->cs_ctrl.gpio_dev) { return -ENODEV; } - data->cs_ctrl.gpio_pin = CONFIG_SPI_FLASH_W25QXXDV_GPIO_SPI_CS_PIN; + data->cs_ctrl.gpio_pin = DT_SPI_FLASH_W25QXXDV_GPIO_SPI_CS_PIN; data->cs_ctrl.delay = CONFIG_SPI_FLASH_W25QXXDV_GPIO_CS_WAIT_DELAY; data->spi_cfg.cs = &data->cs_ctrl; diff --git a/dts/bindings/mtd/winbond,w25q16.yaml b/dts/bindings/mtd/winbond,w25q16.yaml new file mode 100644 index 00000000000..dc7ab609f3c --- /dev/null +++ b/dts/bindings/mtd/winbond,w25q16.yaml @@ -0,0 +1,20 @@ +# +# Copyright (c) 2018, Linaro Limited +# +# SPDX-License-Identifier: Apache-2.0 +# +--- +title: SPI NOR FLASH +version: 0.1 + +description: > + This binding gives a base representation of SPI slave NOR FLASH + +inherits: + !include spi-device.yaml + +properties: + compatible: + constraint: "winbond,w25q16" + +...