Revision 1a072690 hw/omap_spi.c

b/hw/omap_spi.c
24 24

  
25 25
/* Multichannel SPI */
26 26
struct omap_mcspi_s {
27
    MemoryRegion iomem;
27 28
    qemu_irq irq;
28 29
    int chnum;
29 30

  
......
129 130
    omap_mcspi_interrupt_update(s);
130 131
}
131 132

  
132
static uint32_t omap_mcspi_read(void *opaque, target_phys_addr_t addr)
133
static uint64_t omap_mcspi_read(void *opaque, target_phys_addr_t addr,
134
                                unsigned size)
133 135
{
134 136
    struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque;
135 137
    int ch = 0;
136 138
    uint32_t ret;
137 139

  
140
    if (size != 4) {
141
        return omap_badwidth_read32(opaque, addr);
142
    }
143

  
138 144
    switch (addr) {
139 145
    case 0x00:	/* MCSPI_REVISION */
140 146
        return 0x91;
......
199 205
}
200 206

  
201 207
static void omap_mcspi_write(void *opaque, target_phys_addr_t addr,
202
                uint32_t value)
208
                             uint64_t value, unsigned size)
203 209
{
204 210
    struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque;
205 211
    int ch = 0;
206 212

  
213
    if (size != 4) {
214
        return omap_badwidth_write32(opaque, addr, value);
215
    }
216

  
207 217
    switch (addr) {
208 218
    case 0x00:	/* MCSPI_REVISION */
209 219
    case 0x14:	/* MCSPI_SYSSTATUS */
......
267 277
        if (((value >> 12) & 3) == 3)			/* TRM */
268 278
            fprintf(stderr, "%s: invalid TRM value (3)\n", __FUNCTION__);
269 279
        if (((value >> 7) & 0x1f) < 3)			/* WL */
270
            fprintf(stderr, "%s: invalid WL value (%i)\n",
280
            fprintf(stderr, "%s: invalid WL value (%" PRIx64 ")\n",
271 281
                            __FUNCTION__, (value >> 7) & 0x1f);
272 282
        s->ch[ch].config = value & 0x7fffff;
273 283
        break;
......
298 308
    }
299 309
}
300 310

  
301
static CPUReadMemoryFunc * const omap_mcspi_readfn[] = {
302
    omap_badwidth_read32,
303
    omap_badwidth_read32,
304
    omap_mcspi_read,
305
};
306

  
307
static CPUWriteMemoryFunc * const omap_mcspi_writefn[] = {
308
    omap_badwidth_write32,
309
    omap_badwidth_write32,
310
    omap_mcspi_write,
311
static const MemoryRegionOps omap_mcspi_ops = {
312
    .read = omap_mcspi_read,
313
    .write = omap_mcspi_write,
314
    .endianness = DEVICE_NATIVE_ENDIAN,
311 315
};
312 316

  
313 317
struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum,
314 318
                qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk)
315 319
{
316
    int iomemtype;
317 320
    struct omap_mcspi_s *s = (struct omap_mcspi_s *)
318 321
            g_malloc0(sizeof(struct omap_mcspi_s));
319 322
    struct omap_mcspi_ch_s *ch = s->ch;
......
327 330
    }
328 331
    omap_mcspi_reset(s);
329 332

  
330
    iomemtype = cpu_register_io_memory(omap_mcspi_readfn,
331
                    omap_mcspi_writefn, s, DEVICE_NATIVE_ENDIAN);
332
    omap_l4_attach(ta, 0, iomemtype);
333
    memory_region_init_io(&s->iomem, &omap_mcspi_ops, s, "omap.mcspi",
334
                          omap_l4_region_size(ta, 0));
335
    omap_l4_attach_region(ta, 0, &s->iomem);
333 336

  
334 337
    return s;
335 338
}

Also available in: Unified diff