svn commit: r277568 - head/sys/arm/freescale/imx
Ian Lepore
ian at FreeBSD.org
Fri Jan 23 16:05:48 UTC 2015
Author: ian
Date: Fri Jan 23 16:05:47 2015
New Revision: 277568
URL: https://svnweb.freebsd.org/changeset/base/277568
Log:
Add pinctrl driver support for the encoded input register config words
that the linux guys made up on the fly (but didn't document) last August.
This type of encoded config now appears in the imx6 fdt data.
Modified:
head/sys/arm/freescale/imx/imx_iomux.c
Modified: head/sys/arm/freescale/imx/imx_iomux.c
==============================================================================
--- head/sys/arm/freescale/imx/imx_iomux.c Fri Jan 23 16:03:02 2015 (r277567)
+++ head/sys/arm/freescale/imx/imx_iomux.c Fri Jan 23 16:05:47 2015 (r277568)
@@ -117,10 +117,36 @@ WR4(struct iomux_softc *sc, bus_size_t o
bus_write_4(sc->mem_res, off, val);
}
+static void
+iomux_configure_input(struct iomux_softc *sc, uint32_t reg, uint32_t val)
+{
+ u_int select, mask, shift, width;
+
+ /* If register and value are zero, there is nothing to configure. */
+ if (reg == 0 && val == 0)
+ return;
+
+ /*
+ * If the config value has 0xff in the high byte it is encoded:
+ * 31 23 15 7 0
+ * | 0xff | shift | width | select |
+ * We need to mask out the old select value and OR in the new, using a
+ * mask of the given width and shifting the values up by shift.
+ */
+ if ((val & 0xff000000) == 0xff000000) {
+ select = val & 0x000000ff;
+ width = (val & 0x0000ff00) >> 8;
+ shift = (val & 0x00ff0000) >> 16;
+ mask = ((1u << width) - 1) << shift;
+ val = (RD4(sc, reg) & ~mask) | (select << shift);
+ }
+ WR4(sc, reg, val);
+}
+
static int
iomux_configure_pins(device_t dev, phandle_t cfgxref)
{
- struct iomux_softc * sc;
+ struct iomux_softc *sc;
struct pincfg *cfgtuples, *cfg;
phandle_t cfgnode;
int i, ntuples;
@@ -137,8 +163,7 @@ iomux_configure_pins(device_t dev, phand
for (i = 0, cfg = cfgtuples; i < ntuples; i++, cfg++) {
sion = (cfg->padconf_val & PADCONF_SION) ? PADMUX_SION : 0;
WR4(sc, cfg->mux_reg, cfg->mux_val | sion);
- if (cfg->input_reg != 0)
- WR4(sc, cfg->input_reg, cfg->input_val);
+ iomux_configure_input(sc, cfg->input_reg, cfg->input_val);
if ((cfg->padconf_val & PADCONF_NONE) == 0)
WR4(sc, cfg->padconf_reg, cfg->padconf_val);
if (bootverbose) {
More information about the svn-src-head
mailing list