Files
qemu-ios/hw/arm/ipod_touch_gpio.c
T

62 lines
1.6 KiB
C

#include "hw/arm/ipod_touch_gpio.h"
static void s5l8900_gpio_write(void *opaque, hwaddr addr, uint64_t value, unsigned size)
{
//fprintf(stderr, "%s: writing 0x%08x to 0x%08x\n", __func__, value, addr);
IPodTouchGPIOState *s = (struct IPodTouchGPIOState *) opaque;
switch(addr) {
default:
break;
}
}
static uint64_t s5l8900_gpio_read(void *opaque, hwaddr addr, unsigned size)
{
fprintf(stderr, "%s: read from location 0x%08x\n", __func__, addr);
IPodTouchGPIOState *s = (struct IPodTouchGPIOState *) opaque;
switch(addr) {
case 0x184: // TODO: This offset only makes sure that the GPIO triggers associated with the home/power button work correctly!!
return s->gpio_state;
default:
break;
}
return 0;
}
static const MemoryRegionOps gpio_ops = {
.read = s5l8900_gpio_read,
.write = s5l8900_gpio_write,
.endianness = DEVICE_NATIVE_ENDIAN,
};
static void s5l8900_gpio_init(Object *obj)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
DeviceState *dev = DEVICE(sbd);
IPodTouchGPIOState *s = IPOD_TOUCH_GPIO(dev);
memory_region_init_io(&s->iomem, obj, &gpio_ops, s, "gpio", 0x1000);
}
static void s5l8900_gpio_class_init(ObjectClass *klass, void *data)
{
}
static const TypeInfo ipod_touch_gpio_info = {
.name = TYPE_IPOD_TOUCH_GPIO,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(IPodTouchGPIOState),
.instance_init = s5l8900_gpio_init,
.class_init = s5l8900_gpio_class_init,
};
static void ipod_touch_machine_types(void)
{
type_register_static(&ipod_touch_gpio_info);
}
type_init(ipod_touch_machine_types)