Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2856982lqz; Wed, 3 Apr 2024 10:24:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWRfacOeUP1oUe8akgEii+VawDs6rrtxPt7Bt17ddeMD1Wz5ajiTuafrWwar03xi9LmUZcd48PyVVh0c334dVRTtQBZF86wnBaKa5mvdA== X-Google-Smtp-Source: AGHT+IGfVLco203MfgGKxMAF7IXdxCdh6a1yoersXa7+zAWgSB21HzOUYPQ5Cbg0xNVg0Q0mNvg4 X-Received: by 2002:a50:9352:0:b0:56c:195d:b168 with SMTP id n18-20020a509352000000b0056c195db168mr40999eda.26.1712165054265; Wed, 03 Apr 2024 10:24:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712165054; cv=pass; d=google.com; s=arc-20160816; b=uG8I5Md3DMoFVM6fJChSsk7T/TlP4ecXCKiMEq9DnIPDUug11TYnmMcj5lxhjNQpam do1+/1nSwwmAC+k0+yu2j4nPOkl5uPeomy/30Z/JJuVzjzxNDOK12px/ybPreU+TotWm NcMnCV5Mi0gkPii7PSNn9E9UcSlvlfCDoc+HGHJ3i1Y/4ebLB85N4ZbgB2LFJtqqAxKd Kuodfxk5V7qos3CZR6ZI6NpKHxXfDwopHWND4FCaioXkdZ3lGp5ig0F2sPJbIUwr3lAW rq/RSl36zFQlg+9XV6wDS5kNR9mDjRTVTKyv6KGWkz4B4+c2ltplDMzhAruEHBZpOaha zYHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=OUNHASa7szQ+m/1Q7Hr8AEbjVVqcVN4b2LpSyzLoB5c=; fh=DvVVKGqLLFKVVBCRBfgTP/CPXHmj+rvNsh2KWVgS4yU=; b=obblsdQDjUPNg30pYPOxnpDFe/3aQ0BixDD0j3ozw6ix7QOU/m11/STy978sIV9UPs EuIUvCdT8NUllBWnDAKGqXgdmKmJ7tmoQFvvTyg0XIVwJvNE8sp3e/21O/hQ/l0Ep1yY b2sWoB/FKHjZbPctOKQcUiPeCIsrDC6LC7ynacIQnyfvWRCaZdQHBTVf8U8uf57z82To qKnNHsqexqhsCvLxp1fc+Lki4P5cSHBPmGM3jS30s+5v27AmowBJggr7KJ6KCvGASSVI dLU0HLbeF1ZfaQXex1z/3MCw1sQwxM6Lr0tPITwsKccH5vmHlPnLBJmwLIwM4sjxtoWT uehg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ApsnYwXF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130285-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130285-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u30-20020a50a41e000000b0056dfc9fccf4si1171909edb.472.2024.04.03.10.24.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 10:24:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130285-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ApsnYwXF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130285-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130285-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A79291F261A1 for ; Wed, 3 Apr 2024 17:22:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 569E715357D; Wed, 3 Apr 2024 17:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ApsnYwXF" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BDE4153566; Wed, 3 Apr 2024 17:17:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712164642; cv=none; b=i1q7caSZH6TwOPZjWNI5nH/VuJbJjDJKX0Dh9200ZnuJEEscW4vfSobjk6oxtZwNoWD0/YbKVR/Ek4QZK7Lyw/aJQbmDx7OSW92CHDY4wBOag0P/RmpHbDvFpovK2eHKHIlSbhWsLd55o0yPohBDoZqGU3sYATuV2aatduCfl74= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712164642; c=relaxed/simple; bh=ndJUG13AxsRqCLAMfV020HMo0gLnUMLYmOet4DTZZMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uJUyHDN/vpm6+sOc3p75XUSlzQMBP6kWKgT7vu4NV5jkDUm9py200NxsdG08PH55OY+9xqmR4f57pLpLyKIl89uwAdMEaB2JYFp/e6KHo3pGyAeWlTo37I9RbmCpXQXSv524Xd49mN59YWwB4exXKrlQvw/qTvlhj1CgfbJhYhM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ApsnYwXF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56200C43390; Wed, 3 Apr 2024 17:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712164642; bh=ndJUG13AxsRqCLAMfV020HMo0gLnUMLYmOet4DTZZMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ApsnYwXFtepbNOEPrShIAm7n+MZcYO1/7Yg0zYrfGBTkEG3rqE9Ui2UkHu66zWT/M i9vwpU5SKCLUHtNozkoy5msBxg8G1pXzIY2KAk8PMeVDlw+PlT04SMyAJCfdm4+mi6 EBTkeaPP44/rTo16D7n/QOcyFs7F4NjMsE5EkwC5WD5RwmOePUCU5brJh+O5MIHKCm U1TKjCZnimgyB6h+lKJu+JbbQK0VZmfNe9N3ofne+dLeFQQQHpfEMCpKl+yNGuV+s4 slYts/0ixcI0OudkMpoYqFbY2sMTc6+pE9QSa+q9WK+mi0LY89zUnnh7wCWJqvO0uE /Wd2k4EwlnCvA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andy Shevchenko , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Greg Kroah-Hartman , Sasha Levin , jirislaby@kernel.org, andi.shyti@linux.intel.com, u.kleine-koenig@pengutronix.de, john.ogness@linutronix.de, florian.fainelli@broadcom.com, tony@atomide.com, tglx@linutronix.de, justin.chen@broadcom.com, fancer.lancer@gmail.com, linux-serial@vger.kernel.org Subject: [PATCH AUTOSEL 6.8 11/28] serial: 8250_of: Drop quirk fot NPCM from 8250_port Date: Wed, 3 Apr 2024 13:16:13 -0400 Message-ID: <20240403171656.335224-11-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240403171656.335224-1-sashal@kernel.org> References: <20240403171656.335224-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.8.3 Content-Transfer-Encoding: 8bit From: Andy Shevchenko [ Upstream commit cd0eb354d441488feed6685adbeb1acd45db1b8d ] We are not supposed to spread quirks in 8250_port module especially when we have a separate driver for the hardware in question. Move quirk from generic module to the driver that uses it. Signed-off-by: Andy Shevchenko Reviewed-by: Ilpo Järvinen Link: https://lore.kernel.org/r/20240215145029.581389-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_of.c | 44 +++++++++++++++++++++++++++-- drivers/tty/serial/8250/8250_port.c | 24 ---------------- 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c index 34f17a9785e79..9dcc17e332690 100644 --- a/drivers/tty/serial/8250/8250_of.c +++ b/drivers/tty/serial/8250/8250_of.c @@ -4,7 +4,10 @@ * * Copyright (C) 2006 Arnd Bergmann , IBM Corp. */ + +#include #include +#include #include #include #include @@ -25,6 +28,36 @@ struct of_serial_info { int line; }; +/* Nuvoton NPCM timeout register */ +#define UART_NPCM_TOR 7 +#define UART_NPCM_TOIE BIT(7) /* Timeout Interrupt Enable */ + +static int npcm_startup(struct uart_port *port) +{ + /* + * Nuvoton calls the scratch register 'UART_TOR' (timeout + * register). Enable it, and set TIOC (timeout interrupt + * comparator) to be 0x20 for correct operation. + */ + serial_port_out(port, UART_NPCM_TOR, UART_NPCM_TOIE | 0x20); + + return serial8250_do_startup(port); +} + +/* Nuvoton NPCM UARTs have a custom divisor calculation */ +static unsigned int npcm_get_divisor(struct uart_port *port, unsigned int baud, + unsigned int *frac) +{ + return DIV_ROUND_CLOSEST(port->uartclk, 16 * baud + 2) - 2; +} + +static int npcm_setup(struct uart_port *port) +{ + port->get_divisor = npcm_get_divisor; + port->startup = npcm_startup; + return 0; +} + /* * Fill a struct uart_port for a given device node */ @@ -164,10 +197,17 @@ static int of_platform_serial_setup(struct platform_device *ofdev, switch (type) { case PORT_RT2880: ret = rt288x_setup(port); - if (ret) - goto err_pmruntime; + break; + case PORT_NPCM: + ret = npcm_setup(port); + break; + default: + /* Nothing to do */ + ret = 0; break; } + if (ret) + goto err_pmruntime; if (IS_REACHABLE(CONFIG_SERIAL_8250_FSL) && (of_device_is_compatible(np, "fsl,ns16550") || diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 8ca061d3bbb92..4164f8650476d 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -38,10 +38,6 @@ #include "8250.h" -/* Nuvoton NPCM timeout register */ -#define UART_NPCM_TOR 7 -#define UART_NPCM_TOIE BIT(7) /* Timeout Interrupt Enable */ - /* * Debugging. */ @@ -2235,15 +2231,6 @@ int serial8250_do_startup(struct uart_port *port) UART_DA830_PWREMU_MGMT_FREE); } - if (port->type == PORT_NPCM) { - /* - * Nuvoton calls the scratch register 'UART_TOR' (timeout - * register). Enable it, and set TIOC (timeout interrupt - * comparator) to be 0x20 for correct operation. - */ - serial_port_out(port, UART_NPCM_TOR, UART_NPCM_TOIE | 0x20); - } - #ifdef CONFIG_SERIAL_8250_RSA /* * If this is an RSA port, see if we can kick it up to the @@ -2545,15 +2532,6 @@ static void serial8250_shutdown(struct uart_port *port) serial8250_do_shutdown(port); } -/* Nuvoton NPCM UARTs have a custom divisor calculation */ -static unsigned int npcm_get_divisor(struct uart_8250_port *up, - unsigned int baud) -{ - struct uart_port *port = &up->port; - - return DIV_ROUND_CLOSEST(port->uartclk, 16 * baud + 2) - 2; -} - static unsigned int serial8250_do_get_divisor(struct uart_port *port, unsigned int baud, unsigned int *frac) @@ -2598,8 +2576,6 @@ static unsigned int serial8250_do_get_divisor(struct uart_port *port, quot = 0x8001; else if (magic_multiplier && baud >= port->uartclk / 12) quot = 0x8002; - else if (up->port.type == PORT_NPCM) - quot = npcm_get_divisor(up, baud); else quot = uart_get_divisor(port, baud); -- 2.43.0