[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/34] hw/arm/spitz: Keep pointers to MPU and SSI devices in Spitz
From: |
Peter Maydell |
Subject: |
[PULL 19/34] hw/arm/spitz: Keep pointers to MPU and SSI devices in SpitzMachineState |
Date: |
Fri, 3 Jul 2020 17:53:50 +0100 |
Keep pointers to the MPU and the SSI devices in SpitzMachineState.
We're going to want to make GPIO connections between some of the
SSI devices and the SCPs, so we want to keep hold of a pointer to
those; putting the MPU into the struct allows us to pass just
one thing to spitz_ssp_attach() rather than two.
We have to retain the setting of the global "max1111" variable
for the moment as it is used in spitz_adc_temp_on(); later in
this series of commits we will be able to remove it.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20200628142429.17111-4-peter.maydell@linaro.org
---
hw/arm/spitz.c | 50 ++++++++++++++++++++++++++++----------------------
1 file changed, 28 insertions(+), 22 deletions(-)
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index c70e912a33d..f48e966c047 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -43,6 +43,11 @@ typedef struct {
typedef struct {
MachineState parent;
+ PXA2xxState *mpu;
+ DeviceState *mux;
+ DeviceState *lcdtg;
+ DeviceState *ads7846;
+ DeviceState *max1111;
} SpitzMachineState;
#define TYPE_SPITZ_MACHINE "spitz-common"
@@ -709,34 +714,33 @@ static void corgi_ssp_realize(SSISlave *d, Error **errp)
s->bus[2] = ssi_create_bus(dev, "ssi2");
}
-static void spitz_ssp_attach(PXA2xxState *cpu)
+static void spitz_ssp_attach(SpitzMachineState *sms)
{
- DeviceState *mux;
- DeviceState *dev;
void *bus;
- mux = ssi_create_slave(cpu->ssp[CORGI_SSP_PORT - 1], "corgi-ssp");
+ sms->mux = ssi_create_slave(sms->mpu->ssp[CORGI_SSP_PORT - 1],
"corgi-ssp");
- bus = qdev_get_child_bus(mux, "ssi0");
- ssi_create_slave(bus, "spitz-lcdtg");
+ bus = qdev_get_child_bus(sms->mux, "ssi0");
+ sms->lcdtg = ssi_create_slave(bus, "spitz-lcdtg");
- bus = qdev_get_child_bus(mux, "ssi1");
- dev = ssi_create_slave(bus, "ads7846");
- qdev_connect_gpio_out(dev, 0,
- qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_TP_INT));
+ bus = qdev_get_child_bus(sms->mux, "ssi1");
+ sms->ads7846 = ssi_create_slave(bus, "ads7846");
+ qdev_connect_gpio_out(sms->ads7846, 0,
+ qdev_get_gpio_in(sms->mpu->gpio, SPITZ_GPIO_TP_INT));
- bus = qdev_get_child_bus(mux, "ssi2");
- max1111 = ssi_create_slave(bus, "max1111");
- max111x_set_input(max1111, MAX1111_BATT_VOLT, SPITZ_BATTERY_VOLT);
- max111x_set_input(max1111, MAX1111_BATT_TEMP, 0);
- max111x_set_input(max1111, MAX1111_ACIN_VOLT, SPITZ_CHARGEON_ACIN);
+ bus = qdev_get_child_bus(sms->mux, "ssi2");
+ sms->max1111 = ssi_create_slave(bus, "max1111");
+ max1111 = sms->max1111;
+ max111x_set_input(sms->max1111, MAX1111_BATT_VOLT, SPITZ_BATTERY_VOLT);
+ max111x_set_input(sms->max1111, MAX1111_BATT_TEMP, 0);
+ max111x_set_input(sms->max1111, MAX1111_ACIN_VOLT, SPITZ_CHARGEON_ACIN);
- qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_LCDCON_CS,
- qdev_get_gpio_in(mux, 0));
- qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_ADS7846_CS,
- qdev_get_gpio_in(mux, 1));
- qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_MAX1111_CS,
- qdev_get_gpio_in(mux, 2));
+ qdev_connect_gpio_out(sms->mpu->gpio, SPITZ_GPIO_LCDCON_CS,
+ qdev_get_gpio_in(sms->mux, 0));
+ qdev_connect_gpio_out(sms->mpu->gpio, SPITZ_GPIO_ADS7846_CS,
+ qdev_get_gpio_in(sms->mux, 1));
+ qdev_connect_gpio_out(sms->mpu->gpio, SPITZ_GPIO_MAX1111_CS,
+ qdev_get_gpio_in(sms->mux, 2));
}
/* CF Microdrive */
@@ -936,6 +940,7 @@ static struct arm_boot_info spitz_binfo = {
static void spitz_common_init(MachineState *machine)
{
SpitzMachineClass *smc = SPITZ_MACHINE_GET_CLASS(machine);
+ SpitzMachineState *sms = SPITZ_MACHINE(machine);
enum spitz_model_e model = smc->model;
PXA2xxState *mpu;
DeviceState *scp0, *scp1 = NULL;
@@ -945,6 +950,7 @@ static void spitz_common_init(MachineState *machine)
/* Setup CPU & memory */
mpu = pxa270_init(address_space_mem, spitz_binfo.ram_size,
machine->cpu_type);
+ sms->mpu = mpu;
sl_flash_register(mpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
@@ -954,7 +960,7 @@ static void spitz_common_init(MachineState *machine)
/* Setup peripherals */
spitz_keyboard_register(mpu);
- spitz_ssp_attach(mpu);
+ spitz_ssp_attach(sms);
scp0 = sysbus_create_simple("scoop", 0x10800000, NULL);
if (model != akita) {
--
2.20.1
- [PULL 07/34] virtio-iommu-pci: Add array of Interval properties, (continued)
- [PULL 07/34] virtio-iommu-pci: Add array of Interval properties, Peter Maydell, 2020/07/03
- [PULL 09/34] target/arm: kvm: Handle DABT with no valid ISS, Peter Maydell, 2020/07/03
- [PULL 10/34] target/arm: kvm: Handle misconfigured dabt injection, Peter Maydell, 2020/07/03
- [PULL 12/34] tests/acpi: virt: allow DSDT acpi table changes, Peter Maydell, 2020/07/03
- [PULL 13/34] hw/arm/virt-acpi-build: Only expose flash on older machine types, Peter Maydell, 2020/07/03
- [PULL 11/34] tests/acpi: remove stale allowed tables, Peter Maydell, 2020/07/03
- [PULL 14/34] tests/acpi: virt: update golden masters for DSDT, Peter Maydell, 2020/07/03
- [PULL 15/34] target/arm: Fix temp double-free in sve ldr/str, Peter Maydell, 2020/07/03
- [PULL 16/34] hw/display/bcm2835_fb.c: Initialize all fields of struct, Peter Maydell, 2020/07/03
- [PULL 17/34] hw/arm/spitz: Detabify, Peter Maydell, 2020/07/03
- [PULL 19/34] hw/arm/spitz: Keep pointers to MPU and SSI devices in SpitzMachineState,
Peter Maydell <=
- [PULL 18/34] hw/arm/spitz: Create SpitzMachineClass abstract base class, Peter Maydell, 2020/07/03
- [PULL 20/34] hw/arm/spitz: Keep pointers to scp0, scp1 in SpitzMachineState, Peter Maydell, 2020/07/03
- [PULL 21/34] hw/arm/spitz: Implement inbound GPIO lines for bit5 and power signals, Peter Maydell, 2020/07/03
- [PULL 22/34] hw/misc/max111x: provide QOM properties for setting initial values, Peter Maydell, 2020/07/03
- [PULL 23/34] hw/misc/max111x: Don't use vmstate_register(), Peter Maydell, 2020/07/03
- [PULL 24/34] ssi: Add ssi_realize_and_unref(), Peter Maydell, 2020/07/03
- [PULL 26/34] hw/misc/max111x: Use GPIO lines rather than max111x_set_input(), Peter Maydell, 2020/07/03
- [PULL 25/34] hw/arm/spitz: Use max111x properties to set initial values, Peter Maydell, 2020/07/03
- [PULL 27/34] hw/misc/max111x: Create header file for documentation, TYPE_ macros, Peter Maydell, 2020/07/03
- [PULL 28/34] hw/arm/spitz: Encapsulate misc GPIO handling in a device, Peter Maydell, 2020/07/03