dts: flash: w25qxxdv: Add Device Tree Support for SPI FLASH w25qxxdv
Convert the w25qxxdv driver to use device tree for SPI device params. Updated the Arduino 101 config to use device tree to specify the SPI flash. Update the arduino_101_sss to drop Kconfig support for the w25qxxdv flash. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
9f84889779
commit
a4c3feced4
7 changed files with 51 additions and 58 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
17
boards/x86/arduino_101/dts_fixup.h
Normal file
17
boards/x86/arduino_101/dts_fixup.h
Normal file
|
@ -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 */
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
20
dts/bindings/mtd/winbond,w25q16.yaml
Normal file
20
dts/bindings/mtd/winbond,w25q16.yaml
Normal file
|
@ -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"
|
||||
|
||||
...
|
Loading…
Add table
Add a link
Reference in a new issue