am335x_prcm: Delay the frequencies read check

With Linux 4.17 dts the compatible for the prcm added 'simplebus' we mean
that the simplebus driver will attach to it at the BUS_PASS_BUS pass.
Change the pass for the prcm driver to be at BUS_PASS_BUS so we will win
the attach.
This introduce a problem as this driver needs the ti_scm one to be already
attached. ti_scm also attach at BUS_PASS_BUS but after the prcm one as it is
after in the dtb and the simplebus driver simpy walk the tree to attach it's
children.
Use the bus_new_pass method to defer the frequencies read at BUS_PASS_TIMER.
This fixes booting on BeagleBone*

Reported by:	many
This commit is contained in:
Emmanuel Vadot 2018-05-06 14:37:11 +00:00
parent 67e8b08bbe
commit 41cd649615
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=333305

View File

@ -136,6 +136,7 @@ struct am335x_prcm_softc {
struct resource * res[2];
bus_space_tag_t bst;
bus_space_handle_t bsh;
int attach_done;
};
static struct resource_spec am335x_prcm_spec[] = {
@ -424,7 +425,6 @@ static int
am335x_prcm_attach(device_t dev)
{
struct am335x_prcm_softc *sc = device_get_softc(dev);
unsigned int sysclk, fclk;
if (am335x_prcm_sc)
return (ENXIO);
@ -440,6 +440,24 @@ am335x_prcm_attach(device_t dev)
am335x_prcm_sc = sc;
ti_cpu_reset = am335x_prcm_reset;
return (0);
}
static void
am335x_prcm_new_pass(device_t dev)
{
struct am335x_prcm_softc *sc = device_get_softc(dev);
unsigned int sysclk, fclk;
sc = device_get_softc(dev);
if (sc->attach_done ||
bus_current_pass < (BUS_PASS_TIMER + BUS_PASS_ORDER_EARLY)) {
bus_generic_new_pass(dev);
return;
}
sc->attach_done = 1;
if (am335x_clk_get_sysclk_freq(NULL, &sysclk) != 0)
sysclk = 0;
if (am335x_clk_get_arm_fclk_freq(NULL, &fclk) != 0)
@ -447,15 +465,24 @@ am335x_prcm_attach(device_t dev)
if (sysclk && fclk)
device_printf(dev, "Clocks: System %u.%01u MHz, CPU %u MHz\n",
sysclk/1000000, (sysclk % 1000000)/100000, fclk/1000000);
else
else {
device_printf(dev, "can't read frequencies yet (SCM device not ready?)\n");
goto fail;
}
return (0);
return;
fail:
device_detach(dev);
return;
}
static device_method_t am335x_prcm_methods[] = {
DEVMETHOD(device_probe, am335x_prcm_probe),
DEVMETHOD(device_attach, am335x_prcm_attach),
/* Bus interface */
DEVMETHOD(bus_new_pass, am335x_prcm_new_pass),
{ 0, 0 }
};
@ -468,7 +495,7 @@ static driver_t am335x_prcm_driver = {
static devclass_t am335x_prcm_devclass;
EARLY_DRIVER_MODULE(am335x_prcm, simplebus, am335x_prcm_driver,
am335x_prcm_devclass, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_EARLY);
am335x_prcm_devclass, 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
MODULE_VERSION(am335x_prcm, 1);
MODULE_DEPEND(am335x_prcm, ti_scm, 1, 1, 1);