On Mon, May 02, 2016 at 10:25:13AM +0200, Patrick Wildt wrote:
> Hi,
>
> currently the armv7 platform busses always match if the board id is set
> to something they know. This means that even with a device tree the
> platforms will always try to match, even though they should not.
>
> By properly checking for the ma_name member, we can find out if we're
> being asked to run because we're in legacy mode and attach only in that
> case.
>
> ok?
ok jsg@
We'll want that (ma->ma_name == NULL) test in arm/cortex/cortex.c
as well though.
>
> Patrick
>
> diff --git sys/arch/armv7/exynos/exynos.c sys/arch/armv7/exynos/exynos.c
> index 16b7a1e..8e8c7dd 100644
> --- sys/arch/armv7/exynos/exynos.c
> +++ sys/arch/armv7/exynos/exynos.c
> @@ -20,10 +20,8 @@
> #include <sys/systm.h>
>
> #include <machine/bus.h>
> -#if NFDT > 0
> -#include <machine/fdt.h>
> -#endif
>
> +#include <arm/mainbus/mainbus.h>
> #include <armv7/armv7/armv7var.h>
>
> int exynos_match(struct device *, void *, void *);
> @@ -171,12 +169,14 @@ exynos_board_name(void)
> int
> exynos_match(struct device *parent, void *cfdata, void *aux)
> {
> -#if NFDT > 0
> - /* If we're running with fdt, do not attach. */
> - /* XXX: Find a better way. */
> - if (fdt_next_node(0))
> + union mainbus_attach_args *ma = (union mainbus_attach_args *)aux;
> + struct cfdata *cf = (struct cfdata *)cfdata;
> +
> + if (ma->ma_name == NULL)
> + return (0);
> +
> + if (strcmp(cf->cf_driver->cd_name, ma->ma_name) != 0)
> return (0);
> -#endif
>
> return (exynos_board_devs() != NULL);
> }
> diff --git sys/arch/armv7/imx/imx.c sys/arch/armv7/imx/imx.c
> index 0471a21..f6102e0 100644
> --- sys/arch/armv7/imx/imx.c
> +++ sys/arch/armv7/imx/imx.c
> @@ -21,6 +21,7 @@
>
> #include <machine/bus.h>
>
> +#include <arm/mainbus/mainbus.h>
> #include <armv7/armv7/armv7var.h>
>
> int imx_match(struct device *, void *, void *);
> @@ -301,5 +302,14 @@ imx_board_name(void)
> int
> imx_match(struct device *parent, void *cfdata, void *aux)
> {
> + union mainbus_attach_args *ma = (union mainbus_attach_args *)aux;
> + struct cfdata *cf = (struct cfdata *)cfdata;
> +
> + if (ma->ma_name == NULL)
> + return (0);
> +
> + if (strcmp(cf->cf_driver->cd_name, ma->ma_name) != 0)
> + return (0);
> +
> return (imx_board_devs() != NULL);
> }
> diff --git sys/arch/armv7/omap/omap.c sys/arch/armv7/omap/omap.c
> index 837ebef..c195360 100644
> --- sys/arch/armv7/omap/omap.c
> +++ sys/arch/armv7/omap/omap.c
> @@ -20,6 +20,7 @@
>
> #include <machine/bus.h>
>
> +#include <arm/mainbus/mainbus.h>
> #include <armv7/armv7/armv7var.h>
>
> int omap_match(struct device *, void *, void *);
> @@ -175,5 +176,14 @@ omap_board_name(void)
> int
> omap_match(struct device *parent, void *cfdata, void *aux)
> {
> + union mainbus_attach_args *ma = (union mainbus_attach_args *)aux;
> + struct cfdata *cf = (struct cfdata *)cfdata;
> +
> + if (ma->ma_name == NULL)
> + return (0);
> +
> + if (strcmp(cf->cf_driver->cd_name, ma->ma_name) != 0)
> + return (0);
> +
> return (omap_board_devs() != NULL);
> }
> diff --git sys/arch/armv7/sunxi/sunxi.c sys/arch/armv7/sunxi/sunxi.c
> index dac0348..380f9be 100644
> --- sys/arch/armv7/sunxi/sunxi.c
> +++ sys/arch/armv7/sunxi/sunxi.c
> @@ -21,6 +21,7 @@
> #include <machine/bus.h>
>
> #include <arm/armv7/armv7var.h>
> +#include <arm/mainbus/mainbus.h>
> #include <armv7/armv7/armv7var.h>
> #include <armv7/sunxi/sunxireg.h>
>
> @@ -155,5 +156,14 @@ sunxi_board_name(void)
> int
> sunxi_match(struct device *parent, void *cfdata, void *aux)
> {
> + union mainbus_attach_args *ma = (union mainbus_attach_args *)aux;
> + struct cfdata *cf = (struct cfdata *)cfdata;
> +
> + if (ma->ma_name == NULL)
> + return (0);
> +
> + if (strcmp(cf->cf_driver->cd_name, ma->ma_name) != 0)
> + return (0);
> +
> return (sunxi_board_devs() != NULL);
> }
> diff --git sys/arch/armv7/vexpress/vexpress.c
> sys/arch/armv7/vexpress/vexpress.c
> index fcf33f8..1724ddc 100644
> --- sys/arch/armv7/vexpress/vexpress.c
> +++ sys/arch/armv7/vexpress/vexpress.c
> @@ -22,6 +22,7 @@
> #include <machine/bus.h>
>
> #include <arm/cpufunc.h>
> +#include <arm/mainbus/mainbus.h>
> #include <armv7/armv7/armv7var.h>
>
> int vexpress_match(struct device *, void *, void *);
> @@ -105,5 +106,14 @@ vexpress_board_name(void)
> int
> vexpress_match(struct device *parent, void *cfdata, void *aux)
> {
> + union mainbus_attach_args *ma = (union mainbus_attach_args *)aux;
> + struct cfdata *cf = (struct cfdata *)cfdata;
> +
> + if (ma->ma_name == NULL)
> + return (0);
> +
> + if (strcmp(cf->cf_driver->cd_name, ma->ma_name) != 0)
> + return (0);
> +
> return (vexpress_board_devs() != NULL);
> }
>