qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 00/10] aspeed queue
@ 2024-11-04 10:14 Cédric Le Goater
  2024-11-04 10:14 ` [PULL 01/10] hw/arm: enable at24c with aspeed Cédric Le Goater
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Cédric Le Goater

The following changes since commit 92ec7805190313c9e628f8fc4eb4f932c15247bd:

  Merge tag 'pull-riscv-to-apply-20241031-1' of https://github.com/alistair23/qemu into staging (2024-10-31 16:34:25 +0000)

are available in the Git repository at:

  https://github.com/legoater/qemu/ tags/pull-aspeed-20241104

for you to fetch changes up to 8df5fd815e841bf33fb51e1e6e5be9c31d529b94:

  aspeed: Don't set always boot properties of the emmc device (2024-11-04 10:12:02 +0100)

----------------------------------------------------------------
aspeed queue:

* Fixed eMMC size calculation
* Fixed IRQ definitions on AST2700
* Added RTC support to AST2700
* Fixed timer IRQ status on AST2600
* Improved SDHCI model with new registers
* Added -nodefaults support to AST1030
* Provided a way to use an eMMC device without boot partitions

----------------------------------------------------------------
Cédric Le Goater (1):
      aspeed: Don't set always boot properties of the emmc device

Jamin Lin (5):
      aspeed/soc: Support RTC for AST2700
      hw/timer/aspeed: Fix coding style
      hw/timer/aspeed: Fix interrupt status does not be cleared for AST2600
      hw/sd/aspeed_sdhci: Introduce Capabilities Register 2 for SD slot 0 and 1
      aspeed: Support create flash devices via command line for AST1030

Jan Luebbe (1):
      hw/sd/sdcard: Fix calculation of size when using eMMC boot partitions

Patrick Leis (1):
      hw/arm: enable at24c with aspeed

Peter Maydell (2):
      hw/arm/aspeed_ast27x0: Use bsa.h for PPI definitions
      hw/arm/aspeed_ast27x0: Avoid hardcoded '256' in IRQ calculation

 hw/arm/aspeed.c         | 38 +++++++++++++++++++++++++-------------
 hw/arm/aspeed_ast27x0.c | 33 ++++++++++++++++++++++-----------
 hw/sd/aspeed_sdhci.c    | 40 +++++++++++++++++++++++++++++-----------
 hw/sd/sd.c              |  4 +++-
 hw/timer/aspeed_timer.c | 15 +++++++++------
 hw/arm/Kconfig          |  1 +
 6 files changed, 89 insertions(+), 42 deletions(-)



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PULL 01/10] hw/arm: enable at24c with aspeed
  2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
@ 2024-11-04 10:14 ` Cédric Le Goater
  2024-11-04 10:14 ` [PULL 02/10] hw/sd/sdcard: Fix calculation of size when using eMMC boot partitions Cédric Le Goater
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel
  Cc: Patrick Leis, Hao Wu, Andrew Jeffery, Philippe Mathieu-Daudé

From: Patrick Leis <venture@google.com>

Enable AT24C with ASPEED in the KConfig because the boards build this
device.

Signed-off-by: Patrick Leis <venture@google.com>
Reviewed-by: Hao Wu <wuhaotsh@google.com>
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index e7fd9338d11d..1b25e73578e7 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -539,6 +539,7 @@ config ASPEED_SOC
     select PMBUS
     select MAX31785
     select FSI_APB2OPB_ASPEED
+    select AT24C
 
 config MPS2
     bool
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PULL 02/10] hw/sd/sdcard: Fix calculation of size when using eMMC boot partitions
  2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
  2024-11-04 10:14 ` [PULL 01/10] hw/arm: enable at24c with aspeed Cédric Le Goater
@ 2024-11-04 10:14 ` Cédric Le Goater
  2024-11-04 10:14 ` [PULL 03/10] hw/arm/aspeed_ast27x0: Use bsa.h for PPI definitions Cédric Le Goater
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel
  Cc: Jan Luebbe, Cédric Le Goater, Guenter Roeck,
	Cédric Le Goater

From: Jan Luebbe <jlu@pengutronix.de>

The sd_bootpart_offset() function calculates the *runtime* offset which
changes as the guest switches between accessing the main user data area
and the boot partitions by writing to the EXT_CSD_PART_CONFIG_ACC_MASK
bits, so it shouldn't be used to calculate the main user data area size.

Instead, subtract the boot_part_size directly (twice, as there are two
identical boot partitions defined by the eMMC spec).

Suggested-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Fixes: c8cb19876d3e ("hw/sd/sdcard: Support boot area in emmc image")
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
 hw/sd/sd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index b2e2d58e013e..f9bd03f3fd9e 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -834,7 +834,9 @@ static void sd_reset(DeviceState *dev)
         sect = 0;
     }
     size = sect << HWBLOCK_SHIFT;
