Changeset 3fac9e9 in rtems-libbsd


Ignore:
Timestamp:
Apr 26, 2018, 1:23:08 PM (18 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
c1e05b9ea378b2971e3d7704779112b4bc4296da, 4a77611a223ea883fb548679b516d326a020d447
Children:
d45899b
Parents:
c7e162a
Message:

at91_mci: Use real interrupt

Execute at91_mci_intr() in interrupt context. Synchronize MMC requests
via RTEMS interrupt lock.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freebsd/sys/arm/at91/at91_mci.c

    rc7e162a r3fac9e9  
    7171#if defined(__rtems__) && defined(LIBBSP_ARM_ATSAM_BSP_H)
    7272#ifdef __rtems__
     73#include <rtems/irq-extension.h>
    7374#include <libchip/chip.h>
    7475
     
    151152#endif /* __rtems__ */
    152153
     154#ifndef __rtems__
    153155static int mci_debug;
     156#else /* __rtems__ */
     157#define mci_debug 0
     158#endif /* __rtems__ */
    154159
    155160struct at91_mci_softc {
     
    170175        struct resource *mem_res;       /* Memory resource */
    171176        struct mtx sc_mtx;
     177#ifdef __rtems__
     178        RTEMS_INTERRUPT_LOCK_MEMBER(sc_lock)
     179#endif /* __rtems__ */
    172180        bus_dma_tag_t dmatag;
    173181        struct mmc_host host;
     
    205213#endif /* __rtems__ */
    206214
     215#ifndef __rtems__
    207216#define AT91_MCI_LOCK(_sc)              mtx_lock(&(_sc)->sc_mtx)
    208217#define AT91_MCI_UNLOCK(_sc)            mtx_unlock(&(_sc)->sc_mtx)
     
    213222#define AT91_MCI_ASSERT_LOCKED(_sc)     mtx_assert(&_sc->sc_mtx, MA_OWNED);
    214223#define AT91_MCI_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED);
     224#else /* __rtems__ */
     225#define AT91_MCI_LOCK(_sc) \
     226        rtems_interrupt_lock_context at91_mci_lock_context; \
     227        rtems_interrupt_lock_acquire(&(_sc)->sc_lock, &at91_mci_lock_context)
     228#define AT91_MCI_UNLOCK(_sc) \
     229        rtems_interrupt_lock_release(&(_sc)->sc_lock, &at91_mci_lock_context)
     230#define AT91_MCI_LOCK_INIT(_sc) \
     231        rtems_interrupt_lock_initialize(&(_sc)->sc_lock, \
     232            device_get_nameunit((_sc)->dev))
     233#define AT91_MCI_LOCK_DESTROY(_sc) \
     234        rtems_interrupt_lock_destroy(&(_sc)->sc_mtx)
     235#define AT91_MCI_BUS_LOCK(_sc)          mtx_lock(&(_sc)->sc_mtx)
     236#define AT91_MCI_BUS_UNLOCK(_sc)                mtx_unlock(&(_sc)->sc_mtx)
     237#define AT91_MCI_BUS_LOCK_INIT(_sc) \
     238        mtx_init(&_sc->sc_mtx, device_get_nameunit((_sc)->dev), \
     239            "mci", MTX_DEF)
     240#endif /* __rtems__ */
    215241
    216242static inline uint32_t
     
    483509                goto out;
    484510
     511        AT91_MCI_BUS_LOCK_INIT(sc);
    485512#endif /* __rtems__ */
    486513        AT91_MCI_LOCK_INIT(sc);
     
    517544         * Activate the interrupt
    518545         */
     546#ifndef __rtems__
    519547        err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
    520548            NULL, at91_mci_intr, sc, &sc->intrhand);
     549#else /* __rtems__ */
     550        err = rtems_interrupt_handler_install(rman_get_start(sc->irq_res),
     551            device_get_nameunit(dev), RTEMS_INTERRUPT_SHARED, at91_mci_intr,
     552            sc);
     553#endif /* __rtems__ */
    521554        if (err) {
    522555                AT91_MCI_LOCK_DESTROY(sc);
     
    546579            "Allow up to 30MHz clock for 25MHz request when next highest speed 15MHz or less.");
    547580
     581#ifndef __rtems__
    548582        SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "debug",
    549583            CTLFLAG_RWTUN, &mci_debug, 0, "enable debug output");
     584#endif /* __rtems__ */
    550585
    551586        /*
     
    11201155        int err = 0;
    11211156
     1157#ifndef __rtems__
    11221158        AT91_MCI_LOCK(sc);
     1159#else /* __rtems__ */
     1160        AT91_MCI_BUS_LOCK(sc);
     1161#endif /* __rtems__ */
    11231162        while (sc->bus_busy)
    11241163                msleep(sc, &sc->sc_mtx, PZERO, "mciah", hz / 5);
    11251164        sc->bus_busy++;
     1165#ifndef __rtems__
    11261166        AT91_MCI_UNLOCK(sc);
     1167#else /* __rtems__ */
     1168        AT91_MCI_BUS_UNLOCK(sc);
     1169#endif /* __rtems__ */
    11271170        return (err);
    11281171}
     
    11331176        struct at91_mci_softc *sc = device_get_softc(brdev);
    11341177
     1178#ifndef __rtems__
    11351179        AT91_MCI_LOCK(sc);
     1180#else /* __rtems__ */
     1181        AT91_MCI_BUS_LOCK(sc);
     1182#endif /* __rtems__ */
    11361183        sc->bus_busy--;
    11371184        wakeup(sc);
     1185#ifndef __rtems__
    11381186        AT91_MCI_UNLOCK(sc);
     1187#else /* __rtems__ */
     1188        AT91_MCI_BUS_UNLOCK(sc);
     1189#endif /* __rtems__ */
    11391190        return (0);
    11401191}
Note: See TracChangeset for help on using the changeset viewer.