[Skiboot] [PATCH v2 03/14] console: add helper to create serial console nodes

Andrew Donnellan andrew.donnellan at au1.ibm.com
Tue Dec 20 17:34:12 AEDT 2016


On 20/12/16 17:03, Oliver O'Halloran wrote:
> The creation of /ibm,skiboot/console/serial@<xyz> nodes is pretty much
> identical across the various OPAL console drivers. This patch moves it
> into a helper function as a cleanup.
>
> Signed-off-by: Oliver O'Halloran <oohall at gmail.com>

LGTM.

Reviewed-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>

> diff --git a/hw/fsp/fsp-console.c b/hw/fsp/fsp-console.c
> index 46ac28bbd822..8a88f2876aa8 100644
> --- a/hw/fsp/fsp-console.c
> +++ b/hw/fsp/fsp-console.c
> @@ -917,40 +917,32 @@ 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);
> +			dt_add_property_cells(fs_node,
> +				"interrupt-parent", opal_event->phandle);

This hunk isn't needed

>  	}
>  }
>
> diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c
> index 66932652608e..f91bccf7c716 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", INMEM_CON_OUT_LEN);

Change this to use memcons.obuf_size as well for consistency? (Or keep 
the other one using INMEM_CON_OUT_LEN?)

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan at au1.ibm.com  IBM Australia Limited



More information about the Skiboot mailing list