From patchwork Sun Dec 11 01:47:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kumaravel Thiagarajan X-Patchwork-Id: 32021 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1306654wrr; Sat, 10 Dec 2022 05:14:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf68I0zoM5FmVYl6yzbdD8iVnpweCm71OGHU5AVqe3UkSDvkF411+ar9/4yCa8LSKu9y140J X-Received: by 2002:a05:6402:2408:b0:467:6a1a:d994 with SMTP id t8-20020a056402240800b004676a1ad994mr8742362eda.7.1670678070836; Sat, 10 Dec 2022 05:14:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670678070; cv=none; d=google.com; s=arc-20160816; b=ns9AVRKJdeZuKSLvCoA9nrvRiUoiqAZxtvC8pS9JEaLp4Ma8WDOFZP4fsnStnuKrpa wXPcC0ppwSIxNGNmN1ZLiPW3OoobCTe55rssxaHWklObEZUXZGaHhkqe2V4Siry+hjiH VT2NfdQtT1pSH5aSKlo3J+D/nHa3i7pesusG1jxBAF8QTjGie72OPsli9+FN+6m6blTK 5Mig/ML0rjav3XQTaFt1Z7cJVOmhy3unkjJET5WiZXVck0hD9toZQ7s9HVMtvN/EWsBz OiLMMIaYVghS4GB2ig0UWRs4euyPo6tvifwFOsFu0cF7p2vRCNpFkYOKQQIkeaZqe/qm BNsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TXsejilNleNWdUTD7ki/L0MkXDF51omXt8DLO0yV8Xk=; b=lxQhuvY682i14cAme1f7OjuTqg23l5utVb05n+TeKuumspBGACQodegRo8u7GY+TOG 2W8YLTZ9MAXYM8LMeOdqDg1Oe51rCOxBQHOXHZ6ERG3TPCJWrTMS5wFBnB9x26SbdFp6 VTQrOecQlfxtbstiXWxHFXJLHoMRrIT65EtfeCdqwvVZzu+EnK5FHzOm2e7LCo6ZyLGa W56ZlA5Rd+I2Y7rvrPFeOMRJP36iohHhsGgiiBcA2V0npLAS73ln9f5HOjDAfTBGFcYa qK2IEArO90ptC8+Qk65679TexPXaSkNMLstCsIQuosEFFXDDIuI0qgYQ2CHWKbzvoVvN gnYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=XLTcEgvg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g10-20020a056402090a00b0045c97cb9027si4295191edz.421.2022.12.10.05.14.07; Sat, 10 Dec 2022 05:14:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=XLTcEgvg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbiLJNNU (ORCPT + 99 others); Sat, 10 Dec 2022 08:13:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbiLJNNF (ORCPT ); Sat, 10 Dec 2022 08:13:05 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9AACEE0D; Sat, 10 Dec 2022 05:13:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670677982; x=1702213982; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J0cDZjfgb9QtBEeL+5fiJ3N+bzN0LSv55hnEj+yf8QE=; b=XLTcEgvgANxVfD748pFtdQbiz5VK2lmorwZc6c1WDd9d8alPyQ4/XC6D dxSWeSwArpVPxFzhqeVRGfYb0yBPHMu/UCgJMvT3zyW0VaYv98oHwqQ2J 0dr67nL3FkX93x4W1h9lzr1gQMoqcv2J0+dd41+kwUWr4BOhg8RhQqOMC 5yqMoLYz+cTm2rrV7rixDINzg6wNFcpu7Tx5YGRIk0+8Y1MVqVGwPYOQU p4VxXG0lEb/TVl1mpnkIRwHuXt0cDyWFY23BiuqHJrZNlX0fBdY74mAcG qRXEyLbHkva01DLhZD1FchsfaLx4bRc98KIQ1f69IBInA4jzcBf1+Gznx w==; X-IronPort-AV: E=Sophos;i="5.96,234,1665471600"; d="scan'208";a="191021575" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 10 Dec 2022 06:12:52 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Sat, 10 Dec 2022 06:12:52 -0700 Received: from CHE-LT-UNGSOFTWARE.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Sat, 10 Dec 2022 06:12:47 -0700 From: Kumaravel Thiagarajan To: CC: , , , , , , , , , , , , , , , , , Tharun Kumar P Subject: [PATCH v8 tty-next 1/4] serial: 8250_pci: Add serial8250_pci_setup_port definition in 8250_pcilib.c Date: Sun, 11 Dec 2022 07:17:27 +0530 Message-ID: <20221211014730.1233272-2-kumaravel.thiagarajan@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221211014730.1233272-1-kumaravel.thiagarajan@microchip.com> References: <20221211014730.1233272-1-kumaravel.thiagarajan@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_12_24, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751832929016111657?= X-GMAIL-MSGID: =?utf-8?q?1751832929016111657?= Move implementation of setup_port func() to serial8250_pci_setup_port. Co-developed-by: Tharun Kumar P Signed-off-by: Tharun Kumar P Signed-off-by: Kumaravel Thiagarajan Reviewed-by: Ilpo Järvinen Reviewed-by: Andy Shevchenko --- Changes in v8: - Moved SERIAL_8250_PCILIB above 8250_PCI Changes in v7: - Used namespace 'SERIAL_8250_PCI' while exporting and importing symbols - Included structures used in function declaration in 8250_pcilib.h file Changes in v6: - Made this patch first patch of the patch series Changes in v5: - This is the new patch added in v5 version of this patchset - Moved implementation of setup_port from 8250_pci.c to 8250_pcilib.c --- drivers/tty/serial/8250/8250_pci.c | 25 +++--------------- drivers/tty/serial/8250/8250_pcilib.c | 38 +++++++++++++++++++++++++++ drivers/tty/serial/8250/8250_pcilib.h | 15 +++++++++++ drivers/tty/serial/8250/Kconfig | 4 +++ drivers/tty/serial/8250/Makefile | 1 + 5 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 drivers/tty/serial/8250/8250_pcilib.c create mode 100644 drivers/tty/serial/8250/8250_pcilib.h diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 6f66dc2ebacc..58cc9e19bd20 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -24,6 +24,7 @@ #include #include "8250.h" +#include "8250_pcilib.h" /* * init function returns: @@ -89,28 +90,7 @@ static int setup_port(struct serial_private *priv, struct uart_8250_port *port, u8 bar, unsigned int offset, int regshift) { - struct pci_dev *dev = priv->dev; - - if (bar >= PCI_STD_NUM_BARS) - return -EINVAL; - - if (pci_resource_flags(dev, bar) & IORESOURCE_MEM) { - if (!pcim_iomap(dev, bar, 0) && !pcim_iomap_table(dev)) - return -ENOMEM; - - port->port.iotype = UPIO_MEM; - port->port.iobase = 0; - port->port.mapbase = pci_resource_start(dev, bar) + offset; - port->port.membase = pcim_iomap_table(dev)[bar] + offset; - port->port.regshift = regshift; - } else { - port->port.iotype = UPIO_PORT; - port->port.iobase = pci_resource_start(dev, bar) + offset; - port->port.mapbase = 0; - port->port.membase = NULL; - port->port.regshift = 0; - } - return 0; + return serial8250_pci_setup_port(priv->dev, port, bar, offset, regshift); } /* @@ -5759,3 +5739,4 @@ module_pci_driver(serial_pci_driver); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Generic 8250/16x50 PCI serial probe module"); MODULE_DEVICE_TABLE(pci, serial_pci_tbl); +MODULE_IMPORT_NS(SERIAL_8250_PCI); diff --git a/drivers/tty/serial/8250/8250_pcilib.c b/drivers/tty/serial/8250/8250_pcilib.c new file mode 100644 index 000000000000..090385172a09 --- /dev/null +++ b/drivers/tty/serial/8250/8250_pcilib.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * 8250 PCI library. + * + * Copyright (C) 2001 Russell King, All Rights Reserved. + */ +#include +#include +#include +#include + +#include "8250.h" + +int serial8250_pci_setup_port(struct pci_dev *dev, struct uart_8250_port *port, + u8 bar, unsigned int offset, int regshift) +{ + if (bar >= PCI_STD_NUM_BARS) + return -EINVAL; + + if (pci_resource_flags(dev, bar) & IORESOURCE_MEM) { + if (!pcim_iomap(dev, bar, 0) && !pcim_iomap_table(dev)) + return -ENOMEM; + + port->port.iotype = UPIO_MEM; + port->port.iobase = 0; + port->port.mapbase = pci_resource_start(dev, bar) + offset; + port->port.membase = pcim_iomap_table(dev)[bar] + offset; + port->port.regshift = regshift; + } else { + port->port.iotype = UPIO_PORT; + port->port.iobase = pci_resource_start(dev, bar) + offset; + port->port.mapbase = 0; + port->port.membase = NULL; + port->port.regshift = 0; + } + return 0; +} +EXPORT_SYMBOL_NS_GPL(serial8250_pci_setup_port, SERIAL_8250_PCI); diff --git a/drivers/tty/serial/8250/8250_pcilib.h b/drivers/tty/serial/8250/8250_pcilib.h new file mode 100644 index 000000000000..1aaf1b50ce9c --- /dev/null +++ b/drivers/tty/serial/8250/8250_pcilib.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * 8250 PCI library header file. + * + * Copyright (C) 2001 Russell King, All Rights Reserved. + */ + +#include + +struct pci_dev; + +struct uart_8250_port; + +int serial8250_pci_setup_port(struct pci_dev *dev, struct uart_8250_port *port, u8 bar, + unsigned int offset, int regshift); diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index d0b49e15fbf5..768b73d5cb9a 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig @@ -129,9 +129,13 @@ config SERIAL_8250_DMA This builds DMA support that can be used with 8250/16650 compatible UART controllers that support DMA signaling. +config SERIAL_8250_PCILIB + bool + config SERIAL_8250_PCI tristate "8250/16550 PCI device support" depends on SERIAL_8250 && PCI + select SERIAL_8250_PCILIB default SERIAL_8250 help This builds standard PCI serial support. You may be able to diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile index bee908f99ea0..b9179d1f104b 100644 --- a/drivers/tty/serial/8250/Makefile +++ b/drivers/tty/serial/8250/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_SERIAL_8250) += 8250.o 8250_base.o 8250_base-$(CONFIG_SERIAL_8250_DMA) += 8250_dma.o 8250_base-$(CONFIG_SERIAL_8250_DWLIB) += 8250_dwlib.o 8250_base-$(CONFIG_SERIAL_8250_FINTEK) += 8250_fintek.o +8250_base-$(CONFIG_SERIAL_8250_PCILIB) += 8250_pcilib.o obj-$(CONFIG_SERIAL_8250_GSC) += 8250_gsc.o obj-$(CONFIG_SERIAL_8250_PCI) += 8250_pci.o obj-$(CONFIG_SERIAL_8250_EXAR) += 8250_exar.o