From nobody Fri May 3 17:16:48 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1622435734; cv=none; d=zohomail.com; s=zohoarc; b=n2yPctZWzi8OiRLz3IweEwDX3lZaH/sTKUazXTH36I/ioYAJTsK9OntC6qN6QZzBLEr5Q50IAVlIy9VhEqW0SDoaFD/ClbagmU6/9K7uCjn3YaDXzcMuV0vxn7n6bX4/uTNJSHLy9SLpGvAus9iMiKSdLfXDXFOx9gqCpndMZW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622435734; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N2pANu54BIxmGbhyuIPVVe8PTDyt2P8E3u+NqEpZtao=; b=htn0PuBbz76NYlZH9e9jeRftyA/0ZRMXR3WB0zWGHhE5etDlKM5F0MiSUAGoX7gxp5Xtw41icpfniEE1zZEPSMxNjDRzqriUZ9P8zH1h3zXa6CH/ZmyN+rbIjs9T7vU71XozVfuIdTzm/shWyFqTfjeCcCarZX0iu/MTiBX77J8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622435734582922.2666428056731; Sun, 30 May 2021 21:35:34 -0700 (PDT) Received: from localhost ([::1]:53224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnZeH-0005xQ-IK for importer2@patchew.org; Mon, 31 May 2021 00:35:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnZcb-0003ow-4v; Mon, 31 May 2021 00:33:49 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:5624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnZcY-0002P1-Od; Mon, 31 May 2021 00:33:48 -0400 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 31 May 2021 12:33:40 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2021 21:11:39 -0700 Received: from unknown (HELO toolbox.wdc.com) ([10.225.165.65]) by uls-op-cesaip01.wdc.com with ESMTP; 30 May 2021 21:33:40 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1622435625; x=1653971625; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZZBEAFlCHLzJMkkQp7hJCLjN0lO5/I5hMxBAVXTFw4Q=; b=QZYJsg4jnpLBsn97VvZUycnJoABC2+c99E2tOpFM+xl+v0V9wUhgPTxB 9ZCSU1tDJmm7mF0h2ZpEVK2ph/VjlvDlhg1k2I0p1HD4Hgk1BKNZAJL3J M/qbLxB6dp1xfYtwHAG6/bMOZgjtGFm7rWYrFnNPx6n4oaG/eBGvejFMi YEAZWmnpIkYHLixMeZ57dpMTH9hS1NT7Dp+7PKkfTaf9x0BQp4wIHqV2o R3Q9jWV14g/fHbuhV+nNFje+anO/wiFtorWteHLkHws7pjB7o6MbZo+qC 402Cb9f+EKwYyozXo0/8kMYvr0R4bYMfVyyWhbA1c+nJQfsrS6nhKKsDA w==; IronPort-SDR: q6mrPQo3Ig0LZaf5J8ohOT+Iy2ooh1j0ixVDG4+MdO45D0ha5Upwx9bJNhnrWsprFiZp1X96VC p4dhxIcyK6Jy3CZhscHg4SAiNFSVWMlQVEx1d8RgV322ypjMWx6/y+hLFGUWwrurERtx4W7YQk zhiC1kIOq87fQq9E4sp7xemcQ/MhdZIl9DzuITebiVoqEQwyEjOZq5U6Dg2q+zCygYZ+Td9mDs RCmsrYyNRvy+NGM1/+rmk/G2F+vtf6L/wCA8Q37X+pTi0C0O2rGKFc5uoExokv5jgyikDJJvhw 19M= X-IronPort-AV: E=Sophos;i="5.83,236,1616428800"; d="scan'208";a="174840777" IronPort-SDR: cKkaUZ0/D8AqoO0U1vjS4Myx+dXBm08F4da2ZaFPEEvSsy2KXeoOBl16rpTVauynF4ofYnWPbZ Ff/oVBa1QWNKvtUjeOez8vb3jC7QXoBp/5JYyqaApakzbh9PI39kpMdHrnSGYrmdk2vdHpfZER AEi1xigQUQQmfJijVQ+YQtJRtr+JGpOyOnwxwF88MkEuR/cVzL/IkMfz2Y/qD4l29pInGRQjx8 IgSweVDMztS70zxWHl9WjBqwlkV44NPt+P/rQnsVK9fxdJoX/PZTZd9JIFlFN4x4BMo0fgVQrM aEC3UIUks+1kg6D+9GONoadP IronPort-SDR: XeVZEhm4J21rFbwb2SqcmCaOUuMJdIfRp96IjG4xDDoZFV0SBfOX3y8k/Ma6jRRBfZ35M0hc1K 5NnfiozvaaH5UujBJfxkjm6buqSyX3Vc8ihMVujh7ZFQQ+k38lVFVLwufrKSgO9kSwB3gz5atS VFVVw1tGbDanneBXda1zKAy/9qJ3GhLDK17TxeuKiXT97vh84yQ2VVUxIDM7adOtQWCz+k4iX9 ZAf24lA2OO0n7xfuo0hlHli2ngQR/SrSe6fKzYtAUd8I/3z+DnnI+dOs30MaPICbyrkLKxUkOV dz0= WDCIronportException: Internal From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v1 1/3] hw/char/ibex_uart: Make the register layout private Date: Mon, 31 May 2021 14:33:37 +1000 Message-Id: <547296f990a03d5524ab65a9987083d69e4ebaea.1622435529.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=778d471cf=alistair.francis@wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UPPERCASE_50_75=0.008 autolearn=ham autolearn_force=no X-Spam_action: no action 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: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We don't need to expose the register layout in the public header, so don't. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- include/hw/char/ibex_uart.h | 37 ------------------------------------- hw/char/ibex_uart.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/include/hw/char/ibex_uart.h b/include/hw/char/ibex_uart.h index 546f958eb8..a39985516a 100644 --- a/include/hw/char/ibex_uart.h +++ b/include/hw/char/ibex_uart.h @@ -31,43 +31,6 @@ #include "qemu/timer.h" #include "qom/object.h" =20 -REG32(INTR_STATE, 0x00) - FIELD(INTR_STATE, TX_WATERMARK, 0, 1) - FIELD(INTR_STATE, RX_WATERMARK, 1, 1) - FIELD(INTR_STATE, TX_EMPTY, 2, 1) - FIELD(INTR_STATE, RX_OVERFLOW, 3, 1) -REG32(INTR_ENABLE, 0x04) -REG32(INTR_TEST, 0x08) -REG32(CTRL, 0x0C) - FIELD(CTRL, TX_ENABLE, 0, 1) - FIELD(CTRL, RX_ENABLE, 1, 1) - FIELD(CTRL, NF, 2, 1) - FIELD(CTRL, SLPBK, 4, 1) - FIELD(CTRL, LLPBK, 5, 1) - FIELD(CTRL, PARITY_EN, 6, 1) - FIELD(CTRL, PARITY_ODD, 7, 1) - FIELD(CTRL, RXBLVL, 8, 2) - FIELD(CTRL, NCO, 16, 16) -REG32(STATUS, 0x10) - FIELD(STATUS, TXFULL, 0, 1) - FIELD(STATUS, RXFULL, 1, 1) - FIELD(STATUS, TXEMPTY, 2, 1) - FIELD(STATUS, RXIDLE, 4, 1) - FIELD(STATUS, RXEMPTY, 5, 1) -REG32(RDATA, 0x14) -REG32(WDATA, 0x18) -REG32(FIFO_CTRL, 0x1c) - FIELD(FIFO_CTRL, RXRST, 0, 1) - FIELD(FIFO_CTRL, TXRST, 1, 1) - FIELD(FIFO_CTRL, RXILVL, 2, 3) - FIELD(FIFO_CTRL, TXILVL, 5, 2) -REG32(FIFO_STATUS, 0x20) - FIELD(FIFO_STATUS, TXLVL, 0, 5) - FIELD(FIFO_STATUS, RXLVL, 16, 5) -REG32(OVRD, 0x24) -REG32(VAL, 0x28) -REG32(TIMEOUT_CTRL, 0x2c) - #define IBEX_UART_TX_FIFO_SIZE 16 #define IBEX_UART_CLOCK 50000000 /* 50MHz clock */ =20 diff --git a/hw/char/ibex_uart.c b/hw/char/ibex_uart.c index 73b8f2e45b..fe4b6c3c9e 100644 --- a/hw/char/ibex_uart.c +++ b/hw/char/ibex_uart.c @@ -35,6 +35,43 @@ #include "qemu/log.h" #include "qemu/module.h" =20 +REG32(INTR_STATE, 0x00) + FIELD(INTR_STATE, TX_WATERMARK, 0, 1) + FIELD(INTR_STATE, RX_WATERMARK, 1, 1) + FIELD(INTR_STATE, TX_EMPTY, 2, 1) + FIELD(INTR_STATE, RX_OVERFLOW, 3, 1) +REG32(INTR_ENABLE, 0x04) +REG32(INTR_TEST, 0x08) +REG32(CTRL, 0x0C) + FIELD(CTRL, TX_ENABLE, 0, 1) + FIELD(CTRL, RX_ENABLE, 1, 1) + FIELD(CTRL, NF, 2, 1) + FIELD(CTRL, SLPBK, 4, 1) + FIELD(CTRL, LLPBK, 5, 1) + FIELD(CTRL, PARITY_EN, 6, 1) + FIELD(CTRL, PARITY_ODD, 7, 1) + FIELD(CTRL, RXBLVL, 8, 2) + FIELD(CTRL, NCO, 16, 16) +REG32(STATUS, 0x10) + FIELD(STATUS, TXFULL, 0, 1) + FIELD(STATUS, RXFULL, 1, 1) + FIELD(STATUS, TXEMPTY, 2, 1) + FIELD(STATUS, RXIDLE, 4, 1) + FIELD(STATUS, RXEMPTY, 5, 1) +REG32(RDATA, 0x14) +REG32(WDATA, 0x18) +REG32(FIFO_CTRL, 0x1c) + FIELD(FIFO_CTRL, RXRST, 0, 1) + FIELD(FIFO_CTRL, TXRST, 1, 1) + FIELD(FIFO_CTRL, RXILVL, 2, 3) + FIELD(FIFO_CTRL, TXILVL, 5, 2) +REG32(FIFO_STATUS, 0x20) + FIELD(FIFO_STATUS, TXLVL, 0, 5) + FIELD(FIFO_STATUS, RXLVL, 16, 5) +REG32(OVRD, 0x24) +REG32(VAL, 0x28) +REG32(TIMEOUT_CTRL, 0x2c) + static void ibex_uart_update_irqs(IbexUartState *s) { if (s->uart_intr_state & s->uart_intr_enable & R_INTR_STATE_TX_WATERMA= RK_MASK) { --=20 2.31.1 From nobody Fri May 3 17:16:48 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1622435745; cv=none; d=zohomail.com; s=zohoarc; b=Y0Ramz8MJYIAHRK9jklpB1ewsNu5Y26f7+8CVtmFZvy6ZCR+BxOdzv6AWMFkKExKEvm6WETWOBCZ0Fz7vM0ooXbO2wykw/6UElI+esy/eXugsQp/NZaQK7A3BiZ93otSx9Jf1fUU6z2zO+gBh2IQoTY02suBsZXBSrIdcgSf8VU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622435745; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oAgtzVQgZgAwrKsyc/PjyFtK4a+o4mluHWqmFHhDyw0=; b=g5/ypZaWnY2OjDvuMDXK7bdc2a9gSFYvv0eRnR3cbMtDsybKIImwgpDPmovOVW2E76NHi9X7Mp6WWR4+zQfnBer1uDbwxyA2N9V/7uFyzL1GUeUh0M6wfjuRoPkex4NON+V/Vn5A99JfsVNEqSkPH1QLpNHIp3ipMOd2wwxjzp0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622435745699969.9255386783221; Sun, 30 May 2021 21:35:45 -0700 (PDT) Received: from localhost ([::1]:53730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnZeS-0006Hp-Jv for importer2@patchew.org; Mon, 31 May 2021 00:35:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnZcm-0003ty-M9; Mon, 31 May 2021 00:34:00 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:13260) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnZcd-0002Rt-G7; Mon, 31 May 2021 00:34:00 -0400 Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 31 May 2021 12:33:48 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2021 21:13:07 -0700 Received: from unknown (HELO toolbox.wdc.com) ([10.225.165.65]) by uls-op-cesaip02.wdc.com with ESMTP; 30 May 2021 21:33:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1622435631; x=1653971631; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p4Y1r40CxRF7WSIqdGEPN86FJ1IAQ7RhwVf4nomzaNc=; b=G9r+g6nY1TsHpU1ThVKLYBNwaft8ilKDCZ3bdL9rWxex0sUjBOqWTPgy 14z1bUjkw7CjSHRJjs3OOJZpqxhS72SRKhUxLZWt3yEcdy1p5htmX/Maz m3MgB3mR5S9aFyflAZpFojuOnSgs0lLdKvgNfSXeQHBUFIojR84c2nSXo vFl0lDluFBOztZHJVIsLygx+u7tii42Z1Q48fttQNpKT+ekMzIKdOaqvy DjqOMa8bZKqDPv8Kk/wpi4eEuVqgE5ZXvkU8nHm4N+lpMKuNfaQdb6vL9 gltAYLkH7IC2gjcOqBS2yyeQt6/dfZH+B513ibNKHsR7RdjAmkmPsPx0K w==; IronPort-SDR: zb+dyd+xA61M3NrS54dwOiAHdrwP6WeUUlY/aL6YLVtyz3fpR3D+cVXBrJ5fbKfbmPycpWnuaZ MaDc/mJAuO8x9D/HO9iwRVtQxADxe6f+kfF4eIVKdTS5tdGl0PFUQODyqWiQhEf8s9hCpoOX+q QjgMJdZc4wggRwU8QK7y0C30W8plHC1Jg+R3c4p6ZsdK3n6qsLF/R071xVMyoUK6pRmxrlWXwJ OpgcXuSRyHCo/HtxsVpWSjTEMQ625cBot6PpwVjRsvuYnSfQifbC9HtNgQqlOdAvfSiEhBKol9 enw= X-IronPort-AV: E=Sophos;i="5.83,236,1616428800"; d="scan'208";a="281488601" IronPort-SDR: hSBwICbabywz00HXcWLIDAxwMD5D30EydAByi4JK0kaasjjHMG7q30aKPKTanlLPkxGhbOE3Zo +Ng5oX0Z1ZLm2nFNZLaM92sz8M973mrOleznBfgIL/0Eea8D3PKjad8bGkWbw3lKYABFoMZmL2 SdwDNN3yu/cy8tfHyiPcfvQxMAXC77ee7mCZvbAFrcEG+RxF80QXb79UQ/SWpmGcVJxkvTihb4 i2q7VJpHBPQ7s/azwEM8XiYHllY1iRToq/zVQ2WEYijP1um/RJDHdyECgBZ6BIor1I+PuXfo5Z Pn5Ib8k39SeDt1D4KrQ5JZqD IronPort-SDR: bQjQSZ8Y+c00EMbxHXXTkycp1i3T5CQGTYL7O46MoeJyCcQkxtuNJwz5s+/1A10TiH1xdaH3M8 jh2/+itZePJ4E2FIEahEO3PGDElN/Kn/nREo/ofWT0LHHUrBX2/hIlKWsxfIYBo52E4d1RsqKx DQDSKwP5VqHKDkAQqerRbARHRO6wo952lf7DGR7l+zxQOZZ+ZuamEKneOGqbdlAkn5MJZm16Q9 b3QnFh5wunJPwxTRE02Ui+RgX/sWLYaEyXRNoBddS2pEEhHjYUhMhvVEc8wIa/dULy96KtnYOA bUs= WDCIronportException: Internal From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v1 2/3] hw/timer: Initial commit of Ibex Timer Date: Mon, 31 May 2021 14:33:44 +1000 Message-Id: <3a2dd5ce519fb1e66b539cba93750fb5cb706b1a.1622435529.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=778d471cf=alistair.francis@wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Alistair Francis --- include/hw/timer/ibex_timer.h | 52 ++++++ hw/timer/ibex_timer.c | 305 ++++++++++++++++++++++++++++++++++ MAINTAINERS | 6 +- hw/timer/meson.build | 1 + 4 files changed, 360 insertions(+), 4 deletions(-) create mode 100644 include/hw/timer/ibex_timer.h create mode 100644 hw/timer/ibex_timer.c diff --git a/include/hw/timer/ibex_timer.h b/include/hw/timer/ibex_timer.h new file mode 100644 index 0000000000..6a43537003 --- /dev/null +++ b/include/hw/timer/ibex_timer.h @@ -0,0 +1,52 @@ +/* + * QEMU lowRISC Ibex Timer device + * + * Copyright (c) 2021 Western Digital + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef HW_IBEX_TIMER_H +#define HW_IBEX_TIMER_H + +#include "hw/sysbus.h" + +#define TYPE_IBEX_TIMER "ibex-timer" +OBJECT_DECLARE_SIMPLE_TYPE(IbexTimerState, IBEX_TIMER) + +struct IbexTimerState { + /* */ + SysBusDevice parent_obj; + + /* */ + MemoryRegion mmio; + + uint32_t timer_ctrl; + uint32_t timer_cfg0; + uint32_t timer_compare_lower0; + uint32_t timer_compare_upper0; + uint32_t timer_intr_enable; + uint32_t timer_intr_state; + uint32_t timer_intr_test; + + uint32_t timebase_freq; + + qemu_irq irq; +}; +#endif /* HW_IBEX_TIMER_H */ diff --git a/hw/timer/ibex_timer.c b/hw/timer/ibex_timer.c new file mode 100644 index 0000000000..0a1030b15f --- /dev/null +++ b/hw/timer/ibex_timer.c @@ -0,0 +1,305 @@ +/* + * QEMU lowRISC Ibex Timer device + * + * Copyright (c) 2021 Western Digital + * + * For details check the documentation here: + * https://docs.opentitan.org/hw/ip/rv_timer/doc/ + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/timer.h" +#include "hw/timer/ibex_timer.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" +#include "target/riscv/cpu.h" +#include "migration/vmstate.h" + +REG32(CTRL, 0x00) + FIELD(CTRL, ACTIVE, 0, 1) +REG32(CFG0, 0x100) + FIELD(CFG0, PRESCALE, 0, 12) + FIELD(CFG0, STEP, 16, 8) +REG32(LOWER0, 0x104) +REG32(UPPER0, 0x108) +REG32(COMPARE_LOWER0, 0x10C) +REG32(COMPARE_UPPER0, 0x110) +REG32(INTR_ENABLE, 0x114) + FIELD(INTR_ENABLE, IE_0, 0, 1) +REG32(INTR_STATE, 0x118) + FIELD(INTR_STATE, IS_0, 0, 1) +REG32(INTR_TEST, 0x11C) + FIELD(INTR_TEST, T_0, 0, 1) + +static uint64_t cpu_riscv_read_rtc(uint32_t timebase_freq) +{ + return muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), + timebase_freq, NANOSECONDS_PER_SECOND); +} + +static void ibex_timer_update_irqs(IbexTimerState *s) +{ + CPUState *cs =3D qemu_get_cpu(0); + RISCVCPU *cpu =3D RISCV_CPU(cs); + uint64_t value =3D s->timer_compare_lower0 | + ((uint64_t)s->timer_compare_upper0 << 32); + uint64_t next, diff; + uint64_t now =3D cpu_riscv_read_rtc(s->timebase_freq); + + if (!(s->timer_ctrl & R_CTRL_ACTIVE_MASK)) { + /* Timer isn't active */ + return; + } + + /* Update the CPUs mtimecmp */ + cpu->env.timecmp =3D value; + + if (cpu->env.timecmp <=3D now) { + /* + * If the mtimecmp was in the past raise the interrupt now. + */ + riscv_cpu_update_mip(cpu, MIP_MTIP, BOOL_TO_MASK(1)); + if (s->timer_intr_enable & R_INTR_ENABLE_IE_0_MASK) { + s->timer_intr_state |=3D R_INTR_STATE_IS_0_MASK; + qemu_set_irq(s->irq, true); + } + return; + } + + /* Setup a timer to trigger the interrupt in the future */ + riscv_cpu_update_mip(cpu, MIP_MTIP, BOOL_TO_MASK(0)); + qemu_set_irq(s->irq, false); + + diff =3D cpu->env.timecmp - now; + next =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + + muldiv64(diff, + NANOSECONDS_PER_SECOND, + s->timebase_freq); + + if (next < qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)) { + /* We overflowed the timer, just set it as large as we can */ + timer_mod(cpu->env.timer, 0x0FFFFFFFFFFFFFFF); + } else { + timer_mod(cpu->env.timer, next); + } +} + +static void ibex_timer_cb(void *opaque) +{ + IbexTimerState *s =3D opaque; + CPUState *cs =3D qemu_get_cpu(0); + RISCVCPU *cpu =3D RISCV_CPU(cs); + + riscv_cpu_update_mip(cpu, MIP_MTIP, BOOL_TO_MASK(1)); + if (s->timer_intr_enable & R_INTR_ENABLE_IE_0_MASK) { + s->timer_intr_state |=3D R_INTR_STATE_IS_0_MASK; + qemu_set_irq(s->irq, true); + } +} + +static void ibex_timer_reset(DeviceState *dev) +{ + IbexTimerState *s =3D IBEX_TIMER(dev); + + CPUState *cpu =3D qemu_get_cpu(0); + CPURISCVState *env =3D cpu->env_ptr; + env->timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, + &ibex_timer_cb, s); + env->timecmp =3D 0; + + s->timer_ctrl =3D 0x00000000; + s->timer_cfg0 =3D 0x00000000; + s->timer_compare_lower0 =3D 0x0000003c; + s->timer_compare_upper0 =3D 0x00000000; + s->timer_intr_enable =3D 0x00000000; + s->timer_intr_state =3D 0x00000000; + s->timer_intr_test =3D 0x00000000; + + ibex_timer_update_irqs(s); +} + +static uint64_t ibex_timer_read(void *opaque, hwaddr addr, + unsigned int size) +{ + IbexTimerState *s =3D opaque; + uint64_t now =3D cpu_riscv_read_rtc(s->timebase_freq); + uint64_t retvalue =3D 0; + + switch (addr >> 2) { + case R_CTRL: + retvalue =3D s->timer_ctrl; + break; + case R_CFG0: + retvalue =3D s->timer_cfg0; + break; + case R_LOWER0: + retvalue =3D now; + break; + case R_UPPER0: + retvalue =3D now >> 32; + break; + case R_COMPARE_LOWER0: + retvalue =3D s->timer_compare_lower0; + break; + case R_COMPARE_UPPER0: + retvalue =3D s->timer_compare_upper0; + break; + case R_INTR_ENABLE: + retvalue =3D s->timer_intr_enable; + break; + case R_INTR_STATE: + retvalue =3D s->timer_intr_state; + break; + case R_INTR_TEST: + retvalue =3D s->timer_intr_test; + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); + return 0; + } + + return retvalue; +} + +static void ibex_timer_write(void *opaque, hwaddr addr, + uint64_t val64, unsigned int size) +{ + IbexTimerState *s =3D opaque; + uint32_t val =3D val64; + + switch (addr >> 2) { + case R_CTRL: + s->timer_ctrl =3D val; + break; + case R_CFG0: + qemu_log_mask(LOG_UNIMP, "Changing prescale or step not supported"= ); + s->timer_cfg0 =3D val; + break; + case R_LOWER0: + qemu_log_mask(LOG_UNIMP, "Changing timer value is not supported"); + break; + case R_UPPER0: + qemu_log_mask(LOG_UNIMP, "Changing timer value is not supported"); + break; + case R_COMPARE_LOWER0: + s->timer_compare_lower0 =3D val; + ibex_timer_update_irqs(s); + break; + case R_COMPARE_UPPER0: + s->timer_compare_upper0 =3D val; + ibex_timer_update_irqs(s); + break; + case R_INTR_ENABLE: + s->timer_intr_enable =3D val; + break; + case R_INTR_STATE: + /* Write 1 to clear */ + s->timer_intr_state &=3D ~val; + break; + case R_INTR_TEST: + s->timer_intr_test =3D val; + if (s->timer_intr_enable & + s->timer_intr_test & + R_INTR_ENABLE_IE_0_MASK) { + s->timer_intr_state |=3D R_INTR_STATE_IS_0_MASK; + qemu_set_irq(s->irq, true); + } + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); + } +} + +static const MemoryRegionOps ibex_timer_ops =3D { + .read =3D ibex_timer_read, + .write =3D ibex_timer_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl.min_access_size =3D 4, + .impl.max_access_size =3D 4, +}; + +static int ibex_timer_post_load(void *opaque, int version_id) +{ + IbexTimerState *s =3D opaque; + + ibex_timer_update_irqs(s); + return 0; +} + +static const VMStateDescription vmstate_ibex_timer =3D { + .name =3D TYPE_IBEX_TIMER, + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D ibex_timer_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(timer_ctrl, IbexTimerState), + VMSTATE_UINT32(timer_cfg0, IbexTimerState), + VMSTATE_UINT32(timer_compare_lower0, IbexTimerState), + VMSTATE_UINT32(timer_compare_upper0, IbexTimerState), + VMSTATE_UINT32(timer_intr_enable, IbexTimerState), + VMSTATE_UINT32(timer_intr_state, IbexTimerState), + VMSTATE_UINT32(timer_intr_test, IbexTimerState), + VMSTATE_END_OF_LIST() + } +}; + +static Property ibex_timer_properties[] =3D { + DEFINE_PROP_UINT32("timebase-freq", IbexTimerState, timebase_freq, 100= 00), + DEFINE_PROP_END_OF_LIST(), +}; + +static void ibex_timer_init(Object *obj) +{ + IbexTimerState *s =3D IBEX_TIMER(obj); + + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); + + memory_region_init_io(&s->mmio, obj, &ibex_timer_ops, s, + TYPE_IBEX_TIMER, 0x400); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); +} + +static void ibex_timer_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->reset =3D ibex_timer_reset; + dc->vmsd =3D &vmstate_ibex_timer; + device_class_set_props(dc, ibex_timer_properties); +} + +static const TypeInfo ibex_timer_info =3D { + .name =3D TYPE_IBEX_TIMER, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(IbexTimerState), + .instance_init =3D ibex_timer_init, + .class_init =3D ibex_timer_class_init, +}; + +static void ibex_timer_register_types(void) +{ + type_register_static(&ibex_timer_info); +} + +type_init(ibex_timer_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index 5f55404f2f..c46d4e281e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1355,11 +1355,9 @@ M: Alistair Francis L: qemu-riscv@nongnu.org S: Supported F: hw/riscv/opentitan.c -F: hw/char/ibex_uart.c -F: hw/intc/ibex_plic.c +F: hw/*/ibex_*.c F: include/hw/riscv/opentitan.h -F: include/hw/char/ibex_uart.h -F: include/hw/intc/ibex_plic.h +F: include/hw/*/ibex_*.h =20 Microchip PolarFire SoC Icicle Kit M: Bin Meng diff --git a/hw/timer/meson.build b/hw/timer/meson.build index 157f540ecd..1aa3cd2284 100644 --- a/hw/timer/meson.build +++ b/hw/timer/meson.build @@ -33,5 +33,6 @@ softmmu_ss.add(when: 'CONFIG_SSE_COUNTER', if_true: files= ('sse-counter.c')) softmmu_ss.add(when: 'CONFIG_SSE_TIMER', if_true: files('sse-timer.c')) softmmu_ss.add(when: 'CONFIG_STM32F2XX_TIMER', if_true: files('stm32f2xx_t= imer.c')) softmmu_ss.add(when: 'CONFIG_XILINX', if_true: files('xilinx_timer.c')) +specific_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_timer.c')) =20 specific_ss.add(when: 'CONFIG_AVR_TIMER16', if_true: files('avr_timer16.c'= )) --=20 2.31.1 From nobody Fri May 3 17:16:48 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1622435869; cv=none; d=zohomail.com; s=zohoarc; b=mlfZ2DAAArwbZPpZ+9MM0qzobIjdRjKj1KikIC81RfduSOgHNlHIzmsgNjGdUWYvfcqgQ31kYo04lBFUGsQnilcDdaf3wnheV4l6bYXsRihosz2cZTIjGNapBGCQMbuZR6Aiemj7k9fosthWtHISp9rOL4xopjsnh/CXW4btaHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622435869; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=74ycxpdLMaoRp9KTwZaohrh1es7GvWER9C9g+kfeFb8=; b=kySnhbiRQtCifXNF7F3+6qsbE11BVX8L/N+fGCcJFpLm72B0n2w/hTb4Fc9Ffoq2iThR1qjKKA0a9hvkj2Os+nCzRj1hBGcGg27ZYqQspdxNP1YTGZxSzp3x2hJ1C5MXVARDNVeJXkBiBAer5cLLaWPIUIc1vHPU7q1d0LNKKvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=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 1622435869823397.91513589807926; Sun, 30 May 2021 21:37:49 -0700 (PDT) Received: from localhost ([::1]:58672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnZgS-0001EV-SO for importer2@patchew.org; Mon, 31 May 2021 00:37:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnZco-0003vF-9V; Mon, 31 May 2021 00:34:02 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:8607) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnZcl-0002VK-1C; Mon, 31 May 2021 00:34:02 -0400 Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 31 May 2021 12:33:55 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2021 21:11:52 -0700 Received: from unknown (HELO toolbox.wdc.com) ([10.225.165.65]) by uls-op-cesaip02.wdc.com with ESMTP; 30 May 2021 21:33:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1622435639; x=1653971639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q9pHcvED0Oywp8QttAtL6iUyqk1/Ov2XIhKBMD+PYUU=; b=i5IvVVl55XA3yJJWa1wkme+LaN2sgd3vHSz1LBtH0XCEBe60YTBOrFlu EAmme7UjeH7Hf3zqCIrmehoz1/995QVA29yPYXdlM+ku1lBktpvTF9zS0 BnolIspmuPGmruSRNttHzEOLCnyaxPmIxe/XyDZ0au9aqgp+IjV53joTu Ntv8aEf7i9j5xnIKO/LAIYrPTrgm1ABdzWUGkpE2pTGFt2ckbbcXTRJmz GTp1/Lu+ROfMAiAZwYzYMMxYdRqgIlsRi/sF7d3ZZtMf8UgLhB+bQe5Qi xzqIgHO7OEmjPvqGPvC81hW1CuNjw0fDkJ6Znf760VnxVED1ITCugdQAj g==; IronPort-SDR: sTfqZE5I40e8hpt2/bZx0Rs0//m3rHWzW0Jz0X+Vs6/izFsotFW7u1zhD9xS9EB2oPWaRVpsek Sl7E3z+MLuicbBshzAyXoyMj1KAt67jjKufINYb+ZNl1RWWkDsKxaqKver9ZPLkgzUSzJlWA2y nDGSFjQZ6lC/l3w3qmI829wdqu0mFnwERLGduL1MF7Fwrr8t5XoCep+zMk2wrUVKH5i9aY/GXq no4hggPDSmefoXbLaKvf2r/itQTsauK1KY8o4VmuFRr6NZoAaxyO8AO7NTevGmsXeQ2OZLe9xD 5mQ= X-IronPort-AV: E=Sophos;i="5.83,236,1616428800"; d="scan'208";a="169414604" IronPort-SDR: WyQRQS5PH9sc18xwWkn+KKmyE6HMieLJQvTUOG8vjuNb2zelyUDjnnDti4FnM5LMITkzUwd6Fx Y1hdPMqkr7hXXWzkgHSbOXArVaC2cIGTekDVAON4HBMVzlj5T4Vs5iz78RilIuG+oF7jeM/gKt h1gb+ICL3jxCzF2Cdz5s7gtHBEfOLAG4H52g1UNElYnUuk4PE3teikW9UYRm3rv8Yxq8zwJZJ/ 3NCBzjc0mkwq+pSTv5O9Ev3yLpDKsNcEWkvf/38kbYr10IgOBE/dUFSFb/aMWSKH48BVsCtuWD scS9BcZQ+hddjp0XsPqu6g2/ IronPort-SDR: vO1YbsPDAVZyqKyIvEp4W2otUV7i/ZLMv/G9TGeG2Wvl/P1PKfLiFSKcxoaISZc4P4vWCWl3qb hfeCKqkghBKhXWEknrycY3nr2f3xgFGDg08/aqut+Hteo34QvkXU35mv5dhqieHrMStsrIjz9G AA8vO+9tnOcyvku3kNDFotP6v24h/p+E35UAjMhgQv9kAveBokGWmHi2dE/9xsMOrgrCDqvtB0 S74wto+ocnEVkrsUeRQvjiUu3z6ugPQU6UE2PzkisHox9KaEMGLUQE0Ks7KV/y0UezqUdp3wWn YM8= WDCIronportException: Internal From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v1 3/3] hw/riscv: OpenTitan: Connect the mtime and mtimecmp timer Date: Mon, 31 May 2021 14:33:51 +1000 Message-Id: <326d5fa6a311684be25803d4676690e4f60fe24c.1622435529.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=778d471cf=alistair.francis@wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Alistair Francis --- include/hw/riscv/opentitan.h | 5 ++++- hw/riscv/opentitan.c | 14 +++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h index aab9bc9245..86cceef698 100644 --- a/include/hw/riscv/opentitan.h +++ b/include/hw/riscv/opentitan.h @@ -22,6 +22,7 @@ #include "hw/riscv/riscv_hart.h" #include "hw/intc/ibex_plic.h" #include "hw/char/ibex_uart.h" +#include "hw/timer/ibex_timer.h" #include "qom/object.h" =20 #define TYPE_RISCV_IBEX_SOC "riscv.lowrisc.ibex.soc" @@ -35,6 +36,7 @@ struct LowRISCIbexSoCState { RISCVHartArrayState cpus; IbexPlicState plic; IbexUartState uart; + IbexTimerState timer; =20 MemoryRegion flash_mem; MemoryRegion rom; @@ -57,7 +59,7 @@ enum { IBEX_DEV_SPI, IBEX_DEV_I2C, IBEX_DEV_PATTGEN, - IBEX_DEV_RV_TIMER, + IBEX_DEV_TIMER, IBEX_DEV_SENSOR_CTRL, IBEX_DEV_OTP_CTRL, IBEX_DEV_PWRMGR, @@ -82,6 +84,7 @@ enum { }; =20 enum { + IBEX_TIMER_TIMEREXPIRED0_0 =3D 125, IBEX_UART0_RX_PARITY_ERR_IRQ =3D 8, IBEX_UART0_RX_TIMEOUT_IRQ =3D 7, IBEX_UART0_RX_BREAK_ERR_IRQ =3D 6, diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 7545dcda9c..c5a7e3bacb 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -36,7 +36,7 @@ static const MemMapEntry ibex_memmap[] =3D { [IBEX_DEV_SPI] =3D { 0x40050000, 0x1000 }, [IBEX_DEV_I2C] =3D { 0x40080000, 0x1000 }, [IBEX_DEV_PATTGEN] =3D { 0x400e0000, 0x1000 }, - [IBEX_DEV_RV_TIMER] =3D { 0x40100000, 0x1000 }, + [IBEX_DEV_TIMER] =3D { 0x40100000, 0x1000 }, [IBEX_DEV_SENSOR_CTRL] =3D { 0x40110000, 0x1000 }, [IBEX_DEV_OTP_CTRL] =3D { 0x40130000, 0x4000 }, [IBEX_DEV_PWRMGR] =3D { 0x40400000, 0x1000 }, @@ -106,6 +106,8 @@ static void lowrisc_ibex_soc_init(Object *obj) object_initialize_child(obj, "plic", &s->plic, TYPE_IBEX_PLIC); =20 object_initialize_child(obj, "uart", &s->uart, TYPE_IBEX_UART); + + object_initialize_child(obj, "timer", &s->timer, TYPE_IBEX_TIMER); } =20 static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) @@ -159,6 +161,14 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_= soc, Error **errp) 3, qdev_get_gpio_in(DEVICE(&s->plic), IBEX_UART0_RX_OVERFLOW_IRQ)); =20 + if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer), errp)) { + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s->timer), 0, memmap[IBEX_DEV_TIMER].b= ase); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->timer), + 0, qdev_get_gpio_in(DEVICE(&s->plic), + IBEX_TIMER_TIMEREXPIRED0_0)); + create_unimplemented_device("riscv.lowrisc.ibex.gpio", memmap[IBEX_DEV_GPIO].base, memmap[IBEX_DEV_GPIO].size); create_unimplemented_device("riscv.lowrisc.ibex.spi", @@ -167,8 +177,6 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_s= oc, Error **errp) memmap[IBEX_DEV_I2C].base, memmap[IBEX_DEV_I2C].size); create_unimplemented_device("riscv.lowrisc.ibex.pattgen", memmap[IBEX_DEV_PATTGEN].base, memmap[IBEX_DEV_PATTGEN].size); - create_unimplemented_device("riscv.lowrisc.ibex.rv_timer", - memmap[IBEX_DEV_RV_TIMER].base, memmap[IBEX_DEV_RV_TIMER].size); create_unimplemented_device("riscv.lowrisc.ibex.sensor_ctrl", memmap[IBEX_DEV_SENSOR_CTRL].base, memmap[IBEX_DEV_SENSOR_CTRL].si= ze); create_unimplemented_device("riscv.lowrisc.ibex.otp_ctrl", --=20 2.31.1