svn commit: r321938 - head/sys/arm/freescale/imx
Ian Lepore
ian at FreeBSD.org
Wed Aug 2 18:28:07 UTC 2017
Author: ian
Date: Wed Aug 2 18:28:06 2017
New Revision: 321938
URL: https://svnweb.freebsd.org/changeset/base/321938
Log:
Fix the interface to imx_iomux_gpr_get/set(). The functions were defined
as taking a register number, and that would get multiplied by 4 to make
a register address. But the header file that consumers have to reference
this stuff publishes register addresses, not numbers. So now everything
works in terms of register addresses.
Note that the HDMI init code was writing into the wrong register before
this change. Apparently whatever it wrote to was harmless, and apparently
HDMI was working because uboot had set up the right bits.
Modified:
head/sys/arm/freescale/imx/imx_iomux.c
head/sys/arm/freescale/imx/imx_iomuxvar.h
Modified: head/sys/arm/freescale/imx/imx_iomux.c
==============================================================================
--- head/sys/arm/freescale/imx/imx_iomux.c Wed Aug 2 16:01:52 2017 (r321937)
+++ head/sys/arm/freescale/imx/imx_iomux.c Wed Aug 2 18:28:06 2017 (r321938)
@@ -70,7 +70,7 @@
struct iomux_softc {
device_t dev;
struct resource *mem_res;
- u_int last_gpreg;
+ u_int last_gpregaddr;
};
static struct iomux_softc *iomux_sc;
@@ -213,19 +213,19 @@ iomux_attach(device_t dev)
switch (imx_soc_type()) {
case IMXSOC_51:
- sc->last_gpreg = 1;
+ sc->last_gpregaddr = 1 * sizeof(uint32_t);
break;
case IMXSOC_53:
- sc->last_gpreg = 2;
+ sc->last_gpregaddr = 2 * sizeof(uint32_t);
break;
case IMXSOC_6DL:
case IMXSOC_6S:
case IMXSOC_6SL:
case IMXSOC_6Q:
- sc->last_gpreg = 13;
+ sc->last_gpregaddr = 13 * sizeof(uint32_t);
break;
case IMXSOC_6UL:
- sc->last_gpreg = 14;
+ sc->last_gpregaddr = 14 * sizeof(uint32_t);
break;
default:
device_printf(dev, "Unknown SoC type\n");
@@ -261,45 +261,48 @@ iomux_attach(device_t dev)
}
uint32_t
-imx_iomux_gpr_get(u_int regnum)
+imx_iomux_gpr_get(u_int regaddr)
{
struct iomux_softc * sc;
sc = iomux_sc;
KASSERT(sc != NULL, ("%s called before attach", __FUNCTION__));
- KASSERT(regnum >= 0 && regnum <= sc->last_gpreg,
- ("%s bad regnum %u, max %u", __FUNCTION__, regnum, sc->last_gpreg));
+ KASSERT(regaddr >= 0 && regaddr <= sc->last_gpregaddr,
+ ("%s bad regaddr %u, max %u", __FUNCTION__, regaddr,
+ sc->last_gpregaddr));
- return (RD4(iomux_sc, regnum * 4));
+ return (RD4(iomux_sc, regaddr));
}
void
-imx_iomux_gpr_set(u_int regnum, uint32_t val)
+imx_iomux_gpr_set(u_int regaddr, uint32_t val)
{
struct iomux_softc * sc;
sc = iomux_sc;
KASSERT(sc != NULL, ("%s called before attach", __FUNCTION__));
- KASSERT(regnum >= 0 && regnum <= sc->last_gpreg,
- ("%s bad regnum %u, max %u", __FUNCTION__, regnum, sc->last_gpreg));
+ KASSERT(regaddr >= 0 && regaddr <= sc->last_gpregaddr,
+ ("%s bad regaddr %u, max %u", __FUNCTION__, regaddr,
+ sc->last_gpregaddr));
- WR4(iomux_sc, regnum * 4, val);
+ WR4(iomux_sc, regaddr, val);
}
void
-imx_iomux_gpr_set_masked(u_int regnum, uint32_t clrbits, uint32_t setbits)
+imx_iomux_gpr_set_masked(u_int regaddr, uint32_t clrbits, uint32_t setbits)
{
struct iomux_softc * sc;
uint32_t val;
sc = iomux_sc;
KASSERT(sc != NULL, ("%s called before attach", __FUNCTION__));
- KASSERT(regnum >= 0 && regnum <= sc->last_gpreg,
- ("%s bad regnum %u, max %u", __FUNCTION__, regnum, sc->last_gpreg));
+ KASSERT(regaddr >= 0 && regaddr <= sc->last_gpregaddr,
+ ("%s bad regaddr %u, max %u", __FUNCTION__, regaddr,
+ sc->last_gpregaddr));
- val = RD4(iomux_sc, regnum * 4);
+ val = RD4(iomux_sc, regaddr * 4);
val = (val & ~clrbits) | setbits;
- WR4(iomux_sc, regnum * 4, val);
+ WR4(iomux_sc, regaddr, val);
}
static device_method_t imx_iomux_methods[] = {
Modified: head/sys/arm/freescale/imx/imx_iomuxvar.h
==============================================================================
--- head/sys/arm/freescale/imx/imx_iomuxvar.h Wed Aug 2 16:01:52 2017 (r321937)
+++ head/sys/arm/freescale/imx/imx_iomuxvar.h Wed Aug 2 18:28:06 2017 (r321938)
@@ -42,8 +42,8 @@ u_int iomux_get_pad_config(u_int pin);
* with IO pin assignments or pad control. These functions let other soc level
* code manipulate these values.
*/
-uint32_t imx_iomux_gpr_get(u_int regnum);
-void imx_iomux_gpr_set(u_int regnum, uint32_t val);
-void imx_iomux_gpr_set_masked(u_int regnum, uint32_t clrbits, uint32_t setbits);
+uint32_t imx_iomux_gpr_get(u_int regaddr);
+void imx_iomux_gpr_set(u_int regaddr, uint32_t val);
+void imx_iomux_gpr_set_masked(u_int regaddr, uint32_t clrbits, uint32_t setbits);
#endif
More information about the svn-src-all
mailing list