All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm <qemu-arm@nongnu.org>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Alistair Francis" <alistair.francis@xilinx.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"patches@linaro.org" <patches@linaro.org>
Subject: Re: [Qemu-devel] [Qemu-arm] [PATCH v2 3/9] hw/arm/mps2: Add UARTs
Date: Fri, 14 Jul 2017 17:35:46 +0100	[thread overview]
Message-ID: <87fudzugbh.fsf@linaro.org> (raw)
In-Reply-To: <CAFEAcA--sxG2rOdeTvD=uNsOj=RFW8wFVALSaE1QU92Xzow1wA@mail.gmail.com>


Peter Maydell <peter.maydell@linaro.org> writes:

> On 14 July 2017 at 16:52, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>> Peter Maydell <peter.maydell@linaro.org> writes:
>>
>>> Add the UARTs to the MPS2 board models.
>>>
>>> Unfortunately the details of the wiring of the interrupts through
>>> various OR gates differ between AN511 and AN385 so this can't
>>> be purely a data-driven difference.
>>>
>>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>>> Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
>>> ---
>>>  hw/arm/mps2.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>  1 file changed, 86 insertions(+)
>>>
>>> diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
>>> index 3dad02d..180c5d2 100644
>>> --- a/hw/arm/mps2.c
>>> +++ b/hw/arm/mps2.c
>>> @@ -27,9 +27,12 @@
>>>  #include "qemu/error-report.h"
>>>  #include "hw/arm/arm.h"
>>>  #include "hw/arm/armv7m.h"
>>> +#include "hw/or-irq.h"
>>>  #include "hw/boards.h"
>>>  #include "exec/address-spaces.h"
>>> +#include "sysemu/sysemu.h"
>>>  #include "hw/misc/unimp.h"
>>> +#include "hw/char/cmsdk-apb-uart.h"
>>>
>>>  typedef enum MPS2FPGAType {
>>>      FPGA_AN385,
>>> @@ -206,6 +209,89 @@ static void mps2_common_init(MachineState *machine)
>>>      create_unimplemented_device("Ethernet", 0x40200000, 0x00100000);
>>>      create_unimplemented_device("VGA", 0x41000000, 0x0200000);
>>>
>>> +    switch (mmc->fpga_type) {
>>> +    case FPGA_AN385:
>>> +    {
>>> +        /* The overflow IRQs for UARTs 0, 1 and 2 are ORed together.
>>> +         * Overflow for UARTs 4 and 5 doesn't trigger any interrupt.
>>> +         */
>>> +        Object *orgate;
>>> +        DeviceState *orgate_dev;
>>> +        int i;
>>> +
>>> +        orgate = object_new(TYPE_OR_IRQ);
>>> +        object_property_set_int(orgate, 6, "num-lines", &error_fatal);
>>> +        object_property_set_bool(orgate, true, "realized", &error_fatal);
>>> +        orgate_dev = DEVICE(orgate);
>>> +        qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
>>> +
>>> +        for (i = 0; i < 5; i++) {
>>> +            hwaddr uartbase[] = {0x40004000, 0x40005000, 0x40006000,
>>> +                                 0x40007000, 0x40009000};
>>
>> I would expect these to be something like:
>>
>>   static hwaddr an385_uartbase[] = {0x40004000, 0x40005000, 0x40006000,
>>                                     0x40007000, 0x40009000};
>>   static hwaddr an511_uartbase[] = {0x40004000, 0x40005000, 0x4002c000,
>>                                     0x4002d000, 0x4002e000};
>>
>> to save the compiler from filling in the table every loop. Not that it
>> makes much different for an init routine.
>
> I'm slightly surprised the compiler can't tell that these
> are never written and emit the same code for all of them,
> but yeah, let's just 'static const' all of them.

I was just curious so I objdumped - maybe we should poke our TCWG
friends ;-)

--
Alex Bennée

  reply	other threads:[~2017-07-14 16:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-14 10:51 [Qemu-devel] [PATCH v2 0/9] ARM: implement MPS2 board (with 2 FPGA flavours) Peter Maydell
2017-07-14 10:51 ` [Qemu-devel] [PATCH v2 1/9] hw/arm/mps2: Implement skeleton mps2-an385 and mps2-an511 board models Peter Maydell
2017-07-14 14:44   ` [Qemu-devel] [Qemu-arm] " Alex Bennée
2017-07-14 10:51 ` [Qemu-devel] [PATCH v2 2/9] hw/char/cmsdk-apb-uart.c: Implement CMSDK APB UART Peter Maydell
2017-07-14 15:32   ` [Qemu-devel] [Qemu-arm] " Alex Bennée
2017-07-14 15:45     ` Peter Maydell
2017-07-14 16:11       ` Alex Bennée
2017-07-14 16:29   ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-07-14 16:31     ` Peter Maydell
2017-07-14 10:51 ` [Qemu-devel] [PATCH v2 3/9] hw/arm/mps2: Add UARTs Peter Maydell
2017-07-14 15:52   ` [Qemu-devel] [Qemu-arm] " Alex Bennée
2017-07-14 16:07     ` Peter Maydell
2017-07-14 16:35       ` Alex Bennée [this message]
2017-07-14 10:51 ` [Qemu-devel] [PATCH v2 4/9] hw/char/cmsdk-apb-timer: Implement CMSDK APB timer device Peter Maydell
2017-07-14 16:30   ` Philippe Mathieu-Daudé
2017-07-14 10:51 ` [Qemu-devel] [PATCH v2 5/9] hw/arm/mps2: Add timers Peter Maydell
2017-07-14 10:51 ` [Qemu-devel] [PATCH v2 6/9] hw/misc/mps2_scc: Implement MPS2 Serial Communication Controller Peter Maydell
2017-07-14 10:51 ` [Qemu-devel] [PATCH v2 7/9] hw/arm/mps2: Add SCC Peter Maydell
2017-07-14 10:51 ` [Qemu-devel] [PATCH v2 8/9] hw/arm/mps2: Add ethernet Peter Maydell
2017-07-14 16:17   ` [Qemu-devel] [Qemu-arm] " Alex Bennée
2017-07-14 16:23   ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-07-14 10:51 ` [Qemu-devel] [PATCH v2 9/9] MAINTAINERS: Add entries for MPS2 board Peter Maydell
2017-07-14 16:18   ` [Qemu-devel] [Qemu-arm] " Alex Bennée
2017-07-14 16:24   ` [Qemu-devel] " Philippe Mathieu-Daudé
2017-07-14 12:16 ` [Qemu-devel] [PATCH v2 0/9] ARM: implement MPS2 board (with 2 FPGA flavours) no-reply
2017-07-14 16:08 ` no-reply

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=87fudzugbh.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=alistair.francis@xilinx.com \
    --cc=f4bug@amsat.org \
    --cc=patches@linaro.org \
    --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 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.