All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Delevoryas <pdel@fb.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: Alistair Francis <alistair@alistair23.me>,
	Peter Maydell <peter.maydell@linaro.org>,
	Andrew Jeffery <andrew@aj.id.au>, Joel Stanley <joel@jms.id.au>,
	qemu-arm <qemu-arm@nongnu.org>,
	Cameron Esfahani via <qemu-devel@nongnu.org>,
	"patrick@stwcx.xyz" <patrick@stwcx.xyz>,
	Dan Zhang <zhdaniel@fb.com>
Subject: Re: [PATCH 0/2] hw/adc: Add basic Aspeed ADC model
Date: Sun, 3 Oct 2021 17:03:39 +0000	[thread overview]
Message-ID: <764A61F4-4299-4F07-A932-4FD14C32736B@fb.com> (raw)
In-Reply-To: <f553afbb-f29f-6837-8815-334a77c8e7f8@kaod.org>


> On Oct 3, 2021, at 6:56 AM, Cédric Le Goater <clg@kaod.org> wrote:
> 
> On 10/2/21 23:44, pdel@fbc.om wrote:
>> From: Peter Delevoryas <pdel@fb.com>
>> Following up from
>> https://lore.kernel.org/qemu-devel/20210930004235.1656003-1-pdel@fb.com/
>> This is a resubmission of Andrew Jeffery's ADC model, but with the
>> registers converted from typed-member-fields to a regs[] array.
>> Otherwise, it should be pretty much equivalent.
> 
> Thanks for taking over.
> 
>> References to the original patches from Andrew:
>> https://github.com/legoater/qemu/commit/1eff7b1cf10d1777635f7d2cef8ecb441cc607c4
>> https://github.com/legoater/qemu/commit/3052f9d8ccdaf78b753e53574b7e8cc2ee01429f
>> I did A/B "--trace aspeed_adc_engine_*" testing and the output from the
>> boot sequence was equivalent, and I tested that the channel simulation
>> code produces the same sequence of values.
>> Here's the initialization sequence:
>> aspeed_adc_engine_write engine[0] 0x0 0xf  ; Engine init
>> aspeed_adc_engine_read engine[0] 0x0 0x10f ; bit 8 set
>> aspeed_adc_engine_write engine[0] 0x0 0x2f ; Auto compensating sensing mode
>> aspeed_adc_engine_read engine[0] 0x0 0x10f ; bit 8 set (redoing engine init, lol), bit 5 reset
>> Here's some of the channel simulation:
>> (qemu) xp 0x1e6e9010
>> 000000001e6e9010: 0x00070005
>> (qemu) xp 0x1e6e9010
>> 000000001e6e9010: 0x000e000a
>> (qemu) xp 0x1e6e9010
>> 000000001e6e9010: 0x0015000f
>> (qemu) xp 0x1e6e9010
>> 000000001e6e9010: 0x001c0014
>> (qemu) xp 0x1e6e9010
>> 000000001e6e9010: 0x00230019
>> (qemu) xp 0x1e6e9010
>> 000000001e6e9010: 0x002a001e
>> (qemu) xp 0x1e6e9010
>> 000000001e6e9010: 0x00310023
>> (qemu) xp 0x1e6e9010
>> 000000001e6e9010: 0x00380028
>> This was tested with a Fuji OpenBMC image:
>> https://github.com/peterdelevoryas/openbmc/releases/download/fuji.mtd.0/fuji.mtd
>> My refactoring was kinda awkward, it took me a few tries to finally get
>> something that made sense to me. In particular, I don't know if you guys
>> realized this previously, but in the AST2600, there's 2 engines, but
>> still only 16 channels: each engine only has half the registers, as far
>> as I understand.
> 
> yes.
> 
> 
>> That's why I added the "nr-channels" property to the engine. I also
>> tried to add guest-error logs when a driver tries to read or write to
>> the upper-eight channel registers in the 2600 engines. For example:
>> (qemu) xp 0x1e6e9000
>> 000000001e6e9000: 0xffff010f
>> (qemu) xp 0x1e6e9020
>> aspeed_adc_engine_read: engine[0]: data register 4 invalid, only 0...3 valid
>> 000000001e6e9020: 0x00000000
>> (qemu) xp 0x1e6e9030
>> 000000001e6e9030: 0x00000000
>> (qemu) xp 0x1e6e9040
>> 000000001e6e9040: 0x00000000
>> (qemu) xp 0x1e6e9050
>> aspeed_adc_engine_read: engine[0]: bounds register 8 invalid, only 0...7 valid
>> 000000001e6e9050: 0x00000000
>> (qemu) xp 0x1e6e9060
>> aspeed_adc_engine_read: engine[0]: bounds register 12 invalid, only 0...7 valid
>> 000000001e6e9060: 0x00000000
>> (qemu) xp 0x1e6e9070
>> 000000001e6e9070: 0x00000000
>> (qemu) xp 0x1e6e9080
>> 000000001e6e9080: 0x00000000
>> (qemu) xp 0x1e6e9090
>> aspeed_adc_engine_read: engine[0]: hysteresis register 8 invalid, only 0...7 valid
>> 000000001e6e9090: 0x00000000
>> (qemu) xp 0x1e6e90a0
>> aspeed_adc_engine_read: engine[0]: hysteresis register 12 invalid, only 0...7 valid
>> 000000001e6e90a0: 0x00000000
> 
> This looks nice.
> 
>> It might turn out that we should just stick with a closer version of
>> Andrew's original patch, and that would be totally fine with me, I just
>> want to get the ADC support merged one way or another.
> 
> 
> Do you have a test case we could include in qtest ? This is not a
> requirement but it's always good to have.

