linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/ssd130x: Use new regmap bulk write support to drop custom bus
@ 2022-06-18 17:43 Javier Martinez Canillas
  2022-06-24 19:37 ` Sam Ravnborg
  0 siblings, 1 reply; 3+ messages in thread
From: Javier Martinez Canillas @ 2022-06-18 17:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Thomas Zimmermann, Mark Brown, Geert Uytterhoeven,
	Andy Shevchenko, Marek Vasut, Javier Martinez Canillas,
	Daniel Vetter, David Airlie, dri-devel

Data writes for the ssd130x 4-wire SPI protocol need special handling, due
the Data/Command control (D/C) pin having to be toggled prior to the write.

The regmap API only allowed drivers to provide .reg_{read,write} callbacks
to do per register read/write, but didn't provide a way for drivers to do
the same for bulk read/writes.

For this reason, a custom regmap bus was used by the driver just to define
a bulk write callback that implements the D/C pin toggling. But the regmap
API has been extended to support defining bulk read/write handlers, so the
custom regmap bus is not needed anymore and could just be dropped.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---

This patch depends on the following regmap fixes:

https://lkml.org/lkml/2022/6/16/198


 drivers/gpu/drm/solomon/ssd130x-spi.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/solomon/ssd130x-spi.c b/drivers/gpu/drm/solomon/ssd130x-spi.c
index 43722adab1f8..72f066ccd2d9 100644
--- a/drivers/gpu/drm/solomon/ssd130x-spi.c
+++ b/drivers/gpu/drm/solomon/ssd130x-spi.c
@@ -18,11 +18,6 @@ struct ssd130x_spi_transport {
 	struct gpio_desc *dc;
 };
 
-static const struct regmap_config ssd130x_spi_regmap_config = {
-	.reg_bits = 8,
-	.val_bits = 8,
-};
-
 /*
  * The regmap bus .write handler, it is just a wrapper around spi_write()
  * but toggling the Data/Command control pin (D/C#). Since for 4-wire SPI
@@ -56,17 +51,12 @@ static int ssd130x_spi_read(void *context, const void *reg, size_t reg_size,
 	return -EOPNOTSUPP;
 }
 
-/*
- * A custom bus is needed due the special write that toggles a D/C# pin,
- * another option could be to just have a .reg_write() callback but that
- * will prevent to do data writes in bulk.
- *
- * Once the regmap API is extended to support defining a bulk write handler
- * in the struct regmap_config, this can be simplified and the bus dropped.
- */
-static struct regmap_bus regmap_ssd130x_spi_bus = {
+static const struct regmap_config ssd130x_spi_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
 	.write = ssd130x_spi_write,
 	.read = ssd130x_spi_read,
+	.can_multi_write = true,
 };
 
 static int ssd130x_spi_probe(struct spi_device *spi)
@@ -90,8 +80,7 @@ static int ssd130x_spi_probe(struct spi_device *spi)
 	t->spi = spi;
 	t->dc = dc;
 
-	regmap = devm_regmap_init(dev, &regmap_ssd130x_spi_bus, t,
-				  &ssd130x_spi_regmap_config);
+	regmap = devm_regmap_init(dev, NULL, t, &ssd130x_spi_regmap_config);
 	if (IS_ERR(regmap))
 		return PTR_ERR(regmap);
 
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/ssd130x: Use new regmap bulk write support to drop custom bus
  2022-06-18 17:43 [PATCH] drm/ssd130x: Use new regmap bulk write support to drop custom bus Javier Martinez Canillas
@ 2022-06-24 19:37 ` Sam Ravnborg
  2022-07-18  9:13   ` Javier Martinez Canillas
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2022-06-24 19:37 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: linux-kernel, Marek Vasut, David Airlie, dri-devel,
	Andy Shevchenko, Mark Brown, Geert Uytterhoeven,
	Thomas Zimmermann

Hi Javier,

On Sat, Jun 18, 2022 at 07:43:38PM +0200, Javier Martinez Canillas wrote:
> Data writes for the ssd130x 4-wire SPI protocol need special handling, due
> the Data/Command control (D/C) pin having to be toggled prior to the write.
> 
> The regmap API only allowed drivers to provide .reg_{read,write} callbacks
> to do per register read/write, but didn't provide a way for drivers to do
> the same for bulk read/writes.
> 
> For this reason, a custom regmap bus was used by the driver just to define
> a bulk write callback that implements the D/C pin toggling. But the regmap
> API has been extended to support defining bulk read/write handlers, so the
> custom regmap bus is not needed anymore and could just be dropped.
> 
> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Patch looks good, but obviously needs the dependencies sorted out.
Acked-by: Sam Ravnborg <sam@ravnborg.org>

	Sam

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/ssd130x: Use new regmap bulk write support to drop custom bus
  2022-06-24 19:37 ` Sam Ravnborg
@ 2022-07-18  9:13   ` Javier Martinez Canillas
  0 siblings, 0 replies; 3+ messages in thread
From: Javier Martinez Canillas @ 2022-07-18  9:13 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Marek Vasut, David Airlie, linux-kernel, dri-devel,
	Andy Shevchenko, Mark Brown, Geert Uytterhoeven,
	Thomas Zimmermann

Hello Sam,

On 6/24/22 21:37, Sam Ravnborg wrote:
> Hi Javier,
> 
> On Sat, Jun 18, 2022 at 07:43:38PM +0200, Javier Martinez Canillas wrote:
>> Data writes for the ssd130x 4-wire SPI protocol need special handling, due
>> the Data/Command control (D/C) pin having to be toggled prior to the write.
>>
>> The regmap API only allowed drivers to provide .reg_{read,write} callbacks
>> to do per register read/write, but didn't provide a way for drivers to do
>> the same for bulk read/writes.
>>
>> For this reason, a custom regmap bus was used by the driver just to define
>> a bulk write callback that implements the D/C pin toggling. But the regmap
>> API has been extended to support defining bulk read/write handlers, so the
>> custom regmap bus is not needed anymore and could just be dropped.
>>
>> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
> Patch looks good, but obviously needs the dependencies sorted out.
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
>

Thanks. The regmap fixes that were the dependencies landed in v5.19-rc4
and drm-misc-next is already at v5.19-rc6, so I'll push this patch now.

-- 
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-18  9:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-18 17:43 [PATCH] drm/ssd130x: Use new regmap bulk write support to drop custom bus Javier Martinez Canillas
2022-06-24 19:37 ` Sam Ravnborg
2022-07-18  9:13   ` Javier Martinez Canillas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).