Skip to contentSkip to conversation

spi: mxc: Fix compilation problem of DM_SPI class driver

PATCH New Michael Trimarchi 4 participants 10 messages Jun 20, 2018 – Jun 30, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 spi: mxc: Fix compilation problem of DM_SPI class driver

drivers/spi/mxc_spi.c:507: undefined reference to `dev_get_addr' linux-ld.bfd: BFD (GNU Binutils) 2.29.1 assertion fail elf32-arm.c:9509

---
 drivers/spi/mxc_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/mxc_spi.c +1 -1
index b77129c..fcb214a 100644
@@ -504,7 +504,7 @@ static int mxc_spi_probe(struct udevice *bus)
 		return -EINVAL;
 	}
 
-	plat->base = dev_get_addr(bus);
+	plat->base = devfdt_get_addr(bus);
 	if (plat->base == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/3 spi: mxc_spi: Fix chipselect on DM_SPI driver uclass

CS GPIO activation low/high is determinated by the device tree so we don't need to take in accoung in cs_activate and cs_deactivate

---
 drivers/spi/mxc_spi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/mxc_spi.c +3 -3
index fcb214a..0dccc38 100644
@@ -60,7 +60,7 @@ static inline struct mxc_spi_slave *to_mxc_spi_slave(struct spi_slave *slave)
 static void mxc_spi_cs_activate(struct mxc_spi_slave *mxcs)
 {
 	if (CONFIG_IS_ENABLED(DM_SPI)) {
-		dm_gpio_set_value(&mxcs->ss, mxcs->ss_pol);
+		dm_gpio_set_value(&mxcs->ss, 1);
 	} else {
 		if (mxcs->gpio > 0)
 			gpio_set_value(mxcs->gpio, mxcs->ss_pol);
@@ -70,7 +70,7 @@ static void mxc_spi_cs_activate(struct mxc_spi_slave *mxcs)
 static void mxc_spi_cs_deactivate(struct mxc_spi_slave *mxcs)
 {
 	if (CONFIG_IS_ENABLED(DM_SPI)) {
-		dm_gpio_set_value(&mxcs->ss, !(mxcs->ss_pol));
+		dm_gpio_set_value(&mxcs->ss, 0);
 	} else {
 		if (mxcs->gpio > 0)
 			gpio_set_value(mxcs->gpio, !(mxcs->ss_pol));
@@ -508,7 +508,7 @@ static int mxc_spi_probe(struct udevice *bus)
 	if (plat->base == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
-	ret = dm_gpio_set_value(&plat->ss, !(mxcs->ss_pol));
+	ret = dm_gpio_set_value(&plat->ss, 0);
 	if (ret) {
 		dev_err(bus, "Setting cs error\n");
 		return ret;
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/3 spi: mxc_spi: Fix chipselect on DM_SPI driver uclass

Quoted 10 lines

-----Original Message-----
From: Michael Trimarchi [mailto:michael at amarulasolutions.com]
Sent: 2018年6月21日 4:51
To: Jagan Teki <[email protected]>
Cc: Stefano Babic <[email protected]>; Peng Fan <[email protected]>; shyam.saini at amarulasolutions.com; u-boot at lists.denx.de
Subject: [PATCH 2/3] spi: mxc_spi: Fix chipselect on DM_SPI driver uclass

Quoted 2 lines

CS GPIO activation low/high is determinated by the device tree so we don't need to take in accoung in cs_activate and cs_deactivate

Yes.

Quoted 28 lines
---
 drivers/spi/mxc_spi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/mxc_spi.c index fcb214a..0dccc38 renamed from drivers/spi/mxc_spi.c +0 -0

100644

drivers/spi/mxc_spi.c +1 -1
@@ -60,7 +60,7 @@ static inline struct mxc_spi_slave
 *to_mxc_spi_slave(struct spi_slave *slave)  static void
 mxc_spi_cs_activate(struct mxc_spi_slave *mxcs)  {
 	if (CONFIG_IS_ENABLED(DM_SPI)) {
-		dm_gpio_set_value(&mxcs->ss, mxcs->ss_pol);
+		dm_gpio_set_value(&mxcs->ss, 1);
 	} else {
 		if (mxcs->gpio > 0)
 			gpio_set_value(mxcs->gpio, mxcs->ss_pol); @@ -70,7 +70,7 @@

static void mxc_spi_cs_activate(struct mxc_spi_slave *mxcs) static void mxc_spi_cs_deactivate(struct mxc_spi_slave *mxcs) {

drivers/spi/mxc_spi.c +1 -1
 	if (CONFIG_IS_ENABLED(DM_SPI)) {
-		dm_gpio_set_value(&mxcs->ss, !(mxcs->ss_pol));
+		dm_gpio_set_value(&mxcs->ss, 0);
 	} else {
 		if (mxcs->gpio > 0)
 			gpio_set_value(mxcs->gpio, !(mxcs->ss_pol)); @@ -508,7 +508,7

@@ static int mxc_spi_probe(struct udevice *bus)

drivers/spi/mxc_spi.c static int mxc_spi_probe(struct udevice *bus)

Quoted 9 lines
drivers/spi/mxc_spi.c +1 -2
 	if (plat->base == FDT_ADDR_T_NONE)
 		return -ENODEV;
 
-	ret = dm_gpio_set_value(&plat->ss, !(mxcs->ss_pol));
+	ret = dm_gpio_set_value(&plat->ss, 0);
 	if (ret) {
 		dev_err(bus, "Setting cs error\n");
 		return ret;
--
Quoted 1 line

2.7.4

#4 lore raw

PATCH 3/3 spi: mxc_spi: Fix spi mode communication where clock is inverted

In reply to Michael Trimarchi

During spi initialization logic creates a glitch on the clock and if this is followed by the chip select this can be interpretated as clock. Add a delay let the glitch out of chip select

---
 drivers/spi/mxc_spi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/spi/mxc_spi.c +1 -0
index 0dccc38..d450f16 100644
@@ -387,6 +387,7 @@ static int mxc_spi_claim_bus_internal(struct mxc_spi_slave *mxcs, int cs)
 	}
 	reg_write(&regs->period, MXC_CSPIPERIOD_32KHZ);
 	reg_write(&regs->intr, 0);
+	udelay(50);
 
 	return 0;
 }
Signature · 1 line
2.7.4
#5 lore raw

PATCH 3/3 spi: mxc_spi: Fix spi mode communication where clock is inverted

Quoted 11 lines

-----Original Message-----
From: Michael Trimarchi [mailto:michael at amarulasolutions.com]
Sent: 2018年6月21日 4:51
To: Jagan Teki <[email protected]>
Cc: Stefano Babic <[email protected]>; Peng Fan <[email protected]>; shyam.saini at amarulasolutions.com; u-boot at lists.denx.de
Subject: [PATCH 3/3] spi: mxc_spi: Fix spi mode communication where clock is inverted

Quoted 3 lines

During spi initialization logic creates a glitch on the clock and if this is followed by the chip select this can be interpretated as clock. Add a delay let the glitch out of chip select

I did not see issue. What issue do you see and which platform? Adding a delay here seems hacky which forces all SoC using this driver needs a delay.

Quoted 21 lines
---
 drivers/spi/mxc_spi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/spi/mxc_spi.c index 0dccc38..d450f16 renamed from drivers/spi/mxc_spi.c +0 -0

100644

drivers/spi/mxc_spi.c +1 -0
@@ -387,6 +387,7 @@ static int mxc_spi_claim_bus_internal(struct
 mxc_spi_slave *mxcs, int cs)
 	}
 	reg_write(&regs->period, MXC_CSPIPERIOD_32KHZ);
 	reg_write(&regs->intr, 0);
+	udelay(50);
 
 	return 0;

}
--
2.7.4

#6 lore raw

PATCH 3/3 spi: mxc_spi: Fix spi mode communication where clock is inverted

Hi Peng

Quoted 11 lines · Peng Fan
Quoted 11 lines

-----Original Message-----
From: Michael Trimarchi [mailto:michael at amarulasolutions.com]
Sent: 2018年6月21日 4:51
To: Jagan Teki <[email protected]>
Cc: Stefano Babic <[email protected]>; Peng Fan <[email protected]>; shyam.saini at amarulasolutions.com; u-boot at lists.denx.de
Subject: [PATCH 3/3] spi: mxc_spi: Fix spi mode communication where clock is inverted

Quoted 7 lines
Quoted 3 lines

During spi initialization logic creates a glitch on the clock and if this is followed by the chip select this can be interpretated as clock. Add a delay let the glitch out of chip select

I did not see issue. What issue do you see and which platform? Adding a delay here seems hacky which forces all SoC using this driver needs a delay.

You can test it with

sspi 1:0.3 24 700003

-------------\ /------------

               |  |
               |  |
               ---

The glitch look like a clock size and if it happen next to the cs you inject one clock more

Michael

Quoted 22 lines
Quoted 21 lines
---
 drivers/spi/mxc_spi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/spi/mxc_spi.c index 0dccc38..d450f16 renamed from drivers/spi/mxc_spi.c +0 -0

100644

drivers/spi/mxc_spi.c +1 -0
@@ -387,6 +387,7 @@ static int mxc_spi_claim_bus_internal(struct
 mxc_spi_slave *mxcs, int cs)
      }
      reg_write(&regs->period, MXC_CSPIPERIOD_32KHZ);
      reg_write(&regs->intr, 0);
+     udelay(50);
 
      return 0;

}
--
2.7.4

Signature · 4 lines
| Michael Nazzareno Trimarchi                     Amarula Solutions BV |
| COO  -  Founder                                      Cruquiuskade 47 |
| +31(0)851119172                                 Amsterdam 1018 AM NL |
|                  [`as] http://www.amarulasolutions.com               |
#8 lore raw

