From patchwork Wed Dec 21 04:52:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 707643 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tk2PC6MbGz9t0q for ; Wed, 21 Dec 2016 15:54:07 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Km/miXsX"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tk2PC5H69zDwbS for ; Wed, 21 Dec 2016 15:54:07 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Km/miXsX"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tk2Mv6wb2zDwXX for ; Wed, 21 Dec 2016 15:52:59 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Km/miXsX"; dkim-atps=neutral Received: by mail-pg0-x242.google.com with SMTP id g1so12991805pgn.0 for ; Tue, 20 Dec 2016 20:52:59 -0800 (PST) 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; bh=UgGTJb3rjVNAWKqh8f/JW9GyndYDnUB8vigXmGeJe/8=; b=Km/miXsXM9XiyBoSom0i7jxfCFK2icYuTwsJSu+ndg9BTOh5B66IPFGTG4UWfOpAy2 CL8LzHanHXEugs/xjBLUcSQPWkSpNOkFxoxctBzBqu1Jb6fyHjX/Alx4x1kxLW0x3ZoJ hAdwtLnyi8jTZselQNJQGvTLTGKxHg5aUueJrQV0xtk940rlbgjhtf8m3LZRPK7uQKo4 yl8kcnLgFtmKcELdT9kfg0nOnBajE+tKh7tw6UwsUYsRvF3RjylDNpig3akUD5RZROhg lwLSzTbtwxoEgA4eFlnwr1q71onAOMXxQBVMMj3u16Z5DceAWTv4L4pqQWVgdgzM5y9g P3Jw== 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; bh=UgGTJb3rjVNAWKqh8f/JW9GyndYDnUB8vigXmGeJe/8=; b=HpYMt32skqituNNJUz0vm6Q221A/AYSDfSnTDiwWXYSsOgYT8Eo1wvCWit7+7tCW9m dUfy3WXC74IGVBdvXw58C/Ng0vJ1FseYpeZbmANcV9rSlwuAboIhjWYf6K4fu5VXjDM7 bNp2hEiqgLH1iuVR06avaKH6CMAHquCrcPZ/LPFkgETU2HVxd77dvMekjp3ZR7ZwwPLg XNx7lTJ1wSG+yqXOtpI26C60zd0dZ4U6RT5HdK+mpO536kiF6jqbPjffajniSuvNbpoe z+ed3Bdv3ySetrq5Bs47bM63ycYYcJC0FCoLjvtBlQfPaiR8xgJAbTAnh5tYN4aCFsD6 R5uQ== X-Gm-Message-State: AIkVDXJA45JaRaupdoEsiDSkNQq4RaL7ay6Vsd+hDhxYsbYaagMndjtdnPqkP9ojKRUDqQ== X-Received: by 10.98.30.1 with SMTP id e1mr2466638pfe.28.1482295978190; Tue, 20 Dec 2016 20:52:58 -0800 (PST) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id 29sm1289001pfo.58.2016.12.20.20.52.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2016 20:52:57 -0800 (PST) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Wed, 21 Dec 2016 15:52:29 +1100 Message-Id: <1482295952-30060-8-git-send-email-oohall@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482295952-30060-1-git-send-email-oohall@gmail.com> References: <1482295952-30060-1-git-send-email-oohall@gmail.com> Subject: [Skiboot] [PATCH v3 07/10] console: add opal_con_ops structure X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Adds a separate structure to house the operations for the OPAL console. This is used to define a new API for dealing with the OPAL console in the next patch. Signed-off-by: Oliver O'Halloran Reviewed-by: Andrew Donnellan --- core/console.c | 14 ++++++++++++++ hw/fsp/fsp-console.c | 15 +++++++++++++++ hw/lpc-uart.c | 17 +++++++++++++++++ include/console.h | 27 +++++++++++++++++++++++++++ 4 files changed, 73 insertions(+) diff --git a/core/console.c b/core/console.c index be5aa6211ce4..4267a6bb0190 100644 --- a/core/console.c +++ b/core/console.c @@ -373,6 +373,11 @@ static int64_t dummy_console_read(int64_t term_number, int64_t *length, } opal_call(OPAL_CONSOLE_READ, dummy_console_read, 3); +static int64_t dummy_console_flush(int64_t term_number __unused) +{ + return OPAL_UNSUPPORTED; +} + static void dummy_console_poll(void *data __unused) { bool has_data = false; @@ -406,3 +411,12 @@ void dummy_console_add_nodes(void) opal_add_poller(dummy_console_poll, NULL); } + +struct opal_con_ops dummy_opal_con = { + .name = "Dummy Console", + .init = dummy_console_add_nodes, + .read = dummy_console_read, + .write = dummy_console_write, + .space = dummy_console_write_buffer_space, + .flush = dummy_console_flush, +}; diff --git a/hw/fsp/fsp-console.c b/hw/fsp/fsp-console.c index 8fd18d1a8f03..8589e8c031f7 100644 --- a/hw/fsp/fsp-console.c +++ b/hw/fsp/fsp-console.c @@ -818,6 +818,21 @@ void fsp_console_init(void) op_display(OP_LOG, OP_MOD_FSPCON, 0x0005); } +static int64_t fsp_console_flush(int64_t terminal __unused) +{ + /* FIXME: There's probably something we can do here... */ + return OPAL_PARAMETER; +} + +struct opal_con_ops fsp_opal_con = { + .name = "FSP OPAL console", + .init = NULL, /* all the required setup is done in fsp_console_init() */ + .read = fsp_console_read, + .write = fsp_console_write, + .space = fsp_console_write_buffer_space, + .flush = fsp_console_flush, +}; + static void flush_all_input(void) { unsigned int i; diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c index 2383ff54ee32..cc1c16506a47 100644 --- a/hw/lpc-uart.c +++ b/hw/lpc-uart.c @@ -375,6 +375,14 @@ static int64_t uart_opal_read(int64_t term_number, int64_t *length, return OPAL_SUCCESS; } +static int64_t uart_opal_flush(int64_t term_number) +{ + if (term_number != 0) + return OPAL_PARAMETER; + + return uart_con_flush(); +} + static void __uart_do_poll(u8 trace_ctx) { if (!in_buf) @@ -453,6 +461,15 @@ void uart_setup_opal_console(void) opal_add_poller(uart_console_poll, NULL); } +struct opal_con_ops uart_opal_con = { + .name = "OPAL UART console", + .init = uart_setup_opal_console, + .read = uart_opal_read, + .write = uart_opal_write, + .space = uart_opal_write_buffer_space, + .flush = uart_opal_flush, +}; + static bool uart_init_hw(unsigned int speed, unsigned int clock) { unsigned int dll = (clock / 16) / speed; diff --git a/include/console.h b/include/console.h index 08d2961e527a..e821ce703898 100644 --- a/include/console.h +++ b/include/console.h @@ -54,6 +54,28 @@ struct con_ops { int64_t (*flush)(void); }; +struct opal_con_ops { + const char *name; + + /* + * OPAL console driver specific init function. + */ + void (*init)(void); + + int64_t (*write)(int64_t term, int64_t *len, const uint8_t *buf); + int64_t (*read)(int64_t term, int64_t *len, uint8_t *buf); + + /* + * returns the amount of space available in the console write buffer + */ + int64_t (*space)(int64_t term_number, int64_t *length); + + /* + * Forces the write buffer to be flushed by the driver + */ + int64_t (*flush)(int64_t term_number); +}; + extern bool dummy_console_enabled(void); extern void force_dummy_console(void); extern bool flush_console(void); @@ -73,4 +95,9 @@ extern void dummy_console_add_nodes(void); struct dt_node *add_opal_console_node(int index, const char *type, uint32_t write_buffer_size); +/* OPAL console drivers */ +extern struct opal_con_ops uart_opal_con; +extern struct opal_con_ops fsp_opal_con; +extern struct opal_con_ops dummy_opal_con; + #endif /* __CONSOLE_H */