From patchwork Wed Dec 21 04:52:25 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: 707639 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tk2NS6Fn3z9t0q for ; Wed, 21 Dec 2016 15:53:28 +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="TZN8nloN"; 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 3tk2NS5CHwzDwXX for ; Wed, 21 Dec 2016 15:53:28 +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="TZN8nloN"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pg0-x243.google.com (mail-pg0-x243.google.com [IPv6:2607:f8b0:400e:c05::243]) (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 3tk2Mm2JN3zDwXF for ; Wed, 21 Dec 2016 15:52:52 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TZN8nloN"; dkim-atps=neutral Received: by mail-pg0-x243.google.com with SMTP id i5so5166783pgh.2 for ; Tue, 20 Dec 2016 20:52:52 -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=yizwcifH4AIcrGE8PcwYQ0h/ZMwV1hGsJbPvBMx0IT0=; b=TZN8nloNtwQ9Xxegavi3DqowfuTRHMtxjl1IblPrV4obnN1sYJvZBRV8CE5dmGuE1S XaCz/OUiVDZGBq8uWEL4LfCVrsBNg2aiO5d4K4/J+MxpRMovvj26v4MSgvLZyuSB1Q0D hlRWpvGeIWUw+dNsFlEUmsECgkuuBg0VufzRAHqS2ySVKDdl4l9jw4Q9Y0EL2cToYZ+J avWPRrtGH5vqalC4WZ2FCMDwA3xMzXjNyuYvHmtAkOLIvtS741nsK93J7n/xK2ePXnVq yhFHjKSGCc/V3qbDOXPtehrVP2RhaHWPe413xj9KDdAMhFTDl6225HrhuEf0oyYNKSay RWkg== 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=yizwcifH4AIcrGE8PcwYQ0h/ZMwV1hGsJbPvBMx0IT0=; b=mjtqWg98JEdkGXMNqluqjxknCz00vuwRpmsMklropBZZPuaEckFtMNdQQM6E9w2gpI 5bq6ciDsDMxSzI4Uws/ZFaqRj8zZu/pPy6Qm1eOX9srvAMb9J88vxcXOAAAGdtw3XPSV 8tDjH7FOxVx7+QsMou77IydQ/8sf7zqO5bIr8E5gZe31evvInFngmrMtGvu58Xkqds/y 6aUw3JN+08pC/I/+B3Dv3BoPoQf3yXADf9BWZJNtcY44J+PWuIE+F/JLmk3cjjzNJMV6 8KEtanTo1xX6CD97WVoaVY/eJSSKya4m3XiFxeo4go/8zU9O+wnmXtisWeBZjeaqzxXu NY2g== X-Gm-Message-State: AIkVDXJ/mVyKhgk1RwHFUGHDle+Zl2TVnVPvA4+HXo8nxX//YmZMfm88Kg80cip4+CLPZw== X-Received: by 10.98.215.85 with SMTP id v21mr2488673pfl.80.1482295970661; Tue, 20 Dec 2016 20:52:50 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Dec 2016 20:52:50 -0800 (PST) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Wed, 21 Dec 2016 15:52:25 +1100 Message-Id: <1482295952-30060-4-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 03/10] console: add helper to create serial console nodes 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" The creation of /ibm,skiboot/console/serial@ nodes is pretty much identical across the various OPAL console drivers. This patch moves it into a helper function as a cleanup. Reviewed-by: Andrew Donnellan Signed-off-by: Oliver O'Halloran --- v2 -> v3: removed whitespace change fixed a bug where the UART output console buffer was set to 1MB rather than 4KB. --- core/console.c | 43 +++++++++++++++++++++++++++++++------------ hw/fsp/fsp-console.c | 24 ++++++++---------------- hw/lpc-uart.c | 16 ++-------------- include/console.h | 3 +++ 4 files changed, 44 insertions(+), 42 deletions(-) diff --git a/core/console.c b/core/console.c index 20de285f5104..10f105d437fe 100644 --- a/core/console.c +++ b/core/console.c @@ -103,6 +103,36 @@ void enable_mambo_console(void) set_console(&mambo_con_driver); } +/* + * Helper function for adding /ibm,opal/consoles/serial@ nodes + */ +struct dt_node *add_opal_console_node(int index, const char *type, + uint32_t write_buffer_size) +{ + struct dt_node *con, *consoles; + char buffer[32]; + + consoles = dt_find_by_name(opal_node, "consoles"); + if (!consoles) { + consoles = dt_new(opal_node, "consoles"); + assert(consoles); + dt_add_property_cells(consoles, "#address-cells", 1); + dt_add_property_cells(consoles, "#size-cells", 0); + } + + con = dt_new_addr(consoles, "serial", index); + assert(con); + + snprintf(buffer, sizeof(buffer), "ibm,opal-console-%s", type); + dt_add_property_string(con, "compatible", buffer); + + dt_add_property_cells(con, "#write-buffer-size", write_buffer_size); + dt_add_property_cells(con, "reg", index); + dt_add_property_string(con, "device_type", "serial"); + + return con; +} + void clear_console(void) { memset(con_buf, 0, INMEM_CON_LEN); @@ -399,20 +429,9 @@ static void dummy_console_poll(void *data __unused) void dummy_console_add_nodes(void) { - struct dt_node *con, *consoles; struct dt_property *p; - consoles = dt_new(opal_node, "consoles"); - assert(consoles); - dt_add_property_cells(consoles, "#address-cells", 1); - dt_add_property_cells(consoles, "#size-cells", 0); - - con = dt_new_addr(consoles, "serial", 0); - assert(con); - dt_add_property_string(con, "compatible", "ibm,opal-console-raw"); - dt_add_property_cells(con, "#write-buffer-size", INMEM_CON_OUT_LEN); - dt_add_property_cells(con, "reg", 0); - dt_add_property_string(con, "device_type", "serial"); + add_opal_console_node(0, "raw", memcons.obuf_size); /* Mambo might have left a crap one, clear it */ p = __dt_find_property(dt_chosen, "linux,stdout-path"); diff --git a/hw/fsp/fsp-console.c b/hw/fsp/fsp-console.c index 46ac28bbd822..8fd18d1a8f03 100644 --- a/hw/fsp/fsp-console.c +++ b/hw/fsp/fsp-console.c @@ -917,37 +917,29 @@ void fsp_console_reset(void) void fsp_console_add_nodes(void) { + struct dt_node *opal_event; unsigned int i; - struct dt_node *consoles, *opal_event; - consoles = dt_new(opal_node, "consoles"); - dt_add_property_cells(consoles, "#address-cells", 1); - dt_add_property_cells(consoles, "#size-cells", 0); + opal_event = dt_find_by_name(opal_node, "event"); + for (i = 0; i < MAX_SERIAL; i++) { struct fsp_serial *fs = &fsp_serials[i]; struct dt_node *fs_node; - char name[32]; + const char *type; if (fs->log_port || !fs->available) continue; - snprintf(name, sizeof(name), "serial@%d", i); - fs_node = dt_new(consoles, name); if (fs->rsrc_id == 0xffff) - dt_add_property_string(fs_node, "compatible", - "ibm,opal-console-raw"); + type = "raw"; else - dt_add_property_string(fs_node, "compatible", - "ibm,opal-console-hvsi"); - dt_add_property_cells(fs_node, - "#write-buffer-size", SER_BUF_DATA_SIZE); - dt_add_property_cells(fs_node, "reg", i); - dt_add_property_string(fs_node, "device_type", "serial"); + type = "hvsi"; + + fs_node = add_opal_console_node(i, type, SER_BUF_DATA_SIZE); fs->irq = opal_dynamic_event_alloc(); dt_add_property_cells(fs_node, "interrupts", ilog2(fs->irq)); - opal_event = dt_find_by_name(opal_node, "event"); if (opal_event) dt_add_property_cells(fs_node, "interrupt-parent", opal_event->phandle); diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c index 66932652608e..2383ff54ee32 100644 --- a/hw/lpc-uart.c +++ b/hw/lpc-uart.c @@ -420,20 +420,8 @@ void uart_setup_linux_passthrough(void) void uart_setup_opal_console(void) { - struct dt_node *con, *consoles; - - /* Create OPAL console node */ - consoles = dt_new(opal_node, "consoles"); - assert(consoles); - dt_add_property_cells(consoles, "#address-cells", 1); - dt_add_property_cells(consoles, "#size-cells", 0); - - con = dt_new_addr(consoles, "serial", 0); - assert(con); - dt_add_property_string(con, "compatible", "ibm,opal-console-raw"); - dt_add_property_cells(con, "#write-buffer-size", INMEM_CON_OUT_LEN); - dt_add_property_cells(con, "reg", 0); - dt_add_property_string(con, "device_type", "serial"); + /* Add the opal console node */ + add_opal_console_node(0, "raw", OUT_BUF_SIZE); dt_add_property_string(dt_chosen, "linux,stdout-path", "/ibm,opal/consoles/serial@0"); diff --git a/include/console.h b/include/console.h index 4c77433421f6..6a80bef96c7a 100644 --- a/include/console.h +++ b/include/console.h @@ -71,4 +71,7 @@ extern void clear_console(void); extern void memcons_add_properties(void); extern void dummy_console_add_nodes(void); +struct dt_node *add_opal_console_node(int index, const char *type, + uint32_t write_buffer_size); + #endif /* __CONSOLE_H */