From nobody Fri May 3 06:49:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1561574765; cv=none; d=zoho.com; s=zohoarc; b=OA2SQtrLeE7OVXMY+hKm1/ZoMHkdr8tSVWLo+j09MfmYmEPVyYl0SnBONEO/kttKKg9UOxDp8K0wmF+mqaKutOmXUD4nEMTV/LMciHvjx7uLZElxELmc1MESbfOH8mOhufkPuFfrSxjY/zeizoRBlZqDRP1o8+n0wTUoQ67FI5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561574765; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=3tHSTBwW32tzpU6aLeXyo7tegUbzIerwIsPT8vv0B0k=; b=CrTWi+fsStb/54THbx5rpYtkQLX23j5yqH/Qi1R4DPvYj3IX9PVXwj/23jAwcLJQdbXimRQEqC7P5Qi6p75O6LE/uUwtmcyrFZ000brv5PfcBQINkThCPBW213aHvJuY9DD3YJUQ2T3yqPukUXMTRJHEYgiikmDc5uqtvhBCOhA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561574765708844.3237799004979; Wed, 26 Jun 2019 11:46:05 -0700 (PDT) Received: from localhost ([::1]:44286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgCvf-0007gU-2P for importer@patchew.org; Wed, 26 Jun 2019 14:45:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47269) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgCtQ-00060E-QD for qemu-devel@nongnu.org; Wed, 26 Jun 2019 14:43:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgCtO-0005Dh-Iw for qemu-devel@nongnu.org; Wed, 26 Jun 2019 14:43:40 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:9860 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgCtO-00058I-C0 for qemu-devel@nongnu.org; Wed, 26 Jun 2019 14:43:38 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5QIfr2r045635 for ; Wed, 26 Jun 2019 14:43:32 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tcddrt9c8-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 26 Jun 2019 14:43:32 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Jun 2019 19:43:31 +0100 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 26 Jun 2019 19:43:28 +0100 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x5QIhSln13173406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jun 2019 18:43:28 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E449F28058; Wed, 26 Jun 2019 18:43:27 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3843C2805A; Wed, 26 Jun 2019 18:43:27 +0000 (GMT) Received: from talon7.ibm.com (unknown [9.41.179.222]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 26 Jun 2019 18:43:27 +0000 (GMT) From: Eddie James To: qemu-arm@nongnu.org Date: Wed, 26 Jun 2019 13:43:24 -0500 X-Mailer: git-send-email 1.8.3.1 X-TM-AS-GCONF: 00 x-cbid: 19062618-2213-0000-0000-000003A56092 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011336; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01223650; UDB=6.00643968; IPR=6.01004829; MB=3.00027479; MTD=3.00000008; XFM=3.00000015; UTC=2019-06-26 18:43:31 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19062618-2214-0000-0000-00005F01B89F Message-Id: <1561574604-1204-1-git-send-email-eajames@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-26_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906260216 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH] hw/sd/aspeed_sdhci: New device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, andrew@aj.id.au, Eddie James , qemu-devel@nongnu.org, clg@kaod.org, philmd@redhat.com, joel@jms.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The Aspeed SOCs have two SD/MMC controllers. Add a device that encapsulates both of these controllers and models the Aspeed-specific registers and behavior. Both controllers use a single HW interrupt. In order to trigger that interrupt, a function pointer was added to the generic SDHCI structure. This function (if the pointer is set) is called when the SDHCI model changes it's interrupt status, allowing the user (the Aspeed SDHCI model in this case) to set it's own interrupt. This goes on top of Cedric's set of Aspeed changes. Tested, booted, and read from /dev/mmcblk0 and /dev/mmcblk1: ./arm-softmmu/qemu-system-arm -M ast2500-evb -nographic \ -drive file=3Dflash-romulus,format=3Draw,if=3Dmtd \ -drive file=3D,format=3Draw,if=3Dsd \ -drive file=3D,format=3Draw,if=3Dsd \ -kernel zImage \ -dtb aspeed-ast2500-evb.dtb \ -initrd romulus.cpio.lzma \ -d trace:sdhci* -no-reboot Signed-off-by: Eddie James --- hw/arm/aspeed.c | 1 - hw/arm/aspeed_soc.c | 67 ++++++++++++++++++ hw/sd/Makefile.objs | 1 + hw/sd/aspeed_sdhci.c | 163 +++++++++++++++++++++++++++++++++++++++= ++++ hw/sd/sdhci.c | 8 ++- include/hw/arm/aspeed_soc.h | 3 + include/hw/sd/aspeed_sdhci.h | 39 +++++++++++ include/hw/sd/sdhci.h | 1 + 8 files changed, 281 insertions(+), 2 deletions(-) create mode 100644 hw/sd/aspeed_sdhci.c create mode 100644 include/hw/sd/aspeed_sdhci.h diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 5fee2f5..fbec946 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -422,7 +422,6 @@ static void aspeed_machine_class_init(ObjectClass *oc, = void *data) mc->desc =3D board->desc; mc->init =3D aspeed_machine_init; mc->max_cpus =3D ASPEED_CPUS_NUM; - mc->no_sdcard =3D 1; mc->no_floppy =3D 1; mc->no_cdrom =3D 1; mc->no_parallel =3D 1; diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c index 1bbbdae..1378498 100644 --- a/hw/arm/aspeed_soc.c +++ b/hw/arm/aspeed_soc.c @@ -22,6 +22,7 @@ #include "qemu/error-report.h" #include "hw/i2c/aspeed_i2c.h" #include "net/net.h" +#include "sysemu/blockdev.h" =20 #define ASPEED_SOC_IOMEM_SIZE 0x00200000 =20 @@ -62,6 +63,7 @@ static const hwaddr aspeed_soc_ast2500_memmap[] =3D { [ASPEED_XDMA] =3D 0x1E6E7000, [ASPEED_ADC] =3D 0x1E6E9000, [ASPEED_SRAM] =3D 0x1E720000, + [ASPEED_SDHCI] =3D 0x1E740000, [ASPEED_GPIO] =3D 0x1E780000, [ASPEED_RTC] =3D 0x1E781000, [ASPEED_TIMER1] =3D 0x1E782000, @@ -142,6 +144,7 @@ static const int aspeed_soc_ast2400_irqmap[] =3D { [ASPEED_ETH1] =3D 2, [ASPEED_ETH2] =3D 3, [ASPEED_XDMA] =3D 6, + [ASPEED_SDHCI] =3D 26, }; =20 #define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap @@ -378,6 +381,16 @@ static void aspeed_soc_init(Object *obj) sysbus_init_child_obj(obj, "fsi[*]", OBJECT(&s->fsi[0]), sizeof(s->fsi[0]), TYPE_ASPEED_FSI); } + + sysbus_init_child_obj(obj, "sdhci", OBJECT(&s->sdhci), sizeof(s->sdhci= ), + TYPE_ASPEED_SDHCI); + + for (i =3D 0; i < ASPEED_SDHCI_NUM_SLOTS; ++i) { + sysbus_init_child_obj(obj, "sdhci_slot[*]", + OBJECT(&s->sdhci.slots[i].sdhci), + sizeof(s->sdhci.slots[i].sdhci), + TYPE_SYSBUS_SDHCI); + } } =20 static void aspeed_soc_realize(DeviceState *dev, Error **errp) @@ -699,6 +712,60 @@ static void aspeed_soc_realize(DeviceState *dev, Error= **errp) sysbus_connect_irq(SYS_BUS_DEVICE(&s->fsi[0]), 0, aspeed_soc_get_irq(s, ASPEED_FSI1)); } + + /* SD/SDIO */ + for (i =3D 0; i < ASPEED_SDHCI_NUM_SLOTS; i++) { + hwaddr hci_addr =3D sc->info->memmap[ASPEED_SDHCI] + (0x100 * (i += 1)); + DriveInfo *di; + BlockBackend *blk; + DeviceState *card; + + /* + * Compatible with: + * - SD Host Controller Specification Version 2.0 + * - SDIO Specification Version 2.0 + * - MMC Specification Version 4.3 + */ + object_property_set_int(OBJECT(&s->sdhci.slots[i].sdhci), 2, + "sd-spec-version", &err); + if (err) { + error_propagate(errp, err); + return; + } + + object_property_set_uint(OBJECT(&s->sdhci.slots[i].sdhci), + ASPEED_SDHCI_CAPABILITIES, "capareg", &er= r); + if (err) { + error_propagate(errp, err); + return; + } + + object_property_set_bool(OBJECT(&s->sdhci.slots[i].sdhci), true, + "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } + + sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci.slots[i].sdhci), 0, hci_a= ddr); + + di =3D drive_get_next(IF_SD); + blk =3D di ? blk_by_legacy_dinfo(di) : NULL; + card =3D qdev_create(qdev_get_child_bus(DEVICE(&s->sdhci.slots[i].= sdhci), + "sd-bus"), TYPE_SD_CARD); + qdev_prop_set_drive(card, "drive", blk, &error_fatal); + object_property_set_bool(OBJECT(card), true, "realized", &error_fa= tal); + } + + object_property_set_bool(OBJECT(&s->sdhci), true, "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0, + sc->info->memmap[ASPEED_SDHCI]); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, + aspeed_soc_get_irq(s, ASPEED_SDHCI)); } static Property aspeed_soc_properties[] =3D { DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), diff --git a/hw/sd/Makefile.objs b/hw/sd/Makefile.objs index 0665727..a884c23 100644 --- a/hw/sd/Makefile.objs +++ b/hw/sd/Makefile.objs @@ -8,3 +8,4 @@ obj-$(CONFIG_MILKYMIST) +=3D milkymist-memcard.o obj-$(CONFIG_OMAP) +=3D omap_mmc.o obj-$(CONFIG_PXA2XX) +=3D pxa2xx_mmci.o obj-$(CONFIG_RASPI) +=3D bcm2835_sdhost.o +obj-$(CONFIG_ASPEED_SOC) +=3D aspeed_sdhci.o diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c new file mode 100644 index 0000000..f684b12 --- /dev/null +++ b/hw/sd/aspeed_sdhci.c @@ -0,0 +1,163 @@ +/* + * Aspeed SD Host Controller + * Eddie James + * + * Copyright (C) 2019 IBM Corp + * SPDX-License-Identifer: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/error-report.h" +#include "hw/sd/aspeed_sdhci.h" +#include "qapi/error.h" + +#define ASPEED_SDHCI_INFO 0x00 +#define ASPEED_SDHCI_INFO_RESET 0x00030000 +#define ASPEED_SDHCI_DEBOUNCE 0x04 +#define ASPEED_SDHCI_DEBOUNCE_RESET 0x00000005 +#define ASPEED_SDHCI_BUS 0x08 +#define ASPEED_SDHCI_SDIO_140 0x10 +#define ASPEED_SDHCI_SDIO_148 0x18 +#define ASPEED_SDHCI_SDIO_240 0x20 +#define ASPEED_SDHCI_SDIO_248 0x28 +#define ASPEED_SDHCI_WP_POL 0xec +#define ASPEED_SDHCI_CARD_DET 0xf0 +#define ASPEED_SDHCI_IRQ_STAT 0xfc + +#define TO_REG(addr) ((addr) / sizeof(uint32_t)) + +static uint64_t aspeed_sdhci_read(void *opaque, hwaddr addr, unsigned int = size) +{ + uint32_t val =3D 0; + AspeedSDHCIState *sdhci =3D opaque; + + switch (addr) { + case ASPEED_SDHCI_SDIO_140: + val =3D (uint32_t)sdhci->slots[0].sdhci.capareg; + break; + case ASPEED_SDHCI_SDIO_148: + val =3D (uint32_t)sdhci->slots[0].sdhci.maxcurr; + break; + case ASPEED_SDHCI_SDIO_240: + val =3D (uint32_t)sdhci->slots[1].sdhci.capareg; + break; + case ASPEED_SDHCI_SDIO_248: + val =3D (uint32_t)sdhci->slots[1].sdhci.maxcurr; + break; + default: + if (addr < ASPEED_SDHCI_REG_SIZE) { + val =3D sdhci->regs[TO_REG(addr)]; + } + } + + return (uint64_t)val; +} + +static void aspeed_sdhci_write(void *opaque, hwaddr addr, uint64_t val, + unsigned int size) +{ + AspeedSDHCIState *sdhci =3D opaque; + + switch (addr) { + case ASPEED_SDHCI_SDIO_140: + sdhci->slots[0].sdhci.capareg =3D (uint64_t)(uint32_t)val; + break; + case ASPEED_SDHCI_SDIO_148: + sdhci->slots[0].sdhci.maxcurr =3D (uint64_t)(uint32_t)val; + break; + case ASPEED_SDHCI_SDIO_240: + sdhci->slots[1].sdhci.capareg =3D (uint64_t)(uint32_t)val; + break; + case ASPEED_SDHCI_SDIO_248: + sdhci->slots[1].sdhci.maxcurr =3D (uint64_t)(uint32_t)val; + break; + default: + if (addr < ASPEED_SDHCI_REG_SIZE) { + sdhci->regs[TO_REG(addr)] =3D (uint32_t)val; + } + } +} + +static const MemoryRegionOps aspeed_sdhci_ops =3D { + .read =3D aspeed_sdhci_read, + .write =3D aspeed_sdhci_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .valid.min_access_size =3D 4, + .valid.max_access_size =3D 4, +}; + +static void aspeed_sdhci_irq_notify(SDHCIState *s, int level) +{ + AspeedSDHCISlotState *as =3D container_of(s, AspeedSDHCISlotState, sdh= ci); + AspeedSDHCIState *sdhci =3D container_of(as, AspeedSDHCIState, + slots[as->slot]); + + if (level) { + sdhci->regs[TO_REG(ASPEED_SDHCI_IRQ_STAT)] |=3D BIT(as->slot); + + qemu_irq_raise(sdhci->irq); + } else { + sdhci->regs[TO_REG(ASPEED_SDHCI_IRQ_STAT)] &=3D ~BIT(as->slot); + + qemu_irq_lower(sdhci->irq); + } +} + +static void aspeed_sdhci_realize(DeviceState *dev, Error **errp) +{ + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + AspeedSDHCIState *sdhci =3D ASPEED_SDHCI(dev); + + sysbus_init_irq(sbd, &sdhci->irq); + memory_region_init_io(&sdhci->iomem, OBJECT(sdhci), &aspeed_sdhci_ops, + sdhci, TYPE_ASPEED_SDHCI, ASPEED_SDHCI_REG_SIZE); + sysbus_init_mmio(sbd, &sdhci->iomem); + + sdhci->slots[0].slot =3D 0; + sdhci->slots[0].sdhci.irq_notify =3D aspeed_sdhci_irq_notify; + + sdhci->slots[1].slot =3D 1; + sdhci->slots[1].sdhci.irq_notify =3D aspeed_sdhci_irq_notify; +} + +static void aspeed_sdhci_reset(DeviceState *dev) +{ + AspeedSDHCIState *sdhci =3D ASPEED_SDHCI(dev); + + memset(sdhci->regs, 0, ASPEED_SDHCI_REG_SIZE); + sdhci->regs[TO_REG(ASPEED_SDHCI_INFO)] =3D ASPEED_SDHCI_INFO_RESET; + sdhci->regs[TO_REG(ASPEED_SDHCI_DEBOUNCE)] =3D ASPEED_SDHCI_DEBOUNCE_R= ESET; +} + +static const VMStateDescription vmstate_aspeed_sdhci =3D { + .name =3D TYPE_ASPEED_SDHCI, + .version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32_ARRAY(regs, AspeedSDHCIState, ASPEED_SDHCI_NUM_REGS= ), + VMSTATE_END_OF_LIST(), + }, +}; + +static void aspeed_sdhci_class_init(ObjectClass *classp, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(classp); + + dc->realize =3D aspeed_sdhci_realize; + dc->reset =3D aspeed_sdhci_reset; + dc->vmsd =3D &vmstate_aspeed_sdhci; +} + +static TypeInfo aspeed_sdhci_info =3D { + .name =3D TYPE_ASPEED_SDHCI, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(AspeedSDHCIState), + .class_init =3D aspeed_sdhci_class_init, +}; + +static void aspeed_sdhci_register_types(void) +{ + type_register_static(&aspeed_sdhci_info); +} + +type_init(aspeed_sdhci_register_types) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 7b80b1d..51a733b 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -213,7 +213,13 @@ static uint8_t sdhci_slotint(SDHCIState *s) =20 static inline void sdhci_update_irq(SDHCIState *s) { - qemu_set_irq(s->irq, sdhci_slotint(s)); + int level =3D sdhci_slotint(s); + + qemu_set_irq(s->irq, level); + + if (s->irq_notify) { + s->irq_notify(s, level); + } } =20 static void sdhci_raise_insertion_irq(void *opaque) diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h index 7abb394..ba0f72f 100644 --- a/include/hw/arm/aspeed_soc.h +++ b/include/hw/arm/aspeed_soc.h @@ -29,6 +29,7 @@ #include "hw/misc/aspeed_pwm.h" #include "hw/misc/aspeed_lpc.h" #include "hw/misc/aspeed_fsi.h" +#include "hw/sd/aspeed_sdhci.h" =20 #define ASPEED_SPIS_NUM 2 #define ASPEED_WDTS_NUM 4 @@ -62,6 +63,7 @@ typedef struct AspeedSoCState { AspeedPWMState pwm; AspeedLPCState lpc; AspeedFsiState fsi[2]; + AspeedSDHCIState sdhci; } AspeedSoCState; =20 #define TYPE_ASPEED_SOC "aspeed-soc" @@ -108,6 +110,7 @@ enum { ASPEED_SCU, ASPEED_ADC, ASPEED_SRAM, + ASPEED_SDHCI, ASPEED_GPIO, ASPEED_RTC, ASPEED_TIMER1, diff --git a/include/hw/sd/aspeed_sdhci.h b/include/hw/sd/aspeed_sdhci.h new file mode 100644 index 0000000..67fb7ef --- /dev/null +++ b/include/hw/sd/aspeed_sdhci.h @@ -0,0 +1,39 @@ +/* + * Aspeed SD Host Controller + * Eddie James + * + * Copyright (C) 2019 IBM Corp + * SPDX-License-Identifer: GPL-2.0-or-later + */ + +#ifndef ASPEED_SDHCI_H +#define ASPEED_SDHCI_H + +#include "hw/sd/sdhci.h" + +#define TYPE_ASPEED_SDHCI "aspeed.sdhci" +#define ASPEED_SDHCI(obj) OBJECT_CHECK(AspeedSDHCIState, (obj), \ + TYPE_ASPEED_SDHCI) + +#define ASPEED_SDHCI_CAPABILITIES 0x01E80080 +#define ASPEED_SDHCI_NUM_SLOTS 2 +#define ASPEED_SDHCI_NUM_REGS (ASPEED_SDHCI_REG_SIZE / sizeof(uint32_t= )) +#define ASPEED_SDHCI_REG_SIZE 0x100 + +typedef struct AspeedSDHCISlotState { + SDHCIState sdhci; + int slot; +} AspeedSDHCISlotState; + +typedef struct AspeedSDHCIState { + SysBusDevice parent; + + AspeedSDHCISlotState slots[ASPEED_SDHCI_NUM_SLOTS]; + + MemoryRegion iomem; + qemu_irq irq; + + uint32_t regs[ASPEED_SDHCI_NUM_REGS]; +} AspeedSDHCIState; + +#endif /* ASPEED_SDHCI_H */ diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h index cbf415e..90dbf7b 100644 --- a/include/hw/sd/sdhci.h +++ b/include/hw/sd/sdhci.h @@ -48,6 +48,7 @@ typedef struct SDHCIState { QEMUTimer *insert_timer; /* timer for 'changing' sd card. */ QEMUTimer *transfer_timer; qemu_irq irq; + void (*irq_notify)(struct SDHCIState *s, int level); =20 /* Registers cleared on reset */ uint32_t sdmasysad; /* SDMA System Address register */ --=20 1.8.3.1