-    size -= sd_bootpart_offset(sd);
+    if (sd_is_emmc(sd)) {
+        size -= sd->boot_part_size * 2;
+    }
 
     sect = sd_addr_to_wpnum(size) + 1;
 
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PULL 03/10] hw/arm/aspeed_ast27x0: Use bsa.h for PPI definitions
  2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
  2024-11-04 10:14 ` [PULL 01/10] hw/arm: enable at24c with aspeed Cédric Le Goater
  2024-11-04 10:14 ` [PULL 02/10] hw/sd/sdcard: Fix calculation of size when using eMMC boot partitions Cédric Le Goater
@ 2024-11-04 10:14 ` Cédric Le Goater
  2024-11-04 10:14 ` [PULL 04/10] hw/arm/aspeed_ast27x0: Avoid hardcoded '256' in IRQ calculation Cédric Le Goater
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Peter Maydell, Pierrick Bouvier

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

Use the private peripheral interrupt definitions from bsa.h instead
of defining them locally.

Note that bsa.h defines these values as INTID values, which are all
16 greater than the PPI values that we were previously using.  So we
refactor the code to use INTID-based values to match that.

This is the same thing we did in commit d40ab068c07d9 for sbsa-ref.
It removes the "same constant, different values" confusion where this
board code and bsa.h both define an ARCH_GIC_MAINT_IRQ, and allows us
to use symbolic names for the timer interrupt IDs.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/arm/aspeed_ast27x0.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c
index dca660eb6be2..5638a7a5781b 100644
--- a/hw/arm/aspeed_ast27x0.c
+++ b/hw/arm/aspeed_ast27x0.c
@@ -13,6 +13,7 @@
 #include "qapi/error.h"
 #include "hw/misc/unimp.h"
 #include "hw/arm/aspeed_soc.h"
+#include "hw/arm/bsa.h"
 #include "qemu/module.h"
 #include "qemu/error-report.h"
 #include "hw/i2c/aspeed_i2c.h"
@@ -416,28 +417,28 @@ static bool aspeed_soc_ast2700_gic_realize(DeviceState *dev, Error **errp)
 
     for (i = 0; i < sc->num_cpus; i++) {
         DeviceState *cpudev = DEVICE(&a->cpu[i]);
-        int NUM_IRQS = 256, ARCH_GIC_MAINT_IRQ = 9, VIRTUAL_PMU_IRQ = 7;
-        int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;
+        int NUM_IRQS = 256;
+        int intidbase = NUM_IRQS + i * GIC_INTERNAL;
 
         const int timer_irq[] = {
-            [GTIMER_PHYS] = 14,
-            [GTIMER_VIRT] = 11,
-            [GTIMER_HYP]  = 10,
-            [GTIMER_SEC]  = 13,
+            [GTIMER_PHYS] = ARCH_TIMER_NS_EL1_IRQ,
+            [GTIMER_VIRT] = ARCH_TIMER_VIRT_IRQ,
+            [GTIMER_HYP]  = ARCH_TIMER_NS_EL2_IRQ,
+            [GTIMER_SEC]  = ARCH_TIMER_S_EL1_IRQ,
         };
         int j;
 
         for (j = 0; j < ARRAY_SIZE(timer_irq); j++) {
             qdev_connect_gpio_out(cpudev, j,
-                    qdev_get_gpio_in(gicdev, ppibase + timer_irq[j]));
+                    qdev_get_gpio_in(gicdev, intidbase + timer_irq[j]));
         }
 
         qemu_irq irq = qdev_get_gpio_in(gicdev,
-                                        ppibase + ARCH_GIC_MAINT_IRQ);
+                                        intidbase + ARCH_GIC_MAINT_IRQ);
         qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt",
                                     0, irq);
         qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0,
-                qdev_get_gpio_in(gicdev, ppibase + VIRTUAL_PMU_IRQ));
+                qdev_get_gpio_in(gicdev, intidbase + VIRTUAL_PMU_IRQ));
 
         sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
         sysbus_connect_irq(gicbusdev, i + sc->num_cpus,
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PULL 04/10] hw/arm/aspeed_ast27x0: Avoid hardcoded '256' in IRQ calculation
  2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
                   ` (2 preceding siblings ...)
  2024-11-04 10:14 ` [PULL 03/10] hw/arm/aspeed_ast27x0: Use bsa.h for PPI definitions Cédric Le Goater
@ 2024-11-04 10:14 ` Cédric Le Goater
  2024-11-04 10:14 ` [PULL 05/10] aspeed/soc: Support RTC for AST2700 Cédric Le Goater
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Peter Maydell, Pierrick Bouvier

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

