Changeset 54380f42 in rtems


Ignore:
Timestamp:
Oct 6, 2017, 9:02:53 AM (22 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
170df3d
Parents:
e316be7
git-author:
Sebastian Huber <sebastian.huber@…> (10/06/17 09:02:53)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/06/17 10:49:30)
Message:

bsp/imx: Add imx_iomux_configure_pins()

Update #3090.

Location:
c/src/lib/libbsp/arm/imx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/imx/Makefile.am

    re316be7 r54380f42  
    4545include_arm_freescale_imx_HEADERS += include/arm/freescale/imx/imx_gpcreg.h
    4646include_arm_freescale_imx_HEADERS += include/arm/freescale/imx/imx_i2creg.h
     47include_arm_freescale_imx_HEADERS += include/arm/freescale/imx/imx_iomuxreg.h
     48include_arm_freescale_imx_HEADERS += include/arm/freescale/imx/imx_iomuxvar.h
    4749include_arm_freescale_imx_HEADERS += include/arm/freescale/imx/imx_srcreg.h
    4850include_arm_freescale_imx_HEADERS += include/arm/freescale/imx/imx_uartreg.h
     
    9092libbsp_a_SOURCES += startup/bspstart.c
    9193libbsp_a_SOURCES += startup/ccm.c
     94libbsp_a_SOURCES += startup/imx_iomux.c
    9295if HAS_SMP
    9396libbsp_a_SOURCES += ../shared/arm-a9mpcore-smp.c
  • c/src/lib/libbsp/arm/imx/include/bsp.h

    re316be7 r54380f42  
    4444void *imx_get_reg_of_node(const void *fdt, int node);
    4545
     46int imx_iomux_configure_pins(const void *fdt, uint32_t phandle);
     47
    4648rtems_vector_number imx_get_irq_of_node(
    4749  const void *fdt,
  • c/src/lib/libbsp/arm/imx/preinstall.am

    re316be7 r54380f42  
    148148PREINSTALL_FILES += $(PROJECT_INCLUDE)/arm/freescale/imx/imx_i2creg.h
    149149
     150$(PROJECT_INCLUDE)/arm/freescale/imx/imx_iomuxreg.h: include/arm/freescale/imx/imx_iomuxreg.h $(PROJECT_INCLUDE)/arm/freescale/imx/$(dirstamp)
     151        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/arm/freescale/imx/imx_iomuxreg.h
     152PREINSTALL_FILES += $(PROJECT_INCLUDE)/arm/freescale/imx/imx_iomuxreg.h
     153
     154$(PROJECT_INCLUDE)/arm/freescale/imx/imx_iomuxvar.h: include/arm/freescale/imx/imx_iomuxvar.h $(PROJECT_INCLUDE)/arm/freescale/imx/$(dirstamp)
     155        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/arm/freescale/imx/imx_iomuxvar.h
     156PREINSTALL_FILES += $(PROJECT_INCLUDE)/arm/freescale/imx/imx_iomuxvar.h
     157
    150158$(PROJECT_INCLUDE)/arm/freescale/imx/imx_srcreg.h: include/arm/freescale/imx/imx_srcreg.h $(PROJECT_INCLUDE)/arm/freescale/imx/$(dirstamp)
    151159        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/arm/freescale/imx/imx_srcreg.h
  • c/src/lib/libbsp/arm/imx/startup/imx_iomux.c

    re316be7 r54380f42  
    5151
    5252#include <sys/param.h>
     53#ifndef __rtems__
    5354#include <sys/systm.h>
    5455#include <sys/bus.h>
     
    6465#include <dev/ofw/ofw_bus_subr.h>
    6566#include <dev/fdt/fdt_pinctrl.h>
     67#endif /* __rtems__ */
    6668
    6769#include <arm/freescale/imx/imx_iomuxvar.h>
     70#ifndef __rtems__
    6871#include <arm/freescale/imx/imx_machdep.h>
     72#else /* __rtems__ */
     73#include <bsp.h>
     74#include <bsp/fdt.h>
     75#include <rtems/sysinit.h>
     76#include <errno.h>
     77#include <libfdt.h>
     78#include <stdlib.h>
     79
     80typedef size_t bus_size_t;
     81typedef int phandle_t;
     82#endif /* __rtems__ */
    6983
    7084struct iomux_softc {
     85#ifndef __rtems__
    7186        device_t        dev;
    7287        struct resource *mem_res;
    7388        u_int           last_gpregaddr;
     89#else /* __rtems__ */
     90        volatile uint32_t *regs;
     91#endif /* __rtems__ */
    7492};
    7593
     94#ifndef __rtems__
    7695static struct iomux_softc *iomux_sc;
    7796
     
    86105        {NULL,                  false},
    87106};
     107#else /* __rtems__ */
     108static struct iomux_softc iomux_sc_instance;
     109
     110#define iomux_sc (&iomux_sc_instance);
     111
     112static void
     113imx_iomux_init(void)
     114{
     115        const void *fdt;
     116        int node;
     117        struct iomux_softc *sc;
     118
     119        fdt = bsp_fdt_get();
     120        node = fdt_node_offset_by_compatible(fdt, -1, "fsl,imx7d-iomuxc");
     121        sc = iomux_sc;
     122        sc->regs = imx_get_reg_of_node(fdt, node);
     123}
     124
     125RTEMS_SYSINIT_ITEM(imx_iomux_init, RTEMS_SYSINIT_BSP_START,
     126    RTEMS_SYSINIT_ORDER_MIDDLE);
     127
     128#define OF_node_from_xref(phandle) fdt_node_offset_by_phandle(fdt, phandle)
     129
     130static int
     131imx_iomux_getencprop_alloc(const char *fdt, int node, const char *name,
     132    size_t elsz, void **buf)
     133{
     134        int len;
     135        const uint32_t *val;
     136        int i;
     137        uint32_t *cell;
     138
     139        val = fdt_getprop(fdt, node, "fsl,pins", &len);
     140        if (val == NULL || len < 0 || len % elsz != 0) {
     141                return (-1);
     142        }
     143
     144        cell = malloc((size_t)len);
     145        *buf = cell;
     146        if (cell == NULL) {
     147                return (-1);
     148        }
     149
     150        for (i = 0; i < len / 4; ++i) {
     151                cell[i] = fdt32_to_cpu(val[i]);
     152        }
     153
     154        return (len / (int)elsz);
     155}
     156
     157#define OF_getencprop_alloc(node, name, elsz, buf) \
     158    imx_iomux_getencprop_alloc(fdt, node, name, elsz, buf)
     159
     160#define OF_prop_free(buf) free(buf)
     161#endif /* __rtems__ */
    88162
    89163/*
     
    107181{
    108182
     183#ifndef __rtems__
    109184        return (bus_read_4(sc->mem_res, off));
     185#else /* __rtems__ */
     186        return (sc->regs[off / 4]);
     187#endif /* __rtems__ */
    110188}
    111189
     
    114192{
    115193
     194#ifndef __rtems__
    116195        bus_write_4(sc->mem_res, off, val);
     196#else /* __rtems__ */
     197        sc->regs[off / 4] = val;
     198#endif /* __rtems__ */
    117199}
    118200
     
    143225}
    144226
     227#ifndef __rtems__
    145228static int
    146229iomux_configure_pins(device_t dev, phandle_t cfgxref)
     230#else /* __rtems__ */
     231int imx_iomux_configure_pins(const void *fdt, uint32_t cfgxref)
     232#endif /* __rtems__ */
    147233{
    148234        struct iomux_softc *sc;
     
    152238        uint32_t sion;
    153239
     240#ifndef __rtems__
    154241        sc = device_get_softc(dev);
     242#else /* __rtems__ */
     243        sc = iomux_sc;
     244#endif /* __rtems__ */
    155245        cfgnode = OF_node_from_xref(cfgxref);
    156246        ntuples = OF_getencprop_alloc(cfgnode, "fsl,pins", sizeof(*cfgtuples),
     
    166256                if ((cfg->padconf_val & PADCONF_NONE) == 0)
    167257                        WR4(sc, cfg->padconf_reg, cfg->padconf_val);
     258#ifndef __rtems__
    168259                if (bootverbose) {
    169260                        char name[32];
     
    176267                            cfg->padconf_reg, cfg->padconf_val);
    177268                }
     269#endif /* __rtems__ */
    178270        }
    179271        OF_prop_free(cfgtuples);
     
    181273}
    182274
     275#ifndef __rtems__
    183276static int
    184277iomux_probe(device_t dev)
     
    329422    imx_iomux_devclass, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_LATE);
    330423
     424#endif /* __rtems__ */
Note: See TracChangeset for help on using the changeset viewer.