mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/4] ata: implement detect callback
@ 2013-06-17  8:59 Sascha Hauer
  2013-06-17  8:59 ` [PATCH 2/4] ata: Add detect callback for hardware device Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2013-06-17  8:59 UTC (permalink / raw)
  To: barebox

This makes it possible to use the 'detect' command for ata devices.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/ata/disk_ata_drive.c | 24 +++++++++++++++++++-----
 include/ata_drive.h          |  1 +
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c
index 2cff584..4ad7564 100644
--- a/drivers/ata/disk_ata_drive.c
+++ b/drivers/ata/disk_ata_drive.c
@@ -325,14 +325,10 @@ on_error:
 	return rc;
 }
 
-static int ata_set_probe(struct param_d *param, void *priv)
+int ata_port_detect(struct ata_port *port)
 {
-	struct ata_port *port = priv;
 	int ret;
 
-	if (!port->probe)
-		return 0;
-
 	if (port->initialized) {
 		dev_info(&port->class_dev, "already initialized\n");
 		return 0;
@@ -347,6 +343,23 @@ static int ata_set_probe(struct param_d *param, void *priv)
 	return 0;
 }
 
+static int ata_set_probe(struct param_d *param, void *priv)
+{
+	struct ata_port *port = priv;
+
+	if (!port->probe)
+		return 0;
+
+	return ata_port_detect(port);
+}
+
+static int ata_detect(struct device_d *dev)
+{
+	struct ata_port *port = container_of(dev, struct ata_port, class_dev);
+
+	return ata_port_detect(port);
+}
+
 /**
  * Register an ATA drive behind an IDE like interface
  * @param dev The interface device
@@ -360,6 +373,7 @@ int ata_port_register(struct ata_port *port)
 	port->class_dev.id = DEVICE_ID_DYNAMIC;
 	strcpy(port->class_dev.name, "ata");
 	port->class_dev.parent = port->dev;
+	port->class_dev.detect = ata_detect;
 
 	ret = register_device(&port->class_dev);
 	if (ret)
diff --git a/include/ata_drive.h b/include/ata_drive.h
index 049082f..fcb3a3c 100644
--- a/include/ata_drive.h
+++ b/include/ata_drive.h
@@ -100,6 +100,7 @@ struct ata_port {
 
 int ide_port_register(struct device_d *, struct ata_ioports *);
 int ata_port_register(struct ata_port *port);
+int ata_port_detect(struct ata_port *port);
 
 struct device_d;
 
-- 
1.8.3.1


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

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

* [PATCH 2/4] ata: Add detect callback for hardware device
  2013-06-17  8:59 [PATCH 1/4] ata: implement detect callback Sascha Hauer
@ 2013-06-17  8:59 ` Sascha Hauer
  2013-06-17  8:59 ` [PATCH 3/4] ata: ide: Allow to set the devicename Sascha Hauer
  2013-06-17  8:59 ` [PATCH 4/4] ata: i.MX pata: Add devicetree probe support Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2013-06-17  8:59 UTC (permalink / raw)
  To: barebox

To be able to use the 'detect' command on hardware devices.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/ata/disk_ata_drive.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c
index 4ad7564..4c82797 100644
--- a/drivers/ata/disk_ata_drive.c
+++ b/drivers/ata/disk_ata_drive.c
@@ -360,6 +360,13 @@ static int ata_detect(struct device_d *dev)
 	return ata_port_detect(port);
 }
 
