Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1702938pxb; Mon, 8 Mar 2021 04:27:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJz7vLMVS55qtnnkL53JKDGcRBB2terjCXH8YYujAsEDzB9cHbeGB4YJDqNDzgHKaMsNHjO/ X-Received: by 2002:a17:906:af91:: with SMTP id mj17mr14203584ejb.230.1615206433148; Mon, 08 Mar 2021 04:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615206433; cv=none; d=google.com; s=arc-20160816; b=bq0t7NxqdnwfGhnxc1O298gainajDIEVXEHuPkA70q+jladtQ/QZ66+BuCXLqSIzpA yKctov055DyY1hoMY2WVBHWhJx24UrrItMxc/40cJ3Wh6s45oprX9CaTG7ov4PccnK5i KSae8UCEdzI1d4lQNCVQ6qw471Gkgu9Hm+boG00MhKJ63GJzLB8L3g0HLCczJ0Anw7GI itdkPqhQNaFRmL2eMJhZ0NHDbVqSeJULPqIbBq1yVNVw6WcHxaVNQWGVFt0QeIH3ITRr 1m6ToF72inFnAURfr3HG5FrNkox8lcYO/dZTDpfzNlRc4TqEJr2r7kUSkmPlesReZ42c xG/g== 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 :ironport-sdr:ironport-sdr; bh=i2IyuMGoDnaqVSnr7Uz0Xc7DOMo8cnUe8mpIE6T6YYA=; b=MYfQdKe6DE2Hqw1eWLQg+Z5fse8nVmkKQZldnWdRqP2fbK6QCjQSuJk7bqCvrhXApA 3Ss3bHvZJL8LwCJDnjkQy+E3YNohFkmhzmEcteJXkbyGr+A7ryIh44ZS/Hs0vjwvkqUu 2ei+lUKuBmaYG9V70FJflYb3HvaqEMTbL/CqHuhiST+YvLo+h64hx9U5UJ6fLV9t53hd +K4eaZ+0UuSTwZ+lAgTapL8k2XqoI7MrXdz9rKNWTmtA1mr0d3iDZV61kKHFCi77csrt 3OUUqqkSEpv/rA7jw8fJwQVXpcnm/DWoAbfWQ11Sm+CFpTReUXYuWKEioT1ZlIt6zaDU itJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b14si7064287eju.424.2021.03.08.04.26.50; Mon, 08 Mar 2021 04:27:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231572AbhCHMVA (ORCPT + 99 others); Mon, 8 Mar 2021 07:21:00 -0500 Received: from mga07.intel.com ([134.134.136.100]:3493 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230242AbhCHMUs (ORCPT ); Mon, 8 Mar 2021 07:20:48 -0500 IronPort-SDR: zkUiqrQjEn+qsCEUJOSCwPBFYADH3AvbGWl90alNjaCWh9m67sIHP/PnhPKtq+fAoKxeEOgGqD 9gfzXoVSxu/Q== X-IronPort-AV: E=McAfee;i="6000,8403,9916"; a="252044308" X-IronPort-AV: E=Sophos;i="5.81,232,1610438400"; d="scan'208";a="252044308" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2021 04:20:46 -0800 IronPort-SDR: 7A2Xp3zdMiKu2m4t0oKO7pSq1WMAbOBCWTQ3WUNeykqhEmg3sYAOZ+wTPFd3uu1VlYSRbeNBri ZfnE2o8+QO4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,232,1610438400"; d="scan'208";a="602124729" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 08 Mar 2021 04:20:43 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2B596565; Mon, 8 Mar 2021 14:20:38 +0200 (EET) From: Andy Shevchenko To: Wolfram Sang , Jean Delvare , Lee Jones , Andy Shevchenko , Tan Jui Nee , Jim Quinlan , Jonathan Yong , Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org Cc: Jean Delvare , Peter Tyser , hdegoede@redhat.com, henning.schild@siemens.com Subject: [PATCH v1 5/7] mfd: lpc_ich: Switch to generic pci_p2sb_bar() Date: Mon, 8 Mar 2021 14:20:18 +0200 Message-Id: <20210308122020.57071-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210308122020.57071-1-andriy.shevchenko@linux.intel.com> References: <20210308122020.57071-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of open coding pci_p2sb_bar() functionality we are going to use generic library for that. There one more user of it is coming. Besides cleaning up it fixes a potential issue if, by some reason, SPI bar is 64-bit. Signed-off-by: Andy Shevchenko --- drivers/mfd/Kconfig | 1 + drivers/mfd/lpc_ich.c | 20 ++++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index a03de3f7a8ed..c16bec1852e5 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -553,6 +553,7 @@ config LPC_ICH tristate "Intel ICH LPC" depends on PCI select MFD_CORE + select PCI_P2SB if X86 help The LPC bridge function of the Intel ICH provides support for many functional units. This driver provides needed support for diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c index 3a19ed57260e..8e9bd6813287 100644 --- a/drivers/mfd/lpc_ich.c +++ b/drivers/mfd/lpc_ich.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -69,8 +70,6 @@ #define BCR 0xdc #define BCR_WPD BIT(0) -#define SPIBASE_APL_SZ 4096 - #define GPIOBASE_ICH0 0x58 #define GPIOCTRL_ICH0 0x5C #define GPIOBASE_ICH6 0x48 @@ -1126,26 +1125,19 @@ static int lpc_ich_init_spi(struct pci_dev *dev) break; case INTEL_SPI_BXT: { - unsigned int p2sb = PCI_DEVFN(13, 0); unsigned int spi = PCI_DEVFN(13, 2); - struct pci_bus *bus = dev->bus; + int ret; /* * The P2SB is hidden by BIOS and we need to unhide it in * order to read BAR of the SPI flash device. Once that is * done we hide it again. */ - pci_bus_write_config_byte(bus, p2sb, 0xe1, 0x0); - pci_bus_read_config_dword(bus, spi, PCI_BASE_ADDRESS_0, - &spi_base); - if (spi_base != ~0) { - res->start = spi_base & 0xfffffff0; - res->end = res->start + SPIBASE_APL_SZ - 1; - - lpc_ich_test_spi_write(dev, spi, info); - } + ret = pci_p2sb_bar(dev, spi, res); + if (ret) + return ret; - pci_bus_write_config_byte(bus, p2sb, 0xe1, 0x1); + lpc_ich_test_spi_write(dev, spi, info); break; } -- 2.30.1