qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Stefan Hajnoczi" <stefanha@redhat.com>,
	"Jim Mussared" <jim@groklearning.com>,
	"Steffen Görtz" <contrib@steffen-goertz.de>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	qemu-arm <qemu-arm@nongnu.org>, "Joel Stanley" <joel@jms.id.au>,
	"Julia Suvorova" <jusual@mail.ru>
Subject: Re: [Qemu-devel] [PATCH] arm: Stub out NRF51 TWI magnetometer/accelerometer detection
Date: Tue, 8 Jan 2019 13:22:37 +0000	[thread overview]
Message-ID: <CAJSP0QUn+S8vDsTF+Ww12kN4x7PsVOSbujy9HVMuMfnFbV17GA@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA_NiH6Gj1_R6yUXKsgRjhnpqkYJ=84Ugd9t_mPd+af5Wg@mail.gmail.com>

On Tue, Jan 8, 2019 at 11:57 AM Peter Maydell <peter.maydell@linaro.org> wrote:
> On Sat, 5 Jan 2019 at 15:02, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> >
> > From: Steffen Görtz <contrib@steffen-goertz.de>
> >
> > Recent microbit firmwares panic if the TWI magnetometer/accelerometer
> > devices are not detected during startup.  We don't implement TWI (I2C)
> > so let's stub out these devices just to let the firmware boot.
> >
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > Based-on: <20190103091119.9367-1-stefanha@redhat.com>
> > ---
> > Steffen: Please post your Signed-off-by.  I did some minor cleanups so
> > your patch can be merged.  Thanks!
> >
> >  include/hw/arm/nrf51.h     |  1 +
> >  include/hw/arm/nrf51_soc.h |  1 +
> >  hw/arm/nrf51_soc.c         | 62 ++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 64 insertions(+)
>
> >
> > +/* Two-Wire Interface (TWI) is not implemented but the microbit-dal firmware
> > + * panics if the TWI accelerometer and magnetometer WHO_AM_I registers cannot
> > + * be read.  Stub out this read sequence so microbit-dal starts up.
> > + */
> > +static uint32_t twi_read_sequence[] = {0x5A, 0x5A, 0x40};
> > +static uint32_t twi_regs[0x1000 / 4];
> > +
> > +static uint64_t twi_read(void *opaque, hwaddr addr, unsigned int size)
> > +{
> > +    static int i;
> > +    uint64_t data = 0x00;
> > +
> > +    switch (addr) {
> > +    case NRF51_TWI_EVENT_STOPPED:
> > +        data = 0x01;
> > +        break;
> > +    case NRF51_TWI_EVENT_RXDREADY:
> > +        data = 0x01;
> > +        break;
> > +    case NRF51_TWI_EVENT_TXDSENT:
> > +        data = 0x01;
> > +        break;
> > +    case NRF51_TWI_REG_RXD:
> > +        data = twi_read_sequence[i];
> > +        if (i < ARRAY_SIZE(twi_read_sequence)) {
> > +            i++;
> > +        }
> > +        break;
> > +    default:
> > +        data = twi_regs[addr / 4];
> > +        break;
> > +    }
> > +
> > +    qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u] = %" PRIx32 "\n",
> > +                  __func__, addr, size, (uint32_t)data);
> > +
> > +
> > +    return data;
> > +}
> > +
> > +static void twi_write(void *opaque, hwaddr addr, uint64_t data,
> > +                      unsigned int size)
> > +{
> > +    qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " <- 0x%" PRIx64 " [%u]\n",
> > +                  __func__, addr, data, size);
> > +    twi_regs[addr / 4] = data;
> > +}
> > +
> > +static const MemoryRegionOps twi_ops = {
> > +    .read = twi_read,
> > +    .write = twi_write
> > +};
>
> Can you put this in its own device in its own source file,
> please? This is too much device-specific code to have
> in the SoC's source file.

Sure, will send v2.  It should also be hooked up by the microbit
machine type instead of being hardcoded into the nRF51 SoC.

Stefan

  reply	other threads:[~2019-01-08 13:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-05 14:44 [Qemu-devel] [PATCH] arm: Stub out NRF51 TWI magnetometer/accelerometer detection Stefan Hajnoczi
2019-01-08 11:52 ` Peter Maydell
2019-01-08 13:22   ` Stefan Hajnoczi [this message]
2019-01-08 16:35 ` Steffen Görtz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJSP0QUn+S8vDsTF+Ww12kN4x7PsVOSbujy9HVMuMfnFbV17GA@mail.gmail.com \
    --to=stefanha@gmail.com \
    --cc=contrib@steffen-goertz.de \
    --cc=jim@groklearning.com \
    --cc=joel@jms.id.au \
    --cc=jusual@mail.ru \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).