Subject: Re: Adding flag to disable native mode on aceride
To: Chris Gilbert <chris@dokein.co.uk>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-kern
Date: 09/23/2007 15:24:09
My goal is to not rely on driver names in MD code.  Yes, I know we  
already violate this in many places...  Anyway, my point is that you  
don't need to test for "aceride".

-- thorpej@iPhone

On Sep 23, 2007, at 3:07 AM, Chris Gilbert <chris@dokein.co.uk> wrote:

> Jason Thorpe wrote:
>>
>> you should consult the actual PCI bus/device/function numbers, the  
>> way
>> other platforms fix-up MI drivers for MD quirks.
>
> Done.
>
>> The name of the property should reflect that it's aceride-specific  
>> (and
>> not have a name that ties it to the driver): ali1543-ide-force- 
>> compat-mode
>
> Also done.
>
> I also took note of Jachym suggestion to use
> prop_dictionary_{get|set}_bool functions, rather than manipulating a
> prop_bool.
>
> Does the attached diff look ok?  I'm hoping to check it in this week.
>
> Thanks,
> Chris
> Index: arch/cats/cats/autoconf.c
> ===================================================================
> RCS file: /cvsroot/src/sys/arch/cats/cats/autoconf.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 autoconf.c
> --- arch/cats/cats/autoconf.c    30 Jul 2007 12:25:14 -0000    1.11
> +++ arch/cats/cats/autoconf.c    23 Sep 2007 09:53:43 -0000
> @@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
> #include <sys/malloc.h>
> #include <machine/bootconfig.h>
> #include <machine/intr.h>
> +#include <dev/pci/pcivar.h>
>
> #include "isa.h"
>
> @@ -167,5 +168,23 @@ cpu_configure(void)
> void
> device_register(struct device *dev, void *aux)
> {
> +    if (device_is_a(dev, "aceride"))
> +    {
> +        /* cats builtin aceride is on 0:16:0 */
> +        struct pci_attach_args *pa = aux;
> +        if (((pa)->pa_bus == 0
> +            && (pa)->pa_device == 16
> +            && (pa)->pa_function == 0))
> +        {
> +            if (prop_dictionary_set_bool(device_properties(dev),
> +                        "ali1543-ide-force-compat-mode",
> +                        true) == false)
> +            {
> +                printf("WARNING: unable to set "
> +                    "ali1543-ide-force-compat-mode "
> +                    "property for %s\n", dev->dv_xname);
> +            }
> +        }
> +    }
> }
> /* 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    23 Sep 2007 09:53:43 -0000
> @@ -167,6 +167,27 @@ 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
> +         */
> +        bool force_compat_mode;
> +        bool property_is_set;
> +        property_is_set = prop_dictionary_get_bool(
> +                device_properties(&sc->sc_wdcdev.sc_atac.atac_dev),
> +                "ali1543-ide-force-compat-mode",
> +                &force_compat_mode);
> +        if (property_is_set && force_compat_mode)
> +        {
> +            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,