From patchwork Thu Apr 30 02:34:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1279874 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49CKKd49zRz9sSg for ; Thu, 30 Apr 2020 12:37:25 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=pZPv6PkV; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49CKKd2m3jzDr6T for ; Thu, 30 Apr 2020 12:37:25 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49CKGq6WjFzDr6T for ; Thu, 30 Apr 2020 12:34:59 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=pZPv6PkV; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 49CKGp48ggz9sSy; Thu, 30 Apr 2020 12:34:58 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1588214098; bh=PgUKlE49fr0xiv+NVzy0xq73k3QeCnMsMD8FqMm0ONk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pZPv6PkVqUyA/DjiMi6zaaVSQJSt5gsU6wWwkmgsPx9QeN3fkP9DBUdkVdOTuEprV /5fameJ+sN8L8AcTaN/T9uoasnBmeiufnnLFEqPVRZuyT2vBaurb10Hjr3VsX27P5H +oB4GqmlrO+lx0U62GbInWRMX6AYKlr41RPVkBlNUYrIizmLVB3V4SfyHTPoF0zvVa LbqkmSEFmP0qYnDbvW+vwWBRlIuIl3ma5MJjs8cumlm4ff8sZqJwoQABe6xSG2pTjN 5wrUvwcykb9b1Rk1otIAkwQCoUeAkXKBU1E1h+B4CjabqYvDyewgSQ8wNqdA8pMmKl VxBNh92sSHbAQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 30 Apr 2020 12:34:32 +1000 Message-Id: <20200430023440.225504-12-amitay@ozlabs.org> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200430023440.225504-1-amitay@ozlabs.org> References: <20200430023440.225504-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 11/19] libpdbg: Add pib driver using sbefifo X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/sbefifo.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c index 22f11f1..ca3a43d 100644 --- a/libpdbg/sbefifo.c +++ b/libpdbg/sbefifo.c @@ -237,6 +237,40 @@ static int sbefifo_op_thread_sreset(struct chipop *chipop, return sbefifo_op_control(chipop, core_id, thread_id, SBEFIFO_INSN_OP_SRESET); } +static struct sbefifo *pib_to_sbefifo(struct pdbg_target *pib) +{ + struct pdbg_target *target; + struct sbefifo *sbefifo = NULL; + + pdbg_for_each_class_target("sbefifo", target) { + if (pdbg_target_index(target) == pdbg_target_index(pib)) { + sbefifo = target_to_sbefifo(target); + break; + } + } + + if (sbefifo == NULL) + assert(sbefifo); + + return sbefifo; +} + +static int sbefifo_pib_read(struct pib *pib, uint64_t addr, uint64_t *val) +{ + struct sbefifo *sbefifo = pib_to_sbefifo(&pib->target); + struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); + + return sbefifo_scom_get(sctx, addr, val); +} + +static int sbefifo_pib_write(struct pib *pib, uint64_t addr, uint64_t val) +{ + struct sbefifo *sbefifo = pib_to_sbefifo(&pib->target); + struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); + + return sbefifo_scom_put(sctx, addr, val); +} + static struct sbefifo_context *sbefifo_op_get_context(struct sbefifo *sbefifo) { return sbefifo->sf_ctx; @@ -306,6 +340,18 @@ static struct chipop sbefifo_chipop = { }; DECLARE_HW_UNIT(sbefifo_chipop); +static struct pib sbefifo_pib = { + .target = { + .name = "SBE FIFO Chip-op based PIB", + .compatible = "ibm,sbefifo-pib", + .class = "pib", + }, + .read = sbefifo_pib_read, + .write = sbefifo_pib_write, + .fd = -1, +}; +DECLARE_HW_UNIT(sbefifo_pib); + static struct sbefifo kernel_sbefifo = { .target = { .name = "Kernel based FSI SBE FIFO", @@ -323,6 +369,7 @@ static void register_sbefifo(void) { pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &kernel_sbefifo_hw_unit); pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &sbefifo_chipop_hw_unit); + pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &sbefifo_pib_hw_unit); pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &sbefifo_mem_hw_unit); pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &sbefifo_pba_hw_unit); }