Oups, next module dependency on autogenerated header...
Fixed in r363758.

Thanks for report
Michal


On 01.08.2020 6:39, Mateusz Guzik wrote:
> This breaks tinderbox for several arm kernels.
> 
> On 7/30/20, Michal Meloun <m...@freebsd.org> wrote:
>> Author: mmel
>> Date: Thu Jul 30 14:45:05 2020
>> New Revision: 363700
>> URL: https://svnweb.freebsd.org/changeset/base/363700
>>
>> Log:
>>   Move Ti AM335x to dev/extres/clk framework.
>>
>>   Re-implement clocks for these SoC by using now standard extres/clk
>> framework.
>>   This is necessary for future expansion of these. The new  implementation
>>   is (due to the size of the patch) only the initial (minimum) version.
>>   It will be updated/expanded with a subsequent set of particular patches.
>>
>>   This patch is also not tested on OMAP4 based boards (BeagleBone),
>>   so all possible issues should be (and will be) fixed by ASAP once
>>   identified.
>>
>>   Submited by:               Oskar Holmlund (oskar.holml...@ohdata.se)
>>   Differential Revision:  https://reviews.freebsd.org/D25118
>>
>> Added:
>>   head/sys/arm/ti/am335x/am3359_cppi41.c   (contents, props changed)
>>   head/sys/arm/ti/am335x/am335x_usb_phy.c   (contents, props changed)
>>   head/sys/arm/ti/clk/
>>   head/sys/arm/ti/clk/clock_common.c   (contents, props changed)
>>   head/sys/arm/ti/clk/clock_common.h   (contents, props changed)
>>   head/sys/arm/ti/clk/ti_clk_clkctrl.c   (contents, props changed)
>>   head/sys/arm/ti/clk/ti_clk_clkctrl.h   (contents, props changed)
>>   head/sys/arm/ti/clk/ti_clk_dpll.c   (contents, props changed)
>>   head/sys/arm/ti/clk/ti_clk_dpll.h   (contents, props changed)
>>   head/sys/arm/ti/clk/ti_clkctrl.c   (contents, props changed)
>>   head/sys/arm/ti/clk/ti_divider_clock.c   (contents, props changed)
>>   head/sys/arm/ti/clk/ti_dpll_clock.c   (contents, props changed)
>>   head/sys/arm/ti/clk/ti_gate_clock.c   (contents, props changed)
>>   head/sys/arm/ti/clk/ti_mux_clock.c   (contents, props changed)
>>   head/sys/arm/ti/ti_omap4_cm.c   (contents, props changed)
>>   head/sys/arm/ti/ti_omap4_cm.h   (contents, props changed)
>>   head/sys/arm/ti/ti_prm.c   (contents, props changed)
>>   head/sys/arm/ti/ti_prm.h   (contents, props changed)
>>   head/sys/arm/ti/ti_scm_syscon.c   (contents, props changed)
>>   head/sys/arm/ti/ti_sysc.h   (contents, props changed)
>> Deleted:
>>   head/sys/arm/ti/am335x/am335x_prcm.c
>>   head/sys/arm/ti/am335x/am335x_usbss.c
>>   head/sys/arm/ti/ti_hwmods.c
>>   head/sys/arm/ti/ti_hwmods.h
>> Modified:
>>   head/sys/arm/ti/am335x/am335x_dmtimer.c
>>   head/sys/arm/ti/am335x/am335x_dmtpps.c
>>   head/sys/arm/ti/am335x/am335x_dmtreg.h
>>   head/sys/arm/ti/am335x/am335x_gpio.c
>>   head/sys/arm/ti/am335x/am335x_lcd.c
>>   head/sys/arm/ti/am335x/am335x_musb.c
>>   head/sys/arm/ti/am335x/am335x_pwmss.c
>>   head/sys/arm/ti/am335x/am335x_rtc.c
>>   head/sys/arm/ti/am335x/am335x_scm.c
>>   head/sys/arm/ti/am335x/files.am335x
>>   head/sys/arm/ti/cpsw/if_cpsw.c
>>   head/sys/arm/ti/files.ti
>>   head/sys/arm/ti/omap4/files.omap4
>>   head/sys/arm/ti/ti_adc.c
>>   head/sys/arm/ti/ti_edma3.c
>>   head/sys/arm/ti/ti_gpio.c
>>   head/sys/arm/ti/ti_i2c.c
>>   head/sys/arm/ti/ti_mbox.c
>>   head/sys/arm/ti/ti_pinmux.c
>>   head/sys/arm/ti/ti_prcm.c
>>   head/sys/arm/ti/ti_prcm.h
>>   head/sys/arm/ti/ti_pruss.c
>>   head/sys/arm/ti/ti_scm.c
>>   head/sys/arm/ti/ti_sdhci.c
>>   head/sys/arm/ti/ti_sdma.c
>>   head/sys/arm/ti/ti_spi.c
>>   head/sys/arm/ti/ti_sysc.c
>>   head/sys/arm/ti/ti_wdt.c
>>   head/sys/arm/ti/usb/omap_ehci.c
>>   head/sys/arm/ti/usb/omap_host.c
>>   head/sys/arm/ti/usb/omap_tll.c
>>   head/sys/dev/uart/uart_dev_ti8250.c
>>   head/sys/modules/Makefile
>>
>> Added: head/sys/arm/ti/am335x/am3359_cppi41.c
>> ==============================================================================
>> --- /dev/null        00:00:00 1970   (empty, because file is newly added)
>> +++ head/sys/arm/ti/am335x/am3359_cppi41.c   Thu Jul 30 14:45:05
>> 2020 (r363700)
>> @@ -0,0 +1,192 @@
>> +/*-
>> + * Copyright (c) 2019 Emmanuel Vadot <m...@freebsd.org>
>> + *
>> + * Copyright (c) 2020 Oskar Holmlund <oskar.holml...@ohdata.se>
>> + *
>> + * Redistribution and use in source and binary forms, with or without
>> + * modification, are permitted provided that the following conditions
>> + * are met:
>> + * 1. Redistributions of source code must retain the above copyright
>> + *    notice, this list of conditions and the following disclaimer.
>> + * 2. Redistributions in binary form must reproduce the above copyright
>> + *    notice, this list of conditions and the following disclaimer in the
>> + *    documentation and/or other materials provided with the distribution.
>> + *
>> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
>> + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
>> WARRANTIES
>> + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
>> + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
>> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
>> + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
>> + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
>> + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>> + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
>> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>> + * SUCH DAMAGE.
>> + *
>> + * $FreeBSD$
>> + */
>> +/* Based on sys/arm/ti/ti_sysc.c */
>> +
>> +#include <sys/cdefs.h>
>> +__FBSDID("$FreeBSD$");
>> +
>> +#include <sys/param.h>
>> +#include <sys/systm.h>
>> +#include <sys/kernel.h>
>> +#include <sys/module.h>
>> +#include <sys/bus.h>
>> +#include <sys/resource.h>
>> +#include <sys/rman.h>
>> +#include <sys/lock.h>
>> +#include <sys/mutex.h>
>> +
>> +#include <machine/bus.h>
>> +#include <machine/resource.h>
>> +
>> +#include <dev/fdt/simplebus.h>
>> +
>> +#include <dev/ofw/openfirm.h>
>> +#include <dev/ofw/ofw_bus.h>
>> +#include <dev/ofw/ofw_bus_subr.h>
>> +
>> +#include <arm/ti/ti_sysc.h>
>> +
>> +#if 0
>> +#define DPRINTF(dev, msg...) device_printf(dev, msg)
>> +#else
>> +#define DPRINTF(dev, msg...)
>> +#endif
>> +
>> +struct ti_am3359_cppi41_softc {
>> +    device_t                dev;
>> +    struct syscon *         syscon;
>> +    struct resource *       res[4];
>> +    bus_space_tag_t         bst;
>> +    bus_space_handle_t      bsh;
>> +    struct mtx              mtx;
>> +};
>> +
>> +static struct resource_spec ti_am3359_cppi41_res_spec[] = {
>> +    { SYS_RES_MEMORY, 0, RF_ACTIVE | RF_SHAREABLE },
>> +    { SYS_RES_MEMORY, 1, RF_ACTIVE | RF_SHAREABLE },
>> +    { SYS_RES_MEMORY, 2, RF_ACTIVE | RF_SHAREABLE },
>> +    { SYS_RES_MEMORY, 3, RF_ACTIVE | RF_SHAREABLE },
>> +    { -1, 0 }
>> +};
>> +
>> +/* Device */
>> +static struct ofw_compat_data compat_data[] = {
>> +    { "ti,am3359-cppi41",   1 },
>> +    { NULL,         0 }
>> +};
>> +
>> +static int
>> +ti_am3359_cppi41_write_4(device_t dev, bus_addr_t addr, uint32_t val)
>> +{
>> +    struct ti_am3359_cppi41_softc *sc;
>> +
>> +    sc = device_get_softc(dev);
>> +    DPRINTF(sc->dev, "offset=%lx write %x\n", addr, val);
>> +    mtx_lock(&sc->mtx);
>> +    bus_space_write_4(sc->bst, sc->bsh, addr, val);
>> +    mtx_unlock(&sc->mtx);
>> +    return (0);
>> +}
>> +
>> +static uint32_t
>> +ti_am3359_cppi41_read_4(device_t dev, bus_addr_t addr)
>> +{
>> +    struct ti_am3359_cppi41_softc *sc;
>> +    uint32_t val;
>> +
>> +    sc = device_get_softc(dev);
>> +
>> +    mtx_lock(&sc->mtx);
>> +    val = bus_space_read_4(sc->bst, sc->bsh, addr);
>> +    mtx_unlock(&sc->mtx);
>> +    DPRINTF(sc->dev, "offset=%lx Read %x\n", addr, val);
>> +    return (val);
>> +}
>> +
>> +/* device interface */
>> +static int
>> +ti_am3359_cppi41_probe(device_t dev)
>> +{
>> +    if (!ofw_bus_status_okay(dev))
>> +            return (ENXIO);
>> +
>> +    if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
>> +            return (ENXIO);
>> +
>> +    device_set_desc(dev, "TI AM3359 CPPI 41");
>> +    return(BUS_PROBE_DEFAULT);
>> +}
>> +
>> +static int
>> +ti_am3359_cppi41_attach(device_t dev)
>> +{
>> +    struct ti_am3359_cppi41_softc *sc;
>> +    phandle_t node;
>> +    uint32_t reg, reset_bit, timeout=10;
>> +    uint64_t sysc_address;
>> +    device_t parent;
>> +
>> +    sc = device_get_softc(dev);
>> +    sc->dev = dev;
>> +
>> +    if (bus_alloc_resources(dev, ti_am3359_cppi41_res_spec, sc->res)) {
>> +            device_printf(sc->dev, "Cant allocate resources\n");
>> +            return (ENXIO);
>> +    }
>> +
>> +    sc->dev = dev;
>> +    sc->bst = rman_get_bustag(sc->res[0]);
>> +    sc->bsh = rman_get_bushandle(sc->res[0]);
>> +
>> +    mtx_init(&sc->mtx, device_get_nameunit(sc->dev), NULL, MTX_DEF);
>> +    node = ofw_bus_get_node(sc->dev);
>> +
>> +    /* variant of am335x_usbss.c */
>> +    DPRINTF(dev, "-- RESET USB --\n");
>> +    parent = device_get_parent(dev);
>> +    reset_bit = ti_sysc_get_soft_reset_bit(parent);
>> +    if (reset_bit == 0) {
>> +            DPRINTF(dev, "Dont have reset bit\n");
>> +            return (0);
>> +    }
>> +    sysc_address = ti_sysc_get_sysc_address_offset_host(parent);
>> +    DPRINTF(dev, "sysc_address %x\n", sysc_address);
>> +    ti_am3359_cppi41_write_4(dev, sysc_address, reset_bit);
>> +    DELAY(100);
>> +    reg = ti_am3359_cppi41_read_4(dev, sysc_address);
>> +    if ((reg & reset_bit) && timeout--) {
>> +            DPRINTF(dev, "Reset still ongoing - wait a little bit 
>> longer\n");
>> +            DELAY(100);
>> +            reg = ti_am3359_cppi41_read_4(dev, sysc_address);
>> +    }
>> +    if (timeout == 0)
>> +            device_printf(dev, "USB Reset timeout\n");
>> +
>> +    return (0);
>> +}
>> +
>> +
>> +static device_method_t ti_am3359_cppi41_methods[] = {
>> +    DEVMETHOD(device_probe,         ti_am3359_cppi41_probe),
>> +    DEVMETHOD(device_attach,        ti_am3359_cppi41_attach),
>> +
>> +    DEVMETHOD_END
>> +};
>> +
>> +
>> +DEFINE_CLASS_1(ti_am3359_cppi41, ti_am3359_cppi41_driver,
>> +    ti_am3359_cppi41_methods,sizeof(struct ti_am3359_cppi41_softc),
>> +    simplebus_driver);
>> +
>> +static devclass_t ti_am3359_cppi41_devclass;
>> +
>> +EARLY_DRIVER_MODULE(ti_am3359_cppi41, simplebus, ti_am3359_cppi41_driver,
>> +    ti_am3359_cppi41_devclass, 0, 0, BUS_PASS_BUS +
>> BUS_PASS_ORDER_MIDDLE);
>> +MODULE_VERSION(ti_am3359_cppi41, 1);
>> +MODULE_DEPEND(ti_am3359_cppi41, ti_sysc, 1, 1, 1);
>>
>> Modified: head/sys/arm/ti/am335x/am335x_dmtimer.c
>> ==============================================================================
>> --- head/sys/arm/ti/am335x/am335x_dmtimer.c  Thu Jul 30 14:42:50
>> 2020 (r363699)
>> +++ head/sys/arm/ti/am335x/am335x_dmtimer.c  Thu Jul 30 14:45:05
>> 2020 (r363700)
>> @@ -42,12 +42,13 @@ __FBSDID("$FreeBSD$");
>>
>>  #include <machine/machdep.h> /* For arm_set_delay */
>>
>> +#include <dev/extres/clk/clk.h>
>> +
>>  #include <dev/ofw/openfirm.h>
>>  #include <dev/ofw/ofw_bus.h>
>>  #include <dev/ofw/ofw_bus_subr.h>
>>
>> -#include <arm/ti/ti_prcm.h>
>> -#include <arm/ti/ti_hwmods.h>
>> +#include <arm/ti/ti_sysc.h>
>>
>>  #include "am335x_dmtreg.h"
>>
>> @@ -58,7 +59,8 @@ struct am335x_dmtimer_softc {
>>      int                     tmr_irq_rid;
>>      struct resource *       tmr_irq_res;
>>      void                    *tmr_irq_handler;
>> -    uint32_t                sysclk_freq;
>> +    clk_t                   clk_fck;
>> +    uint64_t                sysclk_freq;
>>      uint32_t                tclr;           /* Cached TCLR register. */
>>      union {
>>              struct timecounter tc;
>> @@ -251,6 +253,7 @@ am335x_dmtimer_probe(device_t dev)
>>  {
>>      char strbuf[32];
>>      int tmr_num;
>> +    uint64_t rev_address;
>>
>>      if (!ofw_bus_status_okay(dev))
>>              return (ENXIO);
>> @@ -259,13 +262,22 @@ am335x_dmtimer_probe(device_t dev)
>>              return (ENXIO);
>>
>>      /*
>> -     * Get the hardware unit number (the N from ti,hwmods="timerN").
>> +     * Get the hardware unit number from address of rev register.
>>       * If this isn't the hardware unit we're going to use for either the
>>       * eventtimer or the timecounter, no point in instantiating the device.
>>       */
>> -    tmr_num = ti_hwmods_get_unit(dev, "timer");
>> -    if (tmr_num != ET_TMR_NUM && tmr_num != TC_TMR_NUM)
>> -            return (ENXIO);
>> +    rev_address = ti_sysc_get_rev_address(device_get_parent(dev));
>> +    switch (rev_address) {
>> +            case DMTIMER2_REV:
>> +                    tmr_num = 2;
>> +                    break;
>> +            case DMTIMER3_REV:
>> +                    tmr_num = 3;
>> +                    break;
>> +            default:
>> +                    /* Not DMTIMER2 or DMTIMER3 */
>> +                    return (ENXIO);
>> +    }
>>
>>      snprintf(strbuf, sizeof(strbuf), "AM335x DMTimer%d", tmr_num);
>>      device_set_desc_copy(dev, strbuf);
>> @@ -277,24 +289,47 @@ static int
>>  am335x_dmtimer_attach(device_t dev)
>>  {
>>      struct am335x_dmtimer_softc *sc;
>> -    clk_ident_t timer_id;
>>      int err;
>> +    uint64_t rev_address;
>> +    clk_t sys_clkin;
>>
>>      sc = device_get_softc(dev);
>>      sc->dev = dev;
>>
>> -    /* Get the base clock frequency. */
>> -    if ((err = ti_prcm_clk_get_source_freq(SYS_CLK, &sc->sysclk_freq)) != 0)
>> -            return (err);
>> +    /* expect one clock */
>> +    err = clk_get_by_ofw_index(dev, 0, 0, &sc->clk_fck);
>> +    if (err != 0) {
>> +            device_printf(dev, "Cant find clock index 0. err: %d\n", err);
>> +            return (ENXIO);
>> +    }
>>
>> +    err = clk_get_by_name(dev, "sys_clkin_ck@40", &sys_clkin);
>> +    if (err != 0) {
>> +            device_printf(dev, "Cant find sys_clkin_ck@40 err: %d\n", err);
>> +            return (ENXIO);
>> +    }
>> +
>> +    /* Select M_OSC as DPLL parent */
>> +    err = clk_set_parent_by_clk(sc->clk_fck, sys_clkin);
>> +    if (err != 0) {
>> +            device_printf(dev, "Cant set mux to CLK_M_OSC\n");
>> +            return (ENXIO);
>> +    }
>> +
>>      /* Enable clocks and power on the device. */
>> -    if ((timer_id = ti_hwmods_get_clock(dev)) == INVALID_CLK_IDENT)
>> +    err = ti_sysc_clock_enable(device_get_parent(dev));
>> +    if (err != 0) {
>> +            device_printf(dev, "Cant enable sysc clkctrl, err %d\n", err);
>>              return (ENXIO);
>> -    if ((err = ti_prcm_clk_set_source(timer_id, SYSCLK_CLK)) != 0)
>> -            return (err);
>> -    if ((err = ti_prcm_clk_enable(timer_id)) != 0)
>> -            return (err);
>> +    }
>>
>> +    /* Get the base clock frequency. */
>> +    err = clk_get_freq(sc->clk_fck, &sc->sysclk_freq);
>> +    if (err != 0) {
>> +            device_printf(dev, "Cant get sysclk frequency, err %d\n", err);
>> +            return (ENXIO);
>> +    }
>> +
>>      /* Request the memory resources. */
>>      sc->tmr_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
>>          &sc->tmr_mem_rid, RF_ACTIVE);
>> @@ -302,7 +337,20 @@ am335x_dmtimer_attach(device_t dev)
>>              return (ENXIO);
>>      }
>>
>> -    sc->tmr_num = ti_hwmods_get_unit(dev, "timer");
>> +    rev_address = ti_sysc_get_rev_address(device_get_parent(dev));
>> +    switch (rev_address) {
>> +            case DMTIMER2_REV:
>> +                    sc->tmr_num = 2;
>> +                    break;
>> +            case DMTIMER3_REV:
>> +                    sc->tmr_num = 3;
>> +                    break;
>> +            default:
>> +                    device_printf(dev, "Not timer 2 or 3! %#jx\n",
>> +                        rev_address);
>> +                    return (ENXIO);
>> +    }
>> +
>>      snprintf(sc->tmr_name, sizeof(sc->tmr_name), "DMTimer%d", sc->tmr_num);
>>
>>      /*
>> @@ -334,7 +382,7 @@ static driver_t am335x_dmtimer_driver = {
>>  static devclass_t am335x_dmtimer_devclass;
>>
>>  DRIVER_MODULE(am335x_dmtimer, simplebus, am335x_dmtimer_driver,
>> am335x_dmtimer_devclass, 0, 0);
>> -MODULE_DEPEND(am335x_dmtimer, am335x_prcm, 1, 1, 1);
>> +MODULE_DEPEND(am335x_dmtimer, ti_sysc, 1, 1, 1);
>>
>>  static void
>>  am335x_dmtimer_delay(int usec, void *arg)
>>
>> Modified: head/sys/arm/ti/am335x/am335x_dmtpps.c
>> ==============================================================================
>> --- head/sys/arm/ti/am335x/am335x_dmtpps.c   Thu Jul 30 14:42:50
>> 2020 (r363699)
>> +++ head/sys/arm/ti/am335x/am335x_dmtpps.c   Thu Jul 30 14:45:05
>> 2020 (r363700)
>> @@ -43,6 +43,8 @@
>>  #include <sys/cdefs.h>
>>  __FBSDID("$FreeBSD$");
>>
>> +#include "opt_platform.h"
>> +
>>  #include <sys/param.h>
>>  #include <sys/systm.h>
>>  #include <sys/bus.h>
>> @@ -60,9 +62,9 @@ __FBSDID("$FreeBSD$");
>>  #include <dev/ofw/openfirm.h>
>>  #include <dev/ofw/ofw_bus.h>
>>  #include <dev/ofw/ofw_bus_subr.h>
>> +#include <dev/extres/clk/clk.h>
>>
>> -#include <arm/ti/ti_prcm.h>
>> -#include <arm/ti/ti_hwmods.h>
>> +#include <arm/ti/ti_sysc.h>
>>  #include <arm/ti/ti_pinmux.h>
>>  #include <arm/ti/am335x/am335x_scm_padconf.h>
>>
>> @@ -82,6 +84,8 @@ struct dmtpps_softc {
>>      struct cdev *           pps_cdev;
>>      struct pps_state        pps_state;
>>      struct mtx              pps_mtx;
>> +    clk_t                   clk_fck;
>> +    uint64_t                sysclk_freq;
>>  };
>>
>>  static int dmtpps_tmr_num;  /* Set by probe() */
>> @@ -383,6 +387,7 @@ dmtpps_probe(device_t dev)
>>  {
>>      char strbuf[64];
>>      int tmr_num;
>> +    uint64_t rev_address;
>>
>>      if (!ofw_bus_status_okay(dev))
>>              return (ENXIO);
>> @@ -402,7 +407,33 @@ dmtpps_probe(device_t dev)
>>       * Figure out which hardware timer is being probed and see if it matches
>>       * the configured timer number determined earlier.
>>       */
>> -    tmr_num = ti_hwmods_get_unit(dev, "timer");
>> +    rev_address = ti_sysc_get_rev_address(device_get_parent(dev));
>> +    switch (rev_address) {
>> +            case DMTIMER1_1MS_REV:
>> +                    tmr_num = 1;
>> +                    break;
>> +            case DMTIMER2_REV:
>> +                    tmr_num = 2;
>> +                    break;
>> +            case DMTIMER3_REV:
>> +                    tmr_num = 3;
>> +                    break;
>> +            case DMTIMER4_REV:
>> +                    tmr_num = 4;
>> +                    break;
>> +            case DMTIMER5_REV:
>> +                    tmr_num = 5;
>> +                    break;
>> +            case DMTIMER6_REV:
>> +                    tmr_num = 6;
>> +                    break;
>> +            case DMTIMER7_REV:
>> +                    tmr_num = 7;
>> +                    break;
>> +            default:
>> +                    return (ENXIO);
>> +        }
>> +
>>      if (dmtpps_tmr_num != tmr_num)
>>              return (ENXIO);
>>
>> @@ -418,23 +449,73 @@ dmtpps_attach(device_t dev)
>>  {
>>      struct dmtpps_softc *sc;
>>      struct make_dev_args mda;
>> -    clk_ident_t timer_id;
>> -    int err, sysclk_freq;
>> +    int err;
>> +    clk_t sys_clkin;
>> +    uint64_t rev_address;
>>
>>      sc = device_get_softc(dev);
>>      sc->dev = dev;
>>
>> -    /* Get the base clock frequency. */
>> -    err = ti_prcm_clk_get_source_freq(SYS_CLK, &sysclk_freq);
>> +    /* Figure out which hardware timer this is and set the name string. */
>> +    rev_address = ti_sysc_get_rev_address(device_get_parent(dev));
>> +    switch (rev_address) {
>> +            case DMTIMER1_1MS_REV:
>> +                    sc->tmr_num = 1;
>> +                    break;
>> +            case DMTIMER2_REV:
>> +                    sc->tmr_num = 2;
>> +                    break;
>> +            case DMTIMER3_REV:
>> +                    sc->tmr_num = 3;
>> +                    break;
>> +            case DMTIMER4_REV:
>> +                    sc->tmr_num = 4;
>> +                    break;
>> +            case DMTIMER5_REV:
>> +                    sc->tmr_num = 5;
>> +                    break;
>> +            case DMTIMER6_REV:
>> +                    sc->tmr_num = 6;
>> +                    break;
>> +            case DMTIMER7_REV:
>> +                    sc->tmr_num = 7;
>> +                    break;
>> +        }
>> +    snprintf(sc->tmr_name, sizeof(sc->tmr_name), "DMTimer%d", sc->tmr_num);
>>
>> +    /* expect one clock */
>> +    err = clk_get_by_ofw_index(dev, 0, 0, &sc->clk_fck);
>> +    if (err != 0) {
>> +            device_printf(dev, "Cant find clock index 0. err: %d\n", err);
>> +            return (ENXIO);
>> +    }
>> +
>> +    err = clk_get_by_name(dev, "sys_clkin_ck@40", &sys_clkin);
>> +    if (err != 0) {
>> +            device_printf(dev, "Cant find sys_clkin_ck@40 err: %d\n", err);
>> +            return (ENXIO);
>> +    }
>> +
>> +    /* Select M_OSC as DPLL parent */
>> +    err = clk_set_parent_by_clk(sc->clk_fck, sys_clkin);
>> +    if (err != 0) {
>> +            device_printf(dev, "Cant set mux to CLK_M_OSC\n");
>> +            return (ENXIO);
>> +    }
>> +
>>      /* Enable clocks and power on the device. */
>> -    if ((timer_id = ti_hwmods_get_clock(dev)) == INVALID_CLK_IDENT)
>> +    err = ti_sysc_clock_enable(device_get_parent(dev));
>> +    if (err != 0) {
>> +            device_printf(dev, "Cant enable sysc clkctrl, err %d\n", err);
>>              return (ENXIO);
>> -    if ((err = ti_prcm_clk_set_source(timer_id, SYSCLK_CLK)) != 0)
>> -            return (err);
>> -    if ((err = ti_prcm_clk_enable(timer_id)) != 0)
>> -            return (err);
>> +    }
>>
>> +    /* Get the base clock frequency. */
>> +    err = clk_get_freq(sc->clk_fck, &sc->sysclk_freq);
>> +    if (err != 0) {
>> +            device_printf(dev, "Cant get sysclk frequency, err %d\n", err);
>> +            return (ENXIO);
>> +    }
>>      /* Request the memory resources. */
>>      sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
>>          &sc->mem_rid, RF_ACTIVE);
>> @@ -442,10 +523,6 @@ dmtpps_attach(device_t dev)
>>              return (ENXIO);
>>      }
>>
>> -    /* Figure out which hardware timer this is and set the name string. */
>> -    sc->tmr_num = ti_hwmods_get_unit(dev, "timer");
>> -    snprintf(sc->tmr_name, sizeof(sc->tmr_name), "DMTimer%d", sc->tmr_num);
>> -
>>      /*
>>       * Configure the timer pulse/capture pin to input/capture mode.  This is
>>       * required in addition to configuring the pin as input with the pinmux
>> @@ -468,7 +545,7 @@ dmtpps_attach(device_t dev)
>>      sc->tc.tc_name           = sc->tmr_name;
>>      sc->tc.tc_get_timecount  = dmtpps_get_timecount;
>>      sc->tc.tc_counter_mask   = ~0u;
>> -    sc->tc.tc_frequency      = sysclk_freq;
>> +    sc->tc.tc_frequency      = sc->sysclk_freq;
>>      sc->tc.tc_quality        = 1000;
>>      sc->tc.tc_priv           = sc;
>>
>> @@ -541,5 +618,4 @@ static driver_t dmtpps_driver = {
>>  static devclass_t dmtpps_devclass;
>>
>>  DRIVER_MODULE(am335x_dmtpps, simplebus, dmtpps_driver, dmtpps_devclass, 0,
>> 0);
>> -MODULE_DEPEND(am335x_dmtpps, am335x_prcm, 1, 1, 1);
>> -
>> +MODULE_DEPEND(am335x_dmtpps, ti_sysc, 1, 1, 1);
>>
>> Modified: head/sys/arm/ti/am335x/am335x_dmtreg.h
>> ==============================================================================
>> --- head/sys/arm/ti/am335x/am335x_dmtreg.h   Thu Jul 30 14:42:50
>> 2020 (r363699)
>> +++ head/sys/arm/ti/am335x/am335x_dmtreg.h   Thu Jul 30 14:45:05
>> 2020 (r363700)
>> @@ -73,4 +73,16 @@
>>  #define       DMT_TSICR_RESET         (1 << 1)      /* TSICR perform soft 
>> reset */
>>  #define     DMT_TCAR2               0x48            /* Capture Reg */
>>
>> +/* Location of revision register from TRM Memory map chapter 2 */
>> +/* L4_WKUP */
>> +#define DMTIMER0_REV                0x05000
>> +#define DMTIMER1_1MS_REV    0x31000
>> +/* L4_PER */
>> +#define DMTIMER2_REV                0x40000
>> +#define DMTIMER3_REV                0x42000
>> +#define DMTIMER4_REV                0x44000
>> +#define DMTIMER5_REV                0x46000
>> +#define DMTIMER6_REV                0x48000
>> +#define DMTIMER7_REV                0x4A000
>> +
>>  #endif /* AM335X_DMTREG_H */
>>
>> Modified: head/sys/arm/ti/am335x/am335x_gpio.c
>> ==============================================================================
>> --- head/sys/arm/ti/am335x/am335x_gpio.c     Thu Jul 30 14:42:50 2020        
>> (r363699)
>> +++ head/sys/arm/ti/am335x/am335x_gpio.c     Thu Jul 30 14:45:05 2020        
>> (r363700)
>> @@ -155,3 +155,4 @@ DEFINE_CLASS_1(gpio, am335x_gpio_driver, am335x_gpio_m
>>      sizeof(struct ti_gpio_softc), ti_gpio_driver);
>>  DRIVER_MODULE(am335x_gpio, simplebus, am335x_gpio_driver,
>> am335x_gpio_devclass,
>>      0, 0);
>> +MODULE_DEPEND(am335x_gpio, ti_sysc, 1, 1, 1);
>>
>> Modified: head/sys/arm/ti/am335x/am335x_lcd.c
>> ==============================================================================
>> --- head/sys/arm/ti/am335x/am335x_lcd.c      Thu Jul 30 14:42:50 2020        
>> (r363699)
>> +++ head/sys/arm/ti/am335x/am335x_lcd.c      Thu Jul 30 14:45:05 2020        
>> (r363700)
>> @@ -50,6 +50,8 @@ __FBSDID("$FreeBSD$");
>>
>>  #include <machine/bus.h>
>>
>> +#include <dev/extres/clk/clk.h>
>> +
>>  #include <dev/fdt/fdt_common.h>
>>  #include <dev/ofw/openfirm.h>
>>  #include <dev/ofw/ofw_bus.h>
>> @@ -65,7 +67,7 @@ __FBSDID("$FreeBSD$");
>>  #include <dev/vt/vt.h>
>>  #endif
>>
>> -#include <arm/ti/ti_prcm.h>
>> +#include <arm/ti/ti_sysc.h>
>>  #include <arm/ti/ti_scm.h>
>>
>>  #include "am335x_lcd.h"
>> @@ -219,6 +221,9 @@ struct am335x_lcd_softc {
>>      /* HDMI framer */
>>      phandle_t               sc_hdmi_framer;
>>      eventhandler_tag        sc_hdmi_evh;
>> +
>> +    /* Clock */
>> +    clk_t                   sc_clk_dpll_disp_ck;
>>  };
>>
>>  static void
>> @@ -615,24 +620,28 @@ am335x_lcd_configure(struct am335x_lcd_softc *sc)
>>      uint32_t hbp, hfp, hsw;
>>      uint32_t vbp, vfp, vsw;
>>      uint32_t width, height;
>> -    unsigned int ref_freq;
>> +    uint64_t ref_freq;
>>      int err;
>>
>>      /*
>>       * try to adjust clock to get double of requested frequency
>>       * HDMI/DVI displays are very sensitive to error in frequncy value
>>       */
>> -    if (ti_prcm_clk_set_source_freq(LCDC_CLK, sc->sc_panel.panel_pxl_clk*2))
>> {
>> +
>> +    err = clk_set_freq(sc->sc_clk_dpll_disp_ck, 
>> sc->sc_panel.panel_pxl_clk*2,
>> +        CLK_SET_ROUND_ANY);
>> +    if (err != 0) {
>>              device_printf(sc->sc_dev, "can't set source frequency\n");
>>              return (ENXIO);
>>      }
>>
>> -    if (ti_prcm_clk_get_source_freq(LCDC_CLK, &ref_freq)) {
>> +    err = clk_get_freq(sc->sc_clk_dpll_disp_ck, &ref_freq);
>> +    if (err != 0) {
>>              device_printf(sc->sc_dev, "can't get reference frequency\n");
>>              return (ENXIO);
>>      }
>>
>> -    /* Panle initialization */
>> +    /* Panel initialization */
>>      dma_size =
>> round_page(sc->sc_panel.panel_width*sc->sc_panel.panel_height*sc->sc_panel.bpp/8);
>>
>>      /*
>> @@ -967,6 +976,13 @@ am335x_lcd_attach(device_t dev)
>>              return (ENXIO);
>>      }
>>
>> +    /* Fixme: Cant find any reference in DTS for dpll_disp_ck@498 for now. 
>> */
>> +    err = clk_get_by_name(dev, "dpll_disp_ck@498", 
>> &sc->sc_clk_dpll_disp_ck);
>> +    if (err != 0) {
>> +            device_printf(dev, "Cant get dpll_disp_ck@49\n");
>> +            return (ENXIO);
>> +    }
>> +
>>      sc->sc_panel.ac_bias = 255;
>>      sc->sc_panel.ac_bias_intrpt = 0;
>>      sc->sc_panel.dma_burst_sz = 16;
>> @@ -989,7 +1005,11 @@ am335x_lcd_attach(device_t dev)
>>              }
>>      }
>>
>> -    ti_prcm_clk_enable(LCDC_CLK);
>> +    err = ti_sysc_clock_enable(device_get_parent(dev));
>> +    if (err != 0) {
>> +            device_printf(dev, "Failed to enable sysc clkctrl, err %d\n", 
>> err);
>> +            return (ENXIO);
>> +    }
>>
>>      rid = 0;
>>      sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
>> @@ -1081,3 +1101,4 @@ static devclass_t am335x_lcd_devclass;
>>  DRIVER_MODULE(am335x_lcd, simplebus, am335x_lcd_driver,
>> am335x_lcd_devclass, 0, 0);
>>  MODULE_VERSION(am335x_lcd, 1);
>>  MODULE_DEPEND(am335x_lcd, simplebus, 1, 1, 1);
>> +MODULE_DEPEND(am335x_lcd, ti_sysc, 1, 1, 1);
>>
>> Modified: head/sys/arm/ti/am335x/am335x_musb.c
>> ==============================================================================
>> --- head/sys/arm/ti/am335x/am335x_musb.c     Thu Jul 30 14:42:50 2020        
>> (r363699)
>> +++ head/sys/arm/ti/am335x/am335x_musb.c     Thu Jul 30 14:45:05 2020        
>> (r363700)
>> @@ -66,9 +66,11 @@ __FBSDID("$FreeBSD$");
>>
>>  #include <sys/rman.h>
>>
>> -#include <arm/ti/ti_prcm.h>
>> -#include <arm/ti/ti_scm.h>
>>  #include <arm/ti/am335x/am335x_scm.h>
>> +#include <arm/ti/ti_sysc.h>
>> +#include <dev/extres/clk/clk.h>
>> +#include <dev/extres/syscon/syscon.h>
>> +#include "syscon_if.h"
>>
>>  #define USBCTRL_REV         0x00
>>  #define USBCTRL_CTRL                0x14
>> @@ -130,6 +132,7 @@ struct musbotg_super_softc {
>>      struct musbotg_softc    sc_otg;
>>      struct resource         *sc_mem_res[2];
>>      int                     sc_irq_rid;
>> +    struct syscon           *syscon;
>>  };
>>
>>  static void
>> @@ -155,30 +158,33 @@ static void
>>  musbotg_clocks_on(void *arg)
>>  {
>>      struct musbotg_softc *sc;
>> -    uint32_t c, reg;
>> +    struct musbotg_super_softc *ssc;
>> +    uint32_t reg;
>>
>>      sc = arg;
>> -        reg = USB_CTRL[sc->sc_id];
>> +    ssc = sc->sc_platform_data;
>>
>> -    ti_scm_reg_read_4(reg, &c);
>> -    c &= ~3; /* Enable power */
>> -    c |= 1 << 19; /* VBUS detect enable */
>> -    c |= 1 << 20; /* Session end enable */
>> -    ti_scm_reg_write_4(reg, c);
>> +    reg = SYSCON_READ_4(ssc->syscon, USB_CTRL[sc->sc_id]);
>> +    reg &= ~3; /* Enable power */
>> +    reg |= 1 << 19; /* VBUS detect enable */
>> +    reg |= 1 << 20; /* Session end enable */
>> +
>> +    SYSCON_WRITE_4(ssc->syscon, USB_CTRL[sc->sc_id], reg);
>>  }
>>
>>  static void
>>  musbotg_clocks_off(void *arg)
>>  {
>>      struct musbotg_softc *sc;
>> -    uint32_t c, reg;
>> +    struct musbotg_super_softc *ssc;
>> +    uint32_t reg;
>>
>>      sc = arg;
>> -        reg = USB_CTRL[sc->sc_id];
>> +    ssc = sc->sc_platform_data;
>>
>>      /* Disable power to PHY */
>> -    ti_scm_reg_read_4(reg, &c);
>> -    ti_scm_reg_write_4(reg, c | 3);
>> +    reg = SYSCON_READ_4(ssc->syscon, USB_CTRL[sc->sc_id]);
>> +    SYSCON_WRITE_4(ssc->syscon, USB_CTRL[sc->sc_id], reg | 3);
>>  }
>>
>>  static void
>> @@ -241,9 +247,42 @@ musbotg_attach(device_t dev)
>>      char mode[16];
>>      int err;
>>      uint32_t reg;
>> +    phandle_t opp_table;
>> +    clk_t clk_usbotg_fck;
>>
>>      sc->sc_otg.sc_id = device_get_unit(dev);
>>
>> +    /* FIXME: The devicetree needs to be updated to get a handle to the gate
>> +     * usbotg_fck@47c. see TRM 8.1.12.2 CM_WKUP CM_CLKDCOLDO_DPLL_PER.
>> +     */
>> +    err = clk_get_by_name(dev, "usbotg_fck@47c", &clk_usbotg_fck);
>> +    if (err) {
>> +            device_printf(dev, "Can not find usbotg_fck@47c\n");
>> +            return (ENXIO);
>> +    }
>> +
>> +    err = clk_enable(clk_usbotg_fck);
>> +    if (err) {
>> +            device_printf(dev, "Can not enable usbotg_fck@47c\n");
>> +            return (ENXIO);
>> +    }
>> +
>> +    /* FIXME: For now; Go and kidnap syscon from opp-table */
>> +    opp_table = OF_finddevice("/opp-table");
>> +    if (opp_table == -1) {
>> +            device_printf(dev, "Cant find /opp-table\n");
>> +            return (ENXIO);
>> +    }
>> +    if (!OF_hasprop(opp_table, "syscon")) {
>> +            device_printf(dev, "/opp-table missing syscon property\n");
>> +            return (ENXIO);
>> +    }
>> +    err = syscon_get_by_ofw_property(dev, opp_table, "syscon", &sc->syscon);
>> +    if (err) {
>> +            device_printf(dev, "Failed to get syscon\n");
>> +            return (ENXIO);
>> +    }
>> +
>>      /* Request the memory resources */
>>      err = bus_alloc_resources(dev, am335x_musbotg_mem_spec,
>>              sc->sc_mem_res);
>> @@ -417,5 +456,7 @@ static driver_t musbotg_driver = {
>>
>>  static devclass_t musbotg_devclass;
>>
>> -DRIVER_MODULE(musbotg, usbss, musbotg_driver, musbotg_devclass, 0, 0);
>> -MODULE_DEPEND(musbotg, usbss, 1, 1, 1);
>> +DRIVER_MODULE(musbotg, ti_sysc, musbotg_driver, musbotg_devclass, 0, 0);
>> +MODULE_DEPEND(musbotg, ti_sysc, 1, 1, 1);
>> +MODULE_DEPEND(musbotg, ti_am3359_cppi41, 1, 1, 1);
>> +MODULE_DEPEND(usbss, usb, 1, 1, 1);
>>
>> Modified: head/sys/arm/ti/am335x/am335x_pwmss.c
>> ==============================================================================
>> --- head/sys/arm/ti/am335x/am335x_pwmss.c    Thu Jul 30 14:42:50
>> 2020 (r363699)
>> +++ head/sys/arm/ti/am335x/am335x_pwmss.c    Thu Jul 30 14:45:05
>> 2020 (r363700)
>> @@ -46,10 +46,11 @@ __FBSDID("$FreeBSD$");
>>  #include <dev/ofw/ofw_bus.h>
>>  #include <dev/ofw/ofw_bus_subr.h>
>>
>> -#include <arm/ti/ti_prcm.h>
>> -#include <arm/ti/ti_hwmods.h>
>> -#include <arm/ti/ti_scm.h>
>> +#include <arm/ti/ti_sysc.h>
>>
>> +#include <dev/extres/syscon/syscon.h>
>> +#include "syscon_if.h"
>> +
>>  #include "am335x_pwm.h"
>>  #include "am335x_scm.h"
>>
>> @@ -59,6 +60,11 @@ __FBSDID("$FreeBSD$");
>>  #define             CLKCONFIG_EPWMCLK_EN    (1 << 8)
>>  #define     PWMSS_CLKSTATUS         0x0C
>>
>> +/* TRM chapter 2 memory map table 2-3 + VER register location */
>> +#define PWMSS_REV_0         0x0000
>> +#define PWMSS_REV_1         0x2000
>> +#define PWMSS_REV_2         0x4000
>> +
>>  static device_probe_t am335x_pwmss_probe;
>>  static device_attach_t am335x_pwmss_attach;
>>  static device_detach_t am335x_pwmss_detach;
>> @@ -66,7 +72,7 @@ static device_detach_t am335x_pwmss_detach;
>>  struct am335x_pwmss_softc {
>>      struct simplebus_softc  sc_simplebus;
>>      device_t                sc_dev;
>> -    clk_ident_t             sc_clk;
>> +    struct syscon           *syscon;
>>  };
>>
>>  static device_method_t am335x_pwmss_methods[] = {
>> @@ -97,36 +103,45 @@ am335x_pwmss_attach(device_t dev)
>>  {
>>      struct am335x_pwmss_softc *sc;
>>      uint32_t reg, id;
>> -    phandle_t node;
>> +    uint64_t rev_address;
>> +    phandle_t node, opp_table;
>>
>>      sc = device_get_softc(dev);
>>      sc->sc_dev = dev;
>>
>> -    sc->sc_clk = ti_hwmods_get_clock(dev);
>> -    if (sc->sc_clk == INVALID_CLK_IDENT) {
>> -            device_printf(dev, "failed to get device id based on 
>> ti,hwmods\n");
>> -            return (EINVAL);
>> +    /* FIXME: For now; Go and kidnap syscon from opp-table */
>> +    opp_table = OF_finddevice("/opp-table");
>> +    if (opp_table == -1) {
>> +            device_printf(dev, "Cant find /opp-table\n");
>> +            return (ENXIO);
>>      }
>> +    if (!OF_hasprop(opp_table, "syscon")) {
>> +            device_printf(dev, "/opp-table doesnt have required syscon 
>> property\n");
>> +            return (ENXIO);
>> +    }
>> +    if (syscon_get_by_ofw_property(dev, opp_table, "syscon", &sc->syscon) !=
>> 0) {
>> +            device_printf(dev, "Failed to get syscon\n");
>> +            return (ENXIO);
>> +    }
>>
>> -    ti_prcm_clk_enable(sc->sc_clk);
>> -    ti_scm_reg_read_4(SCM_PWMSS_CTRL, &reg);
>> -    switch (sc->sc_clk) {
>> -            case PWMSS0_CLK:
>> -                    id = 0;
>> -                    break;
>> -            case PWMSS1_CLK:
>> -                    id = 1;
>> -                    break;
>> +    ti_sysc_clock_enable(device_get_parent(dev));
>>
>> -            case PWMSS2_CLK:
>> -                    id = 2;
>> -                    break;
>> -            default:
>> -                    device_printf(dev, "unknown pwmss clock id: %d\n", 
>> sc->sc_clk);
>> -                    return (EINVAL);
>> +    rev_address = ti_sysc_get_rev_address(device_get_parent(dev));
>> +    switch (rev_address) {
>> +    case PWMSS_REV_0:
>> +            id = 0;
>> +            break;
>> +    case PWMSS_REV_1:
>> +            id = 1;
>> +            break;
>> +    case PWMSS_REV_2:
>> +            id = 2;
>> +            break;
>>      }
>> +
>> +    reg = SYSCON_READ_4(sc->syscon, SCM_PWMSS_CTRL);
>>      reg |= (1 << id);
>> -    ti_scm_reg_write_4(SCM_PWMSS_CTRL, reg);
>> +    SYSCON_WRITE_4(sc->syscon, SCM_PWMSS_CTRL, reg);
>>
>>      node = ofw_bus_get_node(dev);
>>
>> @@ -161,3 +176,4 @@ DEFINE_CLASS_1(am335x_pwmss, am335x_pwmss_driver, am33
>>  static devclass_t am335x_pwmss_devclass;
>>  DRIVER_MODULE(am335x_pwmss, simplebus, am335x_pwmss_driver,
>> am335x_pwmss_devclass, 0, 0);
>>  MODULE_VERSION(am335x_pwmss, 1);
>> +MODULE_DEPEND(am335x_pwmss, ti_sysc, 1, 1, 1);
>>
>> Modified: head/sys/arm/ti/am335x/am335x_rtc.c
>> ==============================================================================
>> --- head/sys/arm/ti/am335x/am335x_rtc.c      Thu Jul 30 14:42:50 2020        
>> (r363699)
>> +++ head/sys/arm/ti/am335x/am335x_rtc.c      Thu Jul 30 14:45:05 2020        
>> (r363700)
>> @@ -39,8 +39,9 @@ __FBSDID("$FreeBSD$");
>>
>>  #include <machine/bus.h>
>>
>> +#include <dev/ofw/ofw_bus.h>
>>  #include <dev/ofw/ofw_bus_subr.h>
>> -#include <arm/ti/ti_prcm.h>
>> +#include <arm/ti/ti_sysc.h>
>>  #include <arm/ti/am335x/am335x_rtcvar.h>
>>  #include <arm/ti/am335x/am335x_rtcreg.h>
>>
>> @@ -110,7 +111,7 @@ am335x_rtc_attach(device_t dev)
>>      RTC_LOCK_INIT(sc);
>>
>>      /* Enable the RTC module. */
>> -    ti_prcm_clk_enable(RTC_CLK);
>> +    ti_sysc_clock_enable(device_get_parent(dev));
>>      rev = RTC_READ4(sc, RTC_REVISION);
>>      device_printf(dev, "AM335X RTC v%d.%d.%d\n",
>>              (rev >> 8) & 0x7, (rev >> 6) & 0x3, rev & 0x3f);
>> @@ -209,3 +210,4 @@ static devclass_t am335x_rtc_devclass;
>>  DRIVER_MODULE(am335x_rtc, simplebus, am335x_rtc_driver,
>> am335x_rtc_devclass, 0, 0);
>>  MODULE_VERSION(am335x_rtc, 1);
>>  MODULE_DEPEND(am335x_rtc, simplebus, 1, 1, 1);
>> +MODULE_DEPEND(am335x_rtc, ti_sysc, 1, 1, 1);
>>
>> Modified: head/sys/arm/ti/am335x/am335x_scm.c
>> ==============================================================================
>> --- head/sys/arm/ti/am335x/am335x_scm.c      Thu Jul 30 14:42:50 2020        
>> (r363699)
>> +++ head/sys/arm/ti/am335x/am335x_scm.c      Thu Jul 30 14:45:05 2020        
>> (r363700)
>> @@ -40,11 +40,15 @@ __FBSDID("$FreeBSD$");
>>  #include <arm/ti/ti_cpuid.h>
>>  #include <arm/ti/ti_scm.h>
>>
>> +#include <dev/extres/syscon/syscon.h>
>> +#include "syscon_if.h"
>> +
>>  #define     TZ_ZEROC        2731
>>
>>  struct am335x_scm_softc {
>>      int                     sc_last_temp;
>>      struct sysctl_oid       *sc_temp_oid;
>> +    struct syscon           *syscon;
>>  };
>>
>>  static int
>> @@ -60,7 +64,7 @@ am335x_scm_temp_sysctl(SYSCTL_HANDLER_ARGS)
>>
>>      /* Read the temperature and convert to Kelvin. */
>>      for(i = 50; i > 0; i--) {
>> -            ti_scm_reg_read_4(SCM_BGAP_CTRL, &reg);
>> +            reg = SYSCON_READ_4(sc->syscon, SCM_BGAP_CTRL);
>>              if ((reg & SCM_BGAP_EOCZ) == 0)
>>                      break;
>>              DELAY(50);
>> @@ -96,6 +100,9 @@ am335x_scm_identify(driver_t *driver, device_t parent)
>>  static int
>>  am335x_scm_probe(device_t dev)
>>  {
>> +    /* Just allow the first one */
>> +    if (strcmp(device_get_nameunit(dev), "am335x_scm0") != 0)
>> +            return (ENXIO);
>>
>>      device_set_desc(dev, "AM335x Control Module Extension");
>>
>> @@ -109,21 +116,40 @@ am335x_scm_attach(device_t dev)
>>      struct sysctl_ctx_list *ctx;
>>      struct sysctl_oid_list *tree;
>>      uint32_t reg;
>> +    phandle_t opp_table;
>> +    int err;
>>
>> +    sc = device_get_softc(dev);
>> +
>> +    /* FIXME: For now; Go and kidnap syscon from opp-table */
>> +    opp_table = OF_finddevice("/opp-table");
>> +    if (opp_table == -1) {
>> +            device_printf(dev, "Cant find /opp-table\n");
>> +            return (ENXIO);
>> +    }
>> +    if (!OF_hasprop(opp_table, "syscon")) {
>> +            device_printf(dev, "/opp-table missing syscon property\n");
>> +            return (ENXIO);
>> +    }
>> +    err = syscon_get_by_ofw_property(dev, opp_table, "syscon", &sc->syscon);
>> +    if (err) {
>> +            device_printf(dev, "Failed to get syscon\n");
>> +            return (ENXIO);
>> +    }
>> +
>>      /* Reset the digital outputs. */
>> -    ti_scm_reg_write_4(SCM_BGAP_CTRL, 0);
>> -    ti_scm_reg_read_4(SCM_BGAP_CTRL, &reg);
>> +    SYSCON_WRITE_4(sc->syscon, SCM_BGAP_CTRL, 0);
>> +    reg = SYSCON_READ_4(sc->syscon, SCM_BGAP_CTRL);
>>      DELAY(500);
>>      /* Set continous mode. */
>> -    ti_scm_reg_write_4(SCM_BGAP_CTRL, SCM_BGAP_CONTCONV);
>> -    ti_scm_reg_read_4(SCM_BGAP_CTRL, &reg);
>> +    SYSCON_WRITE_4(sc->syscon, SCM_BGAP_CTRL, SCM_BGAP_CONTCONV);
>> +    reg = SYSCON_READ_4(sc->syscon, SCM_BGAP_CTRL);
>>      DELAY(500);
>>      /* Start the ADC conversion. */
>>      reg = SCM_BGAP_CLRZ | SCM_BGAP_CONTCONV | SCM_BGAP_SOC;
>> -    ti_scm_reg_write_4(SCM_BGAP_CTRL, reg);
>> +    SYSCON_WRITE_4(sc->syscon, SCM_BGAP_CTRL, reg);
>>
>>      /* Temperature sysctl. */
>> -    sc = device_get_softc(dev);
>>          ctx = device_get_sysctl_ctx(dev);
>>      tree = SYSCTL_CHILDREN(device_get_sysctl_tree(dev));
>>      sc->sc_temp_oid = SYSCTL_ADD_PROC(ctx, tree, OID_AUTO,
>> @@ -145,7 +171,7 @@ am335x_scm_detach(device_t dev)
>>              sysctl_remove_oid(sc->sc_temp_oid, 1, 0);
>>
>>      /* Stop the bandgap ADC. */
>> -    ti_scm_reg_write_4(SCM_BGAP_CTRL, SCM_BGAP_BGOFF);
>>
>> *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
>> _______________________________________________
>> svn-src-...@freebsd.org mailing list
>> https://lists.freebsd.org/mailman/listinfo/svn-src-all
>> To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
>>
> 
> 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to