All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] gpio: omap_gpio: Convert to auto-alloc feature when DT is supported
@ 2018-06-25 15:31 Adam Ford
  2018-07-20 12:35 ` [U-Boot] " Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Ford @ 2018-06-25 15:31 UTC (permalink / raw)
  To: u-boot

The omap_gpio driver has a TODO that says when every board is converted
to DM and DT, the omap_gpio_bind can stop using calloc and switch
to auto-alloc.

This patch converts this driver to auto-calloc when DT is enabled.

Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index 79a975ce71..651f6994e4 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -302,6 +302,7 @@ static int omap_gpio_probe(struct udevice *dev)
 	return 0;
 }
 
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
 static int omap_gpio_bind(struct udevice *dev)
 {
 	struct omap_gpio_platdata *plat = dev_get_platdata(dev);
@@ -334,6 +335,7 @@ static int omap_gpio_bind(struct udevice *dev)
 
 	return 0;
 }
+#endif
 
 static const struct udevice_id omap_gpio_ids[] = {
 	{ .compatible = "ti,omap3-gpio" },
@@ -342,12 +344,33 @@ static const struct udevice_id omap_gpio_ids[] = {
 	{ }
 };
 
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+static int omap_gpio_ofdata_to_platdata(struct udevice *dev)
+{
+	struct omap_gpio_platdata *plat = dev_get_platdata(dev);
+	fdt_addr_t addr;
+
+	addr = devfdt_get_addr(dev);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	plat->base = addr;
+	return 0;
+}
+#endif
+
 U_BOOT_DRIVER(gpio_omap) = {
 	.name	= "gpio_omap",
 	.id	= UCLASS_GPIO,
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+	.ofdata_to_platdata = of_match_ptr(omap_gpio_ofdata_to_platdata),
+	.bind	= dm_scan_fdt_dev,
+	.platdata_auto_alloc_size = sizeof(struct omap_gpio_platdata),
+#else
+	.bind   = omap_gpio_bind,
+#endif
 	.ops	= &gpio_omap_ops,
 	.of_match = omap_gpio_ids,
-	.bind	= omap_gpio_bind,
 	.probe	= omap_gpio_probe,
 	.priv_auto_alloc_size = sizeof(struct gpio_bank),
 	.flags = DM_FLAG_PRE_RELOC,
-- 
2.17.1

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

* [U-Boot] gpio: omap_gpio: Convert to auto-alloc feature when DT is supported
  2018-06-25 15:31 [U-Boot] [PATCH] gpio: omap_gpio: Convert to auto-alloc feature when DT is supported Adam Ford
@ 2018-07-20 12:35 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2018-07-20 12:35 UTC (permalink / raw)
  To: u-boot

On Mon, Jun 25, 2018 at 10:31:35AM -0500, Adam Ford wrote:

> The omap_gpio driver has a TODO that says when every board is converted
> to DM and DT, the omap_gpio_bind can stop using calloc and switch
> to auto-alloc.
> 
> This patch converts this driver to auto-calloc when DT is enabled.
> 
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
> index 79a975ce71..651f6994e4 100644

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180720/796df982/attachment.sig>

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

end of thread, other threads:[~2018-07-20 12:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-25 15:31 [U-Boot] [PATCH] gpio: omap_gpio: Convert to auto-alloc feature when DT is supported Adam Ford
2018-07-20 12:35 ` [U-Boot] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.