Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp858985pxb; Thu, 21 Oct 2021 10:48:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMuUnemeJ2Re1IG4i2+L6gywdmRIzqM5zxB6HCLPiPdoCdCi+oMj8N+V3dfgI2p7iAXU2e X-Received: by 2002:a17:906:2f16:: with SMTP id v22mr8924631eji.334.1634838538017; Thu, 21 Oct 2021 10:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634838538; cv=none; d=google.com; s=arc-20160816; b=Fz7xDlhcVujDgrwEQRTl26ejXS10gzchMNomfP5oZzPZh/HQkBSQtapc3AVFGkIqP4 qa5BgRMlxLl2oP6JorJhfCANWumrhsMGt4fpEwM6kdoDtmxAz6nJmtqWVEHdsV96RTLq vsuMgDpZ3YGJ+mJR6xH8prTPiVgm2e9ojHXCS9GYHnTCal9t1xXCiMvYUlsPv+LZQRey yQu+g39FQvdiMhopDaX1mtGFkKe3P8Ap78ORhldWDdq5iKnct5Fo4c6mkpyBFZ1OyUfr XJI05QjZ0zBgsik28jzU2jXuNRsXxFhH8EEhuOWfTM/DiflRv5GtBcRfazjpos7KYdcU KfAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=ptUclAnClC/KmmGAr8nhcG6uMjRIYcBreeo6zNMjNJc=; b=dtPeHwL1+I9XVEfPTig/EgLWQbmTEZYFO0IZLKjmbg+mqU8YzyqkR4/Nhe8vUHOViH EHEzhAszaHc4pqXEj5ZuBh/qToWK3IAkYGpSdNItO2VJNNg5PtOMVt2DftDwL/bgHOvI IqnKoPRaW7quS6lMHAPrXJc2CRH3ZCekthtTTgB+rUUNz8PbIIerXzoz7BAaycmm+w7W JIh+4OKMH7WjCE3TR2uQkvY2tWe46SUGzvltiJd2ufyRyTkQhoNQ6Jm5jLaZ0NOdhIL3 Fh4TscDHBlU05AlW5wSDQVLg4b0mJKZj8gineS1KDkE2o1uPf0aXyEplduQusph7YLgA TH4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FiKMgfWf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si7943395edf.127.2021.10.21.10.48.34; Thu, 21 Oct 2021 10:48:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FiKMgfWf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232503AbhJURql (ORCPT + 99 others); Thu, 21 Oct 2021 13:46:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232558AbhJURp3 (ORCPT ); Thu, 21 Oct 2021 13:45:29 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA780C061764; Thu, 21 Oct 2021 10:42:52 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id w14so4151840edv.11; Thu, 21 Oct 2021 10:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ptUclAnClC/KmmGAr8nhcG6uMjRIYcBreeo6zNMjNJc=; b=FiKMgfWfdrsa0xi5VdPw2NT4Bn8OpRhZ+z70WsyehhOS6AA2ALCaezW4CeeQ9qymZP C2YvNEttXHPUeTLJhvR/QKgDx3j216qhepTFWRGYbVmoklBqi+W5hSOeXpunSOkrkkE0 OHwEOgq6u6I5YinCiutlKNLpF6bTRst4ugRzdat/x0d4w2+ARfjaMWOLMDikLTQmXMhs 5vwiZkC4WnieND7MBasl0SQsyYMvE52NtxK//G5o2vXzS4sI1cEjEuWdnPox3CbHl5Zg mpyIdwsTZfmVD05xKP9OLYNthwRrHpcNyd4k5yI/ZMaXspXfSOUl+1AjjBCMUVq+jMCD 7tpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ptUclAnClC/KmmGAr8nhcG6uMjRIYcBreeo6zNMjNJc=; b=39AX9b3qQGiqByX0OFY47Sg44XIhS6+9g4dRBVLJ0wQbkJ7WhHwwngSvTPQfCA2cLg x5N8/JeohHm/4l+FsubLLTWG1QciniCJqWDISWFjfDGa5oG0gWI1DWW0eVqbgZ5IlIgZ tPtEtOSUe8Xm8NJPzzA0a7jEAeWH1XIt9Ab0WXUVqIAlfB7ZSGHWXuKX8/ohfdPn6/Dl GvdV9u9ZRCXisHys+UjG2Qyeb71roL6GMopfUyb6I0JRwgxrgFCUykDzBpYvZGgQBKv7 kdMJRkCB/u2+4HBvLlJIM1EAjQz1H8CS0bJPmTiH30EIQ1irhQJKgn6jRRZiFtHdHbw6 zebA== X-Gm-Message-State: AOAM533j3i/5VyzpDW3O69KN6AqnQ2isTP6P3KdZvoez9wDBlPW7yhzy jIN9FqilE1935E4ucvHYzZQ= X-Received: by 2002:aa7:d14b:: with SMTP id r11mr9596878edo.173.1634838171073; Thu, 21 Oct 2021 10:42:51 -0700 (PDT) Received: from stitch.. (80.71.140.73.ipv4.parknet.dk. [80.71.140.73]) by smtp.gmail.com with ESMTPSA id h7sm3144847edt.37.2021.10.21.10.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 10:42:50 -0700 (PDT) Sender: Emil Renner Berthing From: Emil Renner Berthing To: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-gpio@vger.kernel.org, linux-serial@vger.kernel.org Cc: Emil Renner Berthing , Palmer Dabbelt , Paul Walmsley , Rob Herring , Michael Turquette , Stephen Boyd , Thomas Gleixner , Marc Zyngier , Philipp Zabel , Linus Walleij , Greg Kroah-Hartman , Daniel Lezcano , Andy Shevchenko , Jiri Slaby , Maximilian Luz , Sagar Kadam , Drew Fustini , Geert Uytterhoeven , Michael Zhu , Fu Wei , Anup Patel , Atish Patra , Matteo Croce , linux-kernel@vger.kernel.org Subject: [PATCH v2 14/16] serial: 8250_dw: Add skip_clk_set_rate quirk Date: Thu, 21 Oct 2021 19:42:21 +0200 Message-Id: <20211021174223.43310-15-kernel@esmil.dk> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211021174223.43310-1-kernel@esmil.dk> References: <20211021174223.43310-1-kernel@esmil.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On the StarFive JH7100 SoC the UART core clocks can't be set to exactly 16 * 115200Hz and many other common bitrates. Trying this will only result in a higher input clock, but low enough that the UART's internal divisor can't come close enough to the baud rate target. So rather than try to set the input clock it's better to rely solely on the UART's internal divisor. Signed-off-by: Emil Renner Berthing --- drivers/tty/serial/8250/8250_dw.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index 5a2ff843ec5d..729b59b14ff1 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -50,6 +50,7 @@ struct dw8250_data { struct reset_control *rst; unsigned int skip_autocfg:1; + unsigned int skip_clk_set_rate:1; unsigned int uart_16550_compatible:1; }; @@ -326,14 +327,18 @@ dw8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old) pm_runtime_put_sync_suspend(port->dev); } -static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, - struct ktermios *old) +static void dw8250_do_clk_set_rate(struct uart_port *p, struct ktermios *termios) { - unsigned long newrate = tty_termios_baud_rate(termios) * 16; struct dw8250_data *d = to_dw8250_data(p->private_data); + unsigned long newrate; long rate; int ret; + if (d->skip_clk_set_rate) + return; + + newrate = tty_termios_baud_rate(termios) * 16; + clk_disable_unprepare(d->clk); rate = clk_round_rate(d->clk, newrate); if (rate > 0) { @@ -349,7 +354,12 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, swap(p->uartclk, rate); } clk_prepare_enable(d->clk); +} +static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, + struct ktermios *old) +{ + dw8250_do_clk_set_rate(p, termios); dw8250_do_set_termios(p, termios, old); } @@ -417,6 +427,8 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) if (of_device_is_compatible(np, "marvell,armada-38x-uart")) p->serial_out = dw8250_serial_out38x; + if (of_device_is_compatible(np, "starfive,jh7100-uart")) + data->skip_clk_set_rate = true; } else if (acpi_dev_present("APMC0D08", NULL, -1)) { p->iotype = UPIO_MEM32; @@ -699,6 +711,7 @@ static const struct of_device_id dw8250_of_match[] = { { .compatible = "cavium,octeon-3860-uart" }, { .compatible = "marvell,armada-38x-uart" }, { .compatible = "renesas,rzn1-uart" }, + { .compatible = "starfive,jh7100-uart" }, { /* Sentinel */ } }; MODULE_DEVICE_TABLE(of, dw8250_of_match); -- 2.33.1