[OpenBIOS] [PATCH 1/3] ide: don't use ioports as part of the controller node address

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Sun Aug 12 14:55:10 CEST 2018


The problem with using the ioport as part of the controller node
address is that the address cannot be determined until after the PCI
BARs have been programmed.

This causes a problem when trying to generate fw bootpaths because by
definition they must be passed to the firmware before PCI initialisation.

Instead of using the controller ioport address, use the controller
index for the node address to provide a consistent device node
regardless of how the PCI BARs are programmed.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
---
 config/examples/ppc64_config.xml |  2 +-
 config/examples/ppc_config.xml   |  2 +-
 drivers/ide.c                    | 18 ++++++++----------
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/config/examples/ppc64_config.xml b/config/examples/ppc64_config.xml
index 5f79c21..bcb605e 100644
--- a/config/examples/ppc64_config.xml
+++ b/config/examples/ppc64_config.xml
@@ -66,7 +66,7 @@
   <option name="CONFIG_DRIVER_IDE" type="boolean" value="true"/>
   <option name="CONFIG_IDE_NUM_CHANNELS" type="integer" value="2"/>
   <option name="CONFIG_IDE_FIRST_UNIT" type="integer" value="1"/>
-  <option name="CONFIG_IDE_DEV_NAME" type="string" value="ata-%d"/>
+  <option name="CONFIG_IDE_DEV_NAME" type="string" value="ata"/>
   <option name="CONFIG_IDE_DEV_TYPE" type="string" value="ata"/>
   <option name="CONFIG_DEBUG_IDE" type="boolean" value="false"/>
   <option name="CONFIG_DRIVER_ADB" type="boolean" value="true"/>
diff --git a/config/examples/ppc_config.xml b/config/examples/ppc_config.xml
index 3112ea5..43277a0 100644
--- a/config/examples/ppc_config.xml
+++ b/config/examples/ppc_config.xml
@@ -72,7 +72,7 @@
   <option name="CONFIG_DRIVER_IDE" type="boolean" value="true"/>
   <option name="CONFIG_IDE_NUM_CHANNELS" type="integer" value="2"/>
   <option name="CONFIG_IDE_FIRST_UNIT" type="integer" value="1"/>
-  <option name="CONFIG_IDE_DEV_NAME" type="string" value="ata-%d"/>
+  <option name="CONFIG_IDE_DEV_NAME" type="string" value="ata"/>
   <option name="CONFIG_IDE_DEV_TYPE" type="string" value="ata"/>
   <option name="CONFIG_DEBUG_IDE" type="boolean" value="false"/>
   <option name="CONFIG_DRIVER_ADB" type="boolean" value="true"/>
diff --git a/drivers/ide.c b/drivers/ide.c
index 274236f..edbd287 100644
--- a/drivers/ide.c
+++ b/drivers/ide.c
@@ -58,7 +58,7 @@ DECLARE_UNNAMED_NODE( ob_ide_ctrl, INSTALL_OPEN, sizeof(int));
 #endif
 
 #ifndef CONFIG_IDE_DEV_NAME
-#define DEV_NAME "ide%d"
+#define DEV_NAME "ide"
 #else
 #define DEV_NAME CONFIG_IDE_DEV_NAME
 #endif
@@ -1457,8 +1457,7 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
 
 		ob_ide_identify_drives(chan);
 
-                snprintf(nodebuff, sizeof(nodebuff), "%s/" DEV_NAME, path,
-                         current_channel);
+		snprintf(nodebuff, sizeof(nodebuff), "%s/" DEV_NAME, path);
 		REGISTER_NAMED_NODE_PHANDLE(ob_ide_ctrl, nodebuff, dnode);
 
 		chan->ph = dnode;
@@ -1469,11 +1468,10 @@ int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
 			     (char *)&props, 2*sizeof(props[0]));
 #endif
 
-		props[0] = __cpu_to_be32(chan->io_regs[0]);
-		props[1] = __cpu_to_be32(1); props[2] = __cpu_to_be32(8);
-		props[3] = __cpu_to_be32(chan->io_regs[8]);
-		props[4] = __cpu_to_be32(1); props[5] = __cpu_to_be32(2);
-		set_property(dnode, "reg", (char *)&props, 6*sizeof(props[0]));
+		props[0] = __cpu_to_be32(current_channel);
+		props[1] = __cpu_to_be32(0);
+		props[2] = 0;
+		set_property(dnode, "reg", (char *)&props, 3*sizeof(props[0]));
 
 		IDE_DPRINTF(DEV_NAME": [io ports 0x%x-0x%x,0x%x]\n",
 		            current_channel, chan->io_regs[0],
@@ -1624,8 +1622,8 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels)
 
 		ob_ide_identify_drives(chan);
 
-                snprintf(nodebuff, sizeof(nodebuff), "%s/" DEV_NAME, path,
-                         current_channel);
+		snprintf(nodebuff, sizeof(nodebuff), "%s/" DEV_NAME "-%d", path,
+                current_channel);
 		REGISTER_NAMED_NODE_PHANDLE(ob_ide_ctrl, nodebuff, dnode);
 
 		chan->ph = dnode;
-- 
2.11.0




More information about the OpenBIOS mailing list