When calculating the index into the GIC's GPIO array for per-CPU
interrupts, we have to start with the number of SPIs.  The code
currently hard-codes this to 'NUM_IRQS = 256'.  However the number of
SPIs is set separately and implicitly by the value of
AST2700_MAX_IRQ, which is the number of SPIs plus 32 (since it is
what we set the GIC num-irq property to).

Define AST2700_MAX_IRQ as the total number of SPIs; this brings
AST2700 into line with AST2600, which defines AST2600_MAX_IRQ as the
number of SPIs not including the 32 internal interrupts.  We can then
use AST2700_MAX_IRQ instead of the hardcoded 256.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 hw/arm/aspeed_ast27x0.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c
index 5638a7a5781b..7b2464409521 100644
--- a/hw/arm/aspeed_ast27x0.c
+++ b/hw/arm/aspeed_ast27x0.c
@@ -66,7 +66,7 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = {
     [ASPEED_DEV_GPIO]      =  0x14C0B000,
 };
 
-#define AST2700_MAX_IRQ 288
+#define AST2700_MAX_IRQ 256
 
 /* Shared Peripheral Interrupt values below are offset by -32 from datasheet */
 static const int aspeed_soc_ast2700_irqmap[] = {
@@ -403,7 +403,7 @@ static bool aspeed_soc_ast2700_gic_realize(DeviceState *dev, Error **errp)
     gicdev = DEVICE(&a->gic);
     qdev_prop_set_uint32(gicdev, "revision", 3);
     qdev_prop_set_uint32(gicdev, "num-cpu", sc->num_cpus);
-    qdev_prop_set_uint32(gicdev, "num-irq", AST2700_MAX_IRQ);
+    qdev_prop_set_uint32(gicdev, "num-irq", AST2700_MAX_IRQ + GIC_INTERNAL);
 
     redist_region_count = qlist_new();
     qlist_append_int(redist_region_count, sc->num_cpus);
@@ -417,8 +417,7 @@ static bool aspeed_soc_ast2700_gic_realize(DeviceState *dev, Error **errp)
 
     for (i = 0; i < sc->num_cpus; i++) {
         DeviceState *cpudev = DEVICE(&a->cpu[i]);
-        int NUM_IRQS = 256;
-        int intidbase = NUM_IRQS + i * GIC_INTERNAL;
+        int intidbase = AST2700_MAX_IRQ + i * GIC_INTERNAL;
 
         const int timer_irq[] = {
             [GTIMER_PHYS] = ARCH_TIMER_NS_EL1_IRQ,
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PULL 05/10] aspeed/soc: Support RTC for AST2700
  2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
                   ` (3 preceding siblings ...)
  2024-11-04 10:14 ` [PULL 04/10] hw/arm/aspeed_ast27x0: Avoid hardcoded '256' in IRQ calculation Cédric Le Goater
@ 2024-11-04 10:14 ` Cédric Le Goater
  2024-11-04 10:14 ` [PULL 06/10] hw/timer/aspeed: Fix coding style Cédric Le Goater
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Jamin Lin, Cédric Le Goater

From: Jamin Lin <jamin_lin@aspeedtech.com>

The RTC controller between AST2600 and AST2700 are identical. Add RTC model for
AST2700 RTC support. The RTC controller registers base address is start at
0x12C0_F000 and its alarm interrupt is connected to GICINT13.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
 hw/arm/aspeed_ast27x0.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c
index 7b2464409521..63d1fcb086d7 100644
--- a/hw/arm/aspeed_ast27x0.c
+++ b/hw/arm/aspeed_ast27x0.c
@@ -64,6 +64,7 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = {
     [ASPEED_DEV_ADC]       =  0x14C00000,
     [ASPEED_DEV_I2C]       =  0x14C0F000,
     [ASPEED_DEV_GPIO]      =  0x14C0B000,
+    [ASPEED_DEV_RTC]       =  0x12C0F000,
 };
 
 #define AST2700_MAX_IRQ 256
@@ -377,6 +378,8 @@ static void aspeed_soc_ast2700_init(Object *obj)
 
     snprintf(typename, sizeof(typename), "aspeed.gpio-%s", socname);
     object_initialize_child(obj, "gpio", &s->gpio, typename);
+
+    object_initialize_child(obj, "rtc", &s->rtc, TYPE_ASPEED_RTC);
 }
 
 /*
@@ -670,6 +673,14 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0,
                        aspeed_soc_get_irq(s, ASPEED_DEV_GPIO));
 
+    /* RTC */
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) {
+        return;
+    }
+    aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->rtc), 0, sc->memmap[ASPEED_DEV_RTC]);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0,
+                       aspeed_soc_get_irq(s, ASPEED_DEV_RTC));
+
     create_unimplemented_device("ast2700.dpmcu", 0x11000000, 0x40000);
     create_unimplemented_device("ast2700.iomem0", 0x12000000, 0x01000000);
     create_unimplemented_device("ast2700.iomem1", 0x14000000, 0x01000000);
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PULL 06/10] hw/timer/aspeed: Fix coding style
  2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
                   ` (4 preceding siblings ...)
  2024-11-04 10:14 ` [PULL 05/10] aspeed/soc: Support RTC for AST2700 Cédric Le Goater
