* [PATCH] ARM: PL061: Introduce N_GPIOS
@ 2020-05-19 8:51 Geert Uytterhoeven
2020-05-19 12:01 ` Philippe Mathieu-Daudé
2020-05-21 16:08 ` Peter Maydell
0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2020-05-19 8:51 UTC (permalink / raw)
To: Peter Maydell
Cc: qemu-arm, Philippe Mathieu-Daudé, Geert Uytterhoeven, qemu-devel
Add a definition for the number of GPIO lines controlled by a PL061
instance, and use it instead of the hardcoded magic value 8.
Suggested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
hw/gpio/pl061.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
index 2a828260bdb0b946..6d3c36bc16cf9e0d 100644
--- a/hw/gpio/pl061.c
+++ b/hw/gpio/pl061.c
@@ -36,6 +36,8 @@ static const uint8_t pl061_id_luminary[12] =
#define TYPE_PL061 "pl061"
#define PL061(obj) OBJECT_CHECK(PL061State, (obj), TYPE_PL061)
+#define N_GPIOS 8
+
typedef struct PL061State {
SysBusDevice parent_obj;
@@ -62,7 +64,7 @@ typedef struct PL061State {
uint32_t cr;
uint32_t amsel;
qemu_irq irq;
- qemu_irq out[8];
+ qemu_irq out[N_GPIOS];
const unsigned char *id;
uint32_t rsvd_start; /* reserved area: [rsvd_start, 0xfcc] */
} PL061State;
@@ -112,7 +114,7 @@ static void pl061_update(PL061State *s)
changed = s->old_out_data ^ out;
if (changed) {
s->old_out_data = out;
- for (i = 0; i < 8; i++) {
+ for (i = 0; i < N_GPIOS; i++) {
mask = 1 << i;
if (changed & mask) {
DPRINTF("Set output %d = %d\n", i, (out & mask) != 0);
@@ -125,7 +127,7 @@ static void pl061_update(PL061State *s)
changed = (s->old_in_data ^ s->data) & ~s->dir;
if (changed) {
s->old_in_data = s->data;
- for (i = 0; i < 8; i++) {
+ for (i = 0; i < N_GPIOS; i++) {
mask = 1 << i;
if (changed & mask) {
DPRINTF("Changed input %d = %d\n", i, (s->data & mask) != 0);
@@ -364,8 +366,8 @@ static void pl061_init(Object *obj)
memory_region_init_io(&s->iomem, obj, &pl061_ops, s, "pl061", 0x1000);
sysbus_init_mmio(sbd, &s->iomem);
sysbus_init_irq(sbd, &s->irq);
- qdev_init_gpio_in(dev, pl061_set_irq, 8);
- qdev_init_gpio_out(dev, s->out, 8);
+ qdev_init_gpio_in(dev, pl061_set_irq, N_GPIOS);
+ qdev_init_gpio_out(dev, s->out, N_GPIOS);
}
static void pl061_class_init(ObjectClass *klass, void *data)
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: PL061: Introduce N_GPIOS
2020-05-19 8:51 [PATCH] ARM: PL061: Introduce N_GPIOS Geert Uytterhoeven
@ 2020-05-19 12:01 ` Philippe Mathieu-Daudé
2020-05-21 16:08 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-19 12:01 UTC (permalink / raw)
To: Geert Uytterhoeven, Peter Maydell; +Cc: qemu-arm, qemu-devel
On 5/19/20 10:51 AM, Geert Uytterhoeven wrote:
> Add a definition for the number of GPIO lines controlled by a PL061
> instance, and use it instead of the hardcoded magic value 8.
>
> Suggested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Thanks for following up.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/gpio/pl061.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
> index 2a828260bdb0b946..6d3c36bc16cf9e0d 100644
> --- a/hw/gpio/pl061.c
> +++ b/hw/gpio/pl061.c
> @@ -36,6 +36,8 @@ static const uint8_t pl061_id_luminary[12] =
> #define TYPE_PL061 "pl061"
> #define PL061(obj) OBJECT_CHECK(PL061State, (obj), TYPE_PL061)
>
> +#define N_GPIOS 8
> +
> typedef struct PL061State {
> SysBusDevice parent_obj;
>
> @@ -62,7 +64,7 @@ typedef struct PL061State {
> uint32_t cr;
> uint32_t amsel;
> qemu_irq irq;
> - qemu_irq out[8];
> + qemu_irq out[N_GPIOS];
> const unsigned char *id;
> uint32_t rsvd_start; /* reserved area: [rsvd_start, 0xfcc] */
> } PL061State;
> @@ -112,7 +114,7 @@ static void pl061_update(PL061State *s)
> changed = s->old_out_data ^ out;
> if (changed) {
> s->old_out_data = out;
> - for (i = 0; i < 8; i++) {
> + for (i = 0; i < N_GPIOS; i++) {
> mask = 1 << i;
> if (changed & mask) {
> DPRINTF("Set output %d = %d\n", i, (out & mask) != 0);
> @@ -125,7 +127,7 @@ static void pl061_update(PL061State *s)
> changed = (s->old_in_data ^ s->data) & ~s->dir;
> if (changed) {
> s->old_in_data = s->data;
> - for (i = 0; i < 8; i++) {
> + for (i = 0; i < N_GPIOS; i++) {
> mask = 1 << i;
> if (changed & mask) {
> DPRINTF("Changed input %d = %d\n", i, (s->data & mask) != 0);
> @@ -364,8 +366,8 @@ static void pl061_init(Object *obj)
> memory_region_init_io(&s->iomem, obj, &pl061_ops, s, "pl061", 0x1000);
> sysbus_init_mmio(sbd, &s->iomem);
> sysbus_init_irq(sbd, &s->irq);
> - qdev_init_gpio_in(dev, pl061_set_irq, 8);
> - qdev_init_gpio_out(dev, s->out, 8);
> + qdev_init_gpio_in(dev, pl061_set_irq, N_GPIOS);
> + qdev_init_gpio_out(dev, s->out, N_GPIOS);
> }
>
> static void pl061_class_init(ObjectClass *klass, void *data)
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: PL061: Introduce N_GPIOS
2020-05-19 8:51 [PATCH] ARM: PL061: Introduce N_GPIOS Geert Uytterhoeven
2020-05-19 12:01 ` Philippe Mathieu-Daudé
@ 2020-05-21 16:08 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2020-05-21 16:08 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: qemu-arm, Philippe Mathieu-Daudé, QEMU Developers
On Tue, 19 May 2020 at 09:51, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
>
> Add a definition for the number of GPIO lines controlled by a PL061
> instance, and use it instead of the hardcoded magic value 8.
>
> Suggested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> hw/gpio/pl061.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
Applied to target-arm.next, thanks.
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-21 16:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-19 8:51 [PATCH] ARM: PL061: Introduce N_GPIOS Geert Uytterhoeven
2020-05-19 12:01 ` Philippe Mathieu-Daudé
2020-05-21 16:08 ` Peter Maydell
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.