Skip to contentSkip to conversation

cros_ec_spi: Work better with CS GPIO descriptors

PATCH In review Stephen Boyd 3 participants 7 messages Dec 3, 2020 – Dec 4, 2020

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

cover cros_ec_spi: Work better with CS GPIO descriptors

Two small patches to work better with the new CS GPIO descriptor logic. The first one fixes a problem found while trying to enable that feature and the second patch removes a line that I noticed while looking in the same area.

Cc Simon Glass <[email protected]>
Cc Gwendal Grignou <[email protected]>
Cc Douglas Anderson <[email protected]>
Cc Alexandru M Stan <[email protected]>

Stephen Boyd (2):
platform/chrome: cros_ec_spi: Don't overwrite spi::mode platform/chrome: cros_ec_spi: Drop bits_per_word assignment

 drivers/platform/chrome/cros_ec_spi.c | 2 --
 1 file changed, 2 deletions(-)

base-commit: b65054597872ce3aefbc6a666385eabdf9e288da

Signature · 1 line
https://chromeos.dev
#1 lore raw

PATCH 1/2 platform/chrome: cros_ec_spi: Don't overwrite spi::mode

There isn't any need to overwrite the mode here in the driver with what has been detected by the firmware, such as DT or ACPI. In fact, if we use the SPI CS gpio descriptor feature we will overwrite the mode with SPI_MODE_0 where it already contains SPI_MODE_0 and more importantly SPI_CS_HIGH. Clearing the SPI_CS_HIGH bit causes the CS line to toggle when the device is probed when it shouldn't change, confusing the driver and making it fail to probe. Drop the assignment and let the spi core take care of it.

Fixes a17d94f0b6e1 ("mfd: Add ChromeOS EC SPI driver")
Cc Simon Glass <[email protected]>
Cc Gwendal Grignou <[email protected]>
Cc Douglas Anderson <[email protected]>
Cc Alexandru M Stan <[email protected]>
---
 drivers/platform/chrome/cros_ec_spi.c | 1 -
 1 file changed, 1 deletion(-)
drivers/platform/chrome/cros_ec_spi.c +0 -1
index dfa1f816a45f..f9df218fc2bb 100644
@@ -742,7 +742,6 @@ static int cros_ec_spi_probe(struct spi_device *spi)
 	int err;
 
 	spi->bits_per_word = 8;
-	spi->mode = SPI_MODE_0;
 	spi->rt = true;
 	err = spi_setup(spi);
 	if (err < 0)
Signature · 1 line
https://chromeos.dev
Reviewed-by Tested-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] platform/chrome: cros_ec_spi: Don't overwrite spi::mode

Hi,

Quoted 10 lines · Stephen Boyd

There isn't any need to overwrite the mode here in the driver with what has been detected by the firmware, such as DT or ACPI. In fact, if we use the SPI CS gpio descriptor feature we will overwrite the mode with SPI_MODE_0 where it already contains SPI_MODE_0 and more importantly SPI_CS_HIGH. Clearing the SPI_CS_HIGH bit causes the CS line to toggle when the device is probed when it shouldn't change, confusing the driver and making it fail to probe. Drop the assignment and let the spi core take care of it.

Quoted 8 lines
Fixes a17d94f0b6e1 ("mfd: Add ChromeOS EC SPI driver")
Cc Simon Glass <[email protected]>
Cc Gwendal Grignou <[email protected]>
Cc Douglas Anderson <[email protected]>
Cc Alexandru M Stan <[email protected]>
---
 drivers/platform/chrome/cros_ec_spi.c | 1 -
Acked-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] platform/chrome: cros_ec_spi: Don't overwrite spi::mode

In reply to Stephen Boyd

Hi Stephen,

Thank you for your patch.

Quoted 9 lines · Stephen Boyd