PATCH 1/3 spi: mxc: Fix compilation problem of DM_SPI class driver

In reply to Michael Trimarchi
Quoted 23 lines

-----Original Message-----
From: Michael Trimarchi [mailto:michael at amarulasolutions.com]
Sent: 2018年6月21日 4:51
To: Jagan Teki <[email protected]>
Cc: Stefano Babic <[email protected]>; Peng Fan <[email protected]>; shyam.saini at amarulasolutions.com; u-boot at lists.denx.de
Subject: [PATCH 1/3] spi: mxc: Fix compilation problem of DM_SPI class driver

drivers/spi/mxc_spi.c:507: undefined reference to `dev_get_addr' linux-ld.bfd: BFD (GNU Binutils) 2.29.1 assertion fail elf32-arm.c:9509

---
 drivers/spi/mxc_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/mxc_spi.c index b77129c..fcb214a renamed from drivers/spi/mxc_spi.c +0 -0

100644

drivers/spi/mxc_spi.c static int mxc_spi_probe(struct udevice *bus) · line 509

Quoted 7 lines
drivers/spi/mxc_spi.c +1 -1
@@ -504,7 +504,7 @@ static int mxc_spi_probe(struct udevice *bus)
 		return -EINVAL;
 	}
 
-	plat->base = dev_get_addr(bus);
+	plat->base = devfdt_get_addr(bus);
 	if (plat->base == FDT_ADDR_T_NONE)
 		return -ENODEV;
Quoted 3 lines
drivers/spi/mxc_spi.c +0 -1
--

2.7.4