From: Rashmica Gupta <rashmica.g@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Andrew Jeffery" <andrew@aj.id.au>,
qemu-arm <qemu-arm@nongnu.org>, "Joel Stanley" <joel@jms.id.au>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Cédric Le Goater" <clg@kaod.org>
Subject: Re: [Qemu-devel] [PATCH v3 1/3] hw/gpio: Add basic Aspeed GPIO model for AST2400 and AST2500
Date: Wed, 14 Aug 2019 17:20:03 +1000 [thread overview]
Message-ID: <7af7a2ca0d5109d092922beda3b1b7bae6b4a12f.camel@gmail.com> (raw)
In-Reply-To: <CAFEAcA_OBg6s+qu-DG_N882Gy_FxX3_fxHLa=tzpHfRzY5fdWQ@mail.gmail.com>
On Tue, 2019-08-06 at 14:57 +0100, Peter Maydell wrote:
> On Tue, 30 Jul 2019 at 06:45, Rashmica Gupta <rashmica.g@gmail.com>
> wrote:
> > GPIO pins are arranged in groups of 8 pins labeled
> > A,B,..,Y,Z,AA,AB,AC.
> > (Note that the ast2400 controller only goes up to group AB).
> > A set has four groups (except set AC which only has one) and is
> > referred to by the groups it is composed of (eg
> > ABCD,EFGH,...,YZAAAB).
> > Each set is accessed and controlled by a bank of 14 registers.
> >
> > These registers operate on a per pin level where each bit in the
> > register
> > corresponds to a pin, except for the command source registers. The
> > command
> > source registers operate on a per group level where bits 24, 16, 8
> > and 0
> > correspond to each group in the set.
> >
> > eg. registers for set ABCD:
> > |D7...D0|C7...C0|B7...B0|A7...A0| <- GPIOs
> > |31...24|23...16|15....8|7.....0| <- bit position
> >
> > Note that there are a couple of groups that only have 4 pins.
> >
> > There are two ways that this model deviates from the behaviour of
> > the
> > actual controller:
> > (1) The only control source driving the GPIO pins in the model is
> > the ARM
> > model (as there currently aren't models for the LPC or
> > Coprocessor).
> >
> > (2) None of the registers in the model are reset tolerant (needs
> > integration with the watchdog).
> >
> > +typedef struct AspeedGPIOReg {
> > + uint16_t set_idx;
> > + uint32_t (*read)(GPIOSets *regs);
> > + void (*write)(AspeedGPIOState *s, GPIOSets *regs,
> > + const GPIOSetProperties *props, uint32_t val);
> > + } AspeedGPIOReg;
>
> Please don't create new abstractions for implementing
> registers that are only used in one device model. We
> have a couple of basic approaches that we use already:
That's fair enough :)
>
> * just open coded switch statements in the read and write
> functions for the device's MMIO regions
Thoughts on the switch statement approach in v4? I think it's
much nicer than two huge switch statements.
> * if you'd rather have a data structure defining each
> register with hook functions where they need to do
> particular behaviour on reads and writes, have a look
> at the APIs in include/hw/register.h. Currently these are
> used just by some of the Xilinx devices, but if you
> want an API shaped like that you can use it.
>
I had a play with the existing register API. I couldn't quite
get it to work. When writing to some registers in a set we
need to look at other registers in that set, and so we need
some kind of structure tells us how to find those registers.
> thanks
> -- PMM
next prev parent reply other threads:[~2019-08-14 7:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-30 5:44 [Qemu-devel] [PATCH v3 0/3] Add Aspeed GPIO controller model Rashmica Gupta
2019-07-30 5:44 ` [Qemu-devel] [PATCH v3 1/3] hw/gpio: Add basic Aspeed GPIO model for AST2400 and AST2500 Rashmica Gupta
2019-08-06 13:57 ` Peter Maydell
2019-08-14 7:20 ` Rashmica Gupta [this message]
2019-07-30 5:45 ` [Qemu-devel] [PATCH v3 2/3] aspeed: add a GPIO controller to the SoC Rashmica Gupta
2019-07-30 5:45 ` [Qemu-devel] [PATCH v3 3/3] hw/gpio: Add in AST2600 specific implementation Rashmica Gupta
2019-08-13 7:31 ` Alexey Kardashevskiy
2019-08-14 7:21 ` Rashmica Gupta
2019-08-06 14:08 ` [Qemu-devel] [PATCH v3 0/3] Add Aspeed GPIO controller model Peter Maydell
2019-08-14 12:46 ` Cédric Le Goater
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=7af7a2ca0d5109d092922beda3b1b7bae6b4a12f.camel@gmail.com \
--to=rashmica.g@gmail.com \
--cc=andrew@aj.id.au \
--cc=clg@kaod.org \
--cc=joel@jms.id.au \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).