Skip to content

Commit

Permalink
Got some of the NAND initializations working
Browse files Browse the repository at this point in the history
  • Loading branch information
devos50 committed Feb 12, 2023
1 parent 463e8d8 commit 999255e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
23 changes: 22 additions & 1 deletion hw/arm/ipod_touch_fmss.c
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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:
Expand All @@ -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 = {
Expand Down
4 changes: 4 additions & 0 deletions include/hw/arm/ipod_touch_fmss.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 999255e

Please sign in to comment.