Commit 96b6b6aa authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Li Yang

serial: ucc_uart: factor out soft_uart initialization

The "soft uart" mechanism is a workaround for a silicon bug which (as
far as I know) only affects some PPC-based SOCs.

The code that determines which microcode blob to request relies on
some powerpc-specific bits (e.g. the mfspr(SPRN_SVR) and hence also
the asm/reg.h header). This makes it a little awkward to allow this
driver to be built for non-PPC based SOCs with a QE, even if they are
not affected by that silicon bug and thus don't need any of the Soft
UART logic.

There's no way around guarding those bits with some ifdeffery, so to
keep that isolated, factor out the
do-we-need-soft-uart-and-if-so-handle-the-firmware to a separate
function, which we can then easily stub out for non-PPC.
Reviewed-by: default avatarTimur Tabi <timur@kernel.org>
Acked-by: default avatarTimur Tabi <timur@kernel.org>
Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: default avatarLi Yang <leoyang.li@nxp.com>
parent 8b1cdc40
......@@ -1183,30 +1183,19 @@ static void uart_firmware_cont(const struct firmware *fw, void *context)
release_firmware(fw);
}
static int ucc_uart_probe(struct platform_device *ofdev)
static int soft_uart_init(struct platform_device *ofdev)
{
struct device_node *np = ofdev->dev.of_node;
const unsigned int *iprop; /* Integer OF properties */
const char *sprop; /* String OF properties */
struct uart_qe_port *qe_port = NULL;
struct resource res;
struct qe_firmware_info *qe_fw_info;
int ret;
/*
* Determine if we need Soft-UART mode
*/
if (of_find_property(np, "soft-uart", NULL)) {
dev_dbg(&ofdev->dev, "using Soft-UART mode\n");
soft_uart = 1;
} else {
return 0;
}
/*
* If we are using Soft-UART, determine if we need to upload the
* firmware, too.
*/
if (soft_uart) {
struct qe_firmware_info *qe_fw_info;
qe_fw_info = qe_get_firmware_info();
/* Check if the firmware has been uploaded. */
......@@ -1246,7 +1235,24 @@ static int ucc_uart_probe(struct platform_device *ofdev)
return ret;
}
}
}
return 0;
}
static int ucc_uart_probe(struct platform_device *ofdev)
{
struct device_node *np = ofdev->dev.of_node;
const unsigned int *iprop; /* Integer OF properties */
const char *sprop; /* String OF properties */
struct uart_qe_port *qe_port = NULL;
struct resource res;
int ret;
/*
* Determine if we need Soft-UART mode
*/
ret = soft_uart_init(ofdev);
if (ret)
return ret;
qe_port = kzalloc(sizeof(struct uart_qe_port), GFP_KERNEL);
if (!qe_port) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment