Subject: Re: Adding flag to disable native mode on aceride
To: Manuel Bouyer <bouyer@antioche.eu.org>
From: Chris Gilbert <chris@dokein.co.uk>
List: port-cats
Date: 08/30/2007 22:18:39
This is a multi-part message in MIME format.
--------------070608000706030709040707
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Manuel Bouyer wrote:
> On Thu, Aug 30, 2007 at 11:18:22PM +0900, Izumi Tsutsui wrote:
>> chris@dokein.co.uk wrote:
>>> Does this look ok?  I'd like to check in the chage in then next couple
>>> of days.
>> If the flag is cats specific, it's better to use proplib(3)
>> to specify such quirks rather than config flags,
>> as iyonix/autoconf.c, sgimips/autoconf.c etc. do
>> for their onboard PCI devices.
> 
> Yes, this looks better to me as well
> 

Ok, attached is the diff using proplib instead of flags.  Does this look ok?

Thanks,
Chris

--------------070608000706030709040707
Content-Type: text/plain;
 name="aceride_compat.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="aceride_compat.diff"

Index: arch/cats/cats/autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/cats/cats/autoconf.c,v
retrieving revision 1.11.6.1
diff -u -p -r1.11.6.1 autoconf.c
--- arch/cats/cats/autoconf.c	11 Aug 2007 21:14:52 -0000	1.11.6.1
+++ arch/cats/cats/autoconf.c	30 Aug 2007 21:08:56 -0000
@@ -152,5 +150,18 @@ cpu_configure(void)
 void
 device_register(struct device *dev, void *aux)
 {
+	if (device_is_a(dev, "aceride"))
+	{
+		prop_bool_t force_compat_mode;
+
+		force_compat_mode = prop_bool_create(true);
+
+		if (prop_dictionary_set(device_properties(dev),
+					"force-compat-mode",
+				       	force_compat_mode) == false)
+			printf("WARNING: unable to set force-compat-mode "
+	       				"property for %s\n", dev->dv_xname);
+	     	prop_object_release(force_compat_mode);
+	}
 }
 /* End of autoconf.c */
Index: dev/pci/aceride.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/aceride.c,v
retrieving revision 1.23
diff -u -p -r1.23 aceride.c
--- dev/pci/aceride.c	9 Feb 2007 21:55:27 -0000	1.23
+++ dev/pci/aceride.c	30 Aug 2007 21:08:56 -0000
@@ -167,7 +167,30 @@ acer_chip_map(struct pciide_softc *sc, s
 	    ~ACER_CHANSTATUSREGS_RO);
 	cr = pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_CLASS_REG);
 	cr |= (PCIIDE_CHANSTATUS_EN << PCI_INTERFACE_SHIFT);
+	
+	{
+		/*
+		 * some BIOSes (port-cats ABLE) enable native mode, but don't
+		 * setup everything correctly, so allow the forcing of
+		 * compat mode
+		 */
+		prop_bool_t pn;
+		pn = prop_dictionary_get(
+				device_properties(&sc->sc_wdcdev.sc_atac.atac_dev),
+				"force-compat-mode");
+		if (pn != NULL) {
+			KASSERT(prop_object_type(pn) == PROP_TYPE_BOOL);
+			if (prop_bool_true(pn))
+			{
+				cr &= ~((PCIIDE_INTERFACE_PCI(0)
+					| PCIIDE_INTERFACE_PCI(1))
+					<< PCI_INTERFACE_SHIFT);
+			}
+		}
+	}
+
 	pci_conf_write(sc->sc_pc, sc->sc_tag, PCI_CLASS_REG, cr);
+
 	/* Don't use cr, re-read the real register content instead */
 	interface = PCI_INTERFACE(pci_conf_read(sc->sc_pc, sc->sc_tag,
 	    PCI_CLASS_REG));

--------------070608000706030709040707--