From patchwork Tue May 19 05:46:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292947 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49R4fs3Bfqz9sTC for ; Tue, 19 May 2020 15:48:05 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=n2C/FdrQ; 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 49R4fs0nMYzDqQs for ; Tue, 19 May 2020 15:48:05 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::643; helo=mail-pl1-x643.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=n2C/FdrQ; dkim-atps=neutral Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4dl4NPbzDqsx for ; Tue, 19 May 2020 15:47:07 +1000 (AEST) Received: by mail-pl1-x643.google.com with SMTP id d3so452651pln.1 for ; Mon, 18 May 2020 22:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lY/iSM1GY113Xr8QPL7oWJQ6URBXaVeNizyto83yh9I=; b=n2C/FdrQKUL6C9qvL7BCVaO5hGpx0xbmkHwyvQPG8D31nbUbIlAIDFYfOXwn3xcp6r +IpiCGfRYoT+LLEtDu4BOoTpwNIjKMgtDtBSc94iF+OiyBUCskZNckloXAFqhRK8He/F jDcn/nC7oAk3gXPjqPxSaH5ErAkCUNbPf53nYaEx1+eSS2KA5mF4f0mb92Wu4PyTjXc5 9A7gEW3YdIlOaRzLBGF/fC8BeVWmh7Oup1zxuAywAcASdh06B1DkZsuLqa2cC2C+wG/3 vSXiRKsb42lKvAewU4cCvfZy2UsS6RUxg5EHwvpJoRncMibD+BUcuGqSl/67vLM0DAjY 1XmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lY/iSM1GY113Xr8QPL7oWJQ6URBXaVeNizyto83yh9I=; b=f8TsHyISOszA5YqVYGnlzLZiFwkVfl9CwyNIn/z77fd29fL2m57AgYfeEpbqW0qwvh KKXEGm1c7yPRFEVP8vKjQZrcxUR7lolRMl7Z7fHRlA8tXY+8mvypy4cgw3LEdu9Lhaez dKbeJbVoSJdNRDHc3OyQTeQA+8Bm7gOKcnIy0jlMSR20QAkQiF4VHxRUXqW1NsU+Ot3R A1bI/AzG0UZ2MN5jhM79dT6V1DzsPAyE8wzyvfMQLfnobx5toF1u78qg2NeNxgosthmG WjS3O1IXdiQKvSa82UCrpBMtvNsJ18eodtUqKy8f43RBQZTmyYQrSuxd3E99q7+1m+Ji +HdA== X-Gm-Message-State: AOAM530r2OFQCBuEkK3utbJYYlEXO8W1lwfH1WGRPtwCnzZ/QDuIuSKl HqiVk+yPO2Ee2Uf7CUHTllEHW4DL X-Google-Smtp-Source: ABdhPJybrTL0/E27Jbb+1eXaTT3day6B3SKRdUOWJM/kf14mjFqeC5GS7I2yqDj86J4N8v0Ke6DRpA== X-Received: by 2002:a17:902:b202:: with SMTP id t2mr20097076plr.1.1589867223944; Mon, 18 May 2020 22:47:03 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:03 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:22 +1000 Message-Id: <20200519054633.113238-2-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 01/12] platform/mambo: Add a mambo OPAL console driver X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Add a "real" opal_con_driver for the mambo platform instead of using the dummy console. This gets mambo using the same console IO path as every other platform and leaves the dummy console only being used for cronus booted systems. Signed-off-by: Oliver O'Halloran --- Yoinked out of Nick's raw console patch set. --- include/console.h | 1 + platforms/mambo/console.c | 64 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/include/console.h b/include/console.h index 02fc7a4b60a5..c14a2e598191 100644 --- a/include/console.h +++ b/include/console.h @@ -85,6 +85,7 @@ struct dt_node *add_opal_console_node(int index, const char *type, extern struct opal_con_ops uart_opal_con; extern struct opal_con_ops fsp_opal_con; extern struct opal_con_ops dummy_opal_con; +extern struct opal_con_ops mambo_opal_con; void mprintf(const char *fmt, ...); diff --git a/platforms/mambo/console.c b/platforms/mambo/console.c index 6d5b20b56e60..f46272d6973c 100644 --- a/platforms/mambo/console.c +++ b/platforms/mambo/console.c @@ -3,6 +3,7 @@ #include #include +#include #include "mambo.h" @@ -42,9 +43,8 @@ size_t mambo_console_write(const char *buf, size_t len) return len; } +/* used to write out the internal console */ static struct con_ops mambo_con_driver = { - .poll_read = mambo_console_poll, - .read = mambo_console_read, .write = mambo_console_write, }; @@ -54,6 +54,66 @@ void enable_mambo_console(void) set_console(&mambo_con_driver); } + +/* OPAL call interface into the underlying mambo console */ +static int64_t mambo_opal_write(int64_t term_number, __be64 *__length, + const uint8_t *buffer) +{ + size_t len = be64_to_cpu(*__length); + + if (term_number != 0) + return OPAL_PARAMETER; + + mambo_console_write(buffer, len); + + return OPAL_SUCCESS; +} + +static int64_t mambo_opal_write_buffer_space(int64_t term_number, + __be64 *__length) +{ + if (term_number != 0) + return OPAL_PARAMETER; + + *__length = cpu_to_be64(256); + + return OPAL_SUCCESS; +} + +static int64_t mambo_opal_read(int64_t term_number, __be64 *__length, + uint8_t *buffer) +{ + size_t req_count = be64_to_cpu(*__length), read_cnt = 0; + + if (term_number != 0) + return OPAL_PARAMETER; + + read_cnt = mambo_console_read(buffer, req_count); + *__length = cpu_to_be64(read_cnt); + + return OPAL_SUCCESS; +} + +static int64_t mambo_opal_flush(int64_t term_number) +{ + if (term_number != 0) + return OPAL_PARAMETER; + return OPAL_SUCCESS; +} + +static void mambo_init_opal_console(void) +{ +} + +struct opal_con_ops mambo_opal_con = { + .name = "OPAL Mambo console", + .init = mambo_init_opal_console, + .read = mambo_opal_read, + .write = mambo_opal_write, + .space = mambo_opal_write_buffer_space, + .flush = mambo_opal_flush, +}; + /* * mambo console based printf(), this is useful for debugging the console * since mambo_console_write() can be safely called from anywhere.