There isn't any need to overwrite the mode here in the driver with what has been detected by the firmware, such as DT or ACPI. In fact, if we use the SPI CS gpio descriptor feature we will overwrite the mode with SPI_MODE_0 where it already contains SPI_MODE_0 and more importantly SPI_CS_HIGH. Clearing the SPI_CS_HIGH bit causes the CS line to toggle when the device is probed when it shouldn't change, confusing the driver and making it fail to probe. Drop the assignment and let the spi core take care of it.

Quoted 7 lines
Fixes a17d94f0b6e1 ("mfd: Add ChromeOS EC SPI driver")
Cc Simon Glass <[email protected]>
Cc Gwendal Grignou <[email protected]>
Cc Douglas Anderson <[email protected]>
Cc Alexandru M Stan <[email protected]>

---

Quoted 16 lines
 drivers/platform/chrome/cros_ec_spi.c | 1 -
 1 file changed, 1 deletion(-)
drivers/platform/chrome/cros_ec_spi.c +0 -1
index dfa1f816a45f..f9df218fc2bb 100644
@@ -742,7 +742,6 @@ static int cros_ec_spi_probe(struct spi_device *spi)
 	int err;
 
 	spi->bits_per_word = 8;
-	spi->mode = SPI_MODE_0;
 	spi->rt = true;
 	err = spi_setup(spi);
 	if (err < 0)
#4 lore raw

PATCH 2/2 platform/chrome: cros_ec_spi: Drop bits_per_word assignment

In reply to Stephen Boyd

This is already handed by default in spi_setup() if the bits_per_word is 0, so just drop it to shave off a line.

Cc Simon Glass <[email protected]>
Cc Gwendal Grignou <[email protected]>
Cc Douglas Anderson <[email protected]>
Cc Alexandru M Stan <[email protected]>
---
 drivers/platform/chrome/cros_ec_spi.c | 1 -
 1 file changed, 1 deletion(-)
drivers/platform/chrome/cros_ec_spi.c +0 -1
index f9df218fc2bb..14c4046fa04d 100644
@@ -741,7 +741,6 @@ static int cros_ec_spi_probe(struct spi_device *spi)
 	struct cros_ec_spi *ec_spi;
 	int err;
 
-	spi->bits_per_word = 8;
 	spi->rt = true;
 	err = spi_setup(spi);
 	if (err < 0)
Signature · 1 line
https://chromeos.dev
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] platform/chrome: cros_ec_spi: Drop bits_per_word assignment

Hi,

Quoted 4 lines · Stephen Boyd

This is already handed by default in spi_setup() if the bits_per_word is 0, so just drop it to shave off a line.

Quoted 8 lines
Cc Simon Glass <[email protected]>
Cc Gwendal Grignou <[email protected]>
Cc Douglas Anderson <[email protected]>
Cc Alexandru M Stan <[email protected]>
---
 drivers/platform/chrome/cros_ec_spi.c | 1 -
 1 file changed, 1 deletion(-)
Acked-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] platform/chrome: cros_ec_spi: Drop bits_per_word assignment

In reply to Stephen Boyd

Hi Stephen,

Thank you for your patch.

Quoted 8 lines · Stephen Boyd

This is already handed by default in spi_setup() if the bits_per_word is 0, so just drop it to shave off a line.

Cc Simon Glass <[email protected]>
Cc Gwendal Grignou <[email protected]>
Cc Douglas Anderson <[email protected]>
Cc Alexandru M Stan <[email protected]>
Quoted 17 lines
---
 drivers/platform/chrome/cros_ec_spi.c | 1 -
 1 file changed, 1 deletion(-)
drivers/platform/chrome/cros_ec_spi.c +0 -1
index f9df218fc2bb..14c4046fa04d 100644
@@ -741,7 +741,6 @@ static int cros_ec_spi_probe(struct spi_device *spi)
 	struct cros_ec_spi *ec_spi;
 	int err;
 
-	spi->bits_per_word = 8;
 	spi->rt = true;
 	err = spi_setup(spi);
 	if (err < 0)