From b1dbbe4da207d2814133953410b77530989aea9a Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Mon, 5 Mar 2018 02:13:28 +0000 Subject: [PATCH] Defer attaching the spibus until timers and interrupts are working. The driver requires interrupts to do transfers, and the drivers for the SPI devices on the bus quite reasonably expect to be able to do IO while probing and attaching. --- sys/arm/freescale/imx/imx_spi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/arm/freescale/imx/imx_spi.c b/sys/arm/freescale/imx/imx_spi.c index b6707db99147..00783d385e79 100644 --- a/sys/arm/freescale/imx/imx_spi.c +++ b/sys/arm/freescale/imx/imx_spi.c @@ -558,9 +558,16 @@ spi_attach(device_t dev) */ WR4(sc, ECSPI_CTLREG, CTLREG_CMODES_MASTER); - /* Attach the bus driver. */ + /* + * Add the spibus driver as a child, and setup a one-shot intrhook to + * attach it after interrupts are working. It will attach actual SPI + * devices as its children, and those devices may need to do IO during + * their attach. We can't do IO until timers and interrupts are working. + */ sc->spibus = device_add_child(dev, "spibus", -1); - return (bus_generic_attach(sc->dev)); + config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev); + + return (0); } static int