2007-04-30 06:22:06 +04:00
|
|
|
/*
|
|
|
|
* PXA270-based Clamshell PDA platforms.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006 Openedhand Ltd.
|
|
|
|
* Written by Andrzej Zaborowski <balrog@zabor.org>
|
|
|
|
*
|
|
|
|
* This code is licensed under the GNU GPL v2.
|
2012-01-13 20:44:23 +04:00
|
|
|
*
|
|
|
|
* Contributions after 2012-01-13 are licensed under the terms of the
|
|
|
|
* GNU GPL, version 2 or (at your option) any later version.
|
2007-04-30 06:22:06 +04:00
|
|
|
*/
|
|
|
|
|
2015-12-07 19:23:45 +03:00
|
|
|
#include "qemu/osdep.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 11:01:28 +03:00
|
|
|
#include "qapi/error.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/arm/pxa.h"
|
2019-05-23 16:47:43 +03:00
|
|
|
#include "hw/arm/boot.h"
|
2019-08-12 08:23:59 +03:00
|
|
|
#include "sysemu/runstate.h"
|
2012-12-17 21:20:04 +04:00
|
|
|
#include "sysemu/sysemu.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/pcmcia.h"
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/i2c/i2c.h"
|
2019-08-12 08:23:42 +03:00
|
|
|
#include "hw/irq.h"
|
2016-01-21 17:15:03 +03:00
|
|
|
#include "hw/ssi/ssi.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/block/flash.h"
|
2012-12-17 21:20:00 +04:00
|
|
|
#include "qemu/timer.h"
|
2020-07-03 18:59:45 +03:00
|
|
|
#include "qemu/log.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/arm/sharpsl.h"
|
2012-11-28 15:06:30 +04:00
|
|
|
#include "ui/console.h"
|
2017-09-19 15:30:53 +03:00
|
|
|
#include "hw/audio/wm8750.h"
|
2007-11-17 20:14:51 +03:00
|
|
|
#include "audio/audio.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/boards.h"
|
|
|
|
#include "hw/sysbus.h"
|
2021-05-18 23:54:52 +03:00
|
|
|
#include "hw/adc/max111x.h"
|
2019-08-12 08:23:45 +03:00
|
|
|
#include "migration/vmstate.h"
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/address-spaces.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2023-09-22 18:21:39 +03:00
|
|
|
#include "audio/audio.h"
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
enum spitz_model_e { spitz, akita, borzoi, terrier };
|
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct SpitzMachineClass {
|
2020-07-03 18:59:43 +03:00
|
|
|
MachineClass parent;
|
|
|
|
enum spitz_model_e model;
|
|
|
|
int arm_id;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2020-07-03 18:59:43 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct SpitzMachineState {
|
2020-07-03 18:59:43 +03:00
|
|
|
MachineState parent;
|
2020-07-03 18:59:44 +03:00
|
|
|
PXA2xxState *mpu;
|
|
|
|
DeviceState *mux;
|
|
|
|
DeviceState *lcdtg;
|
|
|
|
DeviceState *ads7846;
|
|
|
|
DeviceState *max1111;
|
2020-07-03 18:59:44 +03:00
|
|
|
DeviceState *scp0;
|
|
|
|
DeviceState *scp1;
|
2020-07-03 18:59:45 +03:00
|
|
|
DeviceState *misc_gpio;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2020-07-03 18:59:43 +03:00
|
|
|
|
|
|
|
#define TYPE_SPITZ_MACHINE "spitz-common"
|
2020-09-16 21:25:18 +03:00
|
|
|
OBJECT_DECLARE_TYPE(SpitzMachineState, SpitzMachineClass, SPITZ_MACHINE)
|
2020-07-03 18:59:43 +03:00
|
|
|
|
2020-07-03 18:59:45 +03:00
|
|
|
#define zaurus_printf(format, ...) \
|
|
|
|
fprintf(stderr, "%s: " format, __func__, ##__VA_ARGS__)
|
|
|
|
|
2007-04-30 06:22:06 +04:00
|
|
|
/* Spitz Flash */
|
2020-07-03 18:59:43 +03:00
|
|
|
#define FLASH_BASE 0x0c000000
|
|
|
|
#define FLASH_ECCLPLB 0x00 /* Line parity 7 - 0 bit */
|
|
|
|
#define FLASH_ECCLPUB 0x04 /* Line parity 15 - 8 bit */
|
|
|
|
#define FLASH_ECCCP 0x08 /* Column parity 5 - 0 bit */
|
|
|
|
#define FLASH_ECCCNTR 0x0c /* ECC byte counter */
|
|
|
|
#define FLASH_ECCCLRR 0x10 /* Clear ECC */
|
|
|
|
#define FLASH_FLASHIO 0x14 /* Flash I/O */
|
|
|
|
#define FLASH_FLASHCTL 0x18 /* Flash Control */
|
|
|
|
|
|
|
|
#define FLASHCTL_CE0 (1 << 0)
|
|
|
|
#define FLASHCTL_CLE (1 << 1)
|
|
|
|
#define FLASHCTL_ALE (1 << 2)
|
|
|
|
#define FLASHCTL_WP (1 << 3)
|
|
|
|
#define FLASHCTL_CE1 (1 << 4)
|
|
|
|
#define FLASHCTL_RYBY (1 << 5)
|
|
|
|
#define FLASHCTL_NCE (FLASHCTL_CE0 | FLASHCTL_CE1)
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2013-07-24 10:54:33 +04:00
|
|
|
#define TYPE_SL_NAND "sl-nand"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(SLNANDState, SL_NAND)
|
2013-07-24 10:54:33 +04:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct SLNANDState {
|
2013-07-24 10:54:33 +04:00
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
2011-10-03 15:03:56 +04:00
|
|
|
MemoryRegion iomem;
|
2011-07-29 19:35:24 +04:00
|
|
|
DeviceState *nand;
|
2007-04-30 06:22:06 +04:00
|
|
|
uint8_t ctl;
|
2011-01-21 13:12:11 +03:00
|
|
|
uint8_t manf_id;
|
|
|
|
uint8_t chip_id;
|
2009-05-10 04:44:56 +04:00
|
|
|
ECCState ecc;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static uint64_t sl_read(void *opaque, hwaddr addr, unsigned size)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
SLNANDState *s = (SLNANDState *) opaque;
|
2007-04-30 06:22:06 +04:00
|
|
|
int ryby;
|
|
|
|
|
|
|
|
switch (addr) {
|
2020-07-03 18:59:43 +03:00
|
|
|
#define BSHR(byte, from, to) ((s->ecc.lp[byte] >> (from - to)) & (1 << to))
|
2007-04-30 06:22:06 +04:00
|
|
|
case FLASH_ECCLPLB:
|
|
|
|
return BSHR(0, 4, 0) | BSHR(0, 5, 2) | BSHR(0, 6, 4) | BSHR(0, 7, 6) |
|
|
|
|
BSHR(1, 4, 1) | BSHR(1, 5, 3) | BSHR(1, 6, 5) | BSHR(1, 7, 7);
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define BSHL(byte, from, to) ((s->ecc.lp[byte] << (to - from)) & (1 << to))
|
2007-04-30 06:22:06 +04:00
|
|
|
case FLASH_ECCLPUB:
|
|
|
|
return BSHL(0, 0, 0) | BSHL(0, 1, 2) | BSHL(0, 2, 4) | BSHL(0, 3, 6) |
|
|
|
|
BSHL(1, 0, 1) | BSHL(1, 1, 3) | BSHL(1, 2, 5) | BSHL(1, 3, 7);
|
|
|
|
|
|
|
|
case FLASH_ECCCP:
|
|
|
|
return s->ecc.cp;
|
|
|
|
|
|
|
|
case FLASH_ECCCNTR:
|
|
|
|
return s->ecc.count & 0xff;
|
|
|
|
|
|
|
|
case FLASH_FLASHCTL:
|
|
|
|
nand_getpins(s->nand, &ryby);
|
|
|
|
if (ryby)
|
|
|
|
return s->ctl | FLASHCTL_RYBY;
|
|
|
|
else
|
|
|
|
return s->ctl;
|
|
|
|
|
|
|
|
case FLASH_FLASHIO:
|
2011-10-03 15:03:56 +04:00
|
|
|
if (size == 4) {
|
|
|
|
return ecc_digest(&s->ecc, nand_getio(s->nand)) |
|
|
|
|
(ecc_digest(&s->ecc, nand_getio(s->nand)) << 16);
|
|
|
|
}
|
2007-04-30 06:22:06 +04:00
|
|
|
return ecc_digest(&s->ecc, nand_getio(s->nand));
|
|
|
|
|
|
|
|
default:
|
2020-07-03 18:59:45 +03:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR,
|
|
|
|
"sl_read: bad register offset 0x%02" HWADDR_PRIx "\n",
|
|
|
|
addr);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static void sl_write(void *opaque, hwaddr addr,
|
2011-10-03 15:03:56 +04:00
|
|
|
uint64_t value, unsigned size)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
SLNANDState *s = (SLNANDState *) opaque;
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case FLASH_ECCCLRR:
|
|
|
|
/* Value is ignored. */
|
|
|
|
ecc_reset(&s->ecc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FLASH_FLASHCTL:
|
|
|
|
s->ctl = value & 0xff & ~FLASHCTL_RYBY;
|
|
|
|
nand_setpins(s->nand,
|
|
|
|
s->ctl & FLASHCTL_CLE,
|
|
|
|
s->ctl & FLASHCTL_ALE,
|
|
|
|
s->ctl & FLASHCTL_NCE,
|
|
|
|
s->ctl & FLASHCTL_WP,
|
|
|
|
0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FLASH_FLASHIO:
|
|
|
|
nand_setio(s->nand, ecc_digest(&s->ecc, value & 0xff));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2020-07-03 18:59:45 +03:00
|
|
|
qemu_log_mask(LOG_GUEST_ERROR,
|
|
|
|
"sl_write: bad register offset 0x%02" HWADDR_PRIx "\n",
|
|
|
|
addr);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum {
|
|
|
|
FLASH_128M,
|
|
|
|
FLASH_1024M,
|
|
|
|
};
|
|
|
|
|
2011-10-03 15:03:56 +04:00
|
|
|
static const MemoryRegionOps sl_ops = {
|
|
|
|
.read = sl_read,
|
|
|
|
.write = sl_write,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
2011-01-21 13:12:11 +03:00
|
|
|
};
|
|
|
|
|
2009-05-10 04:44:56 +04:00
|
|
|
static void sl_flash_register(PXA2xxState *cpu, int size)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2011-01-21 13:12:11 +03:00
|
|
|
DeviceState *dev;
|
|
|
|
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:31:58 +03:00
|
|
|
dev = qdev_new(TYPE_SL_NAND);
|
2011-01-21 13:12:11 +03:00
|
|
|
|
|
|
|
qdev_prop_set_uint8(dev, "manf_id", NAND_MFR_SAMSUNG);
|
|
|
|
if (size == FLASH_128M)
|
|
|
|
qdev_prop_set_uint8(dev, "chip_id", 0x73);
|
|
|
|
else if (size == FLASH_1024M)
|
|
|
|
qdev_prop_set_uint8(dev, "chip_id", 0xf1);
|
|
|
|
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
|
2013-01-20 05:47:33 +04:00
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, FLASH_BASE);
|
2011-01-21 13:12:11 +03:00
|
|
|
}
|
|
|
|
|
2016-03-07 10:52:16 +03:00
|
|
|
static void sl_nand_init(Object *obj)
|
2013-07-24 10:54:33 +04:00
|
|
|
{
|
2016-03-07 10:52:16 +03:00
|
|
|
SLNANDState *s = SL_NAND(obj);
|
|
|
|
SysBusDevice *dev = SYS_BUS_DEVICE(obj);
|
2011-01-21 13:12:11 +03:00
|
|
|
|
2007-04-30 06:22:06 +04:00
|
|
|
s->ctl = 0;
|
2018-07-23 17:21:26 +03:00
|
|
|
|
|
|
|
memory_region_init_io(&s->iomem, obj, &sl_ops, s, "sl", 0x40);
|
|
|
|
sysbus_init_mmio(dev, &s->iomem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sl_nand_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
|
|
|
SLNANDState *s = SL_NAND(dev);
|
|
|
|
DriveInfo *nand;
|
|
|
|
|
2015-03-23 21:03:13 +03:00
|
|
|
/* FIXME use a qdev drive property instead of drive_get() */
|
2011-07-29 19:35:19 +04:00
|
|
|
nand = drive_get(IF_MTD, 0, 0);
|
2014-10-07 15:59:18 +04:00
|
|
|
s->nand = nand_init(nand ? blk_by_legacy_dinfo(nand) : NULL,
|
2014-10-07 15:59:13 +04:00
|
|
|
s->manf_id, s->chip_id);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Spitz Keyboard */
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define SPITZ_KEY_STROBE_NUM 11
|
|
|
|
#define SPITZ_KEY_SENSE_NUM 7
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
static const int spitz_gpio_key_sense[SPITZ_KEY_SENSE_NUM] = {
|
|
|
|
12, 17, 91, 34, 36, 38, 39
|
|
|
|
};
|
|
|
|
|
|
|
|
static const int spitz_gpio_key_strobe[SPITZ_KEY_STROBE_NUM] = {
|
|
|
|
88, 23, 24, 25, 26, 27, 52, 103, 107, 108, 114
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Eighth additional row maps the special keys */
|
|
|
|
static int spitz_keymap[SPITZ_KEY_SENSE_NUM + 1][SPITZ_KEY_STROBE_NUM] = {
|
|
|
|
{ 0x1d, 0x02, 0x04, 0x06, 0x07, 0x08, 0x0a, 0x0b, 0x0e, 0x3f, 0x40 },
|
|
|
|
{ -1 , 0x03, 0x05, 0x13, 0x15, 0x09, 0x17, 0x18, 0x19, 0x41, 0x42 },
|
|
|
|
{ 0x0f, 0x10, 0x12, 0x14, 0x22, 0x16, 0x24, 0x25, -1 , -1 , -1 },
|
|
|
|
{ 0x3c, 0x11, 0x1f, 0x21, 0x2f, 0x23, 0x32, 0x26, -1 , 0x36, -1 },
|
|
|
|
{ 0x3b, 0x1e, 0x20, 0x2e, 0x30, 0x31, 0x34, -1 , 0x1c, 0x2a, -1 },
|
2007-10-04 23:41:17 +04:00
|
|
|
{ 0x44, 0x2c, 0x2d, 0x0c, 0x39, 0x33, -1 , 0x48, -1 , -1 , 0x38 },
|
|
|
|
{ 0x37, 0x3d, -1 , 0x45, 0x57, 0x58, 0x4b, 0x50, 0x4d, -1 , -1 },
|
2007-04-30 06:22:06 +04:00
|
|
|
{ 0x52, 0x43, 0x01, 0x47, 0x49, -1 , -1 , -1 , -1 , -1 , -1 },
|
|
|
|
};
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define SPITZ_GPIO_AK_INT 13 /* Remote control */
|
|
|
|
#define SPITZ_GPIO_SYNC 16 /* Sync button */
|
|
|
|
#define SPITZ_GPIO_ON_KEY 95 /* Power button */
|
|
|
|
#define SPITZ_GPIO_SWA 97 /* Lid */
|
|
|
|
#define SPITZ_GPIO_SWB 96 /* Tablet mode */
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
/* The special buttons are mapped to unused keys */
|
|
|
|
static const int spitz_gpiomap[5] = {
|
|
|
|
SPITZ_GPIO_AK_INT, SPITZ_GPIO_SYNC, SPITZ_GPIO_ON_KEY,
|
|
|
|
SPITZ_GPIO_SWA, SPITZ_GPIO_SWB,
|
|
|
|
};
|
|
|
|
|
2013-07-24 10:58:32 +04:00
|
|
|
#define TYPE_SPITZ_KEYBOARD "spitz-keyboard"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(SpitzKeyboardState, SPITZ_KEYBOARD)
|
2013-07-24 10:58:32 +04:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct SpitzKeyboardState {
|
2013-07-24 10:58:32 +04:00
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
2007-11-17 17:07:13 +03:00
|
|
|
qemu_irq sense[SPITZ_KEY_SENSE_NUM];
|
|
|
|
qemu_irq gpiomap[5];
|
2007-04-30 06:22:06 +04:00
|
|
|
int keymap[0x80];
|
|
|
|
uint16_t keyrow[SPITZ_KEY_SENSE_NUM];
|
|
|
|
uint16_t strobe_state;
|
|
|
|
uint16_t sense_state;
|
|
|
|
|
|
|
|
uint16_t pre_map[0x100];
|
|
|
|
uint16_t modifiers;
|
|
|
|
uint16_t imodifiers;
|
|
|
|
uint8_t fifo[16];
|
|
|
|
int fifopos, fifolen;
|
|
|
|
QEMUTimer *kbdtimer;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2009-05-10 04:44:56 +04:00
|
|
|
static void spitz_keyboard_sense_update(SpitzKeyboardState *s)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
uint16_t strobe, sense = 0;
|
|
|
|
for (i = 0; i < SPITZ_KEY_SENSE_NUM; i ++) {
|
|
|
|
strobe = s->keyrow[i] & s->strobe_state;
|
|
|
|
if (strobe) {
|
|
|
|
sense |= 1 << i;
|
|
|
|
if (!(s->sense_state & (1 << i)))
|
2007-11-17 17:07:13 +03:00
|
|
|
qemu_irq_raise(s->sense[i]);
|
2007-04-30 06:22:06 +04:00
|
|
|
} else if (s->sense_state & (1 << i))
|
2007-11-17 17:07:13 +03:00
|
|
|
qemu_irq_lower(s->sense[i]);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
s->sense_state = sense;
|
|
|
|
}
|
|
|
|
|
2007-11-17 17:07:13 +03:00
|
|
|
static void spitz_keyboard_strobe(void *opaque, int line, int level)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
SpitzKeyboardState *s = (SpitzKeyboardState *) opaque;
|
2007-11-17 17:07:13 +03:00
|
|
|
|
|
|
|
if (level)
|
|
|
|
s->strobe_state |= 1 << line;
|
|
|
|
else
|
|
|
|
s->strobe_state &= ~(1 << line);
|
|
|
|
spitz_keyboard_sense_update(s);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2009-05-10 04:44:56 +04:00
|
|
|
static void spitz_keyboard_keydown(SpitzKeyboardState *s, int keycode)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
|
|
|
int spitz_keycode = s->keymap[keycode & 0x7f];
|
|
|
|
if (spitz_keycode == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Handle the additional keys */
|
|
|
|
if ((spitz_keycode >> 4) == SPITZ_KEY_SENSE_NUM) {
|
2011-01-21 19:56:10 +03:00
|
|
|
qemu_set_irq(s->gpiomap[spitz_keycode & 0xf], (keycode < 0x80));
|
2007-04-30 06:22:06 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (keycode & 0x80)
|
|
|
|
s->keyrow[spitz_keycode >> 4] &= ~(1 << (spitz_keycode & 0xf));
|
|
|
|
else
|
|
|
|
s->keyrow[spitz_keycode >> 4] |= 1 << (spitz_keycode & 0xf);
|
|
|
|
|
|
|
|
spitz_keyboard_sense_update(s);
|
|
|
|
}
|
|
|
|
|
2014-06-19 21:06:24 +04:00
|
|
|
#define SPITZ_MOD_SHIFT (1 << 7)
|
|
|
|
#define SPITZ_MOD_CTRL (1 << 8)
|
|
|
|
#define SPITZ_MOD_FN (1 << 9)
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define QUEUE_KEY(c) s->fifo[(s->fifopos + s->fifolen ++) & 0xf] = c
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2011-01-21 19:56:10 +03:00
|
|
|
static void spitz_keyboard_handler(void *opaque, int keycode)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2011-01-21 19:56:10 +03:00
|
|
|
SpitzKeyboardState *s = opaque;
|
2007-04-30 06:22:06 +04:00
|
|
|
uint16_t code;
|
|
|
|
int mapcode;
|
|
|
|
switch (keycode) {
|
2020-07-03 18:59:43 +03:00
|
|
|
case 0x2a: /* Left Shift */
|
2007-04-30 06:22:06 +04:00
|
|
|
s->modifiers |= 1;
|
|
|
|
break;
|
|
|
|
case 0xaa:
|
|
|
|
s->modifiers &= ~1;
|
|
|
|
break;
|
2020-07-03 18:59:43 +03:00
|
|
|
case 0x36: /* Right Shift */
|
2007-04-30 06:22:06 +04:00
|
|
|
s->modifiers |= 2;
|
|
|
|
break;
|
|
|
|
case 0xb6:
|
|
|
|
s->modifiers &= ~2;
|
|
|
|
break;
|
2020-07-03 18:59:43 +03:00
|
|
|
case 0x1d: /* Control */
|
2007-04-30 06:22:06 +04:00
|
|
|
s->modifiers |= 4;
|
|
|
|
break;
|
|
|
|
case 0x9d:
|
|
|
|
s->modifiers &= ~4;
|
|
|
|
break;
|
2020-07-03 18:59:43 +03:00
|
|
|
case 0x38: /* Alt */
|
2007-04-30 06:22:06 +04:00
|
|
|
s->modifiers |= 8;
|
|
|
|
break;
|
|
|
|
case 0xb8:
|
|
|
|
s->modifiers &= ~8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
code = s->pre_map[mapcode = ((s->modifiers & 3) ?
|
2014-06-19 21:06:24 +04:00
|
|
|
(keycode | SPITZ_MOD_SHIFT) :
|
|
|
|
(keycode & ~SPITZ_MOD_SHIFT))];
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
if (code != mapcode) {
|
|
|
|
#if 0
|
2014-06-19 21:06:24 +04:00
|
|
|
if ((code & SPITZ_MOD_SHIFT) && !(s->modifiers & 1)) {
|
2007-04-30 06:22:06 +04:00
|
|
|
QUEUE_KEY(0x2a | (keycode & 0x80));
|
2014-06-19 21:06:24 +04:00
|
|
|
}
|
|
|
|
if ((code & SPITZ_MOD_CTRL) && !(s->modifiers & 4)) {
|
2007-04-30 06:22:06 +04:00
|
|
|
QUEUE_KEY(0x1d | (keycode & 0x80));
|
2014-06-19 21:06:24 +04:00
|
|
|
}
|
|
|
|
if ((code & SPITZ_MOD_FN) && !(s->modifiers & 8)) {
|
2007-04-30 06:22:06 +04:00
|
|
|
QUEUE_KEY(0x38 | (keycode & 0x80));
|
2014-06-19 21:06:24 +04:00
|
|
|
}
|
|
|
|
if ((code & SPITZ_MOD_FN) && (s->modifiers & 1)) {
|
2007-04-30 06:22:06 +04:00
|
|
|
QUEUE_KEY(0x2a | (~keycode & 0x80));
|
2014-06-19 21:06:24 +04:00
|
|
|
}
|
|
|
|
if ((code & SPITZ_MOD_FN) && (s->modifiers & 2)) {
|
2007-04-30 06:22:06 +04:00
|
|
|
QUEUE_KEY(0x36 | (~keycode & 0x80));
|
2014-06-19 21:06:24 +04:00
|
|
|
}
|
2007-04-30 06:22:06 +04:00
|
|
|
#else
|
|
|
|
if (keycode & 0x80) {
|
|
|
|
if ((s->imodifiers & 1 ) && !(s->modifiers & 1))
|
|
|
|
QUEUE_KEY(0x2a | 0x80);
|
|
|
|
if ((s->imodifiers & 4 ) && !(s->modifiers & 4))
|
|
|
|
QUEUE_KEY(0x1d | 0x80);
|
|
|
|
if ((s->imodifiers & 8 ) && !(s->modifiers & 8))
|
|
|
|
QUEUE_KEY(0x38 | 0x80);
|
|
|
|
if ((s->imodifiers & 0x10) && (s->modifiers & 1))
|
|
|
|
QUEUE_KEY(0x2a);
|
|
|
|
if ((s->imodifiers & 0x20) && (s->modifiers & 2))
|
|
|
|
QUEUE_KEY(0x36);
|
|
|
|
s->imodifiers = 0;
|
|
|
|
} else {
|
2014-06-19 21:06:24 +04:00
|
|
|
if ((code & SPITZ_MOD_SHIFT) &&
|
|
|
|
!((s->modifiers | s->imodifiers) & 1)) {
|
2007-04-30 06:22:06 +04:00
|
|
|
QUEUE_KEY(0x2a);
|
|
|
|
s->imodifiers |= 1;
|
|
|
|
}
|
2014-06-19 21:06:24 +04:00
|
|
|
if ((code & SPITZ_MOD_CTRL) &&
|
|
|
|
!((s->modifiers | s->imodifiers) & 4)) {
|
2007-04-30 06:22:06 +04:00
|
|
|
QUEUE_KEY(0x1d);
|
|
|
|
s->imodifiers |= 4;
|
|
|
|
}
|
2014-06-19 21:06:24 +04:00
|
|
|
if ((code & SPITZ_MOD_FN) &&
|
|
|
|
!((s->modifiers | s->imodifiers) & 8)) {
|
2007-04-30 06:22:06 +04:00
|
|
|
QUEUE_KEY(0x38);
|
|
|
|
s->imodifiers |= 8;
|
|
|
|
}
|
2014-06-19 21:06:24 +04:00
|
|
|
if ((code & SPITZ_MOD_FN) && (s->modifiers & 1) &&
|
2007-04-30 06:22:06 +04:00
|
|
|
!(s->imodifiers & 0x10)) {
|
|
|
|
QUEUE_KEY(0x2a | 0x80);
|
|
|
|
s->imodifiers |= 0x10;
|
|
|
|
}
|
2014-06-19 21:06:24 +04:00
|
|
|
if ((code & SPITZ_MOD_FN) && (s->modifiers & 2) &&
|
2007-04-30 06:22:06 +04:00
|
|
|
!(s->imodifiers & 0x20)) {
|
|
|
|
QUEUE_KEY(0x36 | 0x80);
|
|
|
|
s->imodifiers |= 0x20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
QUEUE_KEY((code & 0x7f) | (keycode & 0x80));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spitz_keyboard_tick(void *opaque)
|
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
SpitzKeyboardState *s = (SpitzKeyboardState *) opaque;
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
if (s->fifolen) {
|
|
|
|
spitz_keyboard_keydown(s, s->fifo[s->fifopos ++]);
|
|
|
|
s->fifolen --;
|
|
|
|
if (s->fifopos >= 16)
|
|
|
|
s->fifopos = 0;
|
|
|
|
}
|
|
|
|
|
2013-08-21 19:03:08 +04:00
|
|
|
timer_mod(s->kbdtimer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
|
2016-03-21 19:02:30 +03:00
|
|
|
NANOSECONDS_PER_SECOND / 32);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2009-05-10 04:44:56 +04:00
|
|
|
static void spitz_keyboard_pre_map(SpitzKeyboardState *s)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 0x100; i ++)
|
|
|
|
s->pre_map[i] = i;
|
2014-06-19 21:06:24 +04:00
|
|
|
s->pre_map[0x02 | SPITZ_MOD_SHIFT] = 0x02 | SPITZ_MOD_SHIFT; /* exclam */
|
|
|
|
s->pre_map[0x28 | SPITZ_MOD_SHIFT] = 0x03 | SPITZ_MOD_SHIFT; /* quotedbl */
|
|
|
|
s->pre_map[0x04 | SPITZ_MOD_SHIFT] = 0x04 | SPITZ_MOD_SHIFT; /* # */
|
|
|
|
s->pre_map[0x05 | SPITZ_MOD_SHIFT] = 0x05 | SPITZ_MOD_SHIFT; /* dollar */
|
|
|
|
s->pre_map[0x06 | SPITZ_MOD_SHIFT] = 0x06 | SPITZ_MOD_SHIFT; /* percent */
|
|
|
|
s->pre_map[0x08 | SPITZ_MOD_SHIFT] = 0x07 | SPITZ_MOD_SHIFT; /* ampersand */
|
|
|
|
s->pre_map[0x28] = 0x08 | SPITZ_MOD_SHIFT; /* ' */
|
|
|
|
s->pre_map[0x0a | SPITZ_MOD_SHIFT] = 0x09 | SPITZ_MOD_SHIFT; /* ( */
|
|
|
|
s->pre_map[0x0b | SPITZ_MOD_SHIFT] = 0x0a | SPITZ_MOD_SHIFT; /* ) */
|
|
|
|
s->pre_map[0x29 | SPITZ_MOD_SHIFT] = 0x0b | SPITZ_MOD_SHIFT; /* tilde */
|
|
|
|
s->pre_map[0x03 | SPITZ_MOD_SHIFT] = 0x0c | SPITZ_MOD_SHIFT; /* at */
|
|
|
|
s->pre_map[0xd3] = 0x0e | SPITZ_MOD_FN; /* Delete */
|
|
|
|
s->pre_map[0x3a] = 0x0f | SPITZ_MOD_FN; /* Caps_Lock */
|
|
|
|
s->pre_map[0x07 | SPITZ_MOD_SHIFT] = 0x11 | SPITZ_MOD_FN; /* ^ */
|
|
|
|
s->pre_map[0x0d] = 0x12 | SPITZ_MOD_FN; /* equal */
|
|
|
|
s->pre_map[0x0d | SPITZ_MOD_SHIFT] = 0x13 | SPITZ_MOD_FN; /* plus */
|
|
|
|
s->pre_map[0x1a] = 0x14 | SPITZ_MOD_FN; /* [ */
|
|
|
|
s->pre_map[0x1b] = 0x15 | SPITZ_MOD_FN; /* ] */
|
|
|
|
s->pre_map[0x1a | SPITZ_MOD_SHIFT] = 0x16 | SPITZ_MOD_FN; /* { */
|
|
|
|
s->pre_map[0x1b | SPITZ_MOD_SHIFT] = 0x17 | SPITZ_MOD_FN; /* } */
|
|
|
|
s->pre_map[0x27] = 0x22 | SPITZ_MOD_FN; /* semicolon */
|
|
|
|
s->pre_map[0x27 | SPITZ_MOD_SHIFT] = 0x23 | SPITZ_MOD_FN; /* colon */
|
|
|
|
s->pre_map[0x09 | SPITZ_MOD_SHIFT] = 0x24 | SPITZ_MOD_FN; /* asterisk */
|
|
|
|
s->pre_map[0x2b] = 0x25 | SPITZ_MOD_FN; /* backslash */
|
|
|
|
s->pre_map[0x2b | SPITZ_MOD_SHIFT] = 0x26 | SPITZ_MOD_FN; /* bar */
|
|
|
|
s->pre_map[0x0c | SPITZ_MOD_SHIFT] = 0x30 | SPITZ_MOD_FN; /* _ */
|
|
|
|
s->pre_map[0x33 | SPITZ_MOD_SHIFT] = 0x33 | SPITZ_MOD_FN; /* less */
|
|
|
|
s->pre_map[0x35] = 0x33 | SPITZ_MOD_SHIFT; /* slash */
|
|
|
|
s->pre_map[0x34 | SPITZ_MOD_SHIFT] = 0x34 | SPITZ_MOD_FN; /* greater */
|
|
|
|
s->pre_map[0x35 | SPITZ_MOD_SHIFT] = 0x34 | SPITZ_MOD_SHIFT; /* question */
|
|
|
|
s->pre_map[0x49] = 0x48 | SPITZ_MOD_FN; /* Page_Up */
|
|
|
|
s->pre_map[0x51] = 0x50 | SPITZ_MOD_FN; /* Page_Down */
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
s->modifiers = 0;
|
|
|
|
s->imodifiers = 0;
|
|
|
|
s->fifopos = 0;
|
|
|
|
s->fifolen = 0;
|
|
|
|
}
|
|
|
|
|
2014-06-19 21:06:24 +04:00
|
|
|
#undef SPITZ_MOD_SHIFT
|
|
|
|
#undef SPITZ_MOD_CTRL
|
|
|
|
#undef SPITZ_MOD_FN
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2011-01-21 19:56:10 +03:00
|
|
|
static int spitz_keyboard_post_load(void *opaque, int version_id)
|
2007-05-24 22:50:09 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
SpitzKeyboardState *s = (SpitzKeyboardState *) opaque;
|
2007-05-24 22:50:09 +04:00
|
|
|
|
|
|
|
/* Release all pressed keys */
|
|
|
|
memset(s->keyrow, 0, sizeof(s->keyrow));
|
|
|
|
spitz_keyboard_sense_update(s);
|
|
|
|
s->modifiers = 0;
|
|
|
|
s->imodifiers = 0;
|
|
|
|
s->fifopos = 0;
|
|
|
|
s->fifolen = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-10 04:44:56 +04:00
|
|
|
static void spitz_keyboard_register(PXA2xxState *cpu)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2011-01-21 19:56:10 +03:00
|
|
|
int i;
|
|
|
|
DeviceState *dev;
|
2009-05-10 04:44:56 +04:00
|
|
|
SpitzKeyboardState *s;
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2013-07-24 10:58:32 +04:00
|
|
|
dev = sysbus_create_simple(TYPE_SPITZ_KEYBOARD, -1, NULL);
|
|
|
|
s = SPITZ_KEYBOARD(dev);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2007-11-17 17:07:13 +03:00
|
|
|
for (i = 0; i < SPITZ_KEY_SENSE_NUM; i ++)
|
2011-01-21 19:57:50 +03:00
|
|
|
qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(cpu->gpio, spitz_gpio_key_sense[i]));
|
2007-11-17 17:07:13 +03:00
|
|
|
|
|
|
|
for (i = 0; i < 5; i ++)
|
2011-01-21 19:57:50 +03:00
|
|
|
s->gpiomap[i] = qdev_get_gpio_in(cpu->gpio, spitz_gpiomap[i]);
|
2007-11-17 17:07:13 +03:00
|
|
|
|
2011-01-21 19:56:10 +03:00
|
|
|
if (!graphic_rotate)
|
|
|
|
s->gpiomap[4] = qemu_irq_invert(s->gpiomap[4]);
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
qemu_set_irq(s->gpiomap[i], 0);
|
|
|
|
|
2007-04-30 06:22:06 +04:00
|
|
|
for (i = 0; i < SPITZ_KEY_STROBE_NUM; i ++)
|
2011-01-21 19:57:50 +03:00
|
|
|
qdev_connect_gpio_out(cpu->gpio, spitz_gpio_key_strobe[i],
|
2011-01-21 19:56:10 +03:00
|
|
|
qdev_get_gpio_in(dev, i));
|
|
|
|
|
2013-08-21 19:03:08 +04:00
|
|
|
timer_mod(s->kbdtimer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
|
2011-01-21 19:56:10 +03:00
|
|
|
|
|
|
|
qemu_add_kbd_event_handler(spitz_keyboard_handler, s);
|
|
|
|
}
|
|
|
|
|
2016-03-07 10:52:16 +03:00
|
|
|
static void spitz_keyboard_init(Object *obj)
|
2011-01-21 19:56:10 +03:00
|
|
|
{
|
2016-03-07 10:52:16 +03:00
|
|
|
DeviceState *dev = DEVICE(obj);
|
|
|
|
SpitzKeyboardState *s = SPITZ_KEYBOARD(obj);
|
2011-01-21 19:56:10 +03:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < 0x80; i ++)
|
|
|
|
s->keymap[i] = -1;
|
|
|
|
for (i = 0; i < SPITZ_KEY_SENSE_NUM + 1; i ++)
|
|
|
|
for (j = 0; j < SPITZ_KEY_STROBE_NUM; j ++)
|
|
|
|
if (spitz_keymap[i][j] != -1)
|
|
|
|
s->keymap[spitz_keymap[i][j]] = (i << 4) | j;
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
spitz_keyboard_pre_map(s);
|
2007-05-24 22:50:09 +04:00
|
|
|
|
2013-07-24 10:58:32 +04:00
|
|
|
qdev_init_gpio_in(dev, spitz_keyboard_strobe, SPITZ_KEY_STROBE_NUM);
|
|
|
|
qdev_init_gpio_out(dev, s->sense, SPITZ_KEY_SENSE_NUM);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2020-03-05 19:09:16 +03:00
|
|
|
static void spitz_keyboard_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
|
|
|
SpitzKeyboardState *s = SPITZ_KEYBOARD(dev);
|
|
|
|
s->kbdtimer = timer_new_ns(QEMU_CLOCK_VIRTUAL, spitz_keyboard_tick, s);
|
|
|
|
}
|
|
|
|
|
2007-04-30 06:22:06 +04:00
|
|
|
/* LCD backlight controller */
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define LCDTG_RESCTL 0x00
|
|
|
|
#define LCDTG_PHACTRL 0x01
|
|
|
|
#define LCDTG_DUTYCTRL 0x02
|
|
|
|
#define LCDTG_POWERREG0 0x03
|
|
|
|
#define LCDTG_POWERREG1 0x04
|
|
|
|
#define LCDTG_GPOR3 0x05
|
|
|
|
#define LCDTG_PICTRL 0x06
|
|
|
|
#define LCDTG_POLCTRL 0x07
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:46 +03:00
|
|
|
#define TYPE_SPITZ_LCDTG "spitz-lcdtg"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(SpitzLCDTG, SPITZ_LCDTG)
|
2020-07-03 18:59:46 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct SpitzLCDTG {
|
2020-10-12 15:49:55 +03:00
|
|
|
SSIPeripheral ssidev;
|
2011-01-20 18:52:28 +03:00
|
|
|
uint32_t bl_intensity;
|
|
|
|
uint32_t bl_power;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2009-05-15 01:35:09 +04:00
|
|
|
static void spitz_bl_update(SpitzLCDTG *s)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2009-05-15 01:35:09 +04:00
|
|
|
if (s->bl_power && s->bl_intensity)
|
2020-11-02 12:55:23 +03:00
|
|
|
zaurus_printf("LCD Backlight now at %u/63\n", s->bl_intensity);
|
2007-04-30 06:22:06 +04:00
|
|
|
else
|
2008-06-02 05:33:11 +04:00
|
|
|
zaurus_printf("LCD Backlight now off\n");
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2007-11-17 17:07:13 +03:00
|
|
|
static inline void spitz_bl_bit5(void *opaque, int line, int level)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2020-07-03 18:59:44 +03:00
|
|
|
SpitzLCDTG *s = opaque;
|
2009-05-15 01:35:09 +04:00
|
|
|
int prev = s->bl_intensity;
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
if (level)
|
2009-05-15 01:35:09 +04:00
|
|
|
s->bl_intensity &= ~0x20;
|
2007-04-30 06:22:06 +04:00
|
|
|
else
|
2009-05-15 01:35:09 +04:00
|
|
|
s->bl_intensity |= 0x20;
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2009-05-15 01:35:09 +04:00
|
|
|
if (s->bl_power && prev != s->bl_intensity)
|
|
|
|
spitz_bl_update(s);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2007-11-17 17:07:13 +03:00
|
|
|
static inline void spitz_bl_power(void *opaque, int line, int level)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2020-07-03 18:59:44 +03:00
|
|
|
SpitzLCDTG *s = opaque;
|
2009-05-15 01:35:09 +04:00
|
|
|
s->bl_power = !!level;
|
|
|
|
spitz_bl_update(s);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2020-10-12 15:49:55 +03:00
|
|
|
static uint32_t spitz_lcdtg_transfer(SSIPeripheral *dev, uint32_t value)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2020-07-03 18:59:46 +03:00
|
|
|
SpitzLCDTG *s = SPITZ_LCDTG(dev);
|
2009-05-15 01:35:09 +04:00
|
|
|
int addr;
|
|
|
|
addr = value >> 5;
|
|
|
|
value &= 0x1f;
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
switch (addr) {
|
|
|
|
case LCDTG_RESCTL:
|
|
|
|
if (value)
|
2008-06-02 05:33:11 +04:00
|
|
|
zaurus_printf("LCD in QVGA mode\n");
|
2007-04-30 06:22:06 +04:00
|
|
|
else
|
2008-06-02 05:33:11 +04:00
|
|
|
zaurus_printf("LCD in VGA mode\n");
|
2007-04-30 06:22:06 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LCDTG_DUTYCTRL:
|
2009-05-15 01:35:09 +04:00
|
|
|
s->bl_intensity &= ~0x1f;
|
|
|
|
s->bl_intensity |= value;
|
|
|
|
if (s->bl_power)
|
|
|
|
spitz_bl_update(s);
|
2007-04-30 06:22:06 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LCDTG_POWERREG0:
|
|
|
|
/* Set common voltage to M62332FP */
|
|
|
|
break;
|
|
|
|
}
|
2009-05-15 01:35:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-10-12 15:49:55 +03:00
|
|
|
static void spitz_lcdtg_realize(SSIPeripheral *ssi, Error **errp)
|
2009-05-15 01:35:09 +04:00
|
|
|
{
|
2020-07-03 18:59:46 +03:00
|
|
|
SpitzLCDTG *s = SPITZ_LCDTG(ssi);
|
2020-07-03 18:59:44 +03:00
|
|
|
DeviceState *dev = DEVICE(s);
|
2009-05-15 01:35:09 +04:00
|
|
|
|
|
|
|
s->bl_power = 0;
|
|
|
|
s->bl_intensity = 0x20;
|
2020-07-03 18:59:44 +03:00
|
|
|
|
|
|
|
qdev_init_gpio_in_named(dev, spitz_bl_bit5, "bl_bit5", 1);
|
|
|
|
qdev_init_gpio_in_named(dev, spitz_bl_power, "bl_power", 1);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SSP devices */
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define CORGI_SSP_PORT 2
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define SPITZ_GPIO_LCDCON_CS 53
|
|
|
|
#define SPITZ_GPIO_ADS7846_CS 14
|
|
|
|
#define SPITZ_GPIO_MAX1111_CS 20
|
|
|
|
#define SPITZ_GPIO_TP_INT 11
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:46 +03:00
|
|
|
#define TYPE_CORGI_SSP "corgi-ssp"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(CorgiSSPState, CORGI_SSP)
|
2020-07-03 18:59:46 +03:00
|
|
|
|
2007-04-30 06:22:06 +04:00
|
|
|
/* "Demux" the signal based on current chipselect */
|
2020-09-03 23:43:22 +03:00
|
|
|
struct CorgiSSPState {
|
2020-10-12 15:49:55 +03:00
|
|
|
SSIPeripheral ssidev;
|
2009-05-15 01:35:09 +04:00
|
|
|
SSIBus *bus[3];
|
2011-01-20 18:52:28 +03:00
|
|
|
uint32_t enable[3];
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-10-12 15:49:55 +03:00
|
|
|
static uint32_t corgi_ssp_transfer(SSIPeripheral *dev, uint32_t value)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2020-07-03 18:59:46 +03:00
|
|
|
CorgiSSPState *s = CORGI_SSP(dev);
|
2009-05-15 01:35:09 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if (s->enable[i]) {
|
|
|
|
return ssi_transfer(s->bus[i], value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2007-11-17 17:07:13 +03:00
|
|
|
static void corgi_ssp_gpio_cs(void *opaque, int line, int level)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2009-05-15 01:35:09 +04:00
|
|
|
CorgiSSPState *s = (CorgiSSPState *)opaque;
|
|
|
|
assert(line >= 0 && line < 3);
|
|
|
|
s->enable[line] = !level;
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define MAX1111_BATT_VOLT 1
|
|
|
|
#define MAX1111_BATT_TEMP 2
|
|
|
|
#define MAX1111_ACIN_VOLT 3
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define SPITZ_BATTERY_TEMP 0xe0 /* About 2.9V */
|
|
|
|
#define SPITZ_BATTERY_VOLT 0xd0 /* About 4.0V */
|
|
|
|
#define SPITZ_CHARGEON_ACIN 0x80 /* About 5.0V */
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-10-12 15:49:55 +03:00
|
|
|
static void corgi_ssp_realize(SSIPeripheral *d, Error **errp)
|
2009-05-15 01:35:09 +04:00
|
|
|
{
|
2014-02-12 04:27:50 +04:00
|
|
|
DeviceState *dev = DEVICE(d);
|
2020-07-03 18:59:46 +03:00
|
|
|
CorgiSSPState *s = CORGI_SSP(d);
|
2009-05-15 01:35:09 +04:00
|
|
|
|
2014-02-12 04:27:50 +04:00
|
|
|
qdev_init_gpio_in(dev, corgi_ssp_gpio_cs, 3);
|
|
|
|
s->bus[0] = ssi_create_bus(dev, "ssi0");
|
|
|
|
s->bus[1] = ssi_create_bus(dev, "ssi1");
|
|
|
|
s->bus[2] = ssi_create_bus(dev, "ssi2");
|
2009-05-15 01:35:09 +04:00
|
|
|
}
|
|
|
|
|
2020-07-03 18:59:44 +03:00
|
|
|
static void spitz_ssp_attach(SpitzMachineState *sms)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2009-05-15 01:35:09 +04:00
|
|
|
void *bus;
|
|
|
|
|
2020-10-12 15:49:55 +03:00
|
|
|
sms->mux = ssi_create_peripheral(sms->mpu->ssp[CORGI_SSP_PORT - 1],
|
|
|
|
TYPE_CORGI_SSP);
|
2007-11-17 17:07:13 +03:00
|
|
|
|
2020-07-03 18:59:44 +03:00
|
|
|
bus = qdev_get_child_bus(sms->mux, "ssi0");
|
2020-10-12 15:49:55 +03:00
|
|
|
sms->lcdtg = ssi_create_peripheral(bus, TYPE_SPITZ_LCDTG);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:44 +03:00
|
|
|
bus = qdev_get_child_bus(sms->mux, "ssi1");
|
2020-10-12 15:49:55 +03:00
|
|
|
sms->ads7846 = ssi_create_peripheral(bus, "ads7846");
|
2020-07-03 18:59:44 +03:00
|
|
|
qdev_connect_gpio_out(sms->ads7846, 0,
|
|
|
|
qdev_get_gpio_in(sms->mpu->gpio, SPITZ_GPIO_TP_INT));
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:44 +03:00
|
|
|
bus = qdev_get_child_bus(sms->mux, "ssi2");
|
2020-07-03 18:59:45 +03:00
|
|
|
sms->max1111 = qdev_new(TYPE_MAX_1111);
|
2020-07-03 18:59:44 +03:00
|
|
|
qdev_prop_set_uint8(sms->max1111, "input1" /* BATT_VOLT */,
|
|
|
|
SPITZ_BATTERY_VOLT);
|
|
|
|
qdev_prop_set_uint8(sms->max1111, "input2" /* BATT_TEMP */, 0);
|
|
|
|
qdev_prop_set_uint8(sms->max1111, "input3" /* ACIN_VOLT */,
|
|
|
|
SPITZ_CHARGEON_ACIN);
|
|
|
|
ssi_realize_and_unref(sms->max1111, bus, &error_fatal);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:44 +03:00
|
|
|
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));
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* CF Microdrive */
|
|
|
|
|
2009-05-10 04:44:56 +04:00
|
|
|
static void spitz_microdrive_attach(PXA2xxState *cpu, int slot)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PCMCIACardState *md;
|
2009-07-22 18:42:57 +04:00
|
|
|
DriveInfo *dinfo;
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2009-07-22 18:42:57 +04:00
|
|
|
dinfo = drive_get(IF_IDE, 0, 0);
|
2011-08-03 17:08:13 +04:00
|
|
|
if (!dinfo || dinfo->media_cd)
|
2007-12-02 07:51:10 +03:00
|
|
|
return;
|
2011-08-03 17:08:13 +04:00
|
|
|
md = dscm1xxxx_init(dinfo);
|
|
|
|
pxa2xx_pcmcia_attach(cpu->pcmcia[slot], md);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2007-05-24 02:04:23 +04:00
|
|
|
/* Wm8750 and Max7310 on I2C */
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define AKITA_MAX_ADDR 0x18
|
|
|
|
#define SPITZ_WM_ADDRL 0x1b
|
|
|
|
#define SPITZ_WM_ADDRH 0x1a
|
2007-05-24 02:04:23 +04:00
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define SPITZ_GPIO_WM 5
|
2007-05-24 02:04:23 +04:00
|
|
|
|
2007-11-17 17:07:13 +03:00
|
|
|
static void spitz_wm8750_addr(void *opaque, int line, int level)
|
2007-05-24 02:04:23 +04:00
|
|
|
{
|
2011-12-05 06:28:27 +04:00
|
|
|
I2CSlave *wm = (I2CSlave *) opaque;
|
2007-05-24 02:04:23 +04:00
|
|
|
if (level)
|
2021-06-17 14:53:31 +03:00
|
|
|
i2c_slave_set_address(wm, SPITZ_WM_ADDRH);
|
2007-05-24 02:04:23 +04:00
|
|
|
else
|
2021-06-17 14:53:31 +03:00
|
|
|
i2c_slave_set_address(wm, SPITZ_WM_ADDRL);
|
2007-05-24 02:04:23 +04:00
|
|
|
}
|
|
|
|
|
2023-09-22 18:21:39 +03:00
|
|
|
static void spitz_i2c_setup(MachineState *machine, PXA2xxState *cpu)
|
2007-05-24 02:04:23 +04:00
|
|
|
{
|
|
|
|
/* Attach the CPU on one end of our I2C bus. */
|
2013-08-03 02:18:51 +04:00
|
|
|
I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
|
2007-05-24 02:04:23 +04:00
|
|
|
|
|
|
|
/* Attach a WM8750 to the bus */
|
2023-09-22 18:21:39 +03:00
|
|
|
I2CSlave *i2c_dev = i2c_slave_new(TYPE_WM8750, 0);
|
|
|
|
DeviceState *wm = DEVICE(i2c_dev);
|
|
|
|
|
|
|
|
if (machine->audiodev) {
|
|
|
|
qdev_prop_set_string(wm, "audiodev", machine->audiodev);
|
|
|
|
}
|
|
|
|
i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort);
|
2007-05-24 02:04:23 +04:00
|
|
|
|
2007-11-17 17:07:13 +03:00
|
|
|
spitz_wm8750_addr(wm, 0, 0);
|
2011-01-21 19:57:50 +03:00
|
|
|
qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_WM,
|
2014-06-18 11:55:18 +04:00
|
|
|
qemu_allocate_irq(spitz_wm8750_addr, wm, 0));
|
2007-05-24 02:04:23 +04:00
|
|
|
/* .. and to the sound interface. */
|
|
|
|
cpu->i2s->opaque = wm;
|
|
|
|
cpu->i2s->codec_out = wm8750_dac_dat;
|
|
|
|
cpu->i2s->codec_in = wm8750_adc_dat;
|
|
|
|
wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s);
|
|
|
|
}
|
|
|
|
|
2009-05-10 04:44:56 +04:00
|
|
|
static void spitz_akita_i2c_setup(PXA2xxState *cpu)
|
2007-05-24 02:04:23 +04:00
|
|
|
{
|
|
|
|
/* Attach a Max7310 to Akita I2C bus. */
|
2020-07-06 01:41:53 +03:00
|
|
|
i2c_slave_create_simple(pxa2xx_i2c_bus(cpu->i2c[0]), "max7310",
|
2009-05-15 01:35:08 +04:00
|
|
|
AKITA_MAX_ADDR);
|
2007-05-24 02:04:23 +04:00
|
|
|
}
|
|
|
|
|
2007-04-30 06:22:06 +04:00
|
|
|
/* Other peripherals */
|
|
|
|
|
2020-07-03 18:59:45 +03:00
|
|
|
/*
|
|
|
|
* Encapsulation of some miscellaneous GPIO line behaviour for the Spitz boards.
|
|
|
|
*
|
|
|
|
* QEMU interface:
|
|
|
|
* + named GPIO inputs "green-led", "orange-led", "charging", "discharging":
|
|
|
|
* these currently just print messages that the line has been signalled
|
|
|
|
* + named GPIO input "adc-temp-on": set to cause the battery-temperature
|
|
|
|
* value to be passed to the max111x ADC
|
|
|
|
* + named GPIO output "adc-temp": the ADC value, to be wired up to the max111x
|
|
|
|
*/
|
|
|
|
#define TYPE_SPITZ_MISC_GPIO "spitz-misc-gpio"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(SpitzMiscGPIOState, SPITZ_MISC_GPIO)
|
2020-07-03 18:59:45 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct SpitzMiscGPIOState {
|
2020-07-03 18:59:45 +03:00
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
|
|
|
qemu_irq adc_value;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2020-07-03 18:59:45 +03:00
|
|
|
|
|
|
|
static void spitz_misc_charging(void *opaque, int n, int level)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2020-07-03 18:59:45 +03:00
|
|
|
zaurus_printf("Charging %s.\n", level ? "off" : "on");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spitz_misc_discharging(void *opaque, int n, int level)
|
|
|
|
{
|
|
|
|
zaurus_printf("Discharging %s.\n", level ? "off" : "on");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spitz_misc_green_led(void *opaque, int n, int level)
|
|
|
|
{
|
|
|
|
zaurus_printf("Green LED %s.\n", level ? "off" : "on");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spitz_misc_orange_led(void *opaque, int n, int level)
|
|
|
|
{
|
|
|
|
zaurus_printf("Orange LED %s.\n", level ? "off" : "on");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spitz_misc_adc_temp(void *opaque, int n, int level)
|
|
|
|
{
|
|
|
|
SpitzMiscGPIOState *s = SPITZ_MISC_GPIO(opaque);
|
|
|
|
int batt_temp = level ? SPITZ_BATTERY_TEMP : 0;
|
|
|
|
|
|
|
|
qemu_set_irq(s->adc_value, batt_temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spitz_misc_gpio_init(Object *obj)
|
|
|
|
{
|
|
|
|
SpitzMiscGPIOState *s = SPITZ_MISC_GPIO(obj);
|
|
|
|
DeviceState *dev = DEVICE(obj);
|
|
|
|
|
|
|
|
qdev_init_gpio_in_named(dev, spitz_misc_charging, "charging", 1);
|
|
|
|
qdev_init_gpio_in_named(dev, spitz_misc_discharging, "discharging", 1);
|
|
|
|
qdev_init_gpio_in_named(dev, spitz_misc_green_led, "green-led", 1);
|
|
|
|
qdev_init_gpio_in_named(dev, spitz_misc_orange_led, "orange-led", 1);
|
|
|
|
qdev_init_gpio_in_named(dev, spitz_misc_adc_temp, "adc-temp-on", 1);
|
|
|
|
|
|
|
|
qdev_init_gpio_out_named(dev, &s->adc_value, "adc-temp", 1);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define SPITZ_SCP_LED_GREEN 1
|
|
|
|
#define SPITZ_SCP_JK_B 2
|
|
|
|
#define SPITZ_SCP_CHRG_ON 3
|
|
|
|
#define SPITZ_SCP_MUTE_L 4
|
|
|
|
#define SPITZ_SCP_MUTE_R 5
|
|
|
|
#define SPITZ_SCP_CF_POWER 6
|
|
|
|
#define SPITZ_SCP_LED_ORANGE 7
|
|
|
|
#define SPITZ_SCP_JK_A 8
|
|
|
|
#define SPITZ_SCP_ADC_TEMP_ON 9
|
|
|
|
#define SPITZ_SCP2_IR_ON 1
|
|
|
|
#define SPITZ_SCP2_AKIN_PULLUP 2
|
|
|
|
#define SPITZ_SCP2_BACKLIGHT_CONT 7
|
|
|
|
#define SPITZ_SCP2_BACKLIGHT_ON 8
|
|
|
|
#define SPITZ_SCP2_MIC_BIAS 9
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:44 +03:00
|
|
|
static void spitz_scoop_gpio_setup(SpitzMachineState *sms)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2020-07-03 18:59:45 +03:00
|
|
|
DeviceState *miscdev = sysbus_create_simple(TYPE_SPITZ_MISC_GPIO, -1, NULL);
|
|
|
|
|
|
|
|
sms->misc_gpio = miscdev;
|
|
|
|
|
|
|
|
qdev_connect_gpio_out(sms->scp0, SPITZ_SCP_CHRG_ON,
|
|
|
|
qdev_get_gpio_in_named(miscdev, "charging", 0));
|
|
|
|
qdev_connect_gpio_out(sms->scp0, SPITZ_SCP_JK_B,
|
|
|
|
qdev_get_gpio_in_named(miscdev, "discharging", 0));
|
|
|
|
qdev_connect_gpio_out(sms->scp0, SPITZ_SCP_LED_GREEN,
|
|
|
|
qdev_get_gpio_in_named(miscdev, "green-led", 0));
|
|
|
|
qdev_connect_gpio_out(sms->scp0, SPITZ_SCP_LED_ORANGE,
|
|
|
|
qdev_get_gpio_in_named(miscdev, "orange-led", 0));
|
|
|
|
qdev_connect_gpio_out(sms->scp0, SPITZ_SCP_ADC_TEMP_ON,
|
|
|
|
qdev_get_gpio_in_named(miscdev, "adc-temp-on", 0));
|
|
|
|
qdev_connect_gpio_out_named(miscdev, "adc-temp", 0,
|
|
|
|
qdev_get_gpio_in(sms->max1111, MAX1111_BATT_TEMP));
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:44 +03:00
|
|
|
if (sms->scp1) {
|
|
|
|
qdev_connect_gpio_out(sms->scp1, SPITZ_SCP2_BACKLIGHT_CONT,
|
2020-07-03 18:59:44 +03:00
|
|
|
qdev_get_gpio_in_named(sms->lcdtg, "bl_bit5", 0));
|
2020-07-03 18:59:44 +03:00
|
|
|
qdev_connect_gpio_out(sms->scp1, SPITZ_SCP2_BACKLIGHT_ON,
|
2020-07-03 18:59:44 +03:00
|
|
|
qdev_get_gpio_in_named(sms->lcdtg, "bl_power", 0));
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
#define SPITZ_GPIO_HSYNC 22
|
|
|
|
#define SPITZ_GPIO_SD_DETECT 9
|
|
|
|
#define SPITZ_GPIO_SD_WP 81
|
|
|
|
#define SPITZ_GPIO_ON_RESET 89
|
|
|
|
#define SPITZ_GPIO_BAT_COVER 90
|
|
|
|
#define SPITZ_GPIO_CF1_IRQ 105
|
|
|
|
#define SPITZ_GPIO_CF1_CD 94
|
|
|
|
#define SPITZ_GPIO_CF2_IRQ 106
|
|
|
|
#define SPITZ_GPIO_CF2_CD 93
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2007-11-17 17:07:13 +03:00
|
|
|
static int spitz_hsync;
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2007-11-17 17:07:13 +03:00
|
|
|
static void spitz_lcd_hsync_handler(void *opaque, int line, int level)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxState *cpu = (PXA2xxState *) opaque;
|
2011-01-21 19:57:50 +03:00
|
|
|
qemu_set_irq(qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_HSYNC), spitz_hsync);
|
2007-04-30 06:22:06 +04:00
|
|
|
spitz_hsync ^= 1;
|
|
|
|
}
|
|
|
|
|
2016-10-28 16:12:31 +03:00
|
|
|
static void spitz_reset(void *opaque, int line, int level)
|
|
|
|
{
|
|
|
|
if (level) {
|
2017-05-16 00:41:13 +03:00
|
|
|
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
|
2016-10-28 16:12:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-10 04:44:56 +04:00
|
|
|
static void spitz_gpio_setup(PXA2xxState *cpu, int slots)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2007-11-17 17:07:13 +03:00
|
|
|
qemu_irq lcd_hsync;
|
2016-10-28 16:12:31 +03:00
|
|
|
qemu_irq reset;
|
|
|
|
|
2007-04-30 06:22:06 +04:00
|
|
|
/*
|
|
|
|
* Bad hack: We toggle the LCD hsync GPIO on every GPIO status
|
|
|
|
* read to satisfy broken guests that poll-wait for hsync.
|
|
|
|
* Simulating a real hsync event would be less practical and
|
|
|
|
* wouldn't guarantee that a guest ever exits the loop.
|
|
|
|
*/
|
|
|
|
spitz_hsync = 0;
|
2014-06-18 11:55:18 +04:00
|
|
|
lcd_hsync = qemu_allocate_irq(spitz_lcd_hsync_handler, cpu, 0);
|
2007-11-17 17:07:13 +03:00
|
|
|
pxa2xx_gpio_read_notifier(cpu->gpio, lcd_hsync);
|
|
|
|
pxa2xx_lcd_vsync_notifier(cpu->lcd, lcd_hsync);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
/* MMC/SD host */
|
2007-11-17 17:34:44 +03:00
|
|
|
pxa2xx_mmci_handlers(cpu->mmc,
|
2011-01-21 19:57:50 +03:00
|
|
|
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_SD_WP),
|
|
|
|
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_SD_DETECT));
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
/* Battery lock always closed */
|
2011-01-21 19:57:50 +03:00
|
|
|
qemu_irq_raise(qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_BAT_COVER));
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
/* Handle reset */
|
2016-10-28 16:12:31 +03:00
|
|
|
reset = qemu_allocate_irq(spitz_reset, cpu, 0);
|
|
|
|
qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_ON_RESET, reset);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
/* PCMCIA signals: card's IRQ and Card-Detect */
|
|
|
|
if (slots >= 1)
|
2007-11-17 17:07:13 +03:00
|
|
|
pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
|
2011-01-21 19:57:50 +03:00
|
|
|
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_IRQ),
|
|
|
|
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF1_CD));
|
2007-04-30 06:22:06 +04:00
|
|
|
if (slots >= 2)
|
2007-11-17 17:07:13 +03:00
|
|
|
pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
|
2011-01-21 19:57:50 +03:00
|
|
|
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_IRQ),
|
|
|
|
qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_CF2_CD));
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Board init. */
|
2020-07-03 18:59:43 +03:00
|
|
|
#define SPITZ_RAM 0x04000000
|
|
|
|
#define SPITZ_ROM 0x00800000
|
2008-04-24 21:59:27 +04:00
|
|
|
|
2008-04-15 00:27:51 +04:00
|
|
|
static struct arm_boot_info spitz_binfo = {
|
|
|
|
.loader_start = PXA2XX_SDRAM_BASE,
|
|
|
|
.ram_size = 0x04000000,
|
|
|
|
};
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
static void spitz_common_init(MachineState *machine)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2020-07-03 18:59:43 +03:00
|
|
|
SpitzMachineClass *smc = SPITZ_MACHINE_GET_CLASS(machine);
|
2020-07-03 18:59:44 +03:00
|
|
|
SpitzMachineState *sms = SPITZ_MACHINE(machine);
|
2020-07-03 18:59:43 +03:00
|
|
|
enum spitz_model_e model = smc->model;
|
2012-05-14 03:22:03 +04:00
|
|
|
PXA2xxState *mpu;
|
2011-10-03 15:03:56 +04:00
|
|
|
MemoryRegion *rom = g_new(MemoryRegion, 1);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2007-05-08 23:03:12 +04:00
|
|
|
/* Setup CPU & memory */
|
2023-01-09 14:53:05 +03:00
|
|
|
mpu = pxa270_init(spitz_binfo.ram_size, machine->cpu_type);
|
2020-07-03 18:59:44 +03:00
|
|
|
sms->mpu = mpu;
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2012-05-14 03:22:03 +04:00
|
|
|
sl_flash_register(mpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-02-24 21:50:18 +03:00
|
|
|
memory_region_init_rom(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
|
2023-01-09 14:53:05 +03:00
|
|
|
memory_region_add_subregion(get_system_memory(), 0, rom);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
|
|
|
/* Setup peripherals */
|
2012-05-14 03:22:03 +04:00
|
|
|
spitz_keyboard_register(mpu);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:44 +03:00
|
|
|
spitz_ssp_attach(sms);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:44 +03:00
|
|
|
sms->scp0 = sysbus_create_simple("scoop", 0x10800000, NULL);
|
2008-06-02 05:20:15 +04:00
|
|
|
if (model != akita) {
|
2020-07-03 18:59:44 +03:00
|
|
|
sms->scp1 = sysbus_create_simple("scoop", 0x08800040, NULL);
|
|
|
|
} else {
|
|
|
|
sms->scp1 = NULL;
|
2008-06-02 05:20:15 +04:00
|
|
|
}
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:44 +03:00
|
|
|
spitz_scoop_gpio_setup(sms);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2012-05-14 03:22:03 +04:00
|
|
|
spitz_gpio_setup(mpu, (model == akita) ? 1 : 2);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2023-09-22 18:21:39 +03:00
|
|
|
spitz_i2c_setup(machine, mpu);
|
2007-05-24 02:04:23 +04:00
|
|
|
|
|
|
|
if (model == akita)
|
2012-05-14 03:22:03 +04:00
|
|
|
spitz_akita_i2c_setup(mpu);
|
2007-05-24 02:04:23 +04:00
|
|
|
|
2007-04-30 06:22:06 +04:00
|
|
|
if (model == terrier)
|
2007-08-01 06:41:33 +04:00
|
|
|
/* A 6.0 GB microdrive is permanently sitting in CF slot 1. */
|
2012-05-14 03:22:03 +04:00
|
|
|
spitz_microdrive_attach(mpu, 1);
|
2007-04-30 06:22:06 +04:00
|
|
|
else if (model != akita)
|
2008-12-08 02:33:34 +03:00
|
|
|
/* A 4.0 GB microdrive is permanently sitting in CF slot 0. */
|
2012-05-14 03:22:03 +04:00
|
|
|
spitz_microdrive_attach(mpu, 0);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
spitz_binfo.board_id = smc->arm_id;
|
2019-08-09 09:57:21 +03:00
|
|
|
arm_load_kernel(mpu->cpu, machine, &spitz_binfo);
|
2009-04-09 21:48:30 +04:00
|
|
|
sl_bootparam_write(SL_PXA_PARAM_BASE);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
static void spitz_common_class_init(ObjectClass *oc, void *data)
|
2007-04-30 06:22:06 +04:00
|
|
|
{
|
2020-07-03 18:59:43 +03:00
|
|
|
MachineClass *mc = MACHINE_CLASS(oc);
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
mc->block_default_type = IF_IDE;
|
|
|
|
mc->ignore_memory_transaction_failures = true;
|
|
|
|
mc->init = spitz_common_init;
|
hw/arm: Deprecate various old Arm machine types
QEMU includes some models of old Arm machine types which are
a bit problematic for us because:
* they're written in a very old way that uses numerous APIs that we
would like to get away from (eg they don't use qdev, they use
qemu_system_reset_request(), they use vmstate_register(), etc)
* they've been that way for a decade plus and nobody particularly has
stepped up to try to modernise the code (beyond some occasional
work here and there)
* we often don't have test cases for them, which means that if we
do try to do the necessary refactoring work on them we have no
idea if they even still work at all afterwards
All these machine types are also of hardware that has largely passed
away into history and where I would not be surprised to find that
e.g. the Linux kernel support was never tested on real hardware
any more.
After some consultation with the Linux kernel developers, we
are going to deprecate:
All PXA2xx machines:
akita Sharp SL-C1000 (Akita) PDA (PXA270)
borzoi Sharp SL-C3100 (Borzoi) PDA (PXA270)
connex Gumstix Connex (PXA255)
mainstone Mainstone II (PXA27x)
spitz Sharp SL-C3000 (Spitz) PDA (PXA270)
terrier Sharp SL-C3200 (Terrier) PDA (PXA270)
tosa Sharp SL-6000 (Tosa) PDA (PXA255)
verdex Gumstix Verdex Pro XL6P COMs (PXA270)
z2 Zipit Z2 (PXA27x)
All OMAP2 machines:
n800 Nokia N800 tablet aka. RX-34 (OMAP2420)
n810 Nokia N810 tablet aka. RX-44 (OMAP2420)
One of the OMAP1 machines:
cheetah Palm Tungsten|E aka. Cheetah PDA (OMAP310)
Rationale:
* for QEMU dropping individual machines is much less beneficial
than if we can drop support for an entire SoC
* the OMAP2 QEMU code in particular is large, old and unmaintained,
and none of the OMAP2 kernel maintainers said they were using
QEMU in any of their testing/development
* although there is a setup that is booting test kernels on some
of the PXA2xx machines, nobody seemed to be using them as part
of their active kernel development and my impression from the
email thread is that PXA is the closest of all these SoC families
to being dropped from the kernel soon
* nobody said they were using cheetah, so it's entirely
untested and quite probably broken
* on the other hand the OMAP1 sx1 model does seem to be being
used as part of kernel development, and there was interest
in keeping collie around
In particular, the mainstone, tosa and z2 machine types have
already been dropped from Linux.
Mark all these machine types as deprecated.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20240308171621.3749894-1-peter.maydell@linaro.org
2024-03-08 20:16:21 +03:00
|
|
|
mc->deprecation_reason = "machine is old and unmaintained";
|
2023-09-22 18:21:39 +03:00
|
|
|
|
|
|
|
machine_add_audiodev_property(mc);
|
2007-04-30 06:22:06 +04:00
|
|
|
}
|
|
|
|
|
2020-07-03 18:59:43 +03:00
|
|
|
static const TypeInfo spitz_common_info = {
|
|
|
|
.name = TYPE_SPITZ_MACHINE,
|
|
|
|
.parent = TYPE_MACHINE,
|
|
|
|
.abstract = true,
|
|
|
|
.instance_size = sizeof(SpitzMachineState),
|
|
|
|
.class_size = sizeof(SpitzMachineClass),
|
|
|
|
.class_init = spitz_common_class_init,
|
|
|
|
};
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2015-09-19 11:49:44 +03:00
|
|
|
static void akitapda_class_init(ObjectClass *oc, void *data)
|
2015-09-04 21:37:08 +03:00
|
|
|
{
|
2015-09-19 11:49:44 +03:00
|
|
|
MachineClass *mc = MACHINE_CLASS(oc);
|
2020-07-03 18:59:43 +03:00
|
|
|
SpitzMachineClass *smc = SPITZ_MACHINE_CLASS(oc);
|
2015-09-19 11:49:44 +03:00
|
|
|
|
2015-10-16 13:14:53 +03:00
|
|
|
mc->desc = "Sharp SL-C1000 (Akita) PDA (PXA270)";
|
2017-09-13 19:04:57 +03:00
|
|
|
mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c0");
|
2020-07-03 18:59:43 +03:00
|
|
|
smc->model = akita;
|
|
|
|
smc->arm_id = 0x2e8;
|
2015-09-04 21:37:08 +03:00
|
|
|
}
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2015-09-19 11:49:44 +03:00
|
|
|
static const TypeInfo akitapda_type = {
|
|
|
|
.name = MACHINE_TYPE_NAME("akita"),
|
2020-07-03 18:59:43 +03:00
|
|
|
.parent = TYPE_SPITZ_MACHINE,
|
2015-09-19 11:49:44 +03:00
|
|
|
.class_init = akitapda_class_init,
|
|
|
|
};
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2015-09-19 11:49:44 +03:00
|
|
|
static void spitzpda_class_init(ObjectClass *oc, void *data)
|
2015-09-04 21:37:08 +03:00
|
|
|
{
|
2015-09-19 11:49:44 +03:00
|
|
|
MachineClass *mc = MACHINE_CLASS(oc);
|
2020-07-03 18:59:43 +03:00
|
|
|
SpitzMachineClass *smc = SPITZ_MACHINE_CLASS(oc);
|
2015-09-19 11:49:44 +03:00
|
|
|
|
2015-10-16 13:14:53 +03:00
|
|
|
mc->desc = "Sharp SL-C3000 (Spitz) PDA (PXA270)";
|
2017-09-13 19:04:57 +03:00
|
|
|
mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c0");
|
2020-07-03 18:59:43 +03:00
|
|
|
smc->model = spitz;
|
|
|
|
smc->arm_id = 0x2c9;
|
2015-09-04 21:37:08 +03:00
|
|
|
}
|
2007-04-30 06:22:06 +04:00
|
|
|
|
2015-09-19 11:49:44 +03:00
|
|
|
static const TypeInfo spitzpda_type = {
|
|
|
|
.name = MACHINE_TYPE_NAME("spitz"),
|
2020-07-03 18:59:43 +03:00
|
|
|
.parent = TYPE_SPITZ_MACHINE,
|
2015-09-19 11:49:44 +03:00
|
|
|
.class_init = spitzpda_class_init,
|
|
|
|
};
|
2015-09-04 21:37:08 +03:00
|
|
|
|
2015-09-19 11:49:44 +03:00
|
|
|
static void borzoipda_class_init(ObjectClass *oc, void *data)
|
2015-09-04 21:37:08 +03:00
|
|
|
{
|
2015-09-19 11:49:44 +03:00
|
|
|
MachineClass *mc = MACHINE_CLASS(oc);
|
2020-07-03 18:59:43 +03:00
|
|
|
SpitzMachineClass *smc = SPITZ_MACHINE_CLASS(oc);
|
2015-09-19 11:49:44 +03:00
|
|
|
|
2015-10-16 13:14:53 +03:00
|
|
|
mc->desc = "Sharp SL-C3100 (Borzoi) PDA (PXA270)";
|
2017-09-13 19:04:57 +03:00
|
|
|
mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c0");
|
2020-07-03 18:59:43 +03:00
|
|
|
smc->model = borzoi;
|
|
|
|
smc->arm_id = 0x33f;
|
2015-09-04 21:37:08 +03:00
|
|
|
}
|
|
|
|
|
2015-09-19 11:49:44 +03:00
|
|
|
static const TypeInfo borzoipda_type = {
|
|
|
|
.name = MACHINE_TYPE_NAME("borzoi"),
|
2020-07-03 18:59:43 +03:00
|
|
|
.parent = TYPE_SPITZ_MACHINE,
|
2015-09-19 11:49:44 +03:00
|
|
|
.class_init = borzoipda_class_init,
|
|
|
|
};
|
2009-05-15 01:35:09 +04:00
|
|
|
|
2015-09-19 11:49:44 +03:00
|
|
|
static void terrierpda_class_init(ObjectClass *oc, void *data)
|
2009-05-21 03:38:09 +04:00
|
|
|
{
|
2015-09-19 11:49:44 +03:00
|
|
|
MachineClass *mc = MACHINE_CLASS(oc);
|
2020-07-03 18:59:43 +03:00
|
|
|
SpitzMachineClass *smc = SPITZ_MACHINE_CLASS(oc);
|
2015-09-19 11:49:44 +03:00
|
|
|
|
2015-10-16 13:14:53 +03:00
|
|
|
mc->desc = "Sharp SL-C3200 (Terrier) PDA (PXA270)";
|
2017-09-13 19:04:57 +03:00
|
|
|
mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c5");
|
2020-07-03 18:59:43 +03:00
|
|
|
smc->model = terrier;
|
|
|
|
smc->arm_id = 0x33f;
|
2009-05-21 03:38:09 +04:00
|
|
|
}
|
|
|
|
|
2015-09-19 11:49:44 +03:00
|
|
|
static const TypeInfo terrierpda_type = {
|
|
|
|
.name = MACHINE_TYPE_NAME("terrier"),
|
2020-07-03 18:59:43 +03:00
|
|
|
.parent = TYPE_SPITZ_MACHINE,
|
2015-09-19 11:49:44 +03:00
|
|
|
.class_init = terrierpda_class_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void spitz_machine_init(void)
|
|
|
|
{
|
2020-07-03 18:59:43 +03:00
|
|
|
type_register_static(&spitz_common_info);
|
2015-09-19 11:49:44 +03:00
|
|
|
type_register_static(&akitapda_type);
|
|
|
|
type_register_static(&spitzpda_type);
|
|
|
|
type_register_static(&borzoipda_type);
|
|
|
|
type_register_static(&terrierpda_type);
|
|
|
|
}
|
|
|
|
|
2016-02-16 23:59:04 +03:00
|
|
|
type_init(spitz_machine_init)
|
2009-05-21 03:38:09 +04:00
|
|
|
|
2011-01-21 19:56:10 +03:00
|
|
|
static bool is_version_0(void *opaque, int version_id)
|
|
|
|
{
|
|
|
|
return version_id == 0;
|
|
|
|
}
|
|
|
|
|
2021-03-13 20:11:48 +03:00
|
|
|
static const VMStateDescription vmstate_sl_nand_info = {
|
2011-01-21 13:12:11 +03:00
|
|
|
.name = "sl-nand",
|
|
|
|
.version_id = 0,
|
|
|
|
.minimum_version_id = 0,
|
2023-12-21 06:15:59 +03:00
|
|
|
.fields = (const VMStateField[]) {
|
2011-01-21 13:12:11 +03:00
|
|
|
VMSTATE_UINT8(ctl, SLNANDState),
|
|
|
|
VMSTATE_STRUCT(ecc, SLNANDState, 0, vmstate_ecc_state, ECCState),
|
|
|
|
VMSTATE_END_OF_LIST(),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-01-24 23:12:29 +04:00
|
|
|
static Property sl_nand_properties[] = {
|
|
|
|
DEFINE_PROP_UINT8("manf_id", SLNANDState, manf_id, NAND_MFR_SAMSUNG),
|
|
|
|
DEFINE_PROP_UINT8("chip_id", SLNANDState, chip_id, 0xf1),
|
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
|
|
|
static void sl_nand_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2011-12-08 07:34:16 +04:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2012-01-24 23:12:29 +04:00
|
|
|
|
2011-12-08 07:34:16 +04:00
|
|
|
dc->vmsd = &vmstate_sl_nand_info;
|
2020-01-10 18:30:32 +03:00
|
|
|
device_class_set_props(dc, sl_nand_properties);
|
2018-07-23 17:21:26 +03:00
|
|
|
dc->realize = sl_nand_realize;
|
sysbus: Make devices picking up backends unavailable with -device
Device models aren't supposed to go on fishing expeditions for
backends. They should expose suitable properties for the user to set.
For onboard devices, board code sets them.
A number of sysbus devices pick up block backends in their init() /
instance_init() methods with drive_get_next() instead: sl-nand,
milkymist-memcard, pl181, generic-sdhci.
Likewise, a number of sysbus devices pick up character backends in
their init() / realize() methods with qemu_char_get_next_serial():
cadence_uart, digic-uart, etraxfs,serial, lm32-juart, lm32-uart,
milkymist-uart, pl011, stm32f2xx-usart, xlnx.xps-uartlite.
All these mistakes are already marked FIXME. See the commit that
added these FIXMEs for a more detailed explanation of what's wrong.
Fortunately, only machines ppce500 and pseries-* support -device with
sysbus devices, and none of the devices above is supported with these
machines.
Set cannot_instantiate_with_device_add_yet to preserve our luck.
Cc: Andrzej Zaborowski <balrogg@gmail.com>
Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: Antony Pavlov <antonynpavlov@gmail.com>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Michael Walle <michael@walle.cc>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-03-23 21:34:40 +03:00
|
|
|
/* Reason: init() method uses drive_get() */
|
2017-05-03 23:35:44 +03:00
|
|
|
dc->user_creatable = false;
|
2012-01-24 23:12:29 +04:00
|
|
|
}
|
|
|
|
|
2013-01-10 19:19:07 +04:00
|
|
|
static const TypeInfo sl_nand_info = {
|
2013-07-24 10:54:33 +04:00
|
|
|
.name = TYPE_SL_NAND,
|
2011-12-08 07:34:16 +04:00
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(SLNANDState),
|
2016-03-07 10:52:16 +03:00
|
|
|
.instance_init = sl_nand_init,
|
2011-12-08 07:34:16 +04:00
|
|
|
.class_init = sl_nand_class_init,
|
2011-01-21 13:12:11 +03:00
|
|
|
};
|
|
|
|
|
2021-03-13 20:11:48 +03:00
|
|
|
static const VMStateDescription vmstate_spitz_kbd = {
|
2011-01-21 19:56:10 +03:00
|
|
|
.name = "spitz-keyboard",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 0,
|
|
|
|
.post_load = spitz_keyboard_post_load,
|
2023-12-21 06:15:59 +03:00
|
|
|
.fields = (const VMStateField[]) {
|
2011-01-21 19:56:10 +03:00
|
|
|
VMSTATE_UINT16(sense_state, SpitzKeyboardState),
|
|
|
|
VMSTATE_UINT16(strobe_state, SpitzKeyboardState),
|
|
|
|
VMSTATE_UNUSED_TEST(is_version_0, 5),
|
|
|
|
VMSTATE_END_OF_LIST(),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-01-24 23:12:29 +04:00
|
|
|
static void spitz_keyboard_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2011-12-08 07:34:16 +04:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2012-01-24 23:12:29 +04:00
|
|
|
|
2011-12-08 07:34:16 +04:00
|
|
|
dc->vmsd = &vmstate_spitz_kbd;
|
2020-03-05 19:09:16 +03:00
|
|
|
dc->realize = spitz_keyboard_realize;
|
2012-01-24 23:12:29 +04:00
|
|
|
}
|
|
|
|
|
2013-01-10 19:19:07 +04:00
|
|
|
static const TypeInfo spitz_keyboard_info = {
|
2013-07-24 10:58:32 +04:00
|
|
|
.name = TYPE_SPITZ_KEYBOARD,
|
2011-12-08 07:34:16 +04:00
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(SpitzKeyboardState),
|
2016-03-07 10:52:16 +03:00
|
|
|
.instance_init = spitz_keyboard_init,
|
2011-12-08 07:34:16 +04:00
|
|
|
.class_init = spitz_keyboard_class_init,
|
2011-01-21 19:56:10 +03:00
|
|
|
};
|
|
|
|
|
2011-01-20 18:52:28 +03:00
|
|
|
static const VMStateDescription vmstate_corgi_ssp_regs = {
|
|
|
|
.name = "corgi-ssp",
|
2012-07-24 06:23:22 +04:00
|
|
|
.version_id = 2,
|
|
|
|
.minimum_version_id = 2,
|
2023-12-21 06:15:59 +03:00
|
|
|
.fields = (const VMStateField[]) {
|
2020-10-12 15:49:55 +03:00
|
|
|
VMSTATE_SSI_PERIPHERAL(ssidev, CorgiSSPState),
|
2011-01-20 18:52:28 +03:00
|
|
|
VMSTATE_UINT32_ARRAY(enable, CorgiSSPState, 3),
|
|
|
|
VMSTATE_END_OF_LIST(),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-12-16 23:36:39 +04:00
|
|
|
static void corgi_ssp_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2011-12-08 07:34:16 +04:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2020-10-12 15:49:55 +03:00
|
|
|
SSIPeripheralClass *k = SSI_PERIPHERAL_CLASS(klass);
|
2011-12-16 23:36:39 +04:00
|
|
|
|
2016-07-04 15:06:37 +03:00
|
|
|
k->realize = corgi_ssp_realize;
|
2011-12-16 23:36:39 +04:00
|
|
|
k->transfer = corgi_ssp_transfer;
|
2011-12-08 07:34:16 +04:00
|
|
|
dc->vmsd = &vmstate_corgi_ssp_regs;
|
2011-12-16 23:36:39 +04:00
|
|
|
}
|
|
|
|
|
2013-01-10 19:19:07 +04:00
|
|
|
static const TypeInfo corgi_ssp_info = {
|
2020-07-03 18:59:46 +03:00
|
|
|
.name = TYPE_CORGI_SSP,
|
2020-10-12 15:49:55 +03:00
|
|
|
.parent = TYPE_SSI_PERIPHERAL,
|
2011-12-08 07:34:16 +04:00
|
|
|
.instance_size = sizeof(CorgiSSPState),
|
|
|
|
.class_init = corgi_ssp_class_init,
|
2009-05-15 01:35:09 +04:00
|
|
|
};
|
|
|
|
|
2011-01-20 18:52:28 +03:00
|
|
|
static const VMStateDescription vmstate_spitz_lcdtg_regs = {
|
|
|
|
.name = "spitz-lcdtg",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
2023-12-21 06:15:59 +03:00
|
|
|
.fields = (const VMStateField[]) {
|
2020-10-12 15:49:55 +03:00
|
|
|
VMSTATE_SSI_PERIPHERAL(ssidev, SpitzLCDTG),
|
2011-01-20 18:52:28 +03:00
|
|
|
VMSTATE_UINT32(bl_intensity, SpitzLCDTG),
|
|
|
|
VMSTATE_UINT32(bl_power, SpitzLCDTG),
|
|
|
|
VMSTATE_END_OF_LIST(),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-12-16 23:36:39 +04:00
|
|
|
static void spitz_lcdtg_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2011-12-08 07:34:16 +04:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2020-10-12 15:49:55 +03:00
|
|
|
SSIPeripheralClass *k = SSI_PERIPHERAL_CLASS(klass);
|
2011-12-16 23:36:39 +04:00
|
|
|
|
2016-07-04 15:06:37 +03:00
|
|
|
k->realize = spitz_lcdtg_realize;
|
2011-12-16 23:36:39 +04:00
|
|
|
k->transfer = spitz_lcdtg_transfer;
|
2011-12-08 07:34:16 +04:00
|
|
|
dc->vmsd = &vmstate_spitz_lcdtg_regs;
|
2011-12-16 23:36:39 +04:00
|
|
|
}
|
|
|
|
|
2013-01-10 19:19:07 +04:00
|
|
|
static const TypeInfo spitz_lcdtg_info = {
|
2020-07-03 18:59:46 +03:00
|
|
|
.name = TYPE_SPITZ_LCDTG,
|
2020-10-12 15:49:55 +03:00
|
|
|
.parent = TYPE_SSI_PERIPHERAL,
|
2011-12-08 07:34:16 +04:00
|
|
|
.instance_size = sizeof(SpitzLCDTG),
|
|
|
|
.class_init = spitz_lcdtg_class_init,
|
2009-05-15 01:35:09 +04:00
|
|
|
};
|
|
|
|
|
2020-07-03 18:59:45 +03:00
|
|
|
static const TypeInfo spitz_misc_gpio_info = {
|
|
|
|
.name = TYPE_SPITZ_MISC_GPIO,
|
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(SpitzMiscGPIOState),
|
|
|
|
.instance_init = spitz_misc_gpio_init,
|
|
|
|
/*
|
|
|
|
* No class_init required: device has no internal state so does not
|
|
|
|
* need to set up reset or vmstate, and does not have a realize method.
|
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
2012-02-09 18:20:55 +04:00
|
|
|
static void spitz_register_types(void)
|
2009-05-15 01:35:09 +04:00
|
|
|
{
|
2011-12-08 07:34:16 +04:00
|
|
|
type_register_static(&corgi_ssp_info);
|
|
|
|
type_register_static(&spitz_lcdtg_info);
|
|
|
|
type_register_static(&spitz_keyboard_info);
|
|
|
|
type_register_static(&sl_nand_info);
|
2020-07-03 18:59:45 +03:00
|
|
|
type_register_static(&spitz_misc_gpio_info);
|
2009-05-15 01:35:09 +04:00
|
|
|
}
|
|
|
|
|
2012-02-09 18:20:55 +04:00
|
|
|
type_init(spitz_register_types)
|