From patchwork Thu Mar 10 16:16:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 550729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96A39C433F5 for ; Thu, 10 Mar 2022 16:22:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234816AbiCJQXW (ORCPT ); Thu, 10 Mar 2022 11:23:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244204AbiCJQW4 (ORCPT ); Thu, 10 Mar 2022 11:22:56 -0500 Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [217.70.178.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749E719ABDD for ; Thu, 10 Mar 2022 08:20:43 -0800 (PST) Received: from relay6-d.mail.gandi.net (unknown [IPv6:2001:4b98:dc4:8::226]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 3FF18CF168 for ; Thu, 10 Mar 2022 16:17:08 +0000 (UTC) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id B7057C0005; Thu, 10 Mar 2022 16:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1646929020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CJZBZm79jOepeJwYz+AdnFA8gp47gjCL5Z1SD7IGsiA=; b=DZgGosu/Kfy2qhe+UyyPoAgETCzi225XY0Zht+wbAoOivCQEg98kJj3vq/ODk2wWsdqoGh iCgNPaEm9dLYFUy4RIjLZYASU+3YM/FcII9xGCu98FMbDqeIjNd1YbFQuwJnUe2bcA9jYo fKBzCNCZ1+4CFZscKQ2b2qA1VoMrytdhIEvAZm3lK9WXpOOrcYA4MH2BD9Rgj6bAjTZYOI tkYyokxEGNUAqLI2LOjDNLhvcL4GN3r+RP8wRURCzd+oIeKVhZAUyR1NEIrn2Mj9B1IGWR 4RGzbVeCfTsALayDzuk/jGbLdFkHEjZAPHmlhg6FFg2PqpfT8I9MFsGClK84KQ== From: Miquel Raynal To: linux-renesas-soc@vger.kernel.org, Magnus Damm , Gareth Williams , Phil Edworthy , Geert Uytterhoeven , Greg Kroah-Hartman Cc: Jiri Slaby , Andy Shevchenko , linux-serial@vger.kernel.org, Milan Stevanovic , Jimmy Lalande , Pascal Eberhard , Thomas Petazzoni , Herve Codina , Clement Leger , Miquel Raynal Subject: [PATCH 3/7] serial: 8250_dw: Use a fallback CPR value if not synthesized Date: Thu, 10 Mar 2022 17:16:46 +0100 Message-Id: <20220310161650.289387-4-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220310161650.289387-1-miquel.raynal@bootlin.com> References: <20220310161650.289387-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Phil Edworthy This UART controller can be synthesized without the CPR register. In that case, let's use the platform information to provide a CPR value. Signed-off-by: Phil Edworthy Signed-off-by: Miquel Raynal --- drivers/tty/serial/8250/8250_dwlib.c | 10 ++++++++-- drivers/tty/serial/8250/8250_dwlib.h | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c index 622d3b0d89e7..5cf298c5a0f9 100644 --- a/drivers/tty/serial/8250/8250_dwlib.c +++ b/drivers/tty/serial/8250/8250_dwlib.c @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -90,6 +91,7 @@ EXPORT_SYMBOL_GPL(dw8250_do_set_termios); void dw8250_setup_port(struct uart_port *p) { struct uart_8250_port *up = up_to_u8250p(p); + const struct dw8250_platform_data *plat = of_device_get_match_data(up->port.dev); u32 reg; /* @@ -116,8 +118,12 @@ void dw8250_setup_port(struct uart_port *p) } reg = dw8250_readl_ext(p, DW_UART_CPR); - if (!reg) - return; + if (!reg) { + if (!plat) + return; + + reg = plat->cpr; + } /* Select the type based on FIFO */ if (reg & DW_UART_CPR_FIFO_MODE) { diff --git a/drivers/tty/serial/8250/8250_dwlib.h b/drivers/tty/serial/8250/8250_dwlib.h index ef63eaf7e598..ffce2744a28e 100644 --- a/drivers/tty/serial/8250/8250_dwlib.h +++ b/drivers/tty/serial/8250/8250_dwlib.h @@ -16,6 +16,10 @@ struct dw8250_port_data { u8 dlf_size; }; +struct dw8250_platform_data { + u32 cpr; +}; + struct dw8250_data { struct dw8250_port_data data;