From patchwork Thu Oct 1 07:08:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1374884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 4C247l55Pvz9sVM for ; Thu, 1 Oct 2020 17:12:19 +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=LJjVT/AZ; 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 4C247l3sjjzDqTb for ; Thu, 1 Oct 2020 17:12:19 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (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 4C247d1jNtzDqSt for ; Thu, 1 Oct 2020 17:12:13 +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=LJjVT/AZ; 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 4C247Z1ffdz9sVL; Thu, 1 Oct 2020 17:12:09 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1601536332; bh=QRpfrOQ/dqWlr/xtjof2onxyzisi3vXictZXfkwFrLw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LJjVT/AZXAQ9JvAP/Au1Ugcn3hvWHcTPxgsxWlpJcSYAyTq7WdEx1QCHFYfKp3Ahz OjLNISBQZ7SwnuV1k/Ldpf9TfSg8y/0LE9T/ruv7J7++nmvkK7q6nxNTsmwOfzeMtd y4MkdJIgSv7JMcEKeURWQnylepgrxVjXh8kaz56ly6+Y++cSPrua8p4WeZyX0aQa4c 4Fp/CGMtBe+Px9hx3XBp6hqGxp5+Dr7i05gBnQSKkS0HwCD6Lr8fGt52Qou8kDX2td 8/6fPopACi8tjYM21+hwejhYYaNHvPA1A5s8YzA2EwSB2/gudb6rlelvsTaKOtozik A2iHvxrALtvjw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 1 Oct 2020 17:08:12 +1000 Message-Id: <20201001070814.102735-19-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201001070814.102735-1-amitay@ozlabs.org> References: <20201001070814.102735-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 18/20] libpdbg: Add sbefifo based implementation of ocmb getscom/putscom 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: Joel Stanley --- Makefile.am | 1 + libpdbg/ocmb.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 libpdbg/ocmb.c diff --git a/Makefile.am b/Makefile.am index d902863..a970ab9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -178,6 +178,7 @@ libpdbg_la_SOURCES = \ libpdbg/kernel.c \ libpdbg/libpdbg.c \ libpdbg/libpdbg.h \ + libpdbg/ocmb.c \ libpdbg/operations.h \ libpdbg/p8chip.c \ libpdbg/p9chip.c \ diff --git a/libpdbg/ocmb.c b/libpdbg/ocmb.c new file mode 100644 index 0000000..ef929f9 --- /dev/null +++ b/libpdbg/ocmb.c @@ -0,0 +1,85 @@ +/* Copyright 2020 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include + +#include "hwunit.h" + +static struct sbefifo *ocmb_to_sbefifo(struct ocmb *ocmb) +{ + struct pdbg_target *pib = pdbg_target_require_parent("pib", &ocmb->target); + 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; + } + } + + assert(sbefifo); + + return sbefifo; +} + +static int sbefifo_ocmb_getscom(struct ocmb *ocmb, uint64_t addr, uint64_t *value) +{ + struct sbefifo *sbefifo = ocmb_to_sbefifo(ocmb); + struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); + uint8_t instance_id; + + instance_id = pdbg_target_index(&ocmb->target) & 0xff; + + return sbefifo_hw_register_get(sctx, + SBEFIFO_TARGET_TYPE_OCMB, + instance_id, + addr, + value); +} + +static int sbefifo_ocmb_putscom(struct ocmb *ocmb, uint64_t addr, uint64_t value) +{ + struct sbefifo *sbefifo = ocmb_to_sbefifo(ocmb); + struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); + uint8_t instance_id; + + instance_id = pdbg_target_index(&ocmb->target) & 0xff; + + return sbefifo_hw_register_put(sctx, + SBEFIFO_TARGET_TYPE_OCMB, + instance_id, + addr, + value); +} + +static struct ocmb sbefifo_ocmb = { + .target = { + .name = "SBE FIFO Chip-op based OCMB", + .compatible = "ibm,power-ocmb", + .class = "ocmb", + }, + .getscom = sbefifo_ocmb_getscom, + .putscom = sbefifo_ocmb_putscom, +}; +DECLARE_HW_UNIT(sbefifo_ocmb); + +__attribute__((constructor)) +static void register_ocmb(void) +{ + pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &sbefifo_ocmb_hw_unit); +}