mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ata: intf_platform_ide: add OF bindings
@ 2015-09-03 13:38 Peter Mamonov
  2015-09-03 14:24 ` Antony Pavlov
  2015-09-03 15:46 ` [PATCH] " Lucas Stach
  0 siblings, 2 replies; 15+ messages in thread
From: Peter Mamonov @ 2015-09-03 13:38 UTC (permalink / raw)
  To: barebox; +Cc: Peter Mamonov

Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
 drivers/ata/intf_platform_ide.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/intf_platform_ide.c b/drivers/ata/intf_platform_ide.c
index 0d392d8..f20e0e0 100644
--- a/drivers/ata/intf_platform_ide.c
+++ b/drivers/ata/intf_platform_ide.c
@@ -29,6 +29,7 @@
 #include <ata_drive.h>
 #include <platform_ide.h>
 #include <linux/err.h>
+#include <of.h>
 
 /**
  * Setup the register specific addresses for an ATA like divice
@@ -85,10 +86,31 @@ static int platform_ide_probe(struct device_d *dev)
 	void *reg_base, *alt_base = NULL;
 	struct resource *reg, *alt;
 	int mmio = 0;
+	struct device_node *dn = dev->device_node;
+	u32 tmp32;
 
 	if (pdata == NULL) {
-		dev_err(dev, "No platform data. Cannot continue\n");
-		return -EINVAL;
+		/* try to get platform data from the device tree */
+		if (dn == NULL) {
+			dev_err(dev, "No platform data. Cannot continue\n");
+			return -EINVAL;
+		}
+
+		pdata = xzalloc(sizeof(struct ide_port_info));
+
+		if (!pdata) {
+			dev_err(dev, "Platform data allocation failed\n");
+			return -ENOMEM;
+		}
+		device_add_data(dev, pdata, sizeof(struct ide_port_info));
+
+		if (of_property_read_bool(dn, "dataif-be"))
+			pdata->dataif_be = 1;
+
+		if (of_property_read_u32(dn, "reg-shift", &tmp32) == 0)
+			pdata->ioport_shift = (unsigned)tmp32;
+
+		dev->platform_data = pdata;
 	}
 
 	reg_base = dev_request_mem_region(dev, 0);
@@ -136,9 +158,18 @@ static int platform_ide_probe(struct device_d *dev)
 	return rc;
 }
 
+static __maybe_unused struct of_device_id platform_ide_dt_ids[] = {
+	{
+		.compatible = "ata-generic",
+	}, {
+		/* sentinel */
+	}
+};
+
 static struct driver_d platform_ide_driver = {
 	.name   = "ide_intf",
 	.probe  = platform_ide_probe,
+	.of_compatible = DRV_OF_COMPAT(platform_ide_dt_ids),
 };
 device_platform_driver(platform_ide_driver);
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2015-09-09  6:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-03 13:38 [PATCH] ata: intf_platform_ide: add OF bindings Peter Mamonov
2015-09-03 14:24 ` Antony Pavlov
2015-09-03 15:33   ` Peter Mamonov
2015-09-03 16:04   ` Peter Mamonov
2015-09-03 18:13     ` Sascha Hauer
2015-09-07 15:44       ` [PATCHv2] " Peter Mamonov
2015-09-07 15:53         ` Lucas Stach
2015-09-07 16:43           ` [PATCHv3] " Peter Mamonov
2015-09-09  6:54             ` Sascha Hauer
2015-09-03 15:46 ` [PATCH] " Lucas Stach
2015-09-03 16:31   ` Antony Pavlov
2015-09-03 18:16     ` Sascha Hauer
2015-09-04 10:15       ` Peter Mamonov
2015-09-04  9:40   ` Peter Mamonov
2015-09-04 10:23     ` Lucas Stach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox