diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2019-03-13 09:49:47 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2019-03-13 09:49:47 +0000 |
commit | f149cc20d2d70fe3fd7158d15aa684c616682f86 (patch) | |
tree | ce31abefe7665248f1e0a3bdb0226b7e35415f45 /sys/dev/fdt/imxccm.c | |
parent | 16bafd3a92742f31b23656152af75ae48ed1a08e (diff) |
Add support for i.MX8M PWM clocks.
Diffstat (limited to 'sys/dev/fdt/imxccm.c')
-rw-r--r-- | sys/dev/fdt/imxccm.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/sys/dev/fdt/imxccm.c b/sys/dev/fdt/imxccm.c index 47e057783d9..0074ea58061 100644 --- a/sys/dev/fdt/imxccm.c +++ b/sys/dev/fdt/imxccm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxccm.c,v 1.13 2019/03/13 09:41:12 patrick Exp $ */ +/* $OpenBSD: imxccm.c,v 1.14 2019/03/13 09:49:46 patrick Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> * @@ -228,6 +228,7 @@ uint32_t imxccm_get_uartclk(struct imxccm_softc *); uint32_t imxccm_imx8mq_ecspi(struct imxccm_softc *sc, uint32_t); uint32_t imxccm_imx8mq_enet(struct imxccm_softc *sc, uint32_t); uint32_t imxccm_imx8mq_i2c(struct imxccm_softc *sc, uint32_t); +uint32_t imxccm_imx8mq_pwm(struct imxccm_softc *sc, uint32_t); uint32_t imxccm_imx8mq_uart(struct imxccm_softc *sc, uint32_t); uint32_t imxccm_imx8mq_usdhc(struct imxccm_softc *sc, uint32_t); uint32_t imxccm_imx8mq_usb(struct imxccm_softc *sc, uint32_t); @@ -661,6 +662,33 @@ imxccm_imx8mq_i2c(struct imxccm_softc *sc, uint32_t idx) } uint32_t +imxccm_imx8mq_pwm(struct imxccm_softc *sc, uint32_t idx) +{ + uint32_t mux; + + if (idx >= sc->sc_nmuxs || sc->sc_muxs[idx].reg == 0) + return 0; + + mux = HREAD4(sc, sc->sc_muxs[idx].reg); + mux >>= sc->sc_muxs[idx].shift; + mux &= sc->sc_muxs[idx].mask; + + switch (mux) { + case 0: + return clock_get_frequency(sc->sc_node, "osc_25m"); + case 1: + return 100 * 1000 * 1000; /* sys1_pll_100m */ + case 2: + return 160 * 1000 * 1000; /* sys1_pll_160m */ + case 3: + return 40 * 1000 * 1000; /* sys1_pll_40m */ + default: + printf("%s: 0x%08x 0x%08x\n", __func__, idx, mux); + return 0; + } +} + +uint32_t imxccm_imx8mq_uart(struct imxccm_softc *sc, uint32_t idx) { uint32_t mux; @@ -1064,6 +1092,11 @@ imxccm_get_frequency(void *cookie, uint32_t *cells) case IMX8MQ_CLK_ECSPI2_SRC: case IMX8MQ_CLK_ECSPI3_SRC: return imxccm_imx8mq_ecspi(sc, idx); + case IMX8MQ_CLK_PWM1_SRC: + case IMX8MQ_CLK_PWM2_SRC: + case IMX8MQ_CLK_PWM3_SRC: + case IMX8MQ_CLK_PWM4_SRC: + return imxccm_imx8mq_pwm(sc, idx); } } else if (sc->sc_gates == imx7d_gates) { switch (idx) { |