Skip to contentSkip to conversation

fsi/fsi-master-gpio: Delay sampling of FSI data input

PATCH In review Benjamin Herrenschmidt 2 participants 2 messages May 15, 2018 – May 16, 2018 FSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsi/fsi-master-gpio: Delay sampling of FSI data input

Most SoC GPIO implementations, including the Aspeed one, have synchronizers on the GPIO inputs. This means that the value read from a GPIO is a couple of clocks old, from whatever clock source feeds those synchronizers.

In practice, this means that in no-delay mode, we are using a value that can potentially be a bit too old and too close to the clock edge establishing the data on the other side of the link.

The voltage converters we use on some systems make this worse and sensitive to things like voltage fluctuations etc... This is, we believe, the cause of occasional CRC errors encountered during heavy activity on the LPC bus.

This is fixed by introducing a dummy GPIO read before the actual data read. It slows down SBEFIFO by about 15% (less than any delay primitive) and the end result is so far solid.

---
 drivers/fsi/fsi-master-gpio.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/fsi/fsi-master-gpio.c +5 -0
index 98700eac16fd..36a71efd802c 100644
@@ -98,6 +98,11 @@ static int sda_clock_in(struct fsi_master_gpio *master)
 	if (!master->no_delays)
 		ndelay(FSI_GPIO_STD_DLY);
 	gpiod_set_value(master->gpio_clk, 0);
+
+	/* Dummy read to feed the synchronizers */
+	gpiod_get_value(master->gpio_data);
+
+	/* Actual data read */
 	in = gpiod_get_value(master->gpio_data);
 	if (!master->no_delays)
 		ndelay(FSI_GPIO_STD_DLY);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 40 lines · Benjamin Herrenschmidt

Most SoC GPIO implementations, including the Aspeed one, have synchronizers on the GPIO inputs. This means that the value read from a GPIO is a couple of clocks old, from whatever clock source feeds those synchronizers.

In practice, this means that in no-delay mode, we are using a value that can potentially be a bit too old and too close to the clock edge establishing the data on the other side of the link.

The voltage converters we use on some systems make this worse and sensitive to things like voltage fluctuations etc... This is, we believe, the cause of occasional CRC errors encountered during heavy activity on the LPC bus.

This is fixed by introducing a dummy GPIO read before the actual data read. It slows down SBEFIFO by about 15% (less than any delay primitive) and the end result is so far solid.

---
  drivers/fsi/fsi-master-gpio.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/fsi/fsi-master-gpio.c +5 -0
index 98700eac16fd..36a71efd802c 100644
@@ -98,6 +98,11 @@ static int sda_clock_in(struct fsi_master_gpio *master)
  	if (!master->no_delays)
  		ndelay(FSI_GPIO_STD_DLY);
  	gpiod_set_value(master->gpio_clk, 0);
+
+	/* Dummy read to feed the synchronizers */
+	gpiod_get_value(master->gpio_data);
+
+	/* Actual data read */
  	in = gpiod_get_value(master->gpio_data);
  	if (!master->no_delays)
  		ndelay(FSI_GPIO_STD_DLY);