All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hao Wu via <qemu-devel@nongnu.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	minyard@acm.org, Patrick Venture <venture@google.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Havard Skinnemoen <hskinnemoen@google.com>,
	CS20 KFTing <kfting@nuvoton.com>, qemu-arm <qemu-arm@nongnu.org>,
	IS20 Avi Fishman <Avi.Fishman@nuvoton.com>
Subject: Re: [PATCH v2 3/4] hw/adc: Add an ADC module for NPCM7XX
Date: Mon, 14 Dec 2020 09:48:56 -0800	[thread overview]
Message-ID: <CAGcCb11CdDmLrndTTij6wMBNC1p7Y0VCowL+Y11oyg6+YS29Bg@mail.gmail.com> (raw)
In-Reply-To: <2d6eca6e-1690-8411-51c2-c0e7f8e8d677@amsat.org>

[-- Attachment #1: Type: text/plain, Size: 3185 bytes --]

Thanks for your comment! We'll incorporate them into our next patch version.

We plan to let the user use QOM get/set QMP commands to control ADC/PWM
values, similar to hw/misc/tmp105.c. The user can set a voltage value as
input using QOM-set, and the QEMU guest can read the converted value
through this module. Similar for PWM, the user can read the duty-cycle and
frequency using QOM-get. The user can also run a third-party simulator and
alter these values during execution. Our test code also shows how to deal
with these values.

If you have a better suggestion, please let us know.

On Sun, Dec 13, 2020 at 3:47 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> On 12/11/20 11:22 PM, Hao Wu via wrote:
> > The ADC is part of NPCM7XX Module. Its behavior is controled by the
> > ADC_CON register. It converts one of the eight analog inputs into a
> > digital input and stores it in the ADC_DATA register when enabled.
> >
> > Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com>
> > Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
> > Signed-off-by: Hao Wu <wuhaotsh@google.com>
> > ---
> >  docs/system/arm/nuvoton.rst    |   2 +-
> >  hw/adc/meson.build             |   1 +
> >  hw/adc/npcm7xx_adc.c           | 318 ++++++++++++++++++++++++++
> >  hw/arm/npcm7xx.c               |  24 +-
> >  include/hw/adc/npcm7xx_adc.h   |  72 ++++++
> >  include/hw/arm/npcm7xx.h       |   2 +
> >  tests/qtest/meson.build        |   3 +-
> >  tests/qtest/npcm7xx_adc-test.c | 400 +++++++++++++++++++++++++++++++++
> >  8 files changed, 819 insertions(+), 3 deletions(-)
> >  create mode 100644 hw/adc/npcm7xx_adc.c
> >  create mode 100644 include/hw/adc/npcm7xx_adc.h
> >  create mode 100644 tests/qtest/npcm7xx_adc-test.c
> ...
>
> > +static void npcm7xx_adc_init(Object *obj)
> > +{
> > +    NPCM7xxADCState *s = NPCM7XX_ADC(obj);
> > +    SysBusDevice *sbd = &s->parent;
> > +    int i;
> > +
> > +    sysbus_init_irq(sbd, &s->irq);
> > +
> > +    timer_init_ns(&s->conv_timer, QEMU_CLOCK_VIRTUAL,
> > +            npcm7xx_adc_convert_done, s);
> > +    timer_init_ns(&s->reset_timer, QEMU_CLOCK_VIRTUAL,
> > +            npcm7xx_adc_reset_done, s);
> > +    memory_region_init_io(&s->iomem, obj, &npcm7xx_adc_ops, s,
> > +                          TYPE_NPCM7XX_ADC, 4 * KiB);
> > +    sysbus_init_mmio(sbd, &s->iomem);
> > +    s->clock = qdev_init_clock_in(DEVICE(s), "clock", NULL, NULL);
> > +
> > +    for (i = 0; i < NPCM7XX_ADC_NUM_INPUTS; ++i) {
> > +        object_property_add_uint32_ptr(obj, "adci[*]",
> > +                &s->adci[i], OBJ_PROP_FLAG_WRITE);
>
> How do you use this, any example?
>
> FWIW I'm experimenting with other ADC to use the "audio/audio.h"
> API (which is not voice/audio specific, but generic DSP), then
> I can pass any QEMU source and consume it using AUD_read() to fill
> the ADC buffer (device sram or in main ram).
>
> But I'm doing that alone during my free time, so don't expect it
> any time soon :(
>
> > +    }
> > +    object_property_add_uint32_ptr(obj, "vref",
> > +            &s->vref, OBJ_PROP_FLAG_WRITE);
> > +    npcm7xx_adc_calibrate(s);
> > +}
>

[-- Attachment #2: Type: text/html, Size: 4202 bytes --]

  reply	other threads:[~2020-12-14 17:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 22:22 [PATCH v2 0/4] Additional NPCM7xx devices Hao Wu via
2020-12-11 22:22 ` [PATCH v2 1/4] hw/misc: Add clock converter in NPCM7XX CLK module Hao Wu via
2020-12-11 22:22 ` [PATCH v2 2/4] hw/timer: Refactor NPCM7XX Timer to use CLK clock Hao Wu via
2020-12-13 11:28   ` Philippe Mathieu-Daudé
2020-12-11 22:22 ` [PATCH v2 3/4] hw/adc: Add an ADC module for NPCM7XX Hao Wu via
2020-12-13 11:47   ` Philippe Mathieu-Daudé
2020-12-14 17:48     ` Hao Wu via [this message]
2020-12-11 22:22 ` [PATCH v2 4/4] hw/misc: Add a PWM " Hao Wu via
2020-12-13 12:01   ` Philippe Mathieu-Daudé

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=CAGcCb11CdDmLrndTTij6wMBNC1p7Y0VCowL+Y11oyg6+YS29Bg@mail.gmail.com \
    --to=qemu-devel@nongnu.org \
    --cc=Avi.Fishman@nuvoton.com \
    --cc=f4bug@amsat.org \
    --cc=hskinnemoen@google.com \
    --cc=kfting@nuvoton.com \
    --cc=minyard@acm.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=venture@google.com \
    --cc=wuhaotsh@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.