diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2018-06-01 22:01:38 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2018-06-01 22:01:38 +0000 |
commit | 3232408891266ca6ba4c8859a4aeebde46d3fc7c (patch) | |
tree | 64fd521deaa24ca8a34c8e6c45365c247e275fcd /sys/dev/fdt/dwmmc.c | |
parent | d54aa86cfec35cf62cbc268fb7946719ebe2a8f9 (diff) |
Rockchip RK3288/3328/3399 pre-divide the clock. Take this into account when
calculating the base clock. Also explicitly set the clock if a
clock-frequency property is present as documented in the device tree
bindings.
Diffstat (limited to 'sys/dev/fdt/dwmmc.c')
-rw-r--r-- | sys/dev/fdt/dwmmc.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sys/dev/fdt/dwmmc.c b/sys/dev/fdt/dwmmc.c index 15fe5851b78..3c9970ba02a 100644 --- a/sys/dev/fdt/dwmmc.c +++ b/sys/dev/fdt/dwmmc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwmmc.c,v 1.13 2018/06/01 20:45:08 kettenis Exp $ */ +/* $OpenBSD: dwmmc.c,v 1.14 2018/06/01 22:01:37 kettenis Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * @@ -257,7 +257,8 @@ dwmmc_attach(struct device *parent, struct device *self, void *aux) struct dwmmc_softc *sc = (struct dwmmc_softc *)self; struct fdt_attach_args *faa = aux; struct sdmmcbus_attach_args saa; - uint32_t hcon, ciu_div, width; + uint32_t freq, div = 0; + uint32_t hcon, width; int error, timeout; if (faa->fa_nreg < 1) { @@ -307,9 +308,17 @@ dwmmc_attach(struct device *parent, struct device *self, void *aux) return; } + /* Some Rockchip variants pre-divide the clock. */ + if (OF_is_compatible(faa->fa_node, "rockchip,rk3288-dw-mshc")) + div = 1; + + freq = OF_getpropint(faa->fa_node, "clock-frequency", 0); + if (freq > 0) + clock_set_frequency(faa->fa_node, "ciu", (div + 1) * freq); + sc->sc_clkbase = clock_get_frequency(faa->fa_node, "ciu"); - ciu_div = OF_getpropint(faa->fa_node, "samsung,dw-mshc-ciu-div", 0); - sc->sc_clkbase /= (ciu_div + 1); + div = OF_getpropint(faa->fa_node, "samsung,dw-mshc-ciu-div", div); + sc->sc_clkbase /= (div + 1); sc->sc_ih = arm_intr_establish_fdt(faa->fa_node, IPL_BIO, dwmmc_intr, sc, sc->sc_dev.dv_xname); |