mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
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: Timur Tabi <timur@kernel.org> Acked-by: Timur Tabi <timur@kernel.org> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Li Yang <leoyang.li@nxp.com>
This commit is contained in:
parent
8b1cdc4033
commit
96b6b6aaac
1 changed files with 58 additions and 52 deletions
|
@ -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,8 +1235,25 @@ 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) {
|
||||
dev_err(&ofdev->dev, "can't allocate QE port structure\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue