From nobody Sun Nov 24 03:28:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1727801110; cv=none; d=zohomail.com; s=zohoarc; b=MptNqUaQBYCKjLavcN15JPwxyKromhrtVPbeBNi6LgxZoutqiwWVRQK8qvxxogkQFQqgiMIROImMC1na0bVEd7d+5rb6+PDotHg6B0b8gatW/ehv3/dNQ1vSMwTiMfTBVkWKubMTl8whYxJBkIF/GgE6L7PVgBtOsSVQxOBArug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727801110; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=ocY2AihY2nS8wlo3QN2yGRF++YOPczfHqIYOMUcTMuI=; b=T+xcb8jeWfH9u5VF/cIFYv332AIlQ5qIpF446ia8aUsD2SnmLw7cieIQVgXpFGDbUuveL7Vq6SVPPMnq+znY+gdfCmfbJHg0xU0OXj4GsRyKxoGgTrH683L0Wpo+8be5kkiKphmjNhuibZ7e5FcCs+HpGwMR27WMi4Rl9lfTVxg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727801110611893.4643338296567; Tue, 1 Oct 2024 09:45:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1svfuU-0005OZ-0K; Tue, 01 Oct 2024 12:39:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1svfuS-0005No-BD for qemu-devel@nongnu.org; Tue, 01 Oct 2024 12:39:36 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1svfuO-00062x-Do for qemu-devel@nongnu.org; Tue, 01 Oct 2024 12:39:36 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-37ce6a5b785so1686145f8f.1 for ; Tue, 01 Oct 2024 09:39:32 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd56e6547sm12243771f8f.58.2024.10.01.09.39.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 09:39:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727800771; x=1728405571; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ocY2AihY2nS8wlo3QN2yGRF++YOPczfHqIYOMUcTMuI=; b=BinHN4GaPiIWCTrmRynsuxb4j2RxwK4Knr3I4Sx1uCl+PJUOXvl3oQfrLyLo96O3TQ Bf0vfKCEPlGs/j9oLQO2YNSWowLXwHN+10NyDDgZ/TauDRarRno6yjy0IMex5yZGc0DH G+0ftM98pe6tRkU+hiAdkQS9h8nHblUUHlFx1ZmE9HuaAWWcq8y++G7TJ67XvT06YO9s ka1EuP0LKwzsFuiBSlxjkP6jYRBvSiZh4wKB4iA9Y9bTB30NiN96Ll2G8T1EPm0Fm4VF B8Cw932vjgsz5TH3DI6F87xuAPeCYGMGFFvLaaFrIjIJgdkb35QQd36+i28OQRqLSvWl NPSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727800771; x=1728405571; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ocY2AihY2nS8wlo3QN2yGRF++YOPczfHqIYOMUcTMuI=; b=xOb83WLh43ThY/Kj3URi5v99XTJnXiO7A6S3tlFEvzifgQM2z1SO8stfT/37KiFgCh 5y7ITE0WojKVBv6dL+eWE3LZ9hVITmX+oyCYhUpYuTGQMHR0iTC7F7FgXxMkkSgUaJVw aHVCjwJ2iTWd9nSH9iyjn1+/m326tLNSY6bsQXDC+ltQOymgI4L6C3g+IPONMgM14r32 SCRPhpT7VUewTRPsPIdYpkpzZOljZwHF7nOiz3a77uNmraZ3kYDewHCLke/RP4LDW0UO MmAgI4zauVaFlcwViXZKYWjQ+6jD298WpAoeGQCK874co+mc1Bm886fnn1alazzYnCHJ P+wA== X-Gm-Message-State: AOJu0Yzh9HUe9tXy9m/RZ+KvXtGGnGPGAFsRyO3XXH66uX2KWzqDQp8k xrKCgR47jdZl4UadDU1n4Nzsqm6TC1ILsEevs9++yWSKmWb25P9bM0EU3Os6zAC80/mYkzBjT3y c X-Google-Smtp-Source: AGHT+IFPJWJXWWC0eQM6/PUQi5GvKb+kMNVJgWA2sP/Miokx/A1GqLf6s9IqQnf5cobBaJ6SvQWJlw== X-Received: by 2002:a5d:660b:0:b0:374:adf1:9232 with SMTP id ffacd0b85a97d-37cfb9e00d7mr130710f8f.19.1727800770771; Tue, 01 Oct 2024 09:39:30 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/54] hw/sd: Remove pxa2xx_mmci.c Date: Tue, 1 Oct 2024 17:38:44 +0100 Message-Id: <20241001163918.1275441-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241001163918.1275441-1-peter.maydell@linaro.org> References: <20241001163918.1275441-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1727801111206116600 Remove the pxa2xx-specific pxa2xx_mmci device. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20240903160751.4100218-17-peter.maydell@linaro.org --- include/hw/arm/pxa.h | 10 - hw/sd/pxa2xx_mmci.c | 594 ------------------------------------------- hw/sd/meson.build | 1 - hw/sd/trace-events | 4 - 4 files changed, 609 deletions(-) delete mode 100644 hw/sd/pxa2xx_mmci.c diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h index bf7f868700a..cc4de0750af 100644 --- a/include/hw/arm/pxa.h +++ b/include/hw/arm/pxa.h @@ -86,16 +86,6 @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem, hwaddr base, qemu_irq irq); void pxa2xx_lcd_vsync_notifier(PXA2xxLCDState *s, qemu_irq handler); =20 -/* pxa2xx_mmci.c */ -#define TYPE_PXA2XX_MMCI "pxa2xx-mmci" -OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxMMCIState, PXA2XX_MMCI) - -PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem, - hwaddr base, - qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma); -void pxa2xx_mmci_handlers(PXA2xxMMCIState *s, qemu_irq readonly, - qemu_irq coverswitch); - /* pxa2xx_pcmcia.c */ #define TYPE_PXA2XX_PCMCIA "pxa2xx-pcmcia" OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxPCMCIAState, PXA2XX_PCMCIA) diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c deleted file mode 100644 index a834be7cb12..00000000000 --- a/hw/sd/pxa2xx_mmci.c +++ /dev/null @@ -1,594 +0,0 @@ -/* - * Intel XScale PXA255/270 MultiMediaCard/SD/SDIO Controller emulation. - * - * Copyright (c) 2006 Openedhand Ltd. - * Written by Andrzej Zaborowski - * - * This code is licensed under the GPLv2. - * - * Contributions after 2012-01-13 are licensed under the terms of the - * GNU GPL, version 2 or (at your option) any later version. - */ - -#include "qemu/osdep.h" -#include "qapi/error.h" -#include "hw/irq.h" -#include "hw/sysbus.h" -#include "migration/vmstate.h" -#include "hw/arm/pxa.h" -#include "hw/sd/sd.h" -#include "hw/qdev-properties.h" -#include "qemu/log.h" -#include "qemu/module.h" -#include "trace.h" -#include "qom/object.h" - -#define TYPE_PXA2XX_MMCI_BUS "pxa2xx-mmci-bus" -/* This is reusing the SDBus typedef from SD_BUS */ -DECLARE_INSTANCE_CHECKER(SDBus, PXA2XX_MMCI_BUS, - TYPE_PXA2XX_MMCI_BUS) - -struct PXA2xxMMCIState { - SysBusDevice parent_obj; - - MemoryRegion iomem; - qemu_irq irq; - qemu_irq rx_dma; - qemu_irq tx_dma; - qemu_irq inserted; - qemu_irq readonly; - - BlockBackend *blk; - SDBus sdbus; - - uint32_t status; - uint32_t clkrt; - uint32_t spi; - uint32_t cmdat; - uint32_t resp_tout; - uint32_t read_tout; - int32_t blklen; - int32_t numblk; - uint32_t intmask; - uint32_t intreq; - int32_t cmd; - uint32_t arg; - - int32_t active; - int32_t bytesleft; - uint8_t tx_fifo[64]; - uint32_t tx_start; - uint32_t tx_len; - uint8_t rx_fifo[32]; - uint32_t rx_start; - uint32_t rx_len; - uint16_t resp_fifo[9]; - uint32_t resp_len; - - int32_t cmdreq; -}; - -static bool pxa2xx_mmci_vmstate_validate(void *opaque, int version_id) -{ - PXA2xxMMCIState *s =3D opaque; - - return s->tx_start < ARRAY_SIZE(s->tx_fifo) - && s->rx_start < ARRAY_SIZE(s->rx_fifo) - && s->tx_len <=3D ARRAY_SIZE(s->tx_fifo) - && s->rx_len <=3D ARRAY_SIZE(s->rx_fifo) - && s->resp_len <=3D ARRAY_SIZE(s->resp_fifo); -} - - -static const VMStateDescription vmstate_pxa2xx_mmci =3D { - .name =3D "pxa2xx-mmci", - .version_id =3D 2, - .minimum_version_id =3D 2, - .fields =3D (const VMStateField[]) { - VMSTATE_UINT32(status, PXA2xxMMCIState), - VMSTATE_UINT32(clkrt, PXA2xxMMCIState), - VMSTATE_UINT32(spi, PXA2xxMMCIState), - VMSTATE_UINT32(cmdat, PXA2xxMMCIState), - VMSTATE_UINT32(resp_tout, PXA2xxMMCIState), - VMSTATE_UINT32(read_tout, PXA2xxMMCIState), - VMSTATE_INT32(blklen, PXA2xxMMCIState), - VMSTATE_INT32(numblk, PXA2xxMMCIState), - VMSTATE_UINT32(intmask, PXA2xxMMCIState), - VMSTATE_UINT32(intreq, PXA2xxMMCIState), - VMSTATE_INT32(cmd, PXA2xxMMCIState), - VMSTATE_UINT32(arg, PXA2xxMMCIState), - VMSTATE_INT32(cmdreq, PXA2xxMMCIState), - VMSTATE_INT32(active, PXA2xxMMCIState), - VMSTATE_INT32(bytesleft, PXA2xxMMCIState), - VMSTATE_UINT32(tx_start, PXA2xxMMCIState), - VMSTATE_UINT32(tx_len, PXA2xxMMCIState), - VMSTATE_UINT32(rx_start, PXA2xxMMCIState), - VMSTATE_UINT32(rx_len, PXA2xxMMCIState), - VMSTATE_UINT32(resp_len, PXA2xxMMCIState), - VMSTATE_VALIDATE("fifo size incorrect", pxa2xx_mmci_vmstate_valida= te), - VMSTATE_UINT8_ARRAY(tx_fifo, PXA2xxMMCIState, 64), - VMSTATE_UINT8_ARRAY(rx_fifo, PXA2xxMMCIState, 32), - VMSTATE_UINT16_ARRAY(resp_fifo, PXA2xxMMCIState, 9), - VMSTATE_END_OF_LIST() - } -}; - -#define MMC_STRPCL 0x00 /* MMC Clock Start/Stop register */ -#define MMC_STAT 0x04 /* MMC Status register */ -#define MMC_CLKRT 0x08 /* MMC Clock Rate register */ -#define MMC_SPI 0x0c /* MMC SPI Mode register */ -#define MMC_CMDAT 0x10 /* MMC Command/Data register */ -#define MMC_RESTO 0x14 /* MMC Response Time-Out register */ -#define MMC_RDTO 0x18 /* MMC Read Time-Out register */ -#define MMC_BLKLEN 0x1c /* MMC Block Length register */ -#define MMC_NUMBLK 0x20 /* MMC Number of Blocks register */ -#define MMC_PRTBUF 0x24 /* MMC Buffer Partly Full register */ -#define MMC_I_MASK 0x28 /* MMC Interrupt Mask register */ -#define MMC_I_REG 0x2c /* MMC Interrupt Request register */ -#define MMC_CMD 0x30 /* MMC Command register */ -#define MMC_ARGH 0x34 /* MMC Argument High register */ -#define MMC_ARGL 0x38 /* MMC Argument Low register */ -#define MMC_RES 0x3c /* MMC Response FIFO */ -#define MMC_RXFIFO 0x40 /* MMC Receive FIFO */ -#define MMC_TXFIFO 0x44 /* MMC Transmit FIFO */ -#define MMC_RDWAIT 0x48 /* MMC RD_WAIT register */ -#define MMC_BLKS_REM 0x4c /* MMC Blocks Remaining register */ - -/* Bitfield masks */ -#define STRPCL_STOP_CLK (1 << 0) -#define STRPCL_STRT_CLK (1 << 1) -#define STAT_TOUT_RES (1 << 1) -#define STAT_CLK_EN (1 << 8) -#define STAT_DATA_DONE (1 << 11) -#define STAT_PRG_DONE (1 << 12) -#define STAT_END_CMDRES (1 << 13) -#define SPI_SPI_MODE (1 << 0) -#define CMDAT_RES_TYPE (3 << 0) -#define CMDAT_DATA_EN (1 << 2) -#define CMDAT_WR_RD (1 << 3) -#define CMDAT_DMA_EN (1 << 7) -#define CMDAT_STOP_TRAN (1 << 10) -#define INT_DATA_DONE (1 << 0) -#define INT_PRG_DONE (1 << 1) -#define INT_END_CMD (1 << 2) -#define INT_STOP_CMD (1 << 3) -#define INT_CLK_OFF (1 << 4) -#define INT_RXFIFO_REQ (1 << 5) -#define INT_TXFIFO_REQ (1 << 6) -#define INT_TINT (1 << 7) -#define INT_DAT_ERR (1 << 8) -#define INT_RES_ERR (1 << 9) -#define INT_RD_STALLED (1 << 10) -#define INT_SDIO_INT (1 << 11) -#define INT_SDIO_SACK (1 << 12) -#define PRTBUF_PRT_BUF (1 << 0) - -/* Route internal interrupt lines to the global IC and DMA */ -static void pxa2xx_mmci_int_update(PXA2xxMMCIState *s) -{ - uint32_t mask =3D s->intmask; - if (s->cmdat & CMDAT_DMA_EN) { - mask |=3D INT_RXFIFO_REQ | INT_TXFIFO_REQ; - - qemu_set_irq(s->rx_dma, !!(s->intreq & INT_RXFIFO_REQ)); - qemu_set_irq(s->tx_dma, !!(s->intreq & INT_TXFIFO_REQ)); - } - - qemu_set_irq(s->irq, !!(s->intreq & ~mask)); -} - -static void pxa2xx_mmci_fifo_update(PXA2xxMMCIState *s) -{ - if (!s->active) - return; - - if (s->cmdat & CMDAT_WR_RD) { - while (s->bytesleft && s->tx_len) { - sdbus_write_byte(&s->sdbus, s->tx_fifo[s->tx_start++]); - s->tx_start &=3D 0x1f; - s->tx_len --; - s->bytesleft --; - } - if (s->bytesleft) - s->intreq |=3D INT_TXFIFO_REQ; - } else - while (s->bytesleft && s->rx_len < 32) { - s->rx_fifo[(s->rx_start + (s->rx_len ++)) & 0x1f] =3D - sdbus_read_byte(&s->sdbus); - s->bytesleft --; - s->intreq |=3D INT_RXFIFO_REQ; - } - - if (!s->bytesleft) { - s->active =3D 0; - s->intreq |=3D INT_DATA_DONE; - s->status |=3D STAT_DATA_DONE; - - if (s->cmdat & CMDAT_WR_RD) { - s->intreq |=3D INT_PRG_DONE; - s->status |=3D STAT_PRG_DONE; - } - } - - pxa2xx_mmci_int_update(s); -} - -static void pxa2xx_mmci_wakequeues(PXA2xxMMCIState *s) -{ - int rsplen, i; - SDRequest request; - uint8_t response[16]; - - s->active =3D 1; - s->rx_len =3D 0; - s->tx_len =3D 0; - s->cmdreq =3D 0; - - request.cmd =3D s->cmd; - request.arg =3D s->arg; - request.crc =3D 0; /* FIXME */ - - rsplen =3D sdbus_do_command(&s->sdbus, &request, response); - s->intreq |=3D INT_END_CMD; - - memset(s->resp_fifo, 0, sizeof(s->resp_fifo)); - switch (s->cmdat & CMDAT_RES_TYPE) { -#define PXAMMCI_RESP(wd, value0, value1) \ - s->resp_fifo[(wd) + 0] |=3D (value0); \ - s->resp_fifo[(wd) + 1] |=3D (value1) << 8; - case 0: /* No response */ - goto complete; - - case 1: /* R1, R4, R5 or R6 */ - if (rsplen < 4) - goto timeout; - goto complete; - - case 2: /* R2 */ - if (rsplen < 16) - goto timeout; - goto complete; - - case 3: /* R3 */ - if (rsplen < 4) - goto timeout; - goto complete; - - complete: - for (i =3D 0; rsplen > 0; i ++, rsplen -=3D 2) { - PXAMMCI_RESP(i, response[i * 2], response[i * 2 + 1]); - } - s->status |=3D STAT_END_CMDRES; - - if (!(s->cmdat & CMDAT_DATA_EN)) - s->active =3D 0; - else - s->bytesleft =3D s->numblk * s->blklen; - - s->resp_len =3D 0; - break; - - timeout: - s->active =3D 0; - s->status |=3D STAT_TOUT_RES; - break; - } - - pxa2xx_mmci_fifo_update(s); -} - -static uint64_t pxa2xx_mmci_read(void *opaque, hwaddr offset, unsigned siz= e) -{ - PXA2xxMMCIState *s =3D (PXA2xxMMCIState *) opaque; - uint32_t ret =3D 0; - - switch (offset) { - case MMC_STRPCL: - break; - case MMC_STAT: - ret =3D s->status; - break; - case MMC_CLKRT: - ret =3D s->clkrt; - break; - case MMC_SPI: - ret =3D s->spi; - break; - case MMC_CMDAT: - ret =3D s->cmdat; - break; - case MMC_RESTO: - ret =3D s->resp_tout; - break; - case MMC_RDTO: - ret =3D s->read_tout; - break; - case MMC_BLKLEN: - ret =3D s->blklen; - break; - case MMC_NUMBLK: - ret =3D s->numblk; - break; - case MMC_PRTBUF: - break; - case MMC_I_MASK: - ret =3D s->intmask; - break; - case MMC_I_REG: - ret =3D s->intreq; - break; - case MMC_CMD: - ret =3D s->cmd | 0x40; - break; - case MMC_ARGH: - ret =3D s->arg >> 16; - break; - case MMC_ARGL: - ret =3D s->arg & 0xffff; - break; - case MMC_RES: - ret =3D (s->resp_len < 9) ? s->resp_fifo[s->resp_len++] : 0; - break; - case MMC_RXFIFO: - while (size-- && s->rx_len) { - ret |=3D s->rx_fifo[s->rx_start++] << (size << 3); - s->rx_start &=3D 0x1f; - s->rx_len --; - } - s->intreq &=3D ~INT_RXFIFO_REQ; - pxa2xx_mmci_fifo_update(s); - break; - case MMC_RDWAIT: - break; - case MMC_BLKS_REM: - ret =3D s->numblk; - break; - default: - qemu_log_mask(LOG_GUEST_ERROR, - "%s: incorrect register 0x%02" HWADDR_PRIx "\n", - __func__, offset); - } - trace_pxa2xx_mmci_read(size, offset, ret); - - return ret; -} - -static void pxa2xx_mmci_write(void *opaque, - hwaddr offset, uint64_t value, unsigned size) -{ - PXA2xxMMCIState *s =3D (PXA2xxMMCIState *) opaque; - - trace_pxa2xx_mmci_write(size, offset, value); - switch (offset) { - case MMC_STRPCL: - if (value & STRPCL_STRT_CLK) { - s->status |=3D STAT_CLK_EN; - s->intreq &=3D ~INT_CLK_OFF; - - if (s->cmdreq && !(s->cmdat & CMDAT_STOP_TRAN)) { - s->status &=3D STAT_CLK_EN; - pxa2xx_mmci_wakequeues(s); - } - } - - if (value & STRPCL_STOP_CLK) { - s->status &=3D ~STAT_CLK_EN; - s->intreq |=3D INT_CLK_OFF; - s->active =3D 0; - } - - pxa2xx_mmci_int_update(s); - break; - - case MMC_CLKRT: - s->clkrt =3D value & 7; - break; - - case MMC_SPI: - s->spi =3D value & 0xf; - if (value & SPI_SPI_MODE) { - qemu_log_mask(LOG_GUEST_ERROR, - "%s: attempted to use card in SPI mode\n", __fun= c__); - } - break; - - case MMC_CMDAT: - s->cmdat =3D value & 0x3dff; - s->active =3D 0; - s->cmdreq =3D 1; - if (!(value & CMDAT_STOP_TRAN)) { - s->status &=3D STAT_CLK_EN; - - if (s->status & STAT_CLK_EN) - pxa2xx_mmci_wakequeues(s); - } - - pxa2xx_mmci_int_update(s); - break; - - case MMC_RESTO: - s->resp_tout =3D value & 0x7f; - break; - - case MMC_RDTO: - s->read_tout =3D value & 0xffff; - break; - - case MMC_BLKLEN: - s->blklen =3D value & 0xfff; - break; - - case MMC_NUMBLK: - s->numblk =3D value & 0xffff; - break; - - case MMC_PRTBUF: - if (value & PRTBUF_PRT_BUF) { - s->tx_start ^=3D 32; - s->tx_len =3D 0; - } - pxa2xx_mmci_fifo_update(s); - break; - - case MMC_I_MASK: - s->intmask =3D value & 0x1fff; - pxa2xx_mmci_int_update(s); - break; - - case MMC_CMD: - s->cmd =3D value & 0x3f; - break; - - case MMC_ARGH: - s->arg &=3D 0x0000ffff; - s->arg |=3D value << 16; - break; - - case MMC_ARGL: - s->arg &=3D 0xffff0000; - s->arg |=3D value & 0x0000ffff; - break; - - case MMC_TXFIFO: - while (size-- && s->tx_len < 0x20) - s->tx_fifo[(s->tx_start + (s->tx_len ++)) & 0x1f] =3D - (value >> (size << 3)) & 0xff; - s->intreq &=3D ~INT_TXFIFO_REQ; - pxa2xx_mmci_fifo_update(s); - break; - - case MMC_RDWAIT: - case MMC_BLKS_REM: - break; - - default: - qemu_log_mask(LOG_GUEST_ERROR, - "%s: incorrect reg 0x%02" HWADDR_PRIx " " - "(value 0x%08" PRIx64 ")\n", __func__, offset, value= ); - } -} - -static const MemoryRegionOps pxa2xx_mmci_ops =3D { - .read =3D pxa2xx_mmci_read, - .write =3D pxa2xx_mmci_write, - .endianness =3D DEVICE_NATIVE_ENDIAN, -}; - -PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem, - hwaddr base, - qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma) -{ - DeviceState *dev; - - dev =3D sysbus_create_simple(TYPE_PXA2XX_MMCI, base, irq); - qdev_connect_gpio_out_named(dev, "rx-dma", 0, rx_dma); - qdev_connect_gpio_out_named(dev, "tx-dma", 0, tx_dma); - - return PXA2XX_MMCI(dev); -} - -static void pxa2xx_mmci_set_inserted(DeviceState *dev, bool inserted) -{ - PXA2xxMMCIState *s =3D PXA2XX_MMCI(dev); - - qemu_set_irq(s->inserted, inserted); -} - -static void pxa2xx_mmci_set_readonly(DeviceState *dev, bool readonly) -{ - PXA2xxMMCIState *s =3D PXA2XX_MMCI(dev); - - qemu_set_irq(s->readonly, readonly); -} - -void pxa2xx_mmci_handlers(PXA2xxMMCIState *s, qemu_irq readonly, - qemu_irq coverswitch) -{ - DeviceState *dev =3D DEVICE(s); - - s->readonly =3D readonly; - s->inserted =3D coverswitch; - - pxa2xx_mmci_set_inserted(dev, sdbus_get_inserted(&s->sdbus)); - pxa2xx_mmci_set_readonly(dev, sdbus_get_readonly(&s->sdbus)); -} - -static void pxa2xx_mmci_reset(DeviceState *d) -{ - PXA2xxMMCIState *s =3D PXA2XX_MMCI(d); - - s->status =3D 0; - s->clkrt =3D 0; - s->spi =3D 0; - s->cmdat =3D 0; - s->resp_tout =3D 0; - s->read_tout =3D 0; - s->blklen =3D 0; - s->numblk =3D 0; - s->intmask =3D 0; - s->intreq =3D 0; - s->cmd =3D 0; - s->arg =3D 0; - s->active =3D 0; - s->bytesleft =3D 0; - s->tx_start =3D 0; - s->tx_len =3D 0; - s->rx_start =3D 0; - s->rx_len =3D 0; - s->resp_len =3D 0; - s->cmdreq =3D 0; - memset(s->tx_fifo, 0, sizeof(s->tx_fifo)); - memset(s->rx_fifo, 0, sizeof(s->rx_fifo)); - memset(s->resp_fifo, 0, sizeof(s->resp_fifo)); -} - -static void pxa2xx_mmci_instance_init(Object *obj) -{ - PXA2xxMMCIState *s =3D PXA2XX_MMCI(obj); - SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); - DeviceState *dev =3D DEVICE(obj); - - memory_region_init_io(&s->iomem, obj, &pxa2xx_mmci_ops, s, - "pxa2xx-mmci", 0x00100000); - sysbus_init_mmio(sbd, &s->iomem); - sysbus_init_irq(sbd, &s->irq); - qdev_init_gpio_out_named(dev, &s->rx_dma, "rx-dma", 1); - qdev_init_gpio_out_named(dev, &s->tx_dma, "tx-dma", 1); - - qbus_init(&s->sdbus, sizeof(s->sdbus), - TYPE_PXA2XX_MMCI_BUS, DEVICE(obj), "sd-bus"); -} - -static void pxa2xx_mmci_class_init(ObjectClass *klass, void *data) -{ - DeviceClass *dc =3D DEVICE_CLASS(klass); - - dc->vmsd =3D &vmstate_pxa2xx_mmci; - device_class_set_legacy_reset(dc, pxa2xx_mmci_reset); -} - -static void pxa2xx_mmci_bus_class_init(ObjectClass *klass, void *data) -{ - SDBusClass *sbc =3D SD_BUS_CLASS(klass); - - sbc->set_inserted =3D pxa2xx_mmci_set_inserted; - sbc->set_readonly =3D pxa2xx_mmci_set_readonly; -} - -static const TypeInfo pxa2xx_mmci_types[] =3D { - { - .name =3D TYPE_PXA2XX_MMCI, - .parent =3D TYPE_SYS_BUS_DEVICE, - .instance_size =3D sizeof(PXA2xxMMCIState), - .instance_init =3D pxa2xx_mmci_instance_init, - .class_init =3D pxa2xx_mmci_class_init, - }, - { - .name =3D TYPE_PXA2XX_MMCI_BUS, - .parent =3D TYPE_SD_BUS, - .instance_size =3D sizeof(SDBus), - .class_init =3D pxa2xx_mmci_bus_class_init, - }, -}; - -DEFINE_TYPES(pxa2xx_mmci_types) diff --git a/hw/sd/meson.build b/hw/sd/meson.build index bbb75af0c9b..b43d45bc564 100644 --- a/hw/sd/meson.build +++ b/hw/sd/meson.build @@ -5,7 +5,6 @@ system_ss.add(when: 'CONFIG_SDHCI_PCI', if_true: files('sdh= ci-pci.c')) system_ss.add(when: 'CONFIG_SSI_SD', if_true: files('ssi-sd.c')) =20 system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_mmc.c')) -system_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_mmci.c')) system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_sdhost.c')) system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_sdhci.c')) system_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-sdhos= t.c')) diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 43671dc7912..db0644256d9 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -60,10 +60,6 @@ sdcard_set_voltage(uint16_t millivolts) "%u mV" sdcard_ext_csd_update(unsigned index, uint8_t oval, uint8_t nval) "index %= u: 0x%02x -> 0x%02x" sdcard_switch(unsigned access, unsigned index, unsigned value, unsigned se= t) "SWITCH acc:%u idx:%u val:%u set:%u" =20 -# pxa2xx_mmci.c -pxa2xx_mmci_read(uint8_t size, uint32_t addr, uint32_t value) "size %d add= r 0x%02x value 0x%08x" -pxa2xx_mmci_write(uint8_t size, uint32_t addr, uint32_t value) "size %d ad= dr 0x%02x value 0x%08x" - # pl181.c pl181_command_send(uint8_t cmd, uint32_t arg) "sending CMD%02d arg 0x%08" = PRIx32 pl181_command_sent(void) "command sent" --=20 2.34.1