Yeah absolutely! I have to go look more at qtest a little, but I’m sure I
can add some kind of test for this.

> 
> Thanks,
> 
> C.
> 
>> Also, I'm interested in resubmitting Andrew's work on supporting
>> unaligned accesses for models that only implement aligned access, to
>> make supporting 8-bit and 16-bit reads transparent to this model, but
>> I'll submit that separately.
>> 
>> Reference: https://lore.kernel.org/qemu-devel/20170630030058.28943-1-andrew@aj.id.au/
>> Thanks,
>> Peter
>> Andrew Jeffery (2):
>>   hw/adc: Add basic Aspeed ADC model
>>   hw/arm: Integrate ADC model into Aspeed SoC
>>  hw/adc/aspeed_adc.c         | 416 ++++++++++++++++++++++++++++++++++++
>>  hw/adc/meson.build          |   1 +
>>  hw/adc/trace-events         |   3 +
>>  hw/arm/aspeed_ast2600.c     |  11 +
>>  hw/arm/aspeed_soc.c         |  11 +
>>  include/hw/adc/aspeed_adc.h |  55 +++++
>>  include/hw/arm/aspeed_soc.h |   2 +
>>  7 files changed, 499 insertions(+)
>>  create mode 100644 hw/adc/aspeed_adc.c
>>  create mode 100644 include/hw/adc/aspeed_adc.h


      reply	other threads:[~2021-10-03 17:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-02 21:44 [PATCH 0/2] hw/adc: Add basic Aspeed ADC model pdel
2021-10-02 21:44 ` [PATCH 1/2] " pdel
2021-10-03 13:53   ` Cédric Le Goater
2021-10-03 17:03     ` Peter Delevoryas
2021-10-03 17:34       ` Cédric Le Goater
2021-10-03 17:44         ` Peter Delevoryas
2021-10-02 21:44 ` [PATCH 2/2] hw/arm: Integrate ADC model into Aspeed SoC pdel
2021-10-03 13:56 ` [PATCH 0/2] hw/adc: Add basic Aspeed ADC model Cédric Le Goater
2021-10-03 17:03   ` Peter Delevoryas [this message]

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=764A61F4-4299-4F07-A932-4FD14C32736B@fb.com \
    --to=pdel@fb.com \
    --cc=alistair@alistair23.me \
    --cc=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --cc=joel@jms.id.au \
    --cc=patrick@stwcx.xyz \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=zhdaniel@fb.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.