From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 91DAD129A9C; Mon, 26 Feb 2024 14:25:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957528; cv=none; b=sxC5gMSaSxMatRBYrUygoeKRuC4VoNMvNY6umbei80PVT0b/iNSlz2tpQ1YbD9HQvKyYpew3nSoLuC0asg68vlx4GIoKwWjq4X1pdBFCQF0DoTQl+d6DlxoT0RuMl9OjsHs2vNqUJ8WSRVOPhyKaPbk8thnrMjteqBzVV0+FHQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957528; c=relaxed/simple; bh=A8p5Npmvda1MkUKRvwcBNktCV2esnRfoVCvpbf/iEPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iI46eUKIkSAhvgDdToy2xrkWHU6dQue7yBxohPWgWrxQXdJDkwzS1IWa970qjcxqr9RBFwRAHQAlK4wuqq3tEMeqgrCDeksdpM53e6DnJHyoDC5g+hiMN/ex/R9qE8QVyp+xe4mHJ6GklH6cxM0JK/q9kb49aoUlPRtZwmoNGE0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=P5uHZ10t; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="P5uHZ10t" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957527; x=1740493527; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A8p5Npmvda1MkUKRvwcBNktCV2esnRfoVCvpbf/iEPo=; b=P5uHZ10t7RftxGJPwQKuBrbiceU5I6w3pPLtodpHhC68LDIGRkJC8pix H9kIbRVc8+Hl0Zf0xQBxmRFM5VZwDzN3YJLAYZRG2B4uWCquAC7SXQViI TPB5p/xNGWta7HV0t+IHgPbmTpxwlti859DScu4RhsDZV5jsO2GLsug5w ksAdVLUxcFIsxZgVeqQ8AkP0c5zdbkeABzNm/EX0fs65Pd6PgD8jijSMl azcrpX+qAEiT6P3DWcReIntNGGlaxjX8Wz0At9mkXjQj436CrwcbfLVMq kWu0xfz8gzcXuRfk7IrYLNbC7KD9b3Ixo9I3DiD9J8c9Cm4VPqvs6oUWo A==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375147" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375147" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030141" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030141" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:17 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 07994144; Mon, 26 Feb 2024 16:25:15 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Andi Shyti Subject: [PATCH v2 01/14] serial: core: Move struct uart_port::quirks closer to possible values Date: Mon, 26 Feb 2024 16:19:17 +0200 Message-ID: <20240226142514.1485246-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently it's not crystal clear what UPIO_* and UPQ_* definitions belong to. Reindent the code, so it will be easy to read and understand. No functional changes intended. Reviewed-by: Andi Shyti Signed-off-by: Andy Shevchenko --- include/linux/serial_core.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 55b1f3ba48ac..2d2ec99eca93 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -467,8 +467,8 @@ struct uart_port { unsigned int fifosize; /* tx fifo size */ unsigned char x_char; /* xon/xoff char */ unsigned char regshift; /* reg offset shift */ + unsigned char iotype; /* io access style */ - unsigned char quirks; /* internal quirks */ =20 #define UPIO_PORT (SERIAL_IO_PORT) /* 8b I/O port access */ #define UPIO_HUB6 (SERIAL_IO_HUB6) /* Hub6 ISA card */ @@ -479,7 +479,9 @@ struct uart_port { #define UPIO_MEM32BE (SERIAL_IO_MEM32BE) /* 32b big endian */ #define UPIO_MEM16 (SERIAL_IO_MEM16) /* 16b little endian */ =20 - /* quirks must be updated while holding port mutex */ + unsigned char quirks; /* internal quirks */ + + /* internal quirks must be updated while holding port mutex */ #define UPQ_NO_TXEN_TEST BIT(0) =20 unsigned int read_status_mask; /* driver specific */ --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 5D155129A81; Mon, 26 Feb 2024 14:25:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957527; cv=none; b=oGn5opE2C+0wB/7NLebimdLaWfrRI841lPaxFKpwSGtSLh5/BB/PZseD8Xqv9q6u+tUjYMZqgcZC6C0We4hwYMxCuoITaynaDbyUfMy57Fl3jUsdUcB2CWWi7MkBT8tzd4QpH01xAk0OWXeWf7teNXdhzNbW33GYPeD7yIyoBgc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957527; c=relaxed/simple; bh=IPNtP2dbEC5nwNRrbZdk3a6zN5igpayNS2XgmKDfk4s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jWGURrZD9pumCm/BWQyX0YutrbNquDXR7fN0vf30glqV6FhbIkIKHnh2A4W08VrsLwKKlrS3/KmiziJKqTuQ9B6Ns9SFlsxTYgTcG5cbd/uz9u+5xFOGSX1XzakdU+T5ukFjBf1NF1qBjVDf/IQOk/Bj0/JnWQoP3uuvyHL1NmM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=arD/tviI; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="arD/tviI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957527; x=1740493527; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IPNtP2dbEC5nwNRrbZdk3a6zN5igpayNS2XgmKDfk4s=; b=arD/tviIRB4TGhRpSJE37TCr5fzbISB4zt6QnbhqisFEK0c5YYjG++8L 8txACz9DgI5ZvAF3im7WEkWM8doVY3/qB/9yfbWHlskH6sSg8j7YA133Z C8o2t9VIMvAHgEPOQkkwU2SJTWw6lWteVE/t0uqEY7A4CS7mBUGOcDowo qu0f97VCgiE3qrlhOdelCYmuqq2V7nnyUE0TsrmIHN0PlklZVk+h4OvSJ Gd0gxhe/mIe/RxKNtwdj6OF2fZOHChhapElstdsC4A2WE96Zl1VsdGwaQ ES00A1fT7zElNR8Lf2mTwMLPvdw0GQ/IhZlOLDiNzb4yZhVd8c3tep27H A==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375106" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375106" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030138" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030138" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:17 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 18FCD426; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu Subject: [PATCH v2 02/14] serial: core: Add UPIO_UNKNOWN constant for unknown port type Date: Mon, 26 Feb 2024 16:19:18 +0200 Message-ID: <20240226142514.1485246-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In some APIs we would like to assign the special value to iotype and compare against it in another places. Introduce UPIO_UNKNOWN for this purpose. Note, we can't use 0, because it's a valid value for IO port access. Signed-off-by: Andy Shevchenko --- include/linux/serial_core.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 2d2ec99eca93..c2cf9484014c 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -470,6 +470,7 @@ struct uart_port { =20 unsigned char iotype; /* io access style */ =20 +#define UPIO_UNKNOWN ((unsigned char)~0U) /* UCHAR_MAX */ #define UPIO_PORT (SERIAL_IO_PORT) /* 8b I/O port access */ #define UPIO_HUB6 (SERIAL_IO_HUB6) /* Hub6 ISA card */ #define UPIO_MEM (SERIAL_IO_MEM) /* driver-specific */ --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 F39F71C6B9; Mon, 26 Feb 2024 14:25:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957526; cv=none; b=rTBiTuBBPcHUI88nk6n5eEWqGlLxQfp/wPuu9p2PNNRSy30In8rnTCs3bMIF2qi66vL9bcLf35t+dbHgR93OoQ+SWEXvZ5murN7pxdzCqogmsy59ib98b95okMC+LmQyEwV1HdO9W/oelwPw6otWOxc2ltC6p7shDuXPfppn0Ms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957526; c=relaxed/simple; bh=B//5uMMN9W3FfA5/QrjFTADRm2s5rP7KhGSGOFjNn5k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hb/2Mtu+qVZ7VD/9XQJHw5/hc4jWM8QG7xwi9XFiekGOP/kOEQ2uWdMtBNzW3Suo4RB4x5gMWd8hD6rhdYlxq7BDf/XCC5yjEpx6gVj2/jh9YYY2iTh90kisqtwj3+YvJU6r0owHxsGYLKs5TRaNNmDzLul1RTkl6VwkloU+n+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=km0dIvkB; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="km0dIvkB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957524; x=1740493524; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B//5uMMN9W3FfA5/QrjFTADRm2s5rP7KhGSGOFjNn5k=; b=km0dIvkBScYqdH6goBFC61aeZ1+qt+bkvVzTrqxzyRycg79H1MLfDiA6 DfciMgT5kaxl/0nE6HxNgkrX4halm/xjofe/6FpurhbTMiMSgNm9JLIiP U2rUvjq8vVcrlqsaJSixdYBoFbffMqT/XW5tR8qjN9Ke+ibCtAdc65iWz qQwvrbZd2RU8MlH/D+2TY9vtY3IdN3LMStmPW5cZUhRmaSwGkLBzFaO6/ ZvEKjDeqPq6EEMmh2g0DqpD7o5NquG0KrX7wsITPcXfgGTxSIbmTaSlsN Ndz3dwBwpcmJFURmF5UGb/SANTXchTrbdpt7r6osbaENIlZnLl0i0OqeY w==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375090" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375090" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030137" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030137" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:17 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 26743445; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu Subject: [PATCH v2 03/14] serial: port: Introduce a common helper to read properties Date: Mon, 26 Feb 2024 16:19:19 +0200 Message-ID: <20240226142514.1485246-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Several serial drivers want to read the same or similar set of the port properties. Make a common helper for them. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/serial_port.c | 134 +++++++++++++++++++++++++++++++ include/linux/serial_core.h | 1 + 2 files changed, 135 insertions(+) diff --git a/drivers/tty/serial/serial_port.c b/drivers/tty/serial/serial_p= ort.c index 88975a4df306..ecc980e9dba6 100644 --- a/drivers/tty/serial/serial_port.c +++ b/drivers/tty/serial/serial_port.c @@ -8,7 +8,10 @@ =20 #include #include +#include +#include #include +#include #include #include =20 @@ -82,6 +85,137 @@ void uart_remove_one_port(struct uart_driver *drv, stru= ct uart_port *port) } EXPORT_SYMBOL(uart_remove_one_port); =20 +/** + * uart_read_port_properties - read firmware properties of the given UART = port + * @port: corresponding port + * @use_defaults: apply defaults (when %true) or validate the values (when= %false) + * + * The following device properties are supported: + * - clock-frequency (optional) + * - fifo-size (optional) + * - no-loopback-test (optional) + * - reg-shift (defaults may apply) + * - reg-offset (value may be validated) + * - reg-io-width (defaults may apply or value may be validated) + * - interrupts (OF only) + * - serial [alias ID] (OF only) + * + * If the port->dev is of struct platform_device type the interrupt line + * will be retrieved via platform_get_irq() call against that device. + * Otherwise it will be assigned by fwnode_irq_get() call. In both cases + * the index 0 of the resource is used. + * + * The caller is responsible to initialize the following fields of the @po= rt + * ->dev (must be valid) + * ->flags + * ->mapbase + * ->mapsize + * ->regshift (if @use_defaults is false) + * before calling this function. Alternatively the above mentioned fields + * may be zeroed, in such case the only ones, that have associated propert= ies + * found, will be set to the respective values. + * + * If no error happened, the ->irq, ->mapbase, ->mapsize will be altered. + * The ->iotype is always altered. + * + * When @use_defaults is true and the respective property is not found + * the following values will be applied: + * ->regshift =3D 0 + * In this case IRQ must be provided, otherwise an error will be returned. + * + * When @use_defaults is false and the respective property is found + * the following values will be validated: + * - reg-io-width (->iotype) + * - reg-offset (->mapsize against ->mapbase) + * + * Returns: 0 on success or negative errno on failure + */ +int uart_read_port_properties(struct uart_port *port, bool use_defaults) +{ + struct device *dev =3D port->dev; + u32 value; + int ret; + + /* Read optional UART functional clock frequency */ + device_property_read_u32(dev, "clock-frequency", &port->uartclk); + + /* Read the registers alignment (default: 8-bit) */ + ret =3D device_property_read_u32(dev, "reg-shift", &value); + if (ret) + port->regshift =3D use_defaults ? 0 : port->regshift; + else + port->regshift =3D value; + + /* Read the registers I/O access type (default: MMIO 8-bit) */ + ret =3D device_property_read_u32(dev, "reg-io-width", &value); + if (ret) { + port->iotype =3D UPIO_MEM; + } else { + switch (value) { + case 1: + port->iotype =3D UPIO_MEM; + break; + case 2: + port->iotype =3D UPIO_MEM16; + break; + case 4: + port->iotype =3D device_is_big_endian(dev) ? UPIO_MEM32BE : UPIO_MEM32; + break; + default: + if (!use_defaults) { + dev_err(dev, "Unsupported reg-io-width (%u)\n", value); + return -EINVAL; + } + port->iotype =3D UPIO_UNKNOWN; + break; + } + } + + /* Read the address mapping base offset (default: no offset) */ + ret =3D device_property_read_u32(dev, "reg-offset", &value); + if (ret) + value =3D 0; + + /* Check for shifted address mapping overflow */ + if (!use_defaults && port->mapsize < value) { + dev_err(dev, "reg-offset %u exceeds region size %pa\n", value, &port->ma= psize); + return -EINVAL; + } + + port->mapbase +=3D value; + port->mapsize -=3D value; + + /* Read optional FIFO size */ + device_property_read_u32(dev, "fifo-size", &port->fifosize); + + if (device_property_read_bool(dev, "no-loopback-test")) + port->flags |=3D UPF_SKIP_TEST; + + /* Get index of serial line, if found in DT aliases */ + ret =3D of_alias_get_id(dev_of_node(dev), "serial"); + if (ret >=3D 0) + port->line =3D ret; + + if (dev_is_platform(dev)) + ret =3D platform_get_irq(to_platform_device(dev), 0); + else + ret =3D fwnode_irq_get(dev_fwnode(dev), 0); + if (ret =3D=3D -EPROBE_DEFER) + return ret; + if (ret > 0) + port->irq =3D ret; + else if (use_defaults) + /* By default IRQ support is mandatory */ + return ret; + else + port->irq =3D 0; + + port->flags |=3D UPF_SHARE_IRQ; + + return 0; +} +EXPORT_SYMBOL(uart_read_port_properties); + static struct device_driver serial_port_driver =3D { .name =3D "port", .suppress_bind_attrs =3D true, diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index c2cf9484014c..3fc8683e7b53 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -962,6 +962,7 @@ int uart_register_driver(struct uart_driver *uart); void uart_unregister_driver(struct uart_driver *uart); int uart_add_one_port(struct uart_driver *reg, struct uart_port *port); void uart_remove_one_port(struct uart_driver *reg, struct uart_port *port); +int uart_read_port_properties(struct uart_port *port, bool use_defaults); bool uart_match_port(const struct uart_port *port1, const struct uart_port *port2); =20 --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 D32B41292F9; Mon, 26 Feb 2024 14:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957526; cv=none; b=qLMz7TnrE61lXd9LqFU+zcLxXAM0f4jFxwDqc4HJNhgXxHRHSU36ZDld6axgw45vk38F9ilv/2FmNgKfXZz81B9UiG07BPGGuapz4aisbQx181Gcy5KIHJx0p/E07tVUWATzYylVgMkwfjZps03LbE/vnWbFs2HQxztfwcmGamw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957526; c=relaxed/simple; bh=epusIY1XMLW5yDgqCMw/7B8Ke39NBboPe91THB/uUvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RSp1kTO6QREs10TgDIb0K44Xnsk9MgqcY4C+KdR4NOZO9YAebYFtvKB0hMoypUzlacODBlY/S3UFKhinTslWXxsW2Wt8RbTfJRhXhdLMkXL7G/jjwO68G6MB9fT1afV5hibnhC4Swir5uJs+8PMmLYc+6ocnutwsAZpCoAVnOzU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QQe6vPHG; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QQe6vPHG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957525; x=1740493525; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=epusIY1XMLW5yDgqCMw/7B8Ke39NBboPe91THB/uUvU=; b=QQe6vPHG8FBUbok2w0cv/Hsh9KqPn574GZcB0p6xFSCiYHFNVw/seIBG 4MAZO22nGUB08EbTtAPb/JaXWd2Vyb2XuD03owK/y9Oec7I2VkpPFt6ui bMNyfJg4UFhL8Ai1746x/QpF7xilAqckNhUjqqifkDYmBOhZn1sTxZvxT sE9N4yMLjtlUTvnwkNWxW7pTyZ0oJQ7lPxSWn6RBqQkv7Umk9FD+Kn3lm rs8TuE0mooSOt9fFueY63TZhrOvlV+3XxlrQBmUKNMwqc21Kjjma/mR2b ymFW7VBLUX09EZjQaxcrpameUbs+Aaahp0pP8TgjcUxYUB5sRTl8tJbtN A==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375130" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375130" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030140" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030140" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:17 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 348304C1; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Andi Shyti Subject: [PATCH v2 04/14] serial: 8250_aspeed_vuart: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:20 +0200 Message-ID: <20240226142514.1485246-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have now a common helper to read port properties use it instead of sparse home grown solution. Reviewed-by: Andi Shyti Signed-off-by: Andy Shevchenko Reviewed-by: Andrew Jeffery --- drivers/tty/serial/8250/8250_aspeed_vuart.c | 50 +++++++-------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/seri= al/8250/8250_aspeed_vuart.c index 8c2aaf7af7b7..2a4bc39b11af 100644 --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c @@ -419,8 +419,8 @@ static int aspeed_vuart_probe(struct platform_device *p= dev) struct aspeed_vuart *vuart; struct device_node *np; struct resource *res; - u32 clk, prop, sirq[2]; int rc, sirq_polarity; + u32 prop, sirq[2]; struct clk *vclk; =20 np =3D pdev->dev.of_node; @@ -447,53 +447,35 @@ static int aspeed_vuart_probe(struct platform_device = *pdev) port.port.status =3D UPSTAT_SYNC_FIFO; port.port.dev =3D &pdev->dev; port.port.has_sysrq =3D IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE); + port.port.flags =3D UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_FIXED_PORT | UP= F_FIXED_TYPE | + UPF_NO_THRE_TEST; port.bugs |=3D UART_BUG_TXRACE; =20 rc =3D sysfs_create_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); if (rc < 0) return rc; =20 - if (of_property_read_u32(np, "clock-frequency", &clk)) { + rc =3D uart_read_port_properties(&port.port, true); + if (rc) + goto err_sysfs_remove; + + /* Get clk rate through clk driver if present */ + if (!port.port.uartclk) { vclk =3D devm_clk_get_enabled(dev, NULL); if (IS_ERR(vclk)) { rc =3D dev_err_probe(dev, PTR_ERR(vclk), "clk or clock-frequency not de= fined\n"); goto err_sysfs_remove; } =20 - clk =3D clk_get_rate(vclk); + port.port.uartclk =3D clk_get_rate(vclk); } =20 /* If current-speed was set, then try not to change it. */ if (of_property_read_u32(np, "current-speed", &prop) =3D=3D 0) - port.port.custom_divisor =3D clk / (16 * prop); + port.port.custom_divisor =3D port.port.uartclk / (16 * prop); =20 - /* Check for shifted address mapping */ - if (of_property_read_u32(np, "reg-offset", &prop) =3D=3D 0) - port.port.mapbase +=3D prop; - - /* Check for registers offset within the devices address range */ - if (of_property_read_u32(np, "reg-shift", &prop) =3D=3D 0) - port.port.regshift =3D prop; - - /* Check for fifo size */ - if (of_property_read_u32(np, "fifo-size", &prop) =3D=3D 0) - port.port.fifosize =3D prop; - - /* Check for a fixed line number */ - rc =3D of_alias_get_id(np, "serial"); - if (rc >=3D 0) - port.port.line =3D rc; - - port.port.irq =3D irq_of_parse_and_map(np, 0); port.port.handle_irq =3D aspeed_vuart_handle_irq; - port.port.iotype =3D UPIO_MEM; port.port.type =3D PORT_ASPEED_VUART; - port.port.uartclk =3D clk; - port.port.flags =3D UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP - | UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_NO_THRE_TEST; - - if (of_property_read_bool(np, "no-loopback-test")) - port.port.flags |=3D UPF_SKIP_TEST; =20 if (port.port.fifosize) port.capabilities =3D UART_CAP_FIFO; @@ -503,7 +485,7 @@ static int aspeed_vuart_probe(struct platform_device *p= dev) =20 rc =3D serial8250_register_8250_port(&port); if (rc < 0) - goto err_clk_disable; + goto err_sysfs_remove; =20 vuart->line =3D rc; vuart->port =3D serial8250_get_port(vuart->line); @@ -529,7 +511,7 @@ static int aspeed_vuart_probe(struct platform_device *p= dev) rc =3D aspeed_vuart_set_lpc_address(vuart, prop); if (rc < 0) { dev_err_probe(dev, rc, "invalid value in aspeed,lpc-io-reg property\n"); - goto err_clk_disable; + goto err_sysfs_remove; } =20 rc =3D of_property_read_u32_array(np, "aspeed,lpc-interrupts", sirq, 2); @@ -541,14 +523,14 @@ static int aspeed_vuart_probe(struct platform_device = *pdev) rc =3D aspeed_vuart_set_sirq(vuart, sirq[0]); if (rc < 0) { dev_err_probe(dev, rc, "invalid sirq number in aspeed,lpc-interrupts pro= perty\n"); - goto err_clk_disable; + goto err_sysfs_remove; } =20 sirq_polarity =3D aspeed_vuart_map_irq_polarity(sirq[1]); if (sirq_polarity < 0) { rc =3D dev_err_probe(dev, sirq_polarity, "invalid sirq polarity in aspeed,lpc-interrupts property\n"); - goto err_clk_disable; + goto err_sysfs_remove; } =20 aspeed_vuart_set_sirq_polarity(vuart, sirq_polarity); @@ -559,8 +541,6 @@ static int aspeed_vuart_probe(struct platform_device *p= dev) =20 return 0; =20 -err_clk_disable: - irq_dispose_mapping(port.port.irq); err_sysfs_remove: sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); return rc; --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 C54191C6B9; Mon, 26 Feb 2024 14:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957532; cv=none; b=r7aGN3TWu4JPYAvoU5dTJ1eiidfMlCUMiSmUfQO6usuvM8zXnGLMjUWrCNKkfYM/5bBBpsRNqPLsPZuoWUjPF6zUXjGJLtCZoj8w2pmocGovHH/Mpbq0Oku00g34sPU/z/vnMtLV4px6RW/mKVu9UzklUE7Ws3Yyq5JQe24vHJk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957532; c=relaxed/simple; bh=gldZ/Cbp9u0amwonRgNlffL/8B/cyCZTIV2zvUcgOTM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bzbtfRB2bremKl7HEON29kqEalbNQTuskxdFA5K1Cdt3eXQZ7B6bf00AfQMjevQ8Tlokw4zSFhG6yQT1YjD3YwjlRcM90DpQJuEuFrXzAchTOZP+CmGK0JdcwbJwXeyi8Qfxm+S4S5s4dSj1r3zdx3XiAaudVz2PAvl5Kc5XLak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WEfUqRdq; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WEfUqRdq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957531; x=1740493531; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gldZ/Cbp9u0amwonRgNlffL/8B/cyCZTIV2zvUcgOTM=; b=WEfUqRdq7oK6AT16xaxmaNH3d0ZGYGQLJhc3Qc8CJEXM5kvs1BeU2Pkp JVD67kH1Pr+Lec8O5MHEYqkIk/ZxfDAwFA81wumS846Ue+rPYTfrc5/1J ODAAHbQTwTNO5VS4vSWDmlGteqAgkmvO/IA4UHvADWIYW1/veleC5d2mx E6Ret8myuftoljYO0XF4DOp304zQjdfgSCY/EjlBby39nfeBz+d20rd/S wUy+O8M/x/LG1EljR2W8hS6bMOjXuMGoAvhBaAKn7TMl7QIpSR59cyVpP CtpMbQPXrdCQEHFeO0SjiM/YPPWXq4/9Vve/OPSaq5y1gqlvcc5WkCkHM g==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375176" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375176" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030142" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030142" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:23 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 41A3C4C5; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu Subject: [PATCH v2 05/14] serial: 8250_bcm2835aux: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:21 +0200 Message-ID: <20240226142514.1485246-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have now a common helper to read port properties use it instead of sparse home grown solution. Signed-off-by: Andy Shevchenko Reviewed-by: Florian Fainelli Tested-by: Florian Fainelli --- drivers/tty/serial/8250/8250_bcm2835aux.c | 92 +++++++++++------------ 1 file changed, 42 insertions(+), 50 deletions(-) diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial= /8250/8250_bcm2835aux.c index beac6b340ace..69c3c5ca77f7 100644 --- a/drivers/tty/serial/8250/8250_bcm2835aux.c +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c @@ -45,10 +45,6 @@ struct bcm2835aux_data { u32 cntl; }; =20 -struct bcm2835_aux_serial_driver_data { - resource_size_t offset; -}; - static void bcm2835aux_rs485_start_tx(struct uart_8250_port *up) { if (!(up->port.rs485.flags & SER_RS485_RX_DURING_TX)) { @@ -85,10 +81,9 @@ static void bcm2835aux_rs485_stop_tx(struct uart_8250_po= rt *up) =20 static int bcm2835aux_serial_probe(struct platform_device *pdev) { - const struct bcm2835_aux_serial_driver_data *bcm_data; + const struct software_node *bcm2835_swnode; struct uart_8250_port up =3D { }; struct bcm2835aux_data *data; - resource_size_t offset =3D 0; struct resource *res; unsigned int uartclk; int ret; @@ -101,12 +96,8 @@ static int bcm2835aux_serial_probe(struct platform_devi= ce *pdev) /* initialize data */ up.capabilities =3D UART_CAP_FIFO | UART_CAP_MINI; up.port.dev =3D &pdev->dev; - up.port.regshift =3D 2; up.port.type =3D PORT_16550; - up.port.iotype =3D UPIO_MEM; - up.port.fifosize =3D 8; - up.port.flags =3D UPF_SHARE_IRQ | UPF_FIXED_PORT | UPF_FIXED_TYPE | - UPF_SKIP_TEST | UPF_IOREMAP; + up.port.flags =3D UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_SKIP_TEST | UPF_I= OREMAP; up.port.rs485_config =3D serial8250_em485_config; up.port.rs485_supported =3D serial8250_em485_supported; up.rs485_start_tx =3D bcm2835aux_rs485_start_tx; @@ -122,12 +113,6 @@ static int bcm2835aux_serial_probe(struct platform_dev= ice *pdev) if (IS_ERR(data->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(data->clk), "could not get clk\= n"); =20 - /* get the interrupt */ - ret =3D platform_get_irq(pdev, 0); - if (ret < 0) - return ret; - up.port.irq =3D ret; - /* map the main registers */ res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { @@ -135,52 +120,40 @@ static int bcm2835aux_serial_probe(struct platform_de= vice *pdev) return -EINVAL; } =20 - bcm_data =3D device_get_match_data(&pdev->dev); + up.port.mapbase =3D res->start; + up.port.mapsize =3D resource_size(res); =20 - /* Some UEFI implementations (e.g. tianocore/edk2 for the Raspberry Pi) - * describe the miniuart with a base address that encompasses the auxilia= ry - * registers shared between the miniuart and spi. - * - * This is due to historical reasons, see discussion here : - * https://edk2.groups.io/g/devel/topic/87501357#84349 - * - * We need to add the offset between the miniuart and auxiliary - * registers to get the real miniuart base address. - */ - if (bcm_data) - offset =3D bcm_data->offset; + bcm2835_swnode =3D device_get_match_data(&pdev->dev); + if (bcm2835_swnode) { + ret =3D device_add_software_node(&pdev->dev, bcm2835_swnode); + if (ret) + return ret; + } =20 - up.port.mapbase =3D res->start + offset; - up.port.mapsize =3D resource_size(res) - offset; + ret =3D uart_read_port_properties(&up.port, true); + if (ret) + goto rm_swnode; =20 - /* Check for a fixed line number */ - ret =3D of_alias_get_id(pdev->dev.of_node, "serial"); - if (ret >=3D 0) - up.port.line =3D ret; + up.port.regshift =3D 2; + up.port.fifosize =3D 8; =20 /* enable the clock as a last step */ ret =3D clk_prepare_enable(data->clk); if (ret) { - dev_err(&pdev->dev, "unable to enable uart clock - %d\n", - ret); - return ret; + dev_err_probe(&pdev->dev, ret, "unable to enable uart clock\n"); + goto rm_swnode; } =20 uartclk =3D clk_get_rate(data->clk); - if (!uartclk) { - ret =3D device_property_read_u32(&pdev->dev, "clock-frequency", &uartclk= ); - if (ret) { - dev_err_probe(&pdev->dev, ret, "could not get clk rate\n"); - goto dis_clk; - } - } + if (uartclk) + up.port.uartclk =3D uartclk; =20 /* the HW-clock divider for bcm2835aux is 8, * but 8250 expects a divider of 16, * so we have to multiply the actual clock by 2 * to get identical baudrates. */ - up.port.uartclk =3D uartclk * 2; + up.port.uartclk *=3D 2; =20 /* register the port */ ret =3D serial8250_register_8250_port(&up); @@ -194,6 +167,8 @@ static int bcm2835aux_serial_probe(struct platform_devi= ce *pdev) =20 dis_clk: clk_disable_unprepare(data->clk); +rm_swnode: + device_remove_software_node(&pdev->dev); return ret; } =20 @@ -203,10 +178,27 @@ static void bcm2835aux_serial_remove(struct platform_= device *pdev) =20 serial8250_unregister_port(data->line); clk_disable_unprepare(data->clk); + device_remove_software_node(&pdev->dev); } =20 -static const struct bcm2835_aux_serial_driver_data bcm2835_acpi_data =3D { - .offset =3D 0x40, +/* + * Some UEFI implementations (e.g. tianocore/edk2 for the Raspberry Pi) + * describe the miniuart with a base address that encompasses the auxiliary + * registers shared between the miniuart and spi. + * + * This is due to historical reasons, see discussion here: + * https://edk2.groups.io/g/devel/topic/87501357#84349 + * + * We need to add the offset between the miniuart and auxiliary registers + * to get the real miniuart base address. + */ +static const struct property_entry bcm2835_acpi_properties[] =3D { + PROPERTY_ENTRY_U32("reg-offset", 0x40), + { } +}; + +static const struct software_node bcm2835_acpi_node =3D { + .properties =3D bcm2835_acpi_properties, }; =20 static const struct of_device_id bcm2835aux_serial_match[] =3D { @@ -216,7 +208,7 @@ static const struct of_device_id bcm2835aux_serial_matc= h[] =3D { MODULE_DEVICE_TABLE(of, bcm2835aux_serial_match); =20 static const struct acpi_device_id bcm2835aux_serial_acpi_match[] =3D { - { "BCM2836", (kernel_ulong_t)&bcm2835_acpi_data }, + { "BCM2836", (kernel_ulong_t)&bcm2835_acpi_node }, { } }; MODULE_DEVICE_TABLE(acpi, bcm2835aux_serial_acpi_match); --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 CB10D12BEB6; Mon, 26 Feb 2024 14:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957531; cv=none; b=om4zSJLfmiaIHfgC/vkqOjeuSKPW/Cuz+8wCkZzHkTtYTuUfmAFfy2vnkFxFCFeYTPT7LMulumKQuQ1C5ZOjyWvkqV/J1dzTlG3JCNWshzRu+XbDaWpGOq9TxwxS7FznpHrmIaf2n5RNcQEWiU3m8SEIbo04TP+p9fHmOjOS+48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957531; c=relaxed/simple; bh=hEPEnqkJOil/jP3cx9hGmK0SGdKV4rkaOxGN34xAwEM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mJ97SljbJaMQ9qgjRW7DsOVgeSumgG4Fq0aRLVj5VxxsDI3xCsG/CXr2TfwYO1FeIqLBJvXDub7V+YS8Oj/H+NjkOK9Ipcdz/qDwxL3FemlLq5riKO4EDBNV6Y26DXWZNTNSTYdklsyfBFQayJc5w5ZLd1sPdBkd0FJzQ++NVGc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bhyazrkp; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bhyazrkp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957530; x=1740493530; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hEPEnqkJOil/jP3cx9hGmK0SGdKV4rkaOxGN34xAwEM=; b=bhyazrkpRk0MJTAgJoxSrU4K3lrfPZSJUXKVumFeuXASHMpwl6z/vLgB TQe+JvXGvy8ATM+1DnteGgOQ8hYI2NFKa+71U1RQsFvVCpvxaiJZVee7/ MhYrE/iZl28vqM7q4f6dn+nHu8WwXLKnEhQDU415JVCBx2ZZaFFqNd8eR TgtsK7LG/Er9B72wit8KhbfqXltkGXbOZN0wavtxg8eCIwYc9CYwQO0lR URB78Kosae0BnocluZX3OpeCtTUOB/15vNPr9t0oV4mx4YoC34IcNu7gF OsXdnp7O6EnuxEhoSqkDm59OO/phtHZPIPf3zqbfPGOKwkQ+0Py562xJD Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375162" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375162" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030143" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030143" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:23 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4E49F4D7; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu Subject: [PATCH v2 06/14] serial: 8250_bcm7271: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:22 +0200 Message-ID: <20240226142514.1485246-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have now a common helper to read port properties use it instead of sparse home grown solution. Signed-off-by: Andy Shevchenko Reviewed-by: Florian Fainelli Tested-by: Florian Fainelli --- drivers/tty/serial/8250/8250_bcm7271.c | 56 +++++++++----------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/82= 50/8250_bcm7271.c index 1532fa2e8ec4..83ecf18fcf3e 100644 --- a/drivers/tty/serial/8250/8250_bcm7271.c +++ b/drivers/tty/serial/8250/8250_bcm7271.c @@ -935,17 +935,14 @@ static void brcmuart_init_debugfs(struct brcmuart_pri= v *priv, static int brcmuart_probe(struct platform_device *pdev) { struct resource *regs; - struct device_node *np =3D pdev->dev.of_node; const struct of_device_id *of_id =3D NULL; struct uart_8250_port *new_port; struct device *dev =3D &pdev->dev; struct brcmuart_priv *priv; struct clk *baud_mux_clk; struct uart_8250_port up; - int irq; void __iomem *membase =3D NULL; resource_size_t mapbase =3D 0; - u32 clk_rate =3D 0; int ret; int x; int dma_irq; @@ -953,15 +950,12 @@ static int brcmuart_probe(struct platform_device *pde= v) "uart", "dma_rx", "dma_tx", "dma_intr2", "dma_arb" }; =20 - irq =3D platform_get_irq(pdev, 0); - if (irq < 0) - return irq; priv =3D devm_kzalloc(dev, sizeof(struct brcmuart_priv), GFP_KERNEL); if (!priv) return -ENOMEM; =20 - of_id =3D of_match_node(brcmuart_dt_ids, np); + of_id =3D of_match_node(brcmuart_dt_ids, dev->of_node); if (!of_id || !of_id->data) priv->rate_table =3D brcmstb_rate_table; else @@ -1011,7 +1005,23 @@ static int brcmuart_probe(struct platform_device *pd= ev) } } =20 - of_property_read_u32(np, "clock-frequency", &clk_rate); + dev_dbg(dev, "DMA is %senabled\n", priv->dma_enabled ? "" : "not "); + + memset(&up, 0, sizeof(up)); + up.port.type =3D PORT_BCM7271; + up.port.dev =3D dev; + up.port.mapbase =3D mapbase; + up.port.membase =3D membase; + up.port.handle_irq =3D brcmuart_handle_irq; + up.port.flags =3D UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_FIXED_TYPE; + up.port.private_data =3D priv; + + ret =3D uart_read_port_properties(&up.port, true); + if (ret) + goto release_dma; + + up.port.regshift =3D 2; + up.port.iotype =3D device_is_big_endian(dev) ? UPIO_MEM32BE : UPIO_MEM32; =20 /* See if a Baud clock has been specified */ baud_mux_clk =3D devm_clk_get_optional_enabled(dev, "sw_baud"); @@ -1023,39 +1033,11 @@ static int brcmuart_probe(struct platform_device *p= dev) =20 priv->baud_mux_clk =3D baud_mux_clk; init_real_clk_rates(dev, priv); - clk_rate =3D priv->default_mux_rate; + up.port.uartclk =3D priv->default_mux_rate; } else { dev_dbg(dev, "BAUD MUX clock not specified\n"); } =20 - if (clk_rate =3D=3D 0) { - ret =3D dev_err_probe(dev, -EINVAL, "clock-frequency or clk not defined\= n"); - goto release_dma; - } - - dev_dbg(dev, "DMA is %senabled\n", priv->dma_enabled ? "" : "not "); - - memset(&up, 0, sizeof(up)); - up.port.type =3D PORT_BCM7271; - up.port.uartclk =3D clk_rate; - up.port.dev =3D dev; - up.port.mapbase =3D mapbase; - up.port.membase =3D membase; - up.port.irq =3D irq; - up.port.handle_irq =3D brcmuart_handle_irq; - up.port.regshift =3D 2; - up.port.iotype =3D of_device_is_big_endian(np) ? - UPIO_MEM32BE : UPIO_MEM32; - up.port.flags =3D UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF - | UPF_FIXED_PORT | UPF_FIXED_TYPE; - up.port.dev =3D dev; - up.port.private_data =3D priv; - - /* Check for a fixed line number */ - ret =3D of_alias_get_id(np, "serial"); - if (ret >=3D 0) - up.port.line =3D ret; - /* setup HR timer */ hrtimer_init(&priv->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); priv->hrt.function =3D brcmuart_hrtimer_func; --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 B67C712C534; Mon, 26 Feb 2024 14:25:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957534; cv=none; b=Ts3XaOALUvO7vtGpD6qc7DvnVvEbgwzHVP+v7hnrvLvQHba/G6i+m1/mL07qgFC5iGRkiYdFS0fZh/HueT4v1RHJDVF579rSpk19I5eag9xiLPNAC2NcglZXaC1Ks6wj8IHGksvmfD6Wr4ovfsDMRvUwCYCFNcV3wFg6Mue///8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957534; c=relaxed/simple; bh=n8M+Zxd5EsI5el7vSlKXZtzNU2WwNtafBo9TBX3vAmw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a2KHAXzN4ATA2u7yUbATIntSxmMYKHKhCAdXTKplAiVZLMz1nutMSI1ueo3rE8oRaTGIHEbeem31BCwRlxyfo2L/3BY98q9U5uy2f3vADBgWY3kEM+xZwp9PdRIxOKu7IEQxCQxDAZC0wcmf1z+JYVCBEBKxgo9RRmclK8/1rUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CfPcndYW; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CfPcndYW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957533; x=1740493533; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=n8M+Zxd5EsI5el7vSlKXZtzNU2WwNtafBo9TBX3vAmw=; b=CfPcndYWbq06N2wjCD2AQ5vqzwZAUohStdhKvCzCE/J/cLiGi/++BdSf yIRkOJVH5elcLQTcAO59HIwcAUFvNBZ4AoYsvRBYcp4Bw2efbKkq4XdLi S0+WyB3gevGE6FN4Pyv1gfsT72yTKLfpuN8UsmNXVjNh/XuHxv3IUgVQi CmOOWMvTAPifv9pstbfh984jJWk1OrIIxM39m+u9zUeWgldFn4mXNAO2i ssrLXcq8nV0jodXLhUIqlXcQMpzMrGwSlwe/dfLI8Zj9jBw4X+oaQpuyP WQFN8/mIHaFHmH1ndlrWpIQC7roawiomKsSiuIF0Dz0qbRnT6CYAcJH1G Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375211" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375211" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030144" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030144" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:23 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5B595692; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Andi Shyti Subject: [PATCH v2 07/14] serial: 8250_dw: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:23 +0200 Message-ID: <20240226142514.1485246-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have now a common helper to read port properties use it instead of sparse home grown solution. Reviewed-by: Andi Shyti Signed-off-by: Andy Shevchenko --- drivers/tty/serial/8250/8250_dw.c | 67 +++++++++++++------------------ 1 file changed, 27 insertions(+), 40 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/82= 50_dw.c index 2d1f350a4bea..a1825e83231f 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -449,12 +448,7 @@ static void dw8250_quirks(struct uart_port *p, struct = dw8250_data *data) =20 if (np) { unsigned int quirks =3D data->pdata->quirks; - int id; =20 - /* get index of serial line, if found in DT aliases */ - id =3D of_alias_get_id(np, "serial"); - if (id >=3D 0) - p->line =3D id; #ifdef CONFIG_64BIT if (quirks & DW_UART_QUIRK_OCTEON) { p->serial_in =3D dw8250_serial_inq; @@ -465,12 +459,6 @@ static void dw8250_quirks(struct uart_port *p, struct = dw8250_data *data) } #endif =20 - if (of_device_is_big_endian(np)) { - p->iotype =3D UPIO_MEM32BE; - p->serial_in =3D dw8250_serial_in32be; - p->serial_out =3D dw8250_serial_out32be; - } - if (quirks & DW_UART_QUIRK_ARMADA_38X) p->serial_out =3D dw8250_serial_out38x; if (quirks & DW_UART_QUIRK_SKIP_SET_RATE) @@ -510,39 +498,21 @@ static int dw8250_probe(struct platform_device *pdev) struct device *dev =3D &pdev->dev; struct dw8250_data *data; struct resource *regs; - int irq; int err; - u32 val; =20 regs =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!regs) return dev_err_probe(dev, -EINVAL, "no registers defined\n"); =20 - irq =3D platform_get_irq_optional(pdev, 0); - /* no interrupt -> fall back to polling */ - if (irq =3D=3D -ENXIO) - irq =3D 0; - if (irq < 0) - return irq; - spin_lock_init(&p->lock); - p->mapbase =3D regs->start; - p->irq =3D irq; p->handle_irq =3D dw8250_handle_irq; p->pm =3D dw8250_do_pm; p->type =3D PORT_8250; - p->flags =3D UPF_SHARE_IRQ | UPF_FIXED_PORT; + p->flags =3D UPF_FIXED_PORT; p->dev =3D dev; - p->iotype =3D UPIO_MEM; - p->serial_in =3D dw8250_serial_in; - p->serial_out =3D dw8250_serial_out; p->set_ldisc =3D dw8250_set_ldisc; p->set_termios =3D dw8250_set_termios; =20 - p->membase =3D devm_ioremap(dev, regs->start, resource_size(regs)); - if (!p->membase) - return -ENOMEM; - data =3D devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -554,15 +524,35 @@ static int dw8250_probe(struct platform_device *pdev) data->uart_16550_compatible =3D device_property_read_bool(dev, "snps,uart-16550-compatible"); =20 - err =3D device_property_read_u32(dev, "reg-shift", &val); - if (!err) - p->regshift =3D val; + p->mapbase =3D regs->start; + p->mapsize =3D resource_size(regs); =20 - err =3D device_property_read_u32(dev, "reg-io-width", &val); - if (!err && val =3D=3D 4) { - p->iotype =3D UPIO_MEM32; + p->membase =3D devm_ioremap(dev, p->mapbase, p->mapsize); + if (!p->membase) + return -ENOMEM; + + err =3D uart_read_port_properties(p, true); + /* no interrupt -> fall back to polling */ + if (err =3D=3D -ENXIO) + err =3D 0; + if (err) + return err; + + switch (p->iotype) { + case UPIO_MEM: + p->serial_in =3D dw8250_serial_in; + p->serial_out =3D dw8250_serial_out; + break; + case UPIO_MEM32: p->serial_in =3D dw8250_serial_in32; p->serial_out =3D dw8250_serial_out32; + break; + case UPIO_MEM32BE: + p->serial_in =3D dw8250_serial_in32be; + p->serial_out =3D dw8250_serial_out32be; + break; + default: + return -ENODEV; } =20 if (device_property_read_bool(dev, "dcd-override")) { @@ -589,9 +579,6 @@ static int dw8250_probe(struct platform_device *pdev) data->msr_mask_off |=3D UART_MSR_TERI; } =20 - /* Always ask for fixed clock rate from a property. */ - device_property_read_u32(dev, "clock-frequency", &p->uartclk); - /* If there is separate baudclk, get the rate from it. */ data->clk =3D devm_clk_get_optional_enabled(dev, "baudclk"); if (data->clk =3D=3D NULL) --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 A259212C52A; Mon, 26 Feb 2024 14:25:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957534; cv=none; b=PwcxRcoTnPpeL38HL+NlUlnUyU6bwIhLBkcGX158t70ihCdr98dxs0NK6VZRLsojs1PGnfbjCW/dwm/FM3nmX2oK8AnelZq15Yd1zCtug1XQa2e7MutZihm2CDjucEmS5XEvr7JSAa2o/iTY6JaDCf+GS8LyF4fOzC8IvaQNxf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957534; c=relaxed/simple; bh=vhK6pyGf2T+TFWuVP7O7kQnPlVO9Kof9u3xE7jBi6uw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IA7rZo5B6udjGrH5PCqrL5bgpuVAsdKVeWIFKts1AFmmSN1/7HLLaYIDn94rHknrO9niJZhIdkhvk3zIHKuSZeZwLqJHYteLNgqdkkeuB+QlkZznjudjZusnrOQLja/OsbIIql7qR2pHoEJ1A+6TeeOJqrDkNAMoaHnsAhnB2PA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Vvp/mnKU; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Vvp/mnKU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957533; x=1740493533; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vhK6pyGf2T+TFWuVP7O7kQnPlVO9Kof9u3xE7jBi6uw=; b=Vvp/mnKUNSh9GrrLEdZJjuSkGQdGLJ4wM03dsAt+n0K4ZR9jZmz9Ct0k 7Qswqzj1OtopdZ0/fg7GN0DBRYpLdir4uEOEf3D4HeVHFt2yGffUFz0Ad gkdxb7FwcKImQ/+UvEQwBEni04Xx9UFFpDKKA6Qxl2LGwgCIXMcQPyBP9 XJvt9n+cu7EBxfh6mcm1mJV4E5JqDVi6YANtiLaVuCKnz5KRi6t6r6nGI 77dWbJcgg1EpCCYMm9vZ2YYy7CUzEWS+UrhtDzUq12F0B8jUSAZdvRGCb H4RLbS1KlDzZxv7UGNV3sRN6HOOViT+29OeCHS4RKrb/8vME0PMdllu25 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375226" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375226" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030145" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030145" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:23 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 683EC812; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu Subject: [PATCH v2 08/14] serial: 8250_ingenic: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:24 +0200 Message-ID: <20240226142514.1485246-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have now a common helper to read port properties use it instead of sparse home grown solution. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/8250/8250_ingenic.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/tty/serial/8250/8250_ingenic.c b/drivers/tty/serial/82= 50/8250_ingenic.c index a12f737924c0..7603129f1c07 100644 --- a/drivers/tty/serial/8250/8250_ingenic.c +++ b/drivers/tty/serial/8250/8250_ingenic.c @@ -234,7 +234,7 @@ static int ingenic_uart_probe(struct platform_device *p= dev) struct ingenic_uart_data *data; const struct ingenic_uart_config *cdata; struct resource *regs; - int irq, err, line; + int err; =20 cdata =3D of_device_get_match_data(&pdev->dev); if (!cdata) { @@ -242,10 +242,6 @@ static int ingenic_uart_probe(struct platform_device *= pdev) return -ENODEV; } =20 - irq =3D platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - regs =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!regs) { dev_err(&pdev->dev, "no registers defined\n"); @@ -259,21 +255,19 @@ static int ingenic_uart_probe(struct platform_device = *pdev) spin_lock_init(&uart.port.lock); uart.port.type =3D PORT_16550A; uart.port.flags =3D UPF_SKIP_TEST | UPF_IOREMAP | UPF_FIXED_TYPE; - uart.port.iotype =3D UPIO_MEM; uart.port.mapbase =3D regs->start; - uart.port.regshift =3D 2; uart.port.serial_out =3D ingenic_uart_serial_out; uart.port.serial_in =3D ingenic_uart_serial_in; - uart.port.irq =3D irq; uart.port.dev =3D &pdev->dev; - uart.port.fifosize =3D cdata->fifosize; uart.tx_loadsz =3D cdata->tx_loadsz; uart.capabilities =3D UART_CAP_FIFO | UART_CAP_RTOIE; =20 - /* Check for a fixed line number */ - line =3D of_alias_get_id(pdev->dev.of_node, "serial"); - if (line >=3D 0) - uart.port.line =3D line; + err =3D uart_read_port_properties(&uart.port, true); + if (err) + return err; + + uart.port.regshift =3D 2; + uart.port.fifosize =3D cdata->fifosize; =20 uart.port.membase =3D devm_ioremap(&pdev->dev, regs->start, resource_size(regs)); --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 A61E512C520; Mon, 26 Feb 2024 14:25:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957533; cv=none; b=JDAkomHfYAt8PRvO8rbmdfM9apEyewJthJ93KSrhgYF7R6m+Ydfa9sbhOjDbaDe3Gz2jdX+jqvZXF1gWFRw0OZrcikwMDOUYd4eKWKHAZWLuRmX1xpINdWcwTtxtC57eaMK+UnPAPrx7LMrqKBTab5sGx0DiojT11oCYrUOwwXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957533; c=relaxed/simple; bh=KeTPJX3iP5rGOV/714NN6qjfj4XXg/FxlTFlGOhpEw4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iNpuD+DpCvowYAY8rToedrwFcpd5MncvFIEu/w7e0yyKyom4ZJxj55s5ptTph7+bsNw/51+gFzT3SYa7aM67/PhovIdj7lPd4sMqsa2kLRbPeqOjSOIE8EC0KMo9tkMr9+8PHKtfhUpIJ2fn/TDUkBAbCUTs3hPRkVSw8sBNeCU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DQTiLaoe; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DQTiLaoe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957532; x=1740493532; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KeTPJX3iP5rGOV/714NN6qjfj4XXg/FxlTFlGOhpEw4=; b=DQTiLaoeTKT0FbAK12eCszOivW0fPVVrp9xFjaxBHZdeFu2EWExeVBeF WLM8L1DvTRbJjP4T14AzOB5aa0RL6TI/9d5m9kdI1jHUOof5pP/QivYeL rvZmvQhmu0GgEKEzGclhZr+4t+k+hiLcHNtWZHklWFIGl/IpEDTFzXThV 0Ops4Q4Aaiz2PPVzSOaqbydXV29F5Yhv8yssgdoqlfxfNMowLwFRByc6k fX+7cxBSF7muUdzCHcZfvMZegm3kSUhXQFB3B9RncfoHLa2vyZQU2W8IO Btwvi3t0uOcGtI8jIJB4vdzkj6vngS8PtN/RnjZaTuUu+yWwu0X/MAqBg A==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375197" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375197" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030146" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030146" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:24 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 753049AB; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu Subject: [PATCH v2 09/14] serial: 8250_lpc18xx: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:25 +0200 Message-ID: <20240226142514.1485246-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have now a common helper to read port properties use it instead of sparse home grown solution. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/8250/8250_lpc18xx.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/8250/8250_lpc18xx.c b/drivers/tty/serial/82= 50/8250_lpc18xx.c index 8d728a6a5991..e4a6b7b4caf2 100644 --- a/drivers/tty/serial/8250/8250_lpc18xx.c +++ b/drivers/tty/serial/8250/8250_lpc18xx.c @@ -92,11 +92,7 @@ static int lpc18xx_serial_probe(struct platform_device *= pdev) struct lpc18xx_uart_data *data; struct uart_8250_port uart; struct resource *res; - int irq, ret; - - irq =3D platform_get_irq(pdev, 0); - if (irq < 0) - return irq; + int ret; =20 res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { @@ -139,19 +135,12 @@ static int lpc18xx_serial_probe(struct platform_devic= e *pdev) goto dis_clk_reg; } =20 - ret =3D of_alias_get_id(pdev->dev.of_node, "serial"); - if (ret >=3D 0) - uart.port.line =3D ret; - data->dma.rx_param =3D data; data->dma.tx_param =3D data; =20 spin_lock_init(&uart.port.lock); uart.port.dev =3D &pdev->dev; - uart.port.irq =3D irq; - uart.port.iotype =3D UPIO_MEM32; uart.port.mapbase =3D res->start; - uart.port.regshift =3D 2; uart.port.type =3D PORT_16550A; uart.port.flags =3D UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_SKIP_TEST; uart.port.uartclk =3D clk_get_rate(data->clk_uart); @@ -160,6 +149,13 @@ static int lpc18xx_serial_probe(struct platform_device= *pdev) uart.port.rs485_supported =3D lpc18xx_rs485_supported; uart.port.serial_out =3D lpc18xx_uart_serial_out; =20 + ret =3D uart_read_port_properties(&uart.port, true); + if (ret) + return ret; + + uart.port.iotype =3D UPIO_MEM32; + uart.port.regshift =3D 2; + uart.dma =3D &data->dma; uart.dma->rxconf.src_maxburst =3D 1; uart.dma->txconf.dst_maxburst =3D 1; --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 E5CA512C537; Mon, 26 Feb 2024 14:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957536; cv=none; b=rb2kZtbkNJ5XnX9DBq0ugu3rj5OGH4tnWFTSqHx1/6QEiVUSGTq8M3L8fOeJB1X9lpbMsOfyGuHYFOGD+v23l9KkDRbpGruG5MIu/IOpe4nCYar4u/hzif3EO9Bc/IBUKtLoJJ5L4HLZCxzLTYi1GZo/7lgR5YH0OAwtCLO3rUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957536; c=relaxed/simple; bh=IYoY9YglSHFf69pZg59ideH+3au8X4iy+Kx6zcfcQbU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u3+H4baI0mub0MSp0pjMtaOeRqEMC1C369lVq01PeT3vlp3lIu+rP4kSAjejTjMSH6m2hQ08rESBCd8raSSufs57L/9DqMSvQWNr4pHiFeRbAI8SnW9HJt7qfqqF5ouGEnsThOVPXfB2y29EBtS02BKE92hp6WOSsIQzFNfqN+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fNsp2WpB; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fNsp2WpB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957535; x=1740493535; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IYoY9YglSHFf69pZg59ideH+3au8X4iy+Kx6zcfcQbU=; b=fNsp2WpB3A3+TQNDmotj4YsVIQOWiO8RPT4pLYeB4YSFrBfxPBvFsfHH 5eP9PoG0lMpBBera/U1MLcg3nuFRWyNWJHXB/cfg5av1UmBFgKIDnhZmi p/nMMLaIVAlNMefHdnPj39fjbqvt4fhWuGkOLt6YKcnCpxd1B+HUt2Xtv GbFTICiwmA3XT3CaXjiiRBfjuAu4H/LtYc7vOrgL2krlMO3w1V4szvE62 YHVcs1Az7/2Y1sbCYRXCjdQ1fGrzwz6pPFNJqbRsWKqTzMsJ1vWk3mIDO Ww0U5p2rXlyNBQgkLO3NbAxhflsFx0bJ9tXjpVjQTTHdBkv+S/QAnjkke A==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375294" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375294" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030147" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030147" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:24 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7FFC29AD; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Andi Shyti Subject: [PATCH v2 10/14] serial: 8250_of: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:26 +0200 Message-ID: <20240226142514.1485246-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have now a common helper to read port properties use it instead of sparse home grown solution. Reviewed-by: Andi Shyti Signed-off-by: Andy Shevchenko Reviewed-by: Florian Fainelli Tested-by: Florian Fainelli --- drivers/tty/serial/8250/8250_of.c | 105 +++++++----------------------- 1 file changed, 22 insertions(+), 83 deletions(-) diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/82= 50_of.c index 9dcc17e33269..1a699ce2e812 100644 --- a/drivers/tty/serial/8250/8250_of.c +++ b/drivers/tty/serial/8250/8250_of.c @@ -69,37 +69,22 @@ static int of_platform_serial_setup(struct platform_dev= ice *ofdev, struct device *dev =3D &ofdev->dev; struct device_node *np =3D dev->of_node; struct uart_port *port =3D &up->port; - u32 clk, spd, prop; - int ret, irq; + u32 spd; + int ret; =20 memset(port, 0, sizeof *port); =20 pm_runtime_enable(&ofdev->dev); pm_runtime_get_sync(&ofdev->dev); =20 - if (of_property_read_u32(np, "clock-frequency", &clk)) { - - /* Get clk rate through clk driver if present */ - info->clk =3D devm_clk_get_enabled(dev, NULL); - if (IS_ERR(info->clk)) { - ret =3D dev_err_probe(dev, PTR_ERR(info->clk), "failed to get clock\n"); - goto err_pmruntime; - } - - clk =3D clk_get_rate(info->clk); - } - /* If current-speed was set, then try not to change it. */ - if (of_property_read_u32(np, "current-speed", &spd) =3D=3D 0) - port->custom_divisor =3D clk / (16 * spd); - ret =3D of_address_to_resource(np, 0, &resource); if (ret) { dev_err_probe(dev, ret, "invalid address\n"); goto err_pmruntime; } =20 - port->flags =3D UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | - UPF_FIXED_TYPE; + port->dev =3D &ofdev->dev; + port->flags =3D UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_FIXED_TYPE; spin_lock_init(&port->lock); =20 if (resource_type(&resource) =3D=3D IORESOURCE_IO) { @@ -108,70 +93,31 @@ static int of_platform_serial_setup(struct platform_de= vice *ofdev, } else { port->mapbase =3D resource.start; port->mapsize =3D resource_size(&resource); - - /* Check for shifted address mapping */ - if (of_property_read_u32(np, "reg-offset", &prop) =3D=3D 0) { - if (prop >=3D port->mapsize) { - ret =3D dev_err_probe(dev, -EINVAL, "reg-offset %u exceeds region size= %pa\n", - prop, &port->mapsize); - goto err_pmruntime; - } - - port->mapbase +=3D prop; - port->mapsize -=3D prop; - } - - port->iotype =3D UPIO_MEM; - if (of_property_read_u32(np, "reg-io-width", &prop) =3D=3D 0) { - switch (prop) { - case 1: - port->iotype =3D UPIO_MEM; - break; - case 2: - port->iotype =3D UPIO_MEM16; - break; - case 4: - port->iotype =3D of_device_is_big_endian(np) ? - UPIO_MEM32BE : UPIO_MEM32; - break; - default: - ret =3D dev_err_probe(dev, -EINVAL, "unsupported reg-io-width (%u)\n", - prop); - goto err_pmruntime; - } - } port->flags |=3D UPF_IOREMAP; } =20 + ret =3D uart_read_port_properties(port, false); + if (ret) + goto err_pmruntime; + + /* Get clk rate through clk driver if present */ + if (!port->uartclk) { + info->clk =3D devm_clk_get_enabled(dev, NULL); + if (IS_ERR(info->clk)) { + ret =3D dev_err_probe(dev, PTR_ERR(info->clk), "failed to get clock\n"); + goto err_pmruntime; + } + + port->uartclk =3D clk_get_rate(info->clk); + } + /* If current-speed was set, then try not to change it. */ + if (of_property_read_u32(np, "current-speed", &spd) =3D=3D 0) + port->custom_divisor =3D port->uartclk / (16 * spd); + /* Compatibility with the deprecated pxa driver and 8250_pxa drivers. */ if (of_device_is_compatible(np, "mrvl,mmp-uart")) port->regshift =3D 2; =20 - /* Check for registers offset within the devices address range */ - if (of_property_read_u32(np, "reg-shift", &prop) =3D=3D 0) - port->regshift =3D prop; - - /* Check for fifo size */ - if (of_property_read_u32(np, "fifo-size", &prop) =3D=3D 0) - port->fifosize =3D prop; - - /* Check for a fixed line number */ - ret =3D of_alias_get_id(np, "serial"); - if (ret >=3D 0) - port->line =3D ret; - - irq =3D of_irq_get(np, 0); - if (irq < 0) { - if (irq =3D=3D -EPROBE_DEFER) { - ret =3D -EPROBE_DEFER; - goto err_pmruntime; - } - /* IRQ support not mandatory */ - irq =3D 0; - } - - port->irq =3D irq; - info->rst =3D devm_reset_control_get_optional_shared(&ofdev->dev, NULL); if (IS_ERR(info->rst)) { ret =3D PTR_ERR(info->rst); @@ -183,12 +129,6 @@ static int of_platform_serial_setup(struct platform_de= vice *ofdev, goto err_pmruntime; =20 port->type =3D type; - port->uartclk =3D clk; - - if (of_property_read_bool(np, "no-loopback-test")) - port->flags |=3D UPF_SKIP_TEST; - - port->dev =3D &ofdev->dev; port->rs485_config =3D serial8250_em485_config; port->rs485_supported =3D serial8250_em485_supported; up->rs485_start_tx =3D serial8250_em485_start_tx; @@ -280,7 +220,6 @@ static int of_platform_serial_probe(struct platform_dev= ice *ofdev) platform_set_drvdata(ofdev, info); return 0; err_dispose: - irq_dispose_mapping(port8250.port.irq); pm_runtime_put_sync(&ofdev->dev); pm_runtime_disable(&ofdev->dev); err_free: --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 4442012C54B; Mon, 26 Feb 2024 14:25:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957534; cv=none; b=tq89XixmFl3nBfcieJlj79mRi7zqGWgLPNgZYeKKMWQI3ZXm2zo/8X74+CAHNZJ1aVrtKdVZbBo+qTcHRiyBBnnQqlv7HN3jn4JwMvvnDXbqbAHqtPBCJqpB7LKbX8q8yOqWOcguc6d6+TaLsJi0tPYr2A9nW4zjf4iLj6WrOJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957534; c=relaxed/simple; bh=x0OGDwF7erFFwXirCEnUP9h+wCzGSEhdgN5rCP6VdCA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OD9DT4VKXXzPDh6mLcxajuXoE3hMOBhg4hfGvQVShvHsDR9Gk+Xl/HMewSWTUaaC/BxgxxvK+VwS0fQnEUmKVo2DFXRNdRGJBLbgfLsND22tBuOR6asaN7VYxxkNTRr7290bljePDkwIOIxskDGmeVBUuZMxQwT8HBQDLZTtEzE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mVEan7FK; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mVEan7FK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957534; x=1740493534; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x0OGDwF7erFFwXirCEnUP9h+wCzGSEhdgN5rCP6VdCA=; b=mVEan7FKIoMWMSREmnExAweA6eMFFgS2+3eooxvv5dYDhgQ0TeTV1weM SUiYkNoZqwt8DDW2NnQ+b4Wn72fOcVMTy5oh+ZaLYWT4KHGAMnv6iSjL3 wSmkz3n8m9Xh0tClfEPnSXWx+RjVjv0UqPtGJRZAQRn0VYsA0OaiBeNQ0 Tk30R/xTvFjIOJL6lur1+DCCnj7zeTkRmhE8Ih1xYMFBpjj6GLu6O0Hwr ijgTqckXMPAowS1aIYQzlf75LwV4tL3VD2CkNbMVIyyUHIjldr6oOZOpT Ryf9itWHuY/w88oK3wMoPdL+d938Xed++BI4rKsgE+YSYBuuJvCgb5Nhi Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375270" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375270" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030148" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030148" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:24 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8A0AA9DB; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu Subject: [PATCH v2 11/14] serial: 8250_omap: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:27 +0200 Message-ID: <20240226142514.1485246-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have now a common helper to read port properties use it instead of sparse home grown solution. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/8250/8250_omap.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/= 8250_omap.c index 6942990a333c..173af575a43e 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -1394,11 +1394,7 @@ static int omap8250_probe(struct platform_device *pd= ev) struct uart_8250_port up; struct resource *regs; void __iomem *membase; - int irq, ret; - - irq =3D platform_get_irq(pdev, 0); - if (irq < 0) - return irq; + int ret; =20 regs =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!regs) { @@ -1419,7 +1415,6 @@ static int omap8250_probe(struct platform_device *pde= v) up.port.dev =3D &pdev->dev; up.port.mapbase =3D regs->start; up.port.membase =3D membase; - up.port.irq =3D irq; /* * It claims to be 16C750 compatible however it is a little different. * It has EFR and has no FCR7_64byte bit. The AFE (which it claims to @@ -1429,13 +1424,9 @@ static int omap8250_probe(struct platform_device *pd= ev) * or pm callback. */ up.port.type =3D PORT_8250; - up.port.iotype =3D UPIO_MEM; - up.port.flags =3D UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_SOFT_FLOW | - UPF_HARD_FLOW; + up.port.flags =3D UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_SOFT_FLOW | UPF_H= ARD_FLOW; up.port.private_data =3D priv; =20 - up.port.regshift =3D OMAP_UART_REGSHIFT; - up.port.fifosize =3D 64; up.tx_loadsz =3D 64; up.capabilities =3D UART_CAP_FIFO; #ifdef CONFIG_PM @@ -1461,14 +1452,14 @@ static int omap8250_probe(struct platform_device *p= dev) up.rs485_stop_tx =3D serial8250_em485_stop_tx; up.port.has_sysrq =3D IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE); =20 - ret =3D of_alias_get_id(np, "serial"); - if (ret < 0) { - dev_err(&pdev->dev, "failed to get alias\n"); + ret =3D uart_read_port_properties(&up.port, true); + if (ret) return ret; - } - up.port.line =3D ret; =20 - if (of_property_read_u32(np, "clock-frequency", &up.port.uartclk)) { + up.port.regshift =3D OMAP_UART_REGSHIFT; + up.port.fifosize =3D 64; + + if (!up.port.uartclk) { struct clk *clk; =20 clk =3D devm_clk_get(&pdev->dev, NULL); @@ -1560,8 +1551,8 @@ static int omap8250_probe(struct platform_device *pde= v) } #endif =20 - irq_set_status_flags(irq, IRQ_NOAUTOEN); - ret =3D devm_request_irq(&pdev->dev, irq, omap8250_irq, 0, + irq_set_status_flags(up.port.irq, IRQ_NOAUTOEN); + ret =3D devm_request_irq(&pdev->dev, up.port.irq, omap8250_irq, 0, dev_name(&pdev->dev), priv); if (ret < 0) return ret; --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 833EA12C7FC; Mon, 26 Feb 2024 14:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957536; cv=none; b=uQyzlKPswkb1Mkbe79Cg88jK7TZHpXs+O7ndSyaipkEvk5Qx9YBob+8OhZgeWEuZw0cetvgAcEss6SuQbltkLBxKJQz6xXAUkndcUbKr+uQfsQ2PsBaHg3lAgN+MKYEkJHgCbNxs6ql+8nNsVLnMa5ABXSSt6Y+SsdemrTNKXvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957536; c=relaxed/simple; bh=J0xi+n8uZBq6TA4lbxbqQ3C4vIDv86jFL+mrVMUmGoA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WBbFt3c5alT1mb/1facOb4vK0+efv1fCDatylDzRkSAZZ2p7SwsiJ4f6v50cvNm3DF0dGbFMpl9moR4KqS+htp2rIybOOFwuAyDt2jy2RSRTjxpHsMsC1+SdtmcF5nJu915pRBRekuAI2EwSXK+95hZoBQdWy4ORQwii/p/ZqO0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Z+MKX2kW; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Z+MKX2kW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957535; x=1740493535; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J0xi+n8uZBq6TA4lbxbqQ3C4vIDv86jFL+mrVMUmGoA=; b=Z+MKX2kWCWOIqP6LcpXKezsJSGWZKITA9oaGGQ+f6Hcvl02ij9plBqzm midO6vxWsLh3ts2sp2r5toez+ef/x47v0qfO7SYzdrQUgURHFwX32o/zM TNvVRLj7XYJznHcGY0sW6QvpplvumkPfj/VCXPFBugQ1GwGqov6mOohzc zQFzNjhtbp+RHN7xu+lrUupzY7Wp1D9H42P1lh4X+RMvS5klm6MvEORA8 iBpua3b1+Zv1ezAb8ucU/zF3fi9hnaxIk3ThW7Ut2IZ+B/fv1Gjyj5FAX tx/Hd3kFwRQsSPyl5GCHe60qTgWXkcoHy5YxwhAwZ+weDut+6NaaN6ze0 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375237" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375237" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030149" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030149" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:24 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 98B77A0D; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu Subject: [PATCH v2 12/14] serial: 8250_pxa: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:28 +0200 Message-ID: <20240226142514.1485246-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have now a common helper to read port properties use it instead of sparse home grown solution. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/8250/8250_pxa.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/tty/serial/8250/8250_pxa.c b/drivers/tty/serial/8250/8= 250_pxa.c index 77686da42ce8..0c9140b93414 100644 --- a/drivers/tty/serial/8250/8250_pxa.c +++ b/drivers/tty/serial/8250/8250_pxa.c @@ -92,11 +92,7 @@ static int serial_pxa_probe(struct platform_device *pdev) struct uart_8250_port uart =3D {}; struct pxa8250_data *data; struct resource *mmres; - int irq, ret; - - irq =3D platform_get_irq(pdev, 0); - if (irq < 0) - return irq; + int ret; =20 mmres =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mmres) @@ -114,21 +110,21 @@ static int serial_pxa_probe(struct platform_device *p= dev) if (ret) return ret; =20 - ret =3D of_alias_get_id(pdev->dev.of_node, "serial"); - if (ret >=3D 0) - uart.port.line =3D ret; - uart.port.type =3D PORT_XSCALE; - uart.port.iotype =3D UPIO_MEM32; uart.port.mapbase =3D mmres->start; - uart.port.regshift =3D 2; - uart.port.irq =3D irq; - uart.port.fifosize =3D 64; uart.port.flags =3D UPF_IOREMAP | UPF_SKIP_TEST | UPF_FIXED_TYPE; uart.port.dev =3D &pdev->dev; uart.port.uartclk =3D clk_get_rate(data->clk); uart.port.pm =3D serial_pxa_pm; uart.port.private_data =3D data; + + ret =3D uart_read_port_properties(&uart.port, true); + if (ret) + return ret; + + uart.port.iotype =3D UPIO_MEM32; + uart.port.regshift =3D 2; + uart.port.fifosize =3D 64; uart.dl_write =3D serial_pxa_dl_write; =20 ret =3D serial8250_register_8250_port(&uart); --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 4871A12C7EB; Mon, 26 Feb 2024 14:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957535; cv=none; b=IoscVFeG+ZbZRXXFDx3YAtCm5HFCLe2tgGKcXNhcn4WfKkKrUffe/nURMDPirZwC+mtVUJDvSY3ImxphEjXHaYtgEnLH7YEm9EIKHZQyQCMB8SC167yhnhNRAUPRK6CY5o+bKpZOfyi/1l/AulfVYAFv3C1RGdLsO4YAT14qiAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957535; c=relaxed/simple; bh=I4Dp8lscp5MpgtPKkZb6GpVT2AnT2N5Frc+xmVMhCuw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YD1tv0a5RszhFEtklxmYpaC7A18jzjFCEaedQezd8TtlhoQ0xiMGOrPqT0B7r6GwxDVoISlcNvVLjr2OXuO6CKumHb+pGpLX5RPnS+HEFRN4mbZyWePUUmLB8WmmAgKm2EwsJYVQuMqyNLz2NNQOYkuI36aKx0cPzW7gz4SB1f0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DS+iiPGY; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DS+iiPGY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957535; x=1740493535; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I4Dp8lscp5MpgtPKkZb6GpVT2AnT2N5Frc+xmVMhCuw=; b=DS+iiPGYEWrBf4fBkiA2nJmw+2SprsezPtG0ErHNTDS2TaBTYuqgZgrp slz2iss7uupJis8aZgJpqceY1vFfMQKBRevP5CQKikENI6aBrD1m0n+I8 3tUHXzziACNIjhsSorgy4XDizzNeSH9HLTvwsMn3xsMT4Oro+6u1IAoFP KO3BouLE6nRpRGWhd/blfWtIDIk/9wxbf5EPmooLI+rryQMgdogMg0Hiv e1CgEYb5zSNACVTN2W7SNnHLvmeJzhlNddC5Uf/dDpQNdBmi5eKxA7CVb L3UnLA8IEDbwogQQ36vT1Q8HQm1QZEPvrzwYDljuzifu1PV4ozazfMWVW g==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375281" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375281" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030150" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030150" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:24 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A3B5DA43; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu Subject: [PATCH v2 13/14] serial: 8250_tegra: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:29 +0200 Message-ID: <20240226142514.1485246-14-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have now a common helper to read port properties use it instead of sparse home grown solution. Signed-off-by: Andy Shevchenko --- drivers/tty/serial/8250/8250_tegra.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/tty/serial/8250/8250_tegra.c b/drivers/tty/serial/8250= /8250_tegra.c index ba352262df75..ce48d02dfa0d 100644 --- a/drivers/tty/serial/8250/8250_tegra.c +++ b/drivers/tty/serial/8250/8250_tegra.c @@ -57,25 +57,11 @@ static int tegra_uart_probe(struct platform_device *pde= v) port =3D &port8250.port; spin_lock_init(&port->lock); =20 - port->flags =3D UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | - UPF_FIXED_TYPE; - port->iotype =3D UPIO_MEM32; - port->regshift =3D 2; + port->flags =3D UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_FIXED_TYPE; port->type =3D PORT_TEGRA; - port->irqflags |=3D IRQF_SHARED; port->dev =3D &pdev->dev; port->handle_break =3D tegra_uart_handle_break; =20 - ret =3D of_alias_get_id(pdev->dev.of_node, "serial"); - if (ret >=3D 0) - port->line =3D ret; - - ret =3D platform_get_irq(pdev, 0); - if (ret < 0) - return ret; - - port->irq =3D ret; - res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; @@ -88,12 +74,18 @@ static int tegra_uart_probe(struct platform_device *pde= v) port->mapbase =3D res->start; port->mapsize =3D resource_size(res); =20 + ret =3D uart_read_port_properties(port, true); + if (ret) + return ret; + + port->iotype =3D UPIO_MEM32; + port->regshift =3D 2; + uart->rst =3D devm_reset_control_get_optional_shared(&pdev->dev, NULL); if (IS_ERR(uart->rst)) return PTR_ERR(uart->rst); =20 - if (device_property_read_u32(&pdev->dev, "clock-frequency", - &port->uartclk)) { + if (!port->uartclk) { uart->clk =3D devm_clk_get(&pdev->dev, NULL); if (IS_ERR(uart->clk)) { dev_err(&pdev->dev, "failed to get clock!\n"); --=20 2.43.0.rc1.1.gbec44491f096 From nobody Sun Feb 8 02:21:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 E9F3B12CDB1; Mon, 26 Feb 2024 14:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957537; cv=none; b=sOdjyCyx0ChM5mf1Ys0zrTPoa3BGK1zA6jdcQa/LK9sVYauKQpdVyBJHpAet6R6myXfIPsrbtNh7mBsJ0GrvS2CUcIHOhKSLue1gqgtgvZxBzM/FFpZ3nilcAWRtRVEXw9iswAwn19ayuOWFiXLrFgbPeb/AFDDaxP9jzM4DGyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957537; c=relaxed/simple; bh=lTV4RH4qiS21e5gSPVWYHbVcBJWdPYtUVhU20SXaAR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IcXETm9gu4zxUJis05XZ31tsuriiUN9rEAmnVfqQZJ5ZqkuO6Dov732TLtvBAYKxC5YQ5Rhkf2d0lnYN5X8lJa+gkbpD3/vB1ilfUiAOVz5b1V3l5QT2abT8B/mZoQb9dQPeSDoJdHvJzdlVsx82cLbFGvZ51RH+m9+ZVwC68NU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jlhVrdeU; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jlhVrdeU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957536; x=1740493536; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lTV4RH4qiS21e5gSPVWYHbVcBJWdPYtUVhU20SXaAR4=; b=jlhVrdeUqDSZUIRzZ6ZxKAbBNda8h+Xi4zNyKmdFtm8TevpqQB68ofRG 8WYReZzxgbv8UM3V+y9X2t7Trn0DJR1BUcQGywht2r7F98DL1BpsA/YiX 8eJZfHtIWDqSjtnl8ywMnzMA6Ha6q5mUcnKyRXXL8BnhyFp/OfueaNjA9 Q8nsP26E2hgXyMYyNFUNaF87AuZYhVdZnGRAcnzb2QZCP/f4ZmZYDmZpp ivQK/0v0YbA5mV1zxeDaHk76FoDNe8oXdfOJnxbN0t5X/UFKIEa+QoYBE M+X1We8p/5Slj4Z8I7NBGN1qpoQ6GQNEaeiUFZpfJtJpG7UqMlZ+f0gQZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375292" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375292" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030151" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030151" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:24 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id AE687A97; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu Subject: [PATCH v2 14/14] serial: 8250_uniphier: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:30 +0200 Message-ID: <20240226142514.1485246-15-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have now a common helper to read port properties use it instead of sparse home grown solution. Signed-off-by: Andy Shevchenko Reviewed-by: Kunihiko Hayashi Tested-by: Kunihiko Hayashi --- drivers/tty/serial/8250/8250_uniphier.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8= 250/8250_uniphier.c index 6399a38ecce2..d3f270a191ee 100644 --- a/drivers/tty/serial/8250/8250_uniphier.c +++ b/drivers/tty/serial/8250/8250_uniphier.c @@ -162,7 +162,6 @@ static int uniphier_uart_probe(struct platform_device *= pdev) struct uniphier8250_priv *priv; struct resource *regs; void __iomem *membase; - int irq; int ret; =20 regs =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -175,23 +174,12 @@ static int uniphier_uart_probe(struct platform_device= *pdev) if (!membase) return -ENOMEM; =20 - irq =3D platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; =20 memset(&up, 0, sizeof(up)); =20 - ret =3D of_alias_get_id(dev->of_node, "serial"); - if (ret < 0) { - dev_err(dev, "failed to get alias id\n"); - return ret; - } - up.port.line =3D ret; - priv->clk =3D devm_clk_get(dev, NULL); if (IS_ERR(priv->clk)) { dev_err(dev, "failed to get clock\n"); @@ -211,7 +199,10 @@ static int uniphier_uart_probe(struct platform_device = *pdev) up.port.mapbase =3D regs->start; up.port.mapsize =3D resource_size(regs); up.port.membase =3D membase; - up.port.irq =3D irq; + + ret =3D uart_read_port_properties(&up.port, true); + if (ret) + return ret; =20 up.port.type =3D PORT_16550A; up.port.iotype =3D UPIO_MEM32; --=20 2.43.0.rc1.1.gbec44491f096