+static int ata_detect_hw(struct device_d *dev)
+{
+	struct ata_port *port = dev->priv;
+
+	return ata_port_detect(port);
+}
+
 /**
  * Register an ATA drive behind an IDE like interface
  * @param dev The interface device
@@ -379,6 +386,9 @@ int ata_port_register(struct ata_port *port)
 	if (ret)
 		return ret;
 
+	port->dev->priv = port;
+	port->dev->detect = ata_detect_hw;
+
 	dev_add_param_bool(&port->class_dev, "probe", ata_set_probe,
 			NULL, &port->probe, port);
 
-- 
1.8.3.1


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

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

* [PATCH 3/4] ata: ide: Allow to set the devicename
  2013-06-17  8:59 [PATCH 1/4] ata: implement detect callback Sascha Hauer
  2013-06-17  8:59 ` [PATCH 2/4] ata: Add detect callback for hardware device Sascha Hauer
@ 2013-06-17  8:59 ` Sascha Hauer
  2013-06-17  8:59 ` [PATCH 4/4] ata: i.MX pata: Add devicetree probe support Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2013-06-17  8:59 UTC (permalink / raw)
  To: barebox

To get persistent devicenames under /dev/ allow to set the
devicename from the driver instead of using "ata" unconditionally.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/ata/disk_ata_drive.c    | 14 +++++++++-----
 drivers/ata/ide-sff.c           |  3 ++-
 drivers/ata/intf_platform_ide.c |  2 +-
 include/ata_drive.h             |  3 ++-
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c
index 4c82797..a25c75e 100644
--- a/drivers/ata/disk_ata_drive.c
+++ b/drivers/ata/disk_ata_drive.c
@@ -298,12 +298,16 @@ static int ata_port_init(struct ata_port *port)
 #ifdef DEBUG
 	ata_dump_id(port->id);
 #endif
-	rc = cdev_find_free_index("ata");
-	if (rc == -1)
-		pr_err("Cannot find a free index for the disk node\n");
+	if (port->devname) {
+		port->blk.cdev.name = xstrdup(port->devname);
+	} else {
+		rc = cdev_find_free_index("ata");
+		if (rc == -1)
+			pr_err("Cannot find a free index for the disk node\n");
+		port->blk.cdev.name = asprintf("ata%d", rc);
+	}
 
 	port->blk.num_blocks = ata_id_n_sectors(port->id);
-	port->blk.cdev.name = asprintf("ata%d", rc);
 	port->blk.blockbits = SECTOR_SHIFT;
 
 	rc = blockdevice_register(&port->blk);
@@ -378,7 +382,7 @@ int ata_port_register(struct ata_port *port)
 	int ret;
 
 	port->class_dev.id = DEVICE_ID_DYNAMIC;
-	strcpy(port->class_dev.name, "ata");
+
 	port->class_dev.parent = port->dev;
 	port->class_dev.detect = ata_detect;
 
diff --git a/drivers/ata/ide-sff.c b/drivers/ata/ide-sff.c
index 632b0e5..ef55357 100644
--- a/drivers/ata/ide-sff.c
+++ b/drivers/ata/ide-sff.c
@@ -324,7 +324,7 @@ static struct ata_port_operations ide_ops = {
 	.reset = ide_reset,
 };
 
-int ide_port_register(struct device_d *dev, struct ata_ioports *io)
+int ide_port_register(struct device_d *dev, struct ata_ioports *io, const char *devname)
 {
 	struct ide_port *ide;
 	int ret;
@@ -334,6 +334,7 @@ int ide_port_register(struct device_d *dev, struct ata_ioports *io)
 	ide->io = io;
 	ide->port.ops = &ide_ops;
 	ide->port.dev = dev;
+	ide->port.devname = devname;
 
 	ret = ata_port_register(&ide->port);
 
diff --git a/drivers/ata/intf_platform_ide.c b/drivers/ata/intf_platform_ide.c
index 0b56eb4..455ac28 100644
--- a/drivers/ata/intf_platform_ide.c
+++ b/drivers/ata/intf_platform_ide.c
@@ -95,7 +95,7 @@ static int platform_ide_probe(struct device_d *dev)
 	io->reset = pdata->reset;
 	io->dataif_be = pdata->dataif_be;
 
-	rc = ide_port_register(dev, io);
+	rc = ide_port_register(dev, io, NULL);
 	if (rc != 0) {
 		dev_err(dev, "Cannot register IDE interface\n");
 		free(io);
diff --git a/include/ata_drive.h b/include/ata_drive.h
index fcb3a3c..2499e62 100644
--- a/include/ata_drive.h
+++ b/include/ata_drive.h
@@ -91,6 +91,7 @@ struct ata_port {
 	struct ata_port_operations *ops;
 	struct device_d *dev;
 	struct device_d class_dev;
+	const char *devname;
 	void *drvdata;
 	struct block_device blk;
 	uint16_t *id;
@@ -98,7 +99,7 @@ struct ata_port {
 	int probe;
 };
 
-int ide_port_register(struct device_d *, struct ata_ioports *);
+int ide_port_register(struct device_d *, struct ata_ioports *, const char *);
 int ata_port_register(struct ata_port *port);
 int ata_port_detect(struct ata_port *port);
 
-- 
1.8.3.1


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

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

* [PATCH 4/4] ata: i.MX pata: Add devicetree probe support
  2013-06-17  8:59 [PATCH 1/4] ata: implement detect callback Sascha Hauer
  2013-06-17  8:59 ` [PATCH 2/4] ata: Add detect callback for hardware device Sascha Hauer
  2013-06-17  8:59 ` [PATCH 3/4] ata: ide: Allow to set the devicename Sascha Hauer
@ 2013-06-17  8:59 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2013-06-17  8:59 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/ata/pata-imx.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/pata-imx.c b/drivers/ata/pata-imx.c
index 5d44883..1cff856 100644
--- a/drivers/ata/pata-imx.c
+++ b/drivers/ata/pata-imx.c
@@ -152,6 +152,7 @@ static int imx_pata_probe(struct device_d *dev)
 	struct clk *clk;
 	void __iomem *base;
 	int ret;
+	const char *devname;
 
 	io = xzalloc(sizeof(struct ata_ioports));
 	base = dev_request_mem_region(dev, 0);
@@ -172,7 +173,13 @@ static int imx_pata_probe(struct device_d *dev)
 
 	pata_imx_set_bus_timing(base, clk_get_rate(clk), 4);
 
-	ret= ide_port_register(dev, io);
+	if (IS_ENABLED(CONFIG_OFDEVICE)) {
+		devname = of_alias_get(dev->device_node);
+		if (devname)
+			devname = xstrdup(devname);
+	}
+
+	ret = ide_port_register(dev, io, devname);
 	if (ret) {
 		dev_err(dev, "Cannot register IDE interface: %s\n",
 				strerror(-ret));
@@ -190,8 +197,15 @@ out_free:
 	return ret;
 }
 
+static __maybe_unused struct of_device_id imx_pata_dt_ids[] = {
+	{
+		.compatible = "fsl,imx27-pata",
+	},
+};
+
 static struct driver_d imx_pata_driver = {
 	.name   = "imx-pata",
 	.probe  = imx_pata_probe,
+	.of_compatible = DRV_OF_COMPAT(imx_pata_dt_ids),
 };
 device_platform_driver(imx_pata_driver);
-- 
1.8.3.1


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

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

end of thread, other threads:[~2013-06-17  8:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-17  8:59 [PATCH 1/4] ata: implement detect callback Sascha Hauer
2013-06-17  8:59 ` [PATCH 2/4] ata: Add detect callback for hardware device Sascha Hauer
2013-06-17  8:59 ` [PATCH 3/4] ata: ide: Allow to set the devicename Sascha Hauer
2013-06-17  8:59 ` [PATCH 4/4] ata: i.MX pata: Add devicetree probe support Sascha Hauer

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