Mikey is loading
This commit is contained in:
1 parent
c16e8a325a
commit
94c88d8121
9 files changed
+185
-12
No files matched your search
+17
-8
@@ -292,9 +292,10 @@ static void ipod_touch_machine_init(MachineState *machine)
|
||||
sysbus_realize(busdev, &error_fatal);
|
||||
sysbus_connect_irq(busdev, 0, s5l8900_get_irq(nms, S5L8720_DMAC0_IRQ));
|
||||
|
||||
// Init I2C
|
||||
// Init I2C0
|
||||
dev = qdev_new("ipodtouch.i2c");
|
||||
IPodTouchI2CState *i2c_state = IPOD_TOUCH_I2C(dev);
|
||||
i2c_state->base = 0;
|
||||
nms->i2c0_state = i2c_state;
|
||||
busdev = SYS_BUS_DEVICE(dev);
|
||||
sysbus_connect_irq(busdev, 0, s5l8900_get_irq(nms, S5L8720_I2C0_IRQ));
|
||||
@@ -303,6 +304,21 @@ static void ipod_touch_machine_init(MachineState *machine)
|
||||
// init the PMU
|
||||
i2c_slave_create_simple(i2c_state->bus, "pcf50633", 0x73);
|
||||
|
||||
// init the accelerometer
|
||||
I2CSlave *accelerometer = i2c_slave_create_simple(i2c_state->bus, "lis302dl", 0x1D);
|
||||
|
||||
// Init I2C1
|
||||
dev = qdev_new("ipodtouch.i2c");
|
||||
i2c_state = IPOD_TOUCH_I2C(dev);
|
||||
nms->i2c1_state = i2c_state;
|
||||
i2c_state->base = 1;
|
||||
busdev = SYS_BUS_DEVICE(dev);
|
||||
sysbus_connect_irq(busdev, 0, s5l8900_get_irq(nms, S5L8720_I2C1_IRQ));
|
||||
memory_region_add_subregion(sysmem, I2C1_MEM_BASE, &i2c_state->iomem);
|
||||
|
||||
// init the Mikey
|
||||
i2c_slave_create_simple(i2c_state->bus, "cd3272mikey", 0x39);
|
||||
|
||||
// init the FMSS flash controller
|
||||
dev = qdev_new("ipodtouch.fmss");
|
||||
IPodTouchFMSSState *fmss_state = IPOD_TOUCH_FMSS(dev);
|
||||
@@ -311,13 +327,6 @@ static void ipod_touch_machine_init(MachineState *machine)
|
||||
sysbus_connect_irq(busdev, 0, s5l8900_get_irq(nms, S5L8720_FMSS_IRQ));
|
||||
memory_region_add_subregion(sysmem, FMSS_MEM_BASE, &fmss_state->iomem);
|
||||
|
||||
dev = qdev_new("ipodtouch.i2c");
|
||||
i2c_state = IPOD_TOUCH_I2C(dev);
|
||||
nms->i2c1_state = i2c_state;
|
||||
busdev = SYS_BUS_DEVICE(dev);
|
||||
sysbus_connect_irq(busdev, 0, s5l8900_get_irq(nms, S5L8720_I2C1_IRQ));
|
||||
memory_region_add_subregion(sysmem, I2C1_MEM_BASE, &i2c_state->iomem);
|
||||
|
||||
// init the chip ID module
|
||||
dev = qdev_new("ipodtouch.usbphys");
|
||||
IPodTouchUSBPhysState *usb_phys_state = IPOD_TOUCH_USB_PHYS(dev);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#include "hw/arm/ipod_touch_cd3272_mikey.h"
|
||||
|
||||
static int cd3272_mikey_event(I2CSlave *i2c, enum i2c_event event)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t cd3272_mikey_recv(I2CSlave *i2c)
|
||||
{
|
||||
CD3272MikeyState *s = CD3272MIKEY(i2c);
|
||||
printf("Reading mikey register %d\n", s->cmd);
|
||||
|
||||
int res = 0;
|
||||
|
||||
switch(s->cmd) {
|
||||
default:
|
||||
res = 0;
|
||||
}
|
||||
|
||||
s->cmd += 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int cd3272_mikey_send(I2CSlave *i2c, uint8_t data)
|
||||
{
|
||||
CD3272MikeyState *s = CD3272MIKEY(i2c);
|
||||
s->cmd = data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cd3272_mikey_init(Object *obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void cd3272_mikey_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
|
||||
|
||||
k->event = cd3272_mikey_event;
|
||||
k->recv = cd3272_mikey_recv;
|
||||
k->send = cd3272_mikey_send;
|
||||
}
|
||||
|
||||
static const TypeInfo cd3272_mikey_info = {
|
||||
.name = TYPE_CD3272MIKEY,
|
||||
.parent = TYPE_I2C_SLAVE,
|
||||
.instance_init = cd3272_mikey_init,
|
||||
.instance_size = sizeof(CD3272MikeyState),
|
||||
.class_init = cd3272_mikey_class_init,
|
||||
};
|
||||
|
||||
static void cd3272_mikey_register_types(void)
|
||||
{
|
||||
type_register_static(&cd3272_mikey_info);
|
||||
}
|
||||
|
||||
type_init(cd3272_mikey_register_types)
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "hw/arm/ipod_touch_lis302dl.h"
|
||||
|
||||
static int lis302dl_event(I2CSlave *i2c, enum i2c_event event)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t lis302dl_recv(I2CSlave *i2c)
|
||||
{
|
||||
LIS302DLState *s = LIS302DL(i2c);
|
||||
printf("Reading accelerometer register %d\n", s->cmd);
|
||||
|
||||
switch(s->cmd) {
|
||||
case ACCEL_WHOAMI:
|
||||
return ACCEL_WHOAMI_VALUE; // whoami value
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int lis302dl_send(I2CSlave *i2c, uint8_t data)
|
||||
{
|
||||
LIS302DLState *s = LIS302DL(i2c);
|
||||
s->cmd = data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lis302dl_init(Object *obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void lis302dl_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
|
||||
|
||||
k->event = lis302dl_event;
|
||||
k->recv = lis302dl_recv;
|
||||
k->send = lis302dl_send;
|
||||
}
|
||||
|
||||
static const TypeInfo lis302dl_info = {
|
||||
.name = TYPE_LIS302DL,
|
||||
.parent = TYPE_I2C_SLAVE,
|
||||
.instance_init = lis302dl_init,
|
||||
.instance_size = sizeof(LIS302DLState),
|
||||
.class_init = lis302dl_class_init,
|
||||
};
|
||||
|
||||
static void lis302dl_register_types(void)
|
||||
{
|
||||
type_register_static(&lis302dl_info);
|
||||
}
|
||||
|
||||
type_init(lis302dl_register_types)
|
||||
@@ -12,9 +12,9 @@ static uint64_t ipod_touch_mipi_dsi_read(void *opaque, hwaddr addr, unsigned siz
|
||||
case REG_INTSRC:
|
||||
return rDSIM_INTSRC_RxDatDone;
|
||||
case REG_RXFIFO:
|
||||
printf("READ ABC\n");
|
||||
if(!s->return_panel_id) {
|
||||
s->return_panel_id = true;
|
||||
// TODO this should be rewritten as a proper queue!
|
||||
return DSIM_RSP_LONG_READ | (3 << 8); // the latter part indicates the length of the response (the panel ID)
|
||||
} else {
|
||||
s->return_panel_id = false;
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ arm_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmuv3.c'))
|
||||
arm_ss.add(when: 'CONFIG_FSL_IMX6UL', if_true: files('fsl-imx6ul.c', 'mcimx6ul-evk.c'))
|
||||
arm_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c'))
|
||||
arm_ss.add(when: 'CONFIG_XEN', if_true: files('xen_arm.c'))
|
||||
arm_ss.add(when: 'CONFIG_IPOD_TOUCH_2G', if_true: files('ipod_touch_2g.c', 'ipod_touch_clock.c', 'ipod_touch_chipid.c', 'ipod_touch_gpio.c', 'ipod_touch_sysic.c', 'ipod_touch_timer.c', 'ipod_touch_usb_otg.c', 'ipod_touch_usb_phys.c', 'ipod_touch_spi.c', 'ipod_touch_nor_spi.c', 'ipod_touch_sha1.c', 'ipod_touch_aes.c', 'ipod_touch_pke.c', 'ipod_touch_pcf50633_pmu.c', 'ipod_touch_unknown1.c', 'ipod_touch_lcd.c', 'ipod_touch_mipi_dsi.c', 'ipod_touch_fmss.c', 'ipod_touch_block_device.c', 'ipod_touch_mbx.c'))
|
||||
arm_ss.add(when: 'CONFIG_IPOD_TOUCH_2G', if_true: files('ipod_touch_2g.c', 'ipod_touch_clock.c', 'ipod_touch_chipid.c', 'ipod_touch_gpio.c', 'ipod_touch_sysic.c', 'ipod_touch_timer.c', 'ipod_touch_usb_otg.c', 'ipod_touch_usb_phys.c', 'ipod_touch_spi.c', 'ipod_touch_nor_spi.c', 'ipod_touch_sha1.c', 'ipod_touch_aes.c', 'ipod_touch_pke.c', 'ipod_touch_pcf50633_pmu.c', 'ipod_touch_unknown1.c', 'ipod_touch_lcd.c', 'ipod_touch_mipi_dsi.c', 'ipod_touch_fmss.c', 'ipod_touch_block_device.c', 'ipod_touch_mbx.c', 'ipod_touch_cd3272_mikey.c', 'ipod_touch_lis302dl.c'))
|
||||
|
||||
system_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c'))
|
||||
system_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4_boards.c'))
|
||||
|
||||
@@ -96,7 +96,7 @@ static void ipod_touch_i2c_write(void *opaque, hwaddr offset, uint64_t value, un
|
||||
IPodTouchI2CState *s = (IPodTouchI2CState *)opaque;
|
||||
int mode;
|
||||
|
||||
//fprintf(stderr, "s5l8900_i2c_write: offset = 0x%08x, val = 0x%08x\n", offset, value);
|
||||
//printf("s5l8900_i2c_write (base %d): offset = 0x%08x, val = 0x%08x\n", s->base, offset, value);
|
||||
|
||||
qemu_irq_lower(s->irq);
|
||||
|
||||
@@ -198,6 +198,8 @@ static const MemoryRegionOps ipod_touch_i2c_ops = {
|
||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
};
|
||||
|
||||
static int i2c_index = 0;
|
||||
|
||||
static void ipod_touch_i2c_init(Object *obj)
|
||||
{
|
||||
DeviceState *dev = DEVICE(obj);
|
||||
@@ -207,7 +209,12 @@ static void ipod_touch_i2c_init(Object *obj)
|
||||
memory_region_init_io(&s->iomem, obj, &ipod_touch_i2c_ops, s, TYPE_IPOD_TOUCH_I2C, 0x100);
|
||||
sysbus_init_mmio(sbd, &s->iomem);
|
||||
sysbus_init_irq(sbd, &s->irq);
|
||||
s->bus = i2c_init_bus(dev, "i2c");
|
||||
|
||||
char bus_name[5];
|
||||
sprintf(bus_name, "i2c%d", i2c_index);
|
||||
|
||||
s->bus = i2c_init_bus(dev, bus_name);
|
||||
i2c_index += 1;
|
||||
}
|
||||
|
||||
static void ipod_touch_i2c_reset(DeviceState *d)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef HW_CD3272_MIKEY_H
|
||||
#define HW_CD3272_MIKEY_H
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "hw/sysbus.h"
|
||||
#include "hw/i2c/i2c.h"
|
||||
#include "hw/irq.h"
|
||||
#include "time.h"
|
||||
|
||||
#define TYPE_CD3272MIKEY "cd3272mikey"
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(CD3272MikeyState, CD3272MIKEY)
|
||||
|
||||
typedef struct CD3272MikeyState {
|
||||
I2CSlave i2c;
|
||||
uint32_t cmd;
|
||||
} CD3272MikeyState;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef HW_LIS302DL_H
|
||||
#define HW_LIS302DL_H
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "hw/sysbus.h"
|
||||
#include "hw/i2c/i2c.h"
|
||||
#include "hw/irq.h"
|
||||
|
||||
#define TYPE_LIS302DL "lis302dl"
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(LIS302DLState, LIS302DL)
|
||||
|
||||
#define ACCEL_WHOAMI 0x0F
|
||||
|
||||
#define ACCEL_WHOAMI_VALUE 0x3B
|
||||
|
||||
typedef struct LIS302DLState {
|
||||
I2CSlave i2c;
|
||||
uint32_t cmd;
|
||||
} LIS302DLState;
|
||||
|
||||
#endif
|
||||
@@ -47,6 +47,7 @@ typedef struct IPodTouchI2CState {
|
||||
MemoryRegion iomem;
|
||||
I2CBus *bus;
|
||||
qemu_irq irq;
|
||||
uint8_t base;
|
||||
|
||||
uint8_t control;
|
||||
uint8_t status;
|
||||
|
||||
Reference in new issue
Block a user