All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Hao Wu <wuhaotsh@google.com>, hskinnemoen@google.com
Cc: peter.maydell@linaro.org, minyard@acm.org, venture@google.com,
	qemu-devel@nongnu.org, kfting@nuvoton.com, qemu-arm@nongnu.org,
	Avi.Fishman@nuvoton.com
Subject: Re: [PATCH v2 3/4] hw/adc: Add an ADC module for NPCM7XX
Date: Sun, 13 Dec 2020 12:47:56 +0100	[thread overview]
Message-ID: <2d6eca6e-1690-8411-51c2-c0e7f8e8d677@amsat.org> (raw)
In-Reply-To: <20201211222223.2252172-4-wuhaotsh@google.com>

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);
> +}


  reply	other threads:[~2020-12-13 11:53 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é [this message]
2020-12-14 17:48     ` Hao Wu via
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=2d6eca6e-1690-8411-51c2-c0e7f8e8d677@amsat.org \
    --to=f4bug@amsat.org \
    --cc=Avi.Fishman@nuvoton.com \
    --cc=hskinnemoen@google.com \
    --cc=kfting@nuvoton.com \
    --cc=minyard@acm.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@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.