[PATCH] hw/i2c/bcm2835_i2c: Correct iomem size

botszhuang posted 1 patch 3 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260804144611.31735-1-huang.botsz@gmail.com
Maintainers: Peter Maydell <peter.maydell@linaro.org>, "Philippe Mathieu-Daudé" <philmd@mailo.com>
hw/i2c/bcm2835_i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] hw/i2c/bcm2835_i2c: Correct iomem size
Posted by botszhuang 3 weeks, 1 day ago
The last valid register is the Clock Stretch Timeout (CLKT) at
offset 0x1c. Since it is a 32-bit register, the total memory
region size should be 0x1c + 4 = 0x20.

Update the size parameter in memory_region_init_io() from 0x24
to 0x20 to accurately reflect the hardware specification.

Signed-off-by: botszhuang <huang.botsz@gmail.com>
---
 hw/i2c/bcm2835_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/i2c/bcm2835_i2c.c b/hw/i2c/bcm2835_i2c.c
index 34de1f36e5..5f6093087d 100644
--- a/hw/i2c/bcm2835_i2c.c
+++ b/hw/i2c/bcm2835_i2c.c
@@ -222,7 +222,7 @@ static void bcm2835_i2c_realize(DeviceState *dev, Error **errp)
     s->bus = i2c_init_bus(dev, NULL);
 
     memory_region_init_io(&s->iomem, OBJECT(dev), &bcm2835_i2c_ops, s,
-                          TYPE_BCM2835_I2C, 0x24);
+                          TYPE_BCM2835_I2C, 0x20);
     sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
     sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
 }
-- 
2.43.0
Re: [PATCH] hw/i2c/bcm2835_i2c: Correct iomem size
Posted by Peter Maydell 2 weeks, 1 day ago
On Tue, 4 Aug 2026 at 15:46, botszhuang <huang.botsz@gmail.com> wrote:
>
> The last valid register is the Clock Stretch Timeout (CLKT) at
> offset 0x1c. Since it is a 32-bit register, the total memory
> region size should be 0x1c + 4 = 0x20.
>
> Update the size parameter in memory_region_init_io() from 0x24
> to 0x20 to accurately reflect the hardware specification.
>
> Signed-off-by: botszhuang <huang.botsz@gmail.com>



Applied to target-arm.next ready for when we reopen development
for 11.2; thanks.

-- PMM
Re: [PATCH] hw/i2c/bcm2835_i2c: Correct iomem size
Posted by Philippe Mathieu-Daudé 3 weeks ago
On 4/8/26 16:46, botszhuang wrote:
> The last valid register is the Clock Stretch Timeout (CLKT) at
> offset 0x1c. Since it is a 32-bit register, the total memory
> region size should be 0x1c + 4 = 0x20.
> 
> Update the size parameter in memory_region_init_io() from 0x24
> to 0x20 to accurately reflect the hardware specification.
> 

Suggested-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>

> Signed-off-by: botszhuang <huang.botsz@gmail.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>

> ---
>   hw/i2c/bcm2835_i2c.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/i2c/bcm2835_i2c.c b/hw/i2c/bcm2835_i2c.c
> index 34de1f36e5..5f6093087d 100644
> --- a/hw/i2c/bcm2835_i2c.c
> +++ b/hw/i2c/bcm2835_i2c.c
> @@ -222,7 +222,7 @@ static void bcm2835_i2c_realize(DeviceState *dev, Error **errp)
>       s->bus = i2c_init_bus(dev, NULL);
>   
>       memory_region_init_io(&s->iomem, OBJECT(dev), &bcm2835_i2c_ops, s,
> -                          TYPE_BCM2835_I2C, 0x24);
> +                          TYPE_BCM2835_I2C, 0x20);
>       sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
>       sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
>   }