2007-04-30 05:48:07 +04:00
|
|
|
/*
|
|
|
|
* Intel XScale PXA255/270 PC Card and CompactFlash Interface.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006 Openedhand Ltd.
|
|
|
|
* Written by Andrzej Zaborowski <balrog@zabor.org>
|
|
|
|
*
|
|
|
|
* This code is licensed under the GPLv2.
|
2012-01-13 20:44:23 +04:00
|
|
|
*
|
|
|
|
* Contributions after 2012-01-13 are licensed under the terms of the
|
|
|
|
* GNU GPL, version 2 or (at your option) any later version.
|
2007-04-30 05:48:07 +04:00
|
|
|
*/
|
|
|
|
|
2016-01-26 21:17:05 +03:00
|
|
|
#include "qemu/osdep.h"
|
2019-08-12 08:23:42 +03:00
|
|
|
#include "hw/irq.h"
|
2013-08-03 14:23:05 +04:00
|
|
|
#include "hw/sysbus.h"
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:31:58 +03:00
|
|
|
#include "qapi/error.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/pcmcia.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/arm/pxa.h"
|
2007-04-30 05:48:07 +04:00
|
|
|
|
2009-05-10 04:44:56 +04:00
|
|
|
struct PXA2xxPCMCIAState {
|
2013-08-03 14:23:05 +04:00
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
2009-05-10 04:44:56 +04:00
|
|
|
PCMCIASocket slot;
|
2013-08-03 14:23:05 +04:00
|
|
|
MemoryRegion container_mem;
|
2011-10-30 17:50:12 +04:00
|
|
|
MemoryRegion common_iomem;
|
2011-10-30 17:50:13 +04:00
|
|
|
MemoryRegion attr_iomem;
|
2011-10-30 17:50:14 +04:00
|
|
|
MemoryRegion iomem;
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
qemu_irq irq;
|
|
|
|
qemu_irq cd_irq;
|
2013-08-03 14:23:05 +04:00
|
|
|
|
|
|
|
PCMCIACardState *card;
|
2007-04-30 05:48:07 +04:00
|
|
|
};
|
|
|
|
|
2011-10-30 17:50:12 +04:00
|
|
|
static uint64_t pxa2xx_pcmcia_common_read(void *opaque,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr offset, unsigned size)
|
2007-04-30 05:48:07 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
|
2013-07-17 21:46:16 +04:00
|
|
|
PCMCIACardClass *pcc;
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
if (s->slot.attached) {
|
2013-07-17 21:46:16 +04:00
|
|
|
pcc = PCMCIA_CARD_GET_CLASS(s->card);
|
|
|
|
return pcc->common_read(s->card, offset);
|
2007-04-30 05:48:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static void pxa2xx_pcmcia_common_write(void *opaque, hwaddr offset,
|
2011-10-30 17:50:12 +04:00
|
|
|
uint64_t value, unsigned size)
|
2007-04-30 05:48:07 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
|
2013-07-17 21:46:16 +04:00
|
|
|
PCMCIACardClass *pcc;
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
if (s->slot.attached) {
|
2013-07-17 21:46:16 +04:00
|
|
|
pcc = PCMCIA_CARD_GET_CLASS(s->card);
|
|
|
|
pcc->common_write(s->card, offset, value);
|
2007-04-30 05:48:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-30 17:50:13 +04:00
|
|
|
static uint64_t pxa2xx_pcmcia_attr_read(void *opaque,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr offset, unsigned size)
|
2007-04-30 05:48:07 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
|
2013-07-17 21:46:16 +04:00
|
|
|
PCMCIACardClass *pcc;
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
if (s->slot.attached) {
|
2013-07-17 21:46:16 +04:00
|
|
|
pcc = PCMCIA_CARD_GET_CLASS(s->card);
|
|
|
|
return pcc->attr_read(s->card, offset);
|
2007-04-30 05:48:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static void pxa2xx_pcmcia_attr_write(void *opaque, hwaddr offset,
|
2011-10-30 17:50:13 +04:00
|
|
|
uint64_t value, unsigned size)
|
2007-04-30 05:48:07 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
|
2013-07-17 21:46:16 +04:00
|
|
|
PCMCIACardClass *pcc;
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
if (s->slot.attached) {
|
2013-07-17 21:46:16 +04:00
|
|
|
pcc = PCMCIA_CARD_GET_CLASS(s->card);
|
|
|
|
pcc->attr_write(s->card, offset, value);
|
2007-04-30 05:48:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-30 17:50:14 +04:00
|
|
|
static uint64_t pxa2xx_pcmcia_io_read(void *opaque,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr offset, unsigned size)
|
2007-04-30 05:48:07 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
|
2013-07-17 21:46:16 +04:00
|
|
|
PCMCIACardClass *pcc;
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
if (s->slot.attached) {
|
2013-07-17 21:46:16 +04:00
|
|
|
pcc = PCMCIA_CARD_GET_CLASS(s->card);
|
|
|
|
return pcc->io_read(s->card, offset);
|
2007-04-30 05:48:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static void pxa2xx_pcmcia_io_write(void *opaque, hwaddr offset,
|
2011-10-30 17:50:14 +04:00
|
|
|
uint64_t value, unsigned size)
|
2007-04-30 05:48:07 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
|
2013-07-17 21:46:16 +04:00
|
|
|
PCMCIACardClass *pcc;
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
if (s->slot.attached) {
|
2013-07-17 21:46:16 +04:00
|
|
|
pcc = PCMCIA_CARD_GET_CLASS(s->card);
|
|
|
|
pcc->io_write(s->card, offset, value);
|
2007-04-30 05:48:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-30 17:50:12 +04:00
|
|
|
static const MemoryRegionOps pxa2xx_pcmcia_common_ops = {
|
|
|
|
.read = pxa2xx_pcmcia_common_read,
|
|
|
|
.write = pxa2xx_pcmcia_common_write,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN
|
2007-04-30 05:48:07 +04:00
|
|
|
};
|
|
|
|
|
2011-10-30 17:50:13 +04:00
|
|
|
static const MemoryRegionOps pxa2xx_pcmcia_attr_ops = {
|
|
|
|
.read = pxa2xx_pcmcia_attr_read,
|
|
|
|
.write = pxa2xx_pcmcia_attr_write,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN
|
2007-04-30 05:48:07 +04:00
|
|
|
};
|
|
|
|
|
2011-10-30 17:50:14 +04:00
|
|
|
static const MemoryRegionOps pxa2xx_pcmcia_io_ops = {
|
|
|
|
.read = pxa2xx_pcmcia_io_read,
|
|
|
|
.write = pxa2xx_pcmcia_io_write,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN
|
2007-04-30 05:48:07 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void pxa2xx_pcmcia_set_irq(void *opaque, int line, int level)
|
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
|
2007-04-30 05:48:07 +04:00
|
|
|
if (!s->irq)
|
|
|
|
return;
|
|
|
|
|
|
|
|
qemu_set_irq(s->irq, level);
|
|
|
|
}
|
|
|
|
|
2011-10-30 17:50:12 +04:00
|
|
|
PXA2xxPCMCIAState *pxa2xx_pcmcia_init(MemoryRegion *sysmem,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr base)
|
2007-04-30 05:48:07 +04:00
|
|
|
{
|
2013-08-03 14:23:05 +04:00
|
|
|
DeviceState *dev;
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxPCMCIAState *s;
|
2007-04-30 05:48:07 +04:00
|
|
|
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:31:58 +03:00
|
|
|
dev = qdev_new(TYPE_PXA2XX_PCMCIA);
|
2013-08-03 14:23:05 +04:00
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
|
|
|
|
s = PXA2XX_PCMCIA(dev);
|
|
|
|
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
|
2013-08-03 14:23:05 +04:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pxa2xx_pcmcia_initfn(Object *obj)
|
|
|
|
{
|
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
|
|
|
PXA2xxPCMCIAState *s = PXA2XX_PCMCIA(obj);
|
|
|
|
|
|
|
|
memory_region_init(&s->container_mem, obj, "container", 0x10000000);
|
|
|
|
sysbus_init_mmio(sbd, &s->container_mem);
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
/* Socket I/O Memory Space */
|
2015-10-01 11:59:51 +03:00
|
|
|
memory_region_init_io(&s->iomem, obj, &pxa2xx_pcmcia_io_ops, s,
|
2011-10-30 17:50:14 +04:00
|
|
|
"pxa2xx-pcmcia-io", 0x04000000);
|
2013-08-03 14:23:05 +04:00
|
|
|
memory_region_add_subregion(&s->container_mem, 0x00000000,
|
2011-10-30 17:50:14 +04:00
|
|
|
&s->iomem);
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
/* Then next 64 MB is reserved */
|
|
|
|
|
|
|
|
/* Socket Attribute Memory Space */
|
2015-10-01 11:59:51 +03:00
|
|
|
memory_region_init_io(&s->attr_iomem, obj, &pxa2xx_pcmcia_attr_ops, s,
|
2011-10-30 17:50:13 +04:00
|
|
|
"pxa2xx-pcmcia-attribute", 0x04000000);
|
2013-08-03 14:23:05 +04:00
|
|
|
memory_region_add_subregion(&s->container_mem, 0x08000000,
|
2011-10-30 17:50:13 +04:00
|
|
|
&s->attr_iomem);
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
/* Socket Common Memory Space */
|
2015-10-01 11:59:51 +03:00
|
|
|
memory_region_init_io(&s->common_iomem, obj, &pxa2xx_pcmcia_common_ops, s,
|
2011-10-30 17:50:12 +04:00
|
|
|
"pxa2xx-pcmcia-common", 0x04000000);
|
2013-08-03 14:23:05 +04:00
|
|
|
memory_region_add_subregion(&s->container_mem, 0x0c000000,
|
2011-10-30 17:50:12 +04:00
|
|
|
&s->common_iomem);
|
2007-04-30 05:48:07 +04:00
|
|
|
|
2014-06-18 11:55:18 +04:00
|
|
|
s->slot.irq = qemu_allocate_irq(pxa2xx_pcmcia_set_irq, s, 0);
|
2007-05-24 01:47:51 +04:00
|
|
|
|
2013-08-03 14:23:05 +04:00
|
|
|
object_property_add_link(obj, "card", TYPE_PCMCIA_CARD,
|
2014-03-19 11:58:56 +04:00
|
|
|
(Object **)&s->card,
|
|
|
|
NULL, /* read-only property */
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
0);
|
2007-04-30 05:48:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Insert a new card into a slot */
|
2009-05-10 04:44:56 +04:00
|
|
|
int pxa2xx_pcmcia_attach(void *opaque, PCMCIACardState *card)
|
2007-04-30 05:48:07 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
|
2013-07-17 21:46:16 +04:00
|
|
|
PCMCIACardClass *pcc;
|
|
|
|
|
|
|
|
if (s->slot.attached) {
|
2007-04-30 05:48:07 +04:00
|
|
|
return -EEXIST;
|
2013-07-17 21:46:16 +04:00
|
|
|
}
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
if (s->cd_irq) {
|
|
|
|
qemu_irq_raise(s->cd_irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
s->card = card;
|
2013-07-17 21:46:16 +04:00
|
|
|
pcc = PCMCIA_CARD_GET_CLASS(s->card);
|
2007-04-30 05:48:07 +04:00
|
|
|
|
2013-07-17 21:46:16 +04:00
|
|
|
s->slot.attached = true;
|
2007-04-30 05:48:07 +04:00
|
|
|
s->card->slot = &s->slot;
|
2013-07-17 21:46:16 +04:00
|
|
|
pcc->attach(s->card);
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Eject card from the slot */
|
2013-07-17 21:06:47 +04:00
|
|
|
int pxa2xx_pcmcia_detach(void *opaque)
|
2007-04-30 05:48:07 +04:00
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
|
2013-07-17 21:46:16 +04:00
|
|
|
PCMCIACardClass *pcc;
|
|
|
|
|
|
|
|
if (!s->slot.attached) {
|
2007-04-30 05:48:07 +04:00
|
|
|
return -ENOENT;
|
2013-07-17 21:46:16 +04:00
|
|
|
}
|
2007-04-30 05:48:07 +04:00
|
|
|
|
2013-07-17 21:46:16 +04:00
|
|
|
pcc = PCMCIA_CARD_GET_CLASS(s->card);
|
|
|
|
pcc->detach(s->card);
|
2009-09-21 22:11:34 +04:00
|
|
|
s->card->slot = NULL;
|
|
|
|
s->card = NULL;
|
2007-04-30 05:48:07 +04:00
|
|
|
|
2013-07-17 21:46:16 +04:00
|
|
|
s->slot.attached = false;
|
2007-04-30 05:48:07 +04:00
|
|
|
|
2013-07-17 21:46:16 +04:00
|
|
|
if (s->irq) {
|
2007-04-30 05:48:07 +04:00
|
|
|
qemu_irq_lower(s->irq);
|
2013-07-17 21:46:16 +04:00
|
|
|
}
|
|
|
|
if (s->cd_irq) {
|
2007-04-30 05:48:07 +04:00
|
|
|
qemu_irq_lower(s->cd_irq);
|
2013-07-17 21:46:16 +04:00
|
|
|
}
|
2007-04-30 05:48:07 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Who to notify on card events */
|
|
|
|
void pxa2xx_pcmcia_set_irq_cb(void *opaque, qemu_irq irq, qemu_irq cd_irq)
|
|
|
|
{
|
2009-05-10 04:44:56 +04:00
|
|
|
PXA2xxPCMCIAState *s = (PXA2xxPCMCIAState *) opaque;
|
2007-04-30 05:48:07 +04:00
|
|
|
s->irq = irq;
|
|
|
|
s->cd_irq = cd_irq;
|
|
|
|
}
|
2013-08-03 14:23:05 +04:00
|
|
|
|
|
|
|
static const TypeInfo pxa2xx_pcmcia_type_info = {
|
|
|
|
.name = TYPE_PXA2XX_PCMCIA,
|
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(PXA2xxPCMCIAState),
|
|
|
|
.instance_init = pxa2xx_pcmcia_initfn,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void pxa2xx_pcmcia_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&pxa2xx_pcmcia_type_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
type_init(pxa2xx_pcmcia_register_types)
|