[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [Qemu-devel] [RFC PATCH 3/6] sysbus: Specialize gating_up
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-arm] [Qemu-devel] [RFC PATCH 3/6] sysbus: Specialize gating_update to enable/disable memory regions |
Date: |
Fri, 27 Jul 2018 13:43:47 -0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
On 07/27/2018 11:37 AM, Damien Hedde wrote:
> The default methods are overriden to add the activation/deactivation
> of the memory regions according to the gating state: Regions are
> enabled only when powered and clocked.
> As powering-up triggers a reset call, memory regions should
> be reset in specialized sysbus devices.
>
> Signed-off-by: Damien Hedde <address@hidden>
> ---
> include/hw/sysbus.h | 3 +++
> hw/core/sysbus.c | 39 +++++++++++++++++++++++++++++++++++++++
> 2 files changed, 42 insertions(+)
>
> diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
> index 0b59a3b8d6..e17165e78f 100644
> --- a/include/hw/sysbus.h
> +++ b/include/hw/sysbus.h
> @@ -59,6 +59,9 @@ typedef struct SysBusDeviceClass {
> */
> char *(*explicit_ofw_unit_address)(const SysBusDevice *dev);
> void (*connect_irq_notifier)(SysBusDevice *dev, qemu_irq irq);
> +
> + DeviceGatingUpdate parent_power_update;
> + DeviceGatingUpdate parent_clock_update;
> } SysBusDeviceClass;
>
> struct SysBusDevice {
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index 3c8e53b188..4a2dfbe907 100644
> --- a/hw/core/sysbus.c
> +++ b/hw/core/sysbus.c
> @@ -325,6 +325,39 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev)
> return get_system_memory();
> }
>
> +/*
> + * Action take on power or clock update.
> + */
> +static void sysbus_device_gating_update(DeviceState *dev)
> +{
> + SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> + int i;
> +
> + for (i = 0;; i++) {
i < QDEV_MAX_MMIO
> + MemoryRegion *mr = sysbus_mmio_get_region(sbd, i);
> + if (!mr) {
> + break;
> + }
> + memory_region_set_enabled(mr, dev->powered && dev->clocked);
> + }
> +}
> +
> +/*
> + * Action take on power update.
> + *
> + * Call parent method before doing local action.
> + * So that we override any action taken in parent method (eg if reset
> + * is called due to leaving OFF state)
> + */
> +static void sysbus_device_power_update(DeviceState *dev)
> +{
> + SysBusDeviceClass *sbdk = SYS_BUS_DEVICE_GET_CLASS(dev);
> +
> + sbdk->parent_power_update(dev);
> +
> + sysbus_device_gating_update(dev);
> +}
> +
> static void sysbus_device_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *k = DEVICE_CLASS(klass);
> @@ -341,6 +374,12 @@ static void sysbus_device_class_init(ObjectClass *klass,
> void *data)
> * subclass needs to override it and set user_creatable=true.
> */
> k->user_creatable = false;
> +
> + SysBusDeviceClass *sbdk = SYS_BUS_DEVICE_CLASS(klass);
> + device_class_set_parent_power_update(k,
> + sysbus_device_power_update, &sbdk->parent_power_update);
> + device_class_set_parent_clock_update(k,
> + sysbus_device_gating_update, &sbdk->parent_clock_update);
> }
>
> static const TypeInfo sysbus_device_type_info = {
>
- [Qemu-arm] [RFC PATCH 0/6] Clock and power gating support, Damien Hedde, 2018/07/27
- [Qemu-arm] [RFC PATCH 1/6] qdev: add a power and clock gating support, Damien Hedde, 2018/07/27
- [Qemu-arm] [RFC PATCH 5/6] zynq_slcr: add uart clock gating and soft reset support, Damien Hedde, 2018/07/27
- [Qemu-arm] [RFC PATCH 4/6] cadence_uart: add clock/power gating support, Damien Hedde, 2018/07/27
- [Qemu-arm] [RFC PATCH 3/6] sysbus: Specialize gating_update to enable/disable memory regions, Damien Hedde, 2018/07/27
- Re: [Qemu-arm] [Qemu-devel] [RFC PATCH 3/6] sysbus: Specialize gating_update to enable/disable memory regions,
Philippe Mathieu-Daudé <=
- [Qemu-arm] [RFC PATCH 2/6] qdev: add power/clock gating control on bus tree, Damien Hedde, 2018/07/27
- [Qemu-arm] [RFC PATCH 6/6] xilinx_zynq: add uart clock gating support, Damien Hedde, 2018/07/27
- Re: [Qemu-arm] [RFC PATCH 0/6] Clock and power gating support, Peter Maydell, 2018/07/27