Skip to contentSkip to conversation

spi: cadence_qspi: Select flash subnode at runtime

PATCH RESEND Superseded Udit Kumar 2 participants 2 messages Sep 7, 2023 – Sep 12, 2023 SPI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Udit Kumar

author
#0 lore raw

PATCH RESEND 1/1 spi: cadence_qspi: Select flash subnode at runtime

Currently spi driver gets flash parameter from first subnode.

Few boards have more than one flash with different parameters and selection of flash is done by on board switch settings. In such case, uboot needs to be recompiled with updated device tree to align with board switch settings.

This patch allows to select flash node at runtime.

Boards those are supporting multiple flashes
needs to implement cadence_qspi_get_subnode function and return correct flash node.

Cc Apurva Nandan <[email protected]>

---
One of such platform is J721S2 EVM
link https://www.ti.com/lit/pdf/spruj67
Fig 3.1, Page 18 has details of two flashes connected with one controller.

 drivers/spi/cadence_qspi.c | 7 ++++++-
 drivers/spi/cadence_qspi.h | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/spi/cadence_qspi.c +6 -1
index cc3a54f295..7a02ceed10 100644
@@ -40,6 +40,11 @@ __weak int cadence_qspi_versal_flash_reset(struct udevice *dev)
 	return 0;
 }
 
+__weak ofnode  cadence_qspi_get_subnode(struct udevice *dev)
+{
+	return dev_read_first_subnode(dev);
+}
+
 static int cadence_spi_write_speed(struct udevice *bus, uint hz)
 {
 	struct cadence_spi_priv *priv = dev_get_priv(bus);
@@ -401,7 +406,7 @@ static int cadence_spi_of_to_plat(struct udevice *bus)
 	plat->is_dma = dev_read_bool(bus, "cdns,is-dma");
 
 	/* All other parameters are embedded in the child node */
-	subnode = dev_read_first_subnode(bus);
+	subnode = cadence_qspi_get_subnode(bus);
 	if (!ofnode_valid(subnode)) {
 		printf("Error: subnode with SPI flash config missing!\n");
 		return -ENODEV;
drivers/spi/cadence_qspi.h +1 -0
index 1c59d1a9d9..12825f8911 100644
@@ -304,6 +304,7 @@ int cadence_qspi_apb_dma_read(struct cadence_spi_priv *priv,
 int cadence_qspi_apb_wait_for_dma_cmplt(struct cadence_spi_priv *priv);
 int cadence_qspi_apb_exec_flash_cmd(void *reg_base, unsigned int reg);
 int cadence_qspi_versal_flash_reset(struct udevice *dev);
+ofnode cadence_qspi_get_subnode(struct udevice *dev);
 void cadence_qspi_apb_enable_linear_mode(bool enable);
 
 #endif /* __CADENCE_QSPI_H__ */
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Udit

Quoted 13 lines · Udit Kumar

Currently spi driver gets flash parameter from first subnode.

Few boards have more than one flash with different parameters and selection of flash is done by on board switch settings. In such case, uboot needs to be recompiled with updated device tree to align with board switch settings.

This patch allows to select flash node at runtime.

Boards those are supporting multiple flashes
needs to implement cadence_qspi_get_subnode function and return correct flash node.

Quoted 5 lines
Cc Apurva Nandan <[email protected]>

---
One of such platform is J721S2 EVM
link https://www.ti.com/lit/pdf/spruj67

I think this link is wrong, may be you mean
https://www.ti.com/lit/pdf/spruj69

Quoted 11 lines

Fig 3.1, Page 18 has details of two flashes connected with one controller.

  drivers/spi/cadence_qspi.c | 7 ++++++-
  drivers/spi/cadence_qspi.h | 1 +
  2 files changed, 7 insertions(+), 1 deletion(-)
drivers/spi/cadence_qspi.c +0 -0
index cc3a54f295..7a02ceed10 100644

drivers/spi/cadence_qspi.c __weak int cadence_qspi_versal_flash_reset(struct udevice *dev) · line 43

Quoted 4 lines
drivers/spi/cadence_qspi.c +1 -0
@@ -40,6 +40,11 @@ __weak int cadence_qspi_versal_flash_reset(struct udevice *dev)
  	return 0;
  }
 
+__weak ofnode  cadence_qspi_get_subnode(struct udevice *dev)

Extra space after ofnode.

Quoted 21 lines
drivers/spi/cadence_qspi.c +5 -1
+{
+	return dev_read_first_subnode(dev);
+}
+
  static int cadence_spi_write_speed(struct udevice *bus, uint hz)
  {
  	struct cadence_spi_priv *priv = dev_get_priv(bus);
@@ -401,7 +406,7 @@ static int cadence_spi_of_to_plat(struct udevice *bus)
  	plat->is_dma = dev_read_bool(bus, "cdns,is-dma");
 
  	/* All other parameters are embedded in the child node */
-	subnode = dev_read_first_subnode(bus);
+	subnode = cadence_qspi_get_subnode(bus);
  	if (!ofnode_valid(subnode)) {
  		printf("Error: subnode with SPI flash config missing!\n");
  		return -ENODEV;
drivers/spi/cadence_qspi.h +0 -0
index 1c59d1a9d9..12825f8911 100644

drivers/spi/cadence_qspi.h int cadence_qspi_apb_dma_read(struct cadence_spi_priv *priv, · line 310

Quoted 7 lines
drivers/spi/cadence_qspi.h +1 -0
@@ -304,6 +304,7 @@ int cadence_qspi_apb_dma_read(struct cadence_spi_priv *priv,
  int cadence_qspi_apb_wait_for_dma_cmplt(struct cadence_spi_priv *priv);
  int cadence_qspi_apb_exec_flash_cmd(void *reg_base, unsigned int reg);
  int cadence_qspi_versal_flash_reset(struct udevice *dev);
+ofnode cadence_qspi_get_subnode(struct udevice *dev);
  void cadence_qspi_apb_enable_linear_mode(bool enable);
 
  #endif /* __CADENCE_QSPI_H__ */

But otherwise

Signature · 2 lines
Thanking You
Neha Malcom Francis