Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1339621rbb; Mon, 26 Feb 2024 06:27:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUii0iSFlJBvHH98On7YEEn3iIrFBLHdfSk99ZEh2qR0/ZcD5F5klU51mF0As522zAOG7Jc6WpDIYaqnddR/qoLM6935BB64wGDfJQ+KA== X-Google-Smtp-Source: AGHT+IGuSfGEN5o/Td0frXA49f/6lOjgmoz6OCTHR+x90hidQmgqR9A19wzKv7Dr8z/4/HKlyrs3 X-Received: by 2002:a0d:d4cb:0:b0:607:8472:f33d with SMTP id w194-20020a0dd4cb000000b006078472f33dmr6279499ywd.25.1708957655406; Mon, 26 Feb 2024 06:27:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708957655; cv=pass; d=google.com; s=arc-20160816; b=VIZGVSNmIT8OYRpcXY6Jit1tR62gPnA0aO6DdQJ51NV+VxUxg4Cmfm7TkjOll2l0Pl pviERELIn6wyWCJNKXATIgD0nI8Ui5CM0ro+at9naCJ90S26ZJb3bwagVV6HzbGsDTHf xh55362uq1QThPy2a+wxLWErX+w9dAkgfw7i6KpNuHR9zpdPisqhf5zdBgWwpWzjzmEZ LtERIL9e3YArqXEIXeI7+tKlGxg3xmC73qFyKZ4fzoTjb8i1bGJwJONQNQDtj2GcG+aQ g4TqVNUaQbyEMJk4YVXKzMbfJFqDj2mK7EG4Hsw0tDu7wWvI10jKWzj6kWuxOHB4FGW9 6lYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Rfv/w1oagO0PWkpRdEXL5v6wHjn1Olf0DAP5t81QMP8=; fh=xSGBIHWd5RaiKxDKjJ9wuXs6bQZHuqbCRoo49Bl7JGU=; b=BSc6nrwZFUnBv+wAk4pCpf5XLTZAgEFxYwYffvaFDC9C767Teo3aOgHeqXSzw9Wg+O J/ZPeGMJoRFi/xgFg4w0UI8SvdAlaoCDIx63X988A1kHPwMBH7PTe4JTYxy8u2ti3Laa 3k7YaGu1c+EeYv5IVc+Mc7jvOtEptmNzBvIzihQ1fj9QcybJbFWalPKUQRyzrAJNzfBv UnXtdumxcC2dJ6ZwuAqB1VK5nEmZrZsnjBxKs5SwkNGPHuByA5ay9DoNQv2aETuPZJCa JRFg4+yZLt9QTR/8zs8ljnk5YG7BPygfkzkc8DfyfHKqO3I8BDOdtQ5kb0DfVd1EnTQ7 rt5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CfPcndYW; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-81612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y18-20020ac87092000000b0042e7b7c14a8si3611937qto.159.2024.02.26.06.27.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 06:27:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CfPcndYW; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-81612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0AEE81C29CD5 for ; Mon, 26 Feb 2024 14:27:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7722312CD97; Mon, 26 Feb 2024 14:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CfPcndYW" 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 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: 8bit 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/8250_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) if (np) { unsigned int quirks = data->pdata->quirks; - int id; - /* get index of serial line, if found in DT aliases */ - id = of_alias_get_id(np, "serial"); - if (id >= 0) - p->line = id; #ifdef CONFIG_64BIT if (quirks & DW_UART_QUIRK_OCTEON) { p->serial_in = dw8250_serial_inq; @@ -465,12 +459,6 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) } #endif - if (of_device_is_big_endian(np)) { - p->iotype = UPIO_MEM32BE; - p->serial_in = dw8250_serial_in32be; - p->serial_out = dw8250_serial_out32be; - } - if (quirks & DW_UART_QUIRK_ARMADA_38X) p->serial_out = 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 = &pdev->dev; struct dw8250_data *data; struct resource *regs; - int irq; int err; - u32 val; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!regs) return dev_err_probe(dev, -EINVAL, "no registers defined\n"); - irq = platform_get_irq_optional(pdev, 0); - /* no interrupt -> fall back to polling */ - if (irq == -ENXIO) - irq = 0; - if (irq < 0) - return irq; - spin_lock_init(&p->lock); - p->mapbase = regs->start; - p->irq = irq; p->handle_irq = dw8250_handle_irq; p->pm = dw8250_do_pm; p->type = PORT_8250; - p->flags = UPF_SHARE_IRQ | UPF_FIXED_PORT; + p->flags = UPF_FIXED_PORT; p->dev = dev; - p->iotype = UPIO_MEM; - p->serial_in = dw8250_serial_in; - p->serial_out = dw8250_serial_out; p->set_ldisc = dw8250_set_ldisc; p->set_termios = dw8250_set_termios; - p->membase = devm_ioremap(dev, regs->start, resource_size(regs)); - if (!p->membase) - return -ENOMEM; - data = 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 = device_property_read_bool(dev, "snps,uart-16550-compatible"); - err = device_property_read_u32(dev, "reg-shift", &val); - if (!err) - p->regshift = val; + p->mapbase = regs->start; + p->mapsize = resource_size(regs); - err = device_property_read_u32(dev, "reg-io-width", &val); - if (!err && val == 4) { - p->iotype = UPIO_MEM32; + p->membase = devm_ioremap(dev, p->mapbase, p->mapsize); + if (!p->membase) + return -ENOMEM; + + err = uart_read_port_properties(p, true); + /* no interrupt -> fall back to polling */ + if (err == -ENXIO) + err = 0; + if (err) + return err; + + switch (p->iotype) { + case UPIO_MEM: + p->serial_in = dw8250_serial_in; + p->serial_out = dw8250_serial_out; + break; + case UPIO_MEM32: p->serial_in = dw8250_serial_in32; p->serial_out = dw8250_serial_out32; + break; + case UPIO_MEM32BE: + p->serial_in = dw8250_serial_in32be; + p->serial_out = dw8250_serial_out32be; + break; + default: + return -ENODEV; } if (device_property_read_bool(dev, "dcd-override")) { @@ -589,9 +579,6 @@ static int dw8250_probe(struct platform_device *pdev) data->msr_mask_off |= UART_MSR_TERI; } - /* 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 = devm_clk_get_optional_enabled(dev, "baudclk"); if (data->clk == NULL) -- 2.43.0.rc1.1.gbec44491f096