@ 2024-11-04 10:14 ` Cédric Le Goater
  2024-11-04 10:14 ` [PULL 07/10] hw/timer/aspeed: Fix interrupt status does not be cleared for AST2600 Cédric Le Goater
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Jamin Lin, Cédric Le Goater

From: Jamin Lin <jamin_lin@aspeedtech.com>

Fix coding style issues from checkpatch.pl

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
 hw/timer/aspeed_timer.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
index b1f860ecfb80..5af268ea9ebc 100644
--- a/hw/timer/aspeed_timer.c
+++ b/hw/timer/aspeed_timer.c
@@ -276,7 +276,8 @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg,
         old_reload = t->reload;
         t->reload = calculate_min_ticks(t, value);
 
-        /* If the reload value was not previously set, or zero, and
+        /*
+         * If the reload value was not previously set, or zero, and
          * the current value is valid, try to start the timer if it is
          * enabled.
          */
@@ -312,7 +313,8 @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg,
     }
 }
 
-/* Control register operations are broken out into helpers that can be
+/*
+ * Control register operations are broken out into helpers that can be
  * explicitly called on aspeed_timer_reset(), but also from
  * aspeed_timer_ctrl_op().
  */
@@ -396,7 +398,8 @@ static void aspeed_timer_set_ctrl(AspeedTimerCtrlState *s, uint32_t reg)
     AspeedTimer *t;
     const uint8_t enable_mask = BIT(op_enable);
 
-    /* Handle a dependency between the 'enable' and remaining three
+    /*
+     * Handle a dependency between the 'enable' and remaining three
      * configuration bits - i.e. if more than one bit in the control set has
      * changed, including the 'enable' bit, then we want either disable the
      * timer and perform configuration, or perform configuration and then
@@ -582,7 +585,6 @@ static void aspeed_2600_timer_write(AspeedTimerCtrlState *s, hwaddr offset,
     case 0x3C:
         aspeed_timer_set_ctrl(s, s->ctrl & ~tv);
         break;
-
     case 0x38:
     default:
         qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n",
@@ -623,7 +625,8 @@ static void aspeed_timer_reset(DeviceState *dev)
 
     for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
         AspeedTimer *t = &s->timers[i];
-        /* Explicitly call helpers to avoid any conditional behaviour through
+        /*
+         * Explicitly call helpers to avoid any conditional behaviour through
          * aspeed_timer_set_ctrl().
          */
         aspeed_timer_ctrl_enable(t, false);
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PULL 07/10] hw/timer/aspeed: Fix interrupt status does not be cleared for AST2600
  2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
                   ` (5 preceding siblings ...)
  2024-11-04 10:14 ` [PULL 06/10] hw/timer/aspeed: Fix coding style Cédric Le Goater
@ 2024-11-04 10:14 ` Cédric Le Goater
  2024-11-04 10:14 ` [PULL 08/10] hw/sd/aspeed_sdhci: Introduce Capabilities Register 2 for SD slot 0 and 1 Cédric Le Goater
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Jamin Lin, Andrew Jeffery, Cédric Le Goater

From: Jamin Lin <jamin_lin@aspeedtech.com>

According to the datasheet of AST2600 description, interrupt status set by HW
and clear to "0" by software writing "1" on the specific bit.

Therefore, if firmware set the specific bit "1" in the interrupt status
register(0x34), the specific bit of "s->irq_sts" should be cleared 0.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Fixes: fadefada4d07 ("aspeed/timer: Add support for IRQ status register on the AST2600")
Reviewed-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
 hw/timer/aspeed_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
