From 999255e50832e6cf8e3db10922fa872586886ca1 Mon Sep 17 00:00:00 2001 From: Martijn de Vos Date: Sun, 12 Feb 2023 09:14:08 +0100 Subject: [PATCH] Got some of the NAND initializations working --- hw/arm/ipod_touch_fmss.c | 23 ++++++++++++++++++++++- include/hw/arm/ipod_touch_fmss.h | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hw/arm/ipod_touch_fmss.c b/hw/arm/ipod_touch_fmss.c index 8fb1c1517b3c..6dfc2d1c6a68 100644 --- a/hw/arm/ipod_touch_fmss.c +++ b/hw/arm/ipod_touch_fmss.c @@ -1,5 +1,11 @@ #include "hw/arm/ipod_touch_fmss.h" +static void write_chip_info(IPodTouchFMSSState *s) +{ + uint32_t chipid[] = { 0xb614d5ad, 0xb614d5ad, 0xb614d5ad, 0xb614d5ad }; + cpu_physical_memory_write(s->reg_target_addr, &chipid, 0x10); +} + static uint64_t ipod_touch_fmss_read(void *opaque, hwaddr addr, unsigned size) { //fprintf(stderr, "%s: read from location 0x%08x\n", __func__, addr); @@ -10,7 +16,7 @@ static uint64_t ipod_touch_fmss_read(void *opaque, hwaddr addr, unsigned size) case FMSS__CS_BUF_RST_OK: return 0x1; case FMSS__CS_IRQ: - return 0x0; + return s->reg_cs_irq_bit; case FMSS__FMCTRL1: return (0x1 << 30); default: @@ -24,6 +30,21 @@ static void ipod_touch_fmss_write(void *opaque, hwaddr addr, uint64_t val, unsig { IPodTouchFMSSState *s = (IPodTouchFMSSState *)opaque; fprintf(stderr, "%s: writing 0x%08x to 0x%08x\n", __func__, val, addr); + + switch(addr) { + case 0xC00: + if(val == 0x0000ffb5) { s->reg_cs_irq_bit = 1; } // TODO ugly and hard-coded + break; + case FMSS__CS_IRQ: + if(val == 0xD) { s->reg_cs_irq_bit = 0; } // clear interrupt bit + break; + case FMSS_TARGET_ADDR: + s->reg_target_addr = val; + break; + case FMSS_CMD: // I assume this is a CMD register?? + if(val == 0x8) { write_chip_info(s); } + break; + } } static const MemoryRegionOps fmss_ops = { diff --git a/include/hw/arm/ipod_touch_fmss.h b/include/hw/arm/ipod_touch_fmss.h index 55e7c551ff78..000938371102 100644 --- a/include/hw/arm/ipod_touch_fmss.h +++ b/include/hw/arm/ipod_touch_fmss.h @@ -14,12 +14,16 @@ OBJECT_DECLARE_SIMPLE_TYPE(IPodTouchFMSSState, IPOD_TOUCH_FMSS) #define FMSS__FMCTRL1 0x4 #define FMSS__CS_IRQ 0xC0C #define FMSS__CS_BUF_RST_OK 0xC64 +#define FMSS_TARGET_ADDR 0xD08 +#define FMSS_CMD 0xD0C typedef struct IPodTouchFMSSState { SysBusDevice parent_obj; MemoryRegion iomem; qemu_irq irq; + uint32_t reg_cs_irq_bit; + uint32_t reg_target_addr; } IPodTouchFMSSState; #endif \ No newline at end of file