index 5af268ea9ebc..149f7cc5a6aa 100644
--- a/hw/timer/aspeed_timer.c
+++ b/hw/timer/aspeed_timer.c
@@ -580,7 +580,7 @@ static void aspeed_2600_timer_write(AspeedTimerCtrlState *s, hwaddr offset,
 
     switch (offset) {
     case 0x34:
-        s->irq_sts &= tv;
+        s->irq_sts &= ~tv;
         break;
     case 0x3C:
         aspeed_timer_set_ctrl(s, s->ctrl & ~tv);
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PULL 08/10] hw/sd/aspeed_sdhci: Introduce Capabilities Register 2 for SD slot 0 and 1
  2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
                   ` (6 preceding siblings ...)
  2024-11-04 10:14 ` [PULL 07/10] hw/timer/aspeed: Fix interrupt status does not be cleared for AST2600 Cédric Le Goater
@ 2024-11-04 10:14 ` Cédric Le Goater
  2024-11-04 10:15 ` [PULL 09/10] aspeed: Support create flash devices via command line for AST1030 Cédric Le Goater
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Jamin Lin, Cédric Le Goater

From: Jamin Lin <jamin_lin@aspeedtech.com>

The size of SDHCI capabilities register is 64bits, so introduces new
Capabilities Register 2 for SD slot 0 (0x144) and SD slot1 (0x244).

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
[ clg: Fixed code alignment ]
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
 hw/sd/aspeed_sdhci.c | 40 +++++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c
index 427e5336a8fb..98d5460905df 100644
--- a/hw/sd/aspeed_sdhci.c
+++ b/hw/sd/aspeed_sdhci.c
@@ -24,8 +24,10 @@
 #define  ASPEED_SDHCI_DEBOUNCE_RESET 0x00000005
 #define ASPEED_SDHCI_BUS             0x08
 #define ASPEED_SDHCI_SDIO_140        0x10
+#define ASPEED_SDHCI_SDIO_144        0x14
 #define ASPEED_SDHCI_SDIO_148        0x18
 #define ASPEED_SDHCI_SDIO_240        0x20
+#define ASPEED_SDHCI_SDIO_244        0x24
 #define ASPEED_SDHCI_SDIO_248        0x28
 #define ASPEED_SDHCI_WP_POL          0xec
 #define ASPEED_SDHCI_CARD_DET        0xf0
@@ -35,21 +37,27 @@
 
 static uint64_t aspeed_sdhci_read(void *opaque, hwaddr addr, unsigned int size)
 {
-    uint32_t val = 0;
+    uint64_t val = 0;
     AspeedSDHCIState *sdhci = opaque;
 
     switch (addr) {
     case ASPEED_SDHCI_SDIO_140:
-        val = (uint32_t)sdhci->slots[0].capareg;
+        val = extract64(sdhci->slots[0].capareg, 0, 32);
+        break;
+    case ASPEED_SDHCI_SDIO_144:
+        val = extract64(sdhci->slots[0].capareg, 32, 32);
         break;
     case ASPEED_SDHCI_SDIO_148:
-        val = (uint32_t)sdhci->slots[0].maxcurr;
+        val = extract64(sdhci->slots[0].maxcurr, 0, 32);
         break;
     case ASPEED_SDHCI_SDIO_240:
-        val = (uint32_t)sdhci->slots[1].capareg;
+        val = extract64(sdhci->slots[1].capareg, 0, 32);
+        break;
+    case ASPEED_SDHCI_SDIO_244:
+        val = extract64(sdhci->slots[1].capareg, 32, 32);
         break;
     case ASPEED_SDHCI_SDIO_248:
-        val = (uint32_t)sdhci->slots[1].maxcurr;
+        val = extract64(sdhci->slots[1].maxcurr, 0, 32);
         break;
     default:
         if (addr < ASPEED_SDHCI_REG_SIZE) {
@@ -61,9 +69,9 @@ static uint64_t aspeed_sdhci_read(void *opaque, hwaddr addr, unsigned int size)
         }
     }
 
-    trace_aspeed_sdhci_read(addr, size, (uint64_t) val);
+    trace_aspeed_sdhci_read(addr, size, val);
 
-    return (uint64_t)val;
+    return val;
 }
 
 static void aspeed_sdhci_write(void *opaque, hwaddr addr, uint64_t val,
@@ -79,16 +87,26 @@ static void aspeed_sdhci_write(void *opaque, hwaddr addr, uint64_t val,
         sdhci->regs[TO_REG(addr)] = (uint32_t)val & ~ASPEED_SDHCI_INFO_RESET;
         break;
     case ASPEED_SDHCI_SDIO_140:
-        sdhci->slots[0].capareg = (uint64_t)(uint32_t)val;
+        sdhci->slots[0].capareg = deposit64(sdhci->slots[0].capareg, 0, 32, val);
+        break;
+    case ASPEED_SDHCI_SDIO_144:
+        sdhci->slots[0].capareg = deposit64(sdhci->slots[0].capareg, 32, 32, val);
         break;
     case ASPEED_SDHCI_SDIO_148:
-        sdhci->slots[0].maxcurr = (uint64_t)(uint32_t)val;
+        sdhci->slots[0].maxcurr = deposit64(sdhci->slots[0].maxcurr,
+                                            0, 32, val);
         break;
     case ASPEED_SDHCI_SDIO_240:
-        sdhci->slots[1].capareg = (uint64_t)(uint32_t)val;
+        sdhci->slots[1].capareg = deposit64(sdhci->slots[1].capareg,
+                                            0, 32, val);
+        break;
+    case ASPEED_SDHCI_SDIO_244:
+        sdhci->slots[1].capareg = deposit64(sdhci->slots[1].capareg,
+                                            32, 32, val);
         break;
     case ASPEED_SDHCI_SDIO_248:
-        sdhci->slots[1].maxcurr = (uint64_t)(uint32_t)val;
+        sdhci->slots[1].maxcurr = deposit64(sdhci->slots[0].maxcurr,
+                                            0, 32, val);
         break;
     default:
         if (addr < ASPEED_SDHCI_REG_SIZE) {
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PULL 09/10] aspeed: Support create flash devices via command line for AST1030
  2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
                   ` (7 preceding siblings ...)
  2024-11-04 10:14 ` [PULL 08/10] hw/sd/aspeed_sdhci: Introduce Capabilities Register 2 for SD slot 0 and 1 Cédric Le Goater
@ 2024-11-04 10:15 ` Cédric Le Goater
  2024-11-04 10:15 ` [PULL 10/10] aspeed: Don't set always boot properties of the emmc device Cédric Le Goater
  2024-11-04 10:38 ` [PULL 00/10] aspeed queue Cédric Le Goater
  10 siblings, 0 replies; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:15 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Jamin Lin, Cédric Le Goater

From: Jamin Lin <jamin_lin@aspeedtech.com>

Add a "if-statement" in aspeed_minibmc_machine_init function. If users add
"-nodefaults" in command line, the flash devices should be created by users
setting. Otherwise, the flash devices are created at machine init.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
---
 hw/arm/aspeed.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index b4b1ce9efb2b..e447923536b4 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -1594,18 +1594,20 @@ static void aspeed_minibmc_machine_init(MachineState *machine)
     connect_serial_hds_to_uarts(bmc);
     qdev_realize(DEVICE(bmc->soc), NULL, &error_abort);
 
-    aspeed_board_init_flashes(&bmc->soc->fmc,
-                              bmc->fmc_model ? bmc->fmc_model : amc->fmc_model,
-                              amc->num_cs,
-                              0);
+    if (defaults_enabled()) {
+        aspeed_board_init_flashes(&bmc->soc->fmc,
+                            bmc->fmc_model ? bmc->fmc_model : amc->fmc_model,
+                            amc->num_cs,
+                            0);
 
-    aspeed_board_init_flashes(&bmc->soc->spi[0],
-                              bmc->spi_model ? bmc->spi_model : amc->spi_model,
-                              amc->num_cs, amc->num_cs);
+        aspeed_board_init_flashes(&bmc->soc->spi[0],
+                            bmc->spi_model ? bmc->spi_model : amc->spi_model,
+                            amc->num_cs, amc->num_cs);
 
-    aspeed_board_init_flashes(&bmc->soc->spi[1],
-                              bmc->spi_model ? bmc->spi_model : amc->spi_model,
-                              amc->num_cs, (amc->num_cs * 2));
+        aspeed_board_init_flashes(&bmc->soc->spi[1],
+                            bmc->spi_model ? bmc->spi_model : amc->spi_model,
+                            amc->num_cs, (amc->num_cs * 2));
+    }
 
     if (amc->i2c_init) {
         amc->i2c_init(bmc);
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PULL 10/10] aspeed: Don't set always boot properties of the emmc device
  2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
                   ` (8 preceding siblings ...)
  2024-11-04 10:15 ` [PULL 09/10] aspeed: Support create flash devices via command line for AST1030 Cédric Le Goater
@ 2024-11-04 10:15 ` Cédric Le Goater
  2024-11-04 10:38 ` [PULL 00/10] aspeed queue Cédric Le Goater
  10 siblings, 0 replies; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:15 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Cédric Le Goater, Jan Luebbe, Guenter Roeck

Commit e554e45b4478 ("aspeed: Tune eMMC device properties to reflect
HW strapping") added support to boot from an eMMC device by setting
the boot properties of the eMMC device. This change made the
assumption that the device always has boot areas.

However, if the machine boots from the flash device (or -kernel) and
uses an eMMC device without boot areas, support would be broken. This
impacts the ast2600-evb machine which can choose to boot from flash or
eMMC using the "boot-emmc" machine option.

To provide some flexibility for Aspeed machine users to use different
flavors of eMMC devices (with or without boot areas), do not set the
eMMC device boot properties when the machine is not configured to boot
from eMMC. However, this approach makes another assumption about eMMC
devices, namely that eMMC devices from which the machine does not boot
do not have boot areas.

A preferable alternative would be to add support for user creatable
eMMC devices and define the device boot properties on the QEMU command
line :

  -blockdev node-name=emmc0,driver=file,filename=mmc-ast2600-evb.raw \
  -device emmc,bus=sdhci-bus.2,drive=emmc0,boot-partition-size=1048576,boot-config=8

This is a global change requiring more thinking. Nevertheless, in the
case of the ast2600-evb machine booting from an eMMC device and when
default devices are created, the proposed change still makes sense
since the device is required to have boot areas.

Cc: Jan Luebbe <jlu@pengutronix.de>
Fixes: e554e45b4478 ("aspeed: Tune eMMC device properties to reflect
HW strapping")
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jan Luebbe <jlu@pengutronix.de>
---
 hw/arm/aspeed.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index e447923536b4..6ca145362cbd 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -338,10 +338,20 @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo, bool emmc,
             return;
         }
         card = qdev_new(emmc ? TYPE_EMMC : TYPE_SD_CARD);
-        if (emmc) {
+
+        /*
+         * Force the boot properties of the eMMC device only when the
+         * machine is strapped to boot from eMMC. Without these
+         * settings, the machine would not boot.
+         *
+         * This also allows the machine to use an eMMC device without
+         * boot areas when booting from the flash device (or -kernel)
+         * Ideally, the device and its properties should be defined on
+         * the command line.
+         */
+        if (emmc && boot_emmc) {
             qdev_prop_set_uint64(card, "boot-partition-size", 1 * MiB);
-            qdev_prop_set_uint8(card, "boot-config",
-                                boot_emmc ? 0x1 << 3 : 0x0);
+            qdev_prop_set_uint8(card, "boot-config", 0x1 << 3);
         }
         qdev_prop_set_drive_err(card, "drive", blk_by_legacy_dinfo(dinfo),
                                 &error_fatal);
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PULL 00/10] aspeed queue
  2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
                   ` (9 preceding siblings ...)
  2024-11-04 10:15 ` [PULL 10/10] aspeed: Don't set always boot properties of the emmc device Cédric Le Goater
@ 2024-11-04 10:38 ` Cédric Le Goater
  2024-11-05 14:22   ` Peter Maydell
  10 siblings, 1 reply; 13+ messages in thread
From: Cédric Le Goater @ 2024-11-04 10:38 UTC (permalink / raw)
  To: qemu-arm, qemu-devel; +Cc: Philippe Mathieu-Daudé

On 11/4/24 11:14, Cédric Le Goater wrote:
> The following changes since commit 92ec7805190313c9e628f8fc4eb4f932c15247bd:
> 
>    Merge tag 'pull-riscv-to-apply-20241031-1' of https://github.com/alistair23/qemu into staging (2024-10-31 16:34:25 +0000)
> 
> are available in the Git repository at:
> 
>    https://github.com/legoater/qemu/ tags/pull-aspeed-20241104
> 
> for you to fetch changes up to 8df5fd815e841bf33fb51e1e6e5be9c31d529b94:
> 
>    aspeed: Don't set always boot properties of the emmc device (2024-11-04 10:12:02 +0100)
> 
> ----------------------------------------------------------------
> aspeed queue:
> 
> * Fixed eMMC size calculation
> * Fixed IRQ definitions on AST2700
> * Added RTC support to AST2700
> * Fixed timer IRQ status on AST2600
> * Improved SDHCI model with new registers
> * Added -nodefaults support to AST1030
> * Provided a way to use an eMMC device without boot partitions
> 
> ----------------------------------------------------------------
> Cédric Le Goater (1):
>        aspeed: Don't set always boot properties of the emmc device
> 
> Jamin Lin (5):
>        aspeed/soc: Support RTC for AST2700
>        hw/timer/aspeed: Fix coding style
>        hw/timer/aspeed: Fix interrupt status does not be cleared for AST2600
>        hw/sd/aspeed_sdhci: Introduce Capabilities Register 2 for SD slot 0 and 1
>        aspeed: Support create flash devices via command line for AST1030
> 
> Jan Luebbe (1):
>        hw/sd/sdcard: Fix calculation of size when using eMMC boot partitions
> 
> Patrick Leis (1):
>        hw/arm: enable at24c with aspeed
> 
> Peter Maydell (2):
>        hw/arm/aspeed_ast27x0: Use bsa.h for PPI definitions
>        hw/arm/aspeed_ast27x0: Avoid hardcoded '256' in IRQ calculation
> 
>   hw/arm/aspeed.c         | 38 +++++++++++++++++++++++++-------------
>   hw/arm/aspeed_ast27x0.c | 33 ++++++++++++++++++++++-----------
>   hw/sd/aspeed_sdhci.c    | 40 +++++++++++++++++++++++++++++-----------
>   hw/sd/sd.c              |  4 +++-
>   hw/timer/aspeed_timer.c | 15 +++++++++------
>   hw/arm/Kconfig          |  1 +
>   6 files changed, 89 insertions(+), 42 deletions(-)
> 

I just did an update with Philippe's trailers. No code change.

Thanks,

C.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PULL 00/10] aspeed queue
  2024-11-04 10:38 ` [PULL 00/10] aspeed queue Cédric Le Goater
@ 2024-11-05 14:22   ` Peter Maydell
  0 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2024-11-05 14:22 UTC (permalink / raw)
  To: Cédric Le Goater; +Cc: qemu-arm, qemu-devel, Philippe Mathieu-Daudé

On Mon, 4 Nov 2024 at 10:39, Cédric Le Goater <clg@redhat.com> wrote:
>
> On 11/4/24 11:14, Cédric Le Goater wrote:
> > The following changes since commit 92ec7805190313c9e628f8fc4eb4f932c15247bd:
> >
> >    Merge tag 'pull-riscv-to-apply-20241031-1' of https://github.com/alistair23/qemu into staging (2024-10-31 16:34:25 +0000)
> >
> > are available in the Git repository at:
> >
> >    https://github.com/legoater/qemu/ tags/pull-aspeed-20241104
> >
> > for you to fetch changes up to 8df5fd815e841bf33fb51e1e6e5be9c31d529b94:
> >
> >    aspeed: Don't set always boot properties of the emmc device (2024-11-04 10:12:02 +0100)
> >
> > ----------------------------------------------------------------
> > aspeed queue:
> >
> > * Fixed eMMC size calculation
> > * Fixed IRQ definitions on AST2700
> > * Added RTC support to AST2700
> > * Fixed timer IRQ status on AST2600
> > * Improved SDHCI model with new registers
> > * Added -nodefaults support to AST1030
> > * Provided a way to use an eMMC device without boot partitions
> >
> > ----------------------------------------------------------------
> > Cédric Le Goater (1):
> >        aspeed: Don't set always boot properties of the emmc device
> >
> > Jamin Lin (5):
> >        aspeed/soc: Support RTC for AST2700
> >        hw/timer/aspeed: Fix coding style
> >        hw/timer/aspeed: Fix interrupt status does not be cleared for AST2600
> >        hw/sd/aspeed_sdhci: Introduce Capabilities Register 2 for SD slot 0 and 1
> >        aspeed: Support create flash devices via command line for AST1030
> >
> > Jan Luebbe (1):
> >        hw/sd/sdcard: Fix calculation of size when using eMMC boot partitions
> >
> > Patrick Leis (1):
> >        hw/arm: enable at24c with aspeed
> >
> > Peter Maydell (2):
> >        hw/arm/aspeed_ast27x0: Use bsa.h for PPI definitions
> >        hw/arm/aspeed_ast27x0: Avoid hardcoded '256' in IRQ calculation
> >
> >   hw/arm/aspeed.c         | 38 +++++++++++++++++++++++++-------------
> >   hw/arm/aspeed_ast27x0.c | 33 ++++++++++++++++++++++-----------
> >   hw/sd/aspeed_sdhci.c    | 40 +++++++++++++++++++++++++++++-----------
> >   hw/sd/sd.c              |  4 +++-
> >   hw/timer/aspeed_timer.c | 15 +++++++++------
> >   hw/arm/Kconfig          |  1 +
> >   6 files changed, 89 insertions(+), 42 deletions(-)
> >
>
> I just did an update with Philippe's trailers. No code change.


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/9.2
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-11-05 14:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-04 10:14 [PULL 00/10] aspeed queue Cédric Le Goater
2024-11-04 10:14 ` [PULL 01/10] hw/arm: enable at24c with aspeed Cédric Le Goater
2024-11-04 10:14 ` [PULL 02/10] hw/sd/sdcard: Fix calculation of size when using eMMC boot partitions Cédric Le Goater
2024-11-04 10:14 ` [PULL 03/10] hw/arm/aspeed_ast27x0: Use bsa.h for PPI definitions Cédric Le Goater
2024-11-04 10:14 ` [PULL 04/10] hw/arm/aspeed_ast27x0: Avoid hardcoded '256' in IRQ calculation Cédric Le Goater
2024-11-04 10:14 ` [PULL 05/10] aspeed/soc: Support RTC for AST2700 Cédric Le Goater
2024-11-04 10:14 ` [PULL 06/10] hw/timer/aspeed: Fix coding style Cédric Le Goater
2024-11-04 10:14 ` [PULL 07/10] hw/timer/aspeed: Fix interrupt status does not be cleared for AST2600 Cédric Le Goater
2024-11-04 10:14 ` [PULL 08/10] hw/sd/aspeed_sdhci: Introduce Capabilities Register 2 for SD slot 0 and 1 Cédric Le Goater
2024-11-04 10:15 ` [PULL 09/10] aspeed: Support create flash devices via command line for AST1030 Cédric Le Goater
2024-11-04 10:15 ` [PULL 10/10] aspeed: Don't set always boot properties of the emmc device Cédric Le Goater
2024-11-04 10:38 ` [PULL 00/10] aspeed queue Cédric Le Goater
2024-11-05 14:22   ` Peter Maydell

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).