All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper
@ 2022-05-10 15:14 Andy Shevchenko
  2022-05-10 15:14 ` [PATCH v5 1/8] platform/x86/intel: Add Primary to Sideband (P2SB) bridge support Andy Shevchenko
                   ` (9 more replies)
  0 siblings, 10 replies; 17+ messages in thread
From: Andy Shevchenko @ 2022-05-10 15:14 UTC (permalink / raw)
  To: Tony Luck, Andy Shevchenko, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Lee Jones, Łukasz Bartosik, Hans de Goede,
	Linus Walleij, Jonathan Yong, linux-kernel, linux-edac,
	linux-i2c, linux-gpio, platform-driver-x86
  Cc: Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross

There are a few users and at least one more is coming (*1) that would
like to utilize P2SB mechanism of hiding and unhiding a device from
the PCI configuration space.

Here is the series to consolidate p2sb handling code for existing users
and provide a generic way for new comer(s).

It also includes a patch to enable GPIO controllers on Apollo Lake
when it's used with ABL bootloader w/o ACPI support (*2).

The patch that brings the helper ("platform/x86/intel: Add Primary to
Sideband (P2SB) bridge support") has a commit message that sheds a light
on what the P2SB is and why this is needed.

The changes made in v5 do not change the main idea and the functionality
in a big scale. What we need is probably one more retest done by Henning
(*3). I hope to have it merged to v5.19-rc1 that Siemens can develop
their changes based on this series (*4).

I have tested this on Apollo Lake platform (I'm able to see SPI NOR and
since we have an ACPI device for GPIO I do not see any attempts to recreate
one).

*1) One in this series, and one is a recent merge of the Simatic IPC drivers
*2) This patch can be postponed as Lee hasn't given his tag yet.
*3) Henning gave his tag and I dared to used it even against changed patch 1
*4) The changes were posted in between of v4 and v5 of this series, but need
    more work.

Taking into account the *2) the series is ready to be merged via PDx86 tree.

Changes in v5:
- rewritten patch 1 to use pci_scan_single_device() (Lukas, Bjorn)
- rebased patch 2 on top of the new Intel SPI NOR codebase
- fixed a potential bug and rewritten resource filling in patch 5 (Lee)
- added many different tags in a few patches (Jean, Wolfram, Henning)

Changes in v4:
- added tag to the entire series (Hans)
- added tag to pin control patch (Mika)
- dropped PCI core changes (PCI core doesn't want modifications to be made)
- as a consequence of the above merged necessary bits into p2sb.c
- added a check that p2sb is really hidden (Hans)
- added EDAC patches (reviewed by maintainer internally)

Changes in v3:
- resent with cover letter

Changes in v2:
- added parentheses around bus in macros (Joe)
- added tag (Jean)
- fixed indentation and wrapping in the header (Christoph)
- moved out of PCI realm to PDx86 as the best common denominator (Bjorn)
- added a verbose commit message to explain P2SB thingy (Bjorn)
- converted first parameter from pci_dev to pci_bus
- made first two parameters (bus and devfn) optional (Henning, Lee)
- added Intel pin control patch to the series (Henning, Mika)
- fixed English style in the commit message of one of MFD patch (Lee)
- added tags to my MFD LPC ICH patches (Lee)
- used consistently (c) (Lee)
- made indexing for MFD cell and resource arrays (Lee)
- fixed the resource size in i801 (Jean)

Andy Shevchenko (6):
  pinctrl: intel: Check against matching data instead of ACPI companion
  mfd: lpc_ich: Factor out lpc_ich_enable_spi_write()
  mfd: lpc_ich: Switch to generic p2sb_bar()
  i2c: i801: convert to use common P2SB accessor
  EDAC, pnd2: Use proper I/O accessors and address space annotation
  EDAC, pnd2: convert to use common P2SB accessor

Jonathan Yong (1):
  platform/x86/intel: Add Primary to Sideband (P2SB) bridge support

Tan Jui Nee (1):
  mfd: lpc_ich: Add support for pinctrl in non-ACPI system

 drivers/edac/Kconfig                   |   1 +
 drivers/edac/pnd2_edac.c               |  62 +++-------
 drivers/i2c/busses/Kconfig             |   1 +
 drivers/i2c/busses/i2c-i801.c          |  39 ++----
 drivers/mfd/Kconfig                    |   1 +
 drivers/mfd/lpc_ich.c                  | 161 +++++++++++++++++++------
 drivers/pinctrl/intel/pinctrl-intel.c  |  14 +--
 drivers/platform/x86/intel/Kconfig     |  12 ++
 drivers/platform/x86/intel/Makefile    |   2 +
 drivers/platform/x86/intel/p2sb.c      | 133 ++++++++++++++++++++
 include/linux/platform_data/x86/p2sb.h |  28 +++++
 11 files changed, 338 insertions(+), 116 deletions(-)
 create mode 100644 drivers/platform/x86/intel/p2sb.c
 create mode 100644 include/linux/platform_data/x86/p2sb.h


base-commit: 3bf222d317a20170ee17f082626c1e0f83537e13
-- 
2.35.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v5 1/8] platform/x86/intel: Add Primary to Sideband (P2SB) bridge support
  2022-05-10 15:14 [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Andy Shevchenko
@ 2022-05-10 15:14 ` Andy Shevchenko
  2022-05-10 15:14 ` [PATCH v5 2/8] pinctrl: intel: Check against matching data instead of ACPI companion Andy Shevchenko
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2022-05-10 15:14 UTC (permalink / raw)
  To: Tony Luck, Andy Shevchenko, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Lee Jones, Łukasz Bartosik, Hans de Goede,
	Linus Walleij, Jonathan Yong, linux-kernel, linux-edac,
	linux-i2c, linux-gpio, platform-driver-x86
  Cc: Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross, Henning Schild

From: Jonathan Yong <jonathan.yong@intel.com>

SoC features such as GPIO are accessed via a reserved MMIO area,
we don't know its address but can obtain it from the BAR of
the P2SB device, that device is normally hidden so we have to
temporarily unhide it, read address and hide it back.

There are already a few users and at least one more is coming which
require an access to Primary to Sideband (P2SB) bridge in order
to get IO or MMIO BAR hidden by BIOS.

Create a library to access P2SB for x86 devices in a unified way.

Background information
======================
Note, the term "bridge" is used in the documentation and it has nothing
to do with a PCI (host) bridge as per the PCI specifications.

The P2SB is an interesting device by its nature and hardware design.
First of all, it has several devices in the hardware behind it. These
devices may or may not be represented as ACPI devices by a firmware.

It also has a hardwired (to 0s) the least significant bits of the
base address register which is represented by the only 64-bit BAR0.
It means that OS mustn't reallocate the BAR.

On top of that in some cases P2SB is represented by function 0 on PCI
slot (in terms of B:D.F) and according to the PCI specification any
other function can't be seen until function 0 is present and visible.

In the PCI configuration space of P2SB device the full 32-bit register
is allocated for the only purpose of hiding the entire P2SB device. As
per [3]:

  3.1.39 P2SB Control (P2SBC)—Offset E0h

  Hide Device (HIDE): When this bit is set, the P2SB will return 1s on
  any PCI Configuration Read on IOSF-P. All other transactions including
  PCI Configuration Writes on IOSF-P are unaffected by this. This does
  not affect reads performed on the IOSF-SB interface.

This doesn't prevent MMIO accesses, although preventing the OS from
assigning these addresses. The firmware on the affected platforms marks
the region as unusable (by cutting it off from the PCI host bridge
resources) as depicted in the Apollo Lake example below:

  PCI host bridge to bus 0000:00
  pci_bus 0000:00: root bus resource [io  0x0070-0x0077]
  pci_bus 0000:00: root bus resource [io  0x0000-0x006f window]
  pci_bus 0000:00: root bus resource [io  0x0078-0x0cf7 window]
  pci_bus 0000:00: root bus resource [io  0x0d00-0xffff window]
  pci_bus 0000:00: root bus resource [mem 0x7c000001-0x7fffffff window]
  pci_bus 0000:00: root bus resource [mem 0x7b800001-0x7bffffff window]
  pci_bus 0000:00: root bus resource [mem 0x80000000-0xcfffffff window]
  pci_bus 0000:00: root bus resource [mem 0xe0000000-0xefffffff window]
  pci_bus 0000:00: root bus resource [bus 00-ff]

The P2SB 16MB BAR is located at 0xd0000000-0xd0ffffff memory window.

The generic solution
====================
The generic solution for all cases when we need to access to the information
behind P2SB device is a library code where users ask for necessary resources
by demand and hence those users take care of not being run on the systems
where this access is not required.

The library provides the p2sb_bar() API to retrieve the MMIO of the BAR0 of
the device from P2SB device slot.

P2SB unconditional unhiding awareness
=====================================
Technically it's possible to unhide the P2SB device and devices on
the same PCI slot and access them at any time as needed. But there are
several potential issues with that:

 - the systems were never tested against such configuration and hence
   nobody knows what kind of bugs it may bring, especially when we talk
   about SPI NOR case which contains Intel FirmWare Image (IFWI) code
   (including BIOS) and already known to be problematic in the past for
   end users

 - the PCI by its nature is a hotpluggable bus and in case somebody
   attaches a driver to the functions of a P2SB slot device(s) the
   end user experience and system behaviour can be unpredictable

 - the kernel code would need some ugly hacks (or code looking as an
   ugly hack) under arch/x86/pci in order to enable these devices on
   only selected platforms (which may include CPU ID table followed by
   a potentially growing number of DMI strings

The future improvements
=======================
The future improvements with this code may go in order to gain some kind
of cache, if it's possible at all, to prevent unhiding and hiding many
times to take static information that may be saved once per boot.

Links
=====
[1]: https://lab.whitequark.org/notes/2017-11-08/accessing-intel-ich-pch-gpios/
[2]: https://cdrdv2.intel.com/v1/dl/getContent/332690?wapkw=332690
[3]: https://cdrdv2.intel.com/v1/dl/getContent/332691?wapkw=332691
[4]: https://medium.com/@jacksonchen_43335/bios-gpio-p2sb-70e9b829b403

Signed-off-by: Jonathan Yong <jonathan.yong@intel.com>
Co-developed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Henning Schild <henning.schild@siemens.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/platform/x86/intel/Kconfig     |  12 +++
 drivers/platform/x86/intel/Makefile    |   2 +
 drivers/platform/x86/intel/p2sb.c      | 127 +++++++++++++++++++++++++
 include/linux/platform_data/x86/p2sb.h |  28 ++++++
 4 files changed, 169 insertions(+)
 create mode 100644 drivers/platform/x86/intel/p2sb.c
 create mode 100644 include/linux/platform_data/x86/p2sb.h

diff --git a/drivers/platform/x86/intel/Kconfig b/drivers/platform/x86/intel/Kconfig
index 1f01a8a23c57..f0c4334bc0ca 100644
--- a/drivers/platform/x86/intel/Kconfig
+++ b/drivers/platform/x86/intel/Kconfig
@@ -69,6 +69,18 @@ config INTEL_OAKTRAIL
 	  enable/disable the Camera, WiFi, BT etc. devices. If in doubt, say Y
 	  here; it will only load on supported platforms.
 
+config P2SB
+	bool "Primary to Sideband (P2SB) bridge access support"
+	depends on PCI
+	help
+	  The Primary to Sideband (P2SB) bridge is an interface to some
+	  PCI devices connected through it. In particular, SPI NOR controller
+	  in Intel Apollo Lake SoC is one of such devices.
+
+	  The main purpose of this library is to unhide P2SB device in case
+	  firmware kept it hidden on some platforms in order to access devices
+	  behind it.
+
 config INTEL_BXTWC_PMIC_TMU
 	tristate "Intel Broxton Whiskey Cove TMU Driver"
 	depends on INTEL_SOC_PMIC_BXTWC
diff --git a/drivers/platform/x86/intel/Makefile b/drivers/platform/x86/intel/Makefile
index c61bc3e97121..8a999f70e55c 100644
--- a/drivers/platform/x86/intel/Makefile
+++ b/drivers/platform/x86/intel/Makefile
@@ -27,6 +27,8 @@ intel_int0002_vgpio-y			:= int0002_vgpio.o
 obj-$(CONFIG_INTEL_INT0002_VGPIO)	+= intel_int0002_vgpio.o
 intel_oaktrail-y			:= oaktrail.o
 obj-$(CONFIG_INTEL_OAKTRAIL)		+= intel_oaktrail.o
+intel_p2sb-y				:= p2sb.o
+obj-$(CONFIG_P2SB)			+= intel_p2sb.o
 intel_sdsi-y				:= sdsi.o
 obj-$(CONFIG_INTEL_SDSI)		+= intel_sdsi.o
 intel_vsec-y				:= vsec.o
diff --git a/drivers/platform/x86/intel/p2sb.c b/drivers/platform/x86/intel/p2sb.c
new file mode 100644
index 000000000000..b598ef14dbc6
--- /dev/null
+++ b/drivers/platform/x86/intel/p2sb.c
@@ -0,0 +1,127 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Primary to Sideband (P2SB) bridge access support
+ *
+ * Copyright (c) 2017, 2021-2022 Intel Corporation.
+ *
+ * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+ *	    Jonathan Yong <jonathan.yong@intel.com>
+ */
+
+#include <linux/bits.h>
+#include <linux/export.h>
+#include <linux/pci.h>
+#include <linux/platform_data/x86/p2sb.h>
+
+#include <asm/cpu_device_id.h>
+#include <asm/intel-family.h>
+
+#define P2SBC			0xe0
+#define P2SBC_HIDE		BIT(8)
+
+static const struct x86_cpu_id p2sb_cpu_ids[] = {
+	X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT,	PCI_DEVFN(13, 0)),
+	{}
+};
+
+static int p2sb_get_devfn(unsigned int *devfn)
+{
+	const struct x86_cpu_id *id;
+
+	id = x86_match_cpu(p2sb_cpu_ids);
+	if (!id)
+		return -ENODEV;
+
+	*devfn = (unsigned int)id->driver_data;
+	return 0;
+}
+
+static int p2sb_read_bar0(struct pci_dev *pdev, struct resource *mem)
+{
+	/* Copy resource from the first BAR of the device in question */
+	*mem = pdev->resource[0];
+	return 0;
+}
+
+static int p2sb_scan_and_read(struct pci_bus *bus, unsigned int devfn, struct resource *mem)
+{
+	struct pci_dev *pdev;
+	int ret;
+
+	pdev = pci_scan_single_device(bus, devfn);
+	if (!pdev)
+		return -ENODEV;
+
+	ret = p2sb_read_bar0(pdev, mem);
+
+	pci_stop_and_remove_bus_device(pdev);
+	return ret;
+}
+
+/**
+ * p2sb_bar - Get Primary to Sideband (P2SB) bridge device BAR
+ * @bus: PCI bus to communicate with
+ * @devfn: PCI slot and function to communicate with
+ * @mem: memory resource to be filled in
+ *
+ * The BIOS prevents the P2SB device from being enumerated by the PCI
+ * subsystem, so we need to unhide and hide it back to lookup the BAR.
+ *
+ * if @bus is NULL, the bus 0 in domain 0 will be used.
+ * If @devfn is 0, it will be replaced by devfn of the P2SB device.
+ *
+ * Caller must provide a valid pointer to @mem.
+ *
+ * Locking is handled by pci_rescan_remove_lock mutex.
+ *
+ * Return:
+ * 0 on success or appropriate errno value on error.
+ */
+int p2sb_bar(struct pci_bus *bus, unsigned int devfn, struct resource *mem)
+{
+	struct pci_dev *pdev_p2sb;
+	unsigned int devfn_p2sb;
+	u32 value = P2SBC_HIDE;
+	int ret;
+
+	/* Get devfn for P2SB device itself */
+	ret = p2sb_get_devfn(&devfn_p2sb);
+	if (ret)
+		return ret;
+
+	/* if @bus is NULL, use bus 0 in domain 0 */
+	bus = bus ?: pci_find_bus(0, 0);
+
+	/*
+	 * Prevent concurrent PCI bus scan from seeing the P2SB device and
+	 * removing via sysfs while it is temporarily exposed.
+	 */
+	pci_lock_rescan_remove();
+
+	/* Unhide the P2SB device, if needed */
+	pci_bus_read_config_dword(bus, devfn_p2sb, P2SBC, &value);
+	if (value & P2SBC_HIDE)
+		pci_bus_write_config_dword(bus, devfn_p2sb, P2SBC, 0);
+
+	pdev_p2sb = pci_scan_single_device(bus, devfn_p2sb);
+	if (devfn)
+		ret = p2sb_scan_and_read(bus, devfn, mem);
+	else
+		ret = p2sb_read_bar0(pdev_p2sb, mem);
+	pci_stop_and_remove_bus_device(pdev_p2sb);
+
+	/* Hide the P2SB device, if it was hidden */
+	if (value & P2SBC_HIDE)
+		pci_bus_write_config_dword(bus, devfn_p2sb, P2SBC, P2SBC_HIDE);
+
+	pci_unlock_rescan_remove();
+
+	if (ret)
+		return ret;
+
+	if (mem->flags == 0)
+		return -ENODEV;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(p2sb_bar);
diff --git a/include/linux/platform_data/x86/p2sb.h b/include/linux/platform_data/x86/p2sb.h
new file mode 100644
index 000000000000..a1d5fddc8f13
--- /dev/null
+++ b/include/linux/platform_data/x86/p2sb.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Primary to Sideband (P2SB) bridge access support
+ */
+
+#ifndef _PLATFORM_DATA_X86_P2SB_H
+#define _PLATFORM_DATA_X86_P2SB_H
+
+#include <linux/errno.h>
+#include <linux/kconfig.h>
+
+struct pci_bus;
+struct resource;
+
+#if IS_BUILTIN(CONFIG_P2SB)
+
+int p2sb_bar(struct pci_bus *bus, unsigned int devfn, struct resource *mem);
+
+#else /* CONFIG_P2SB */
+
+static inline int p2sb_bar(struct pci_bus *bus, unsigned int devfn, struct resource *mem)
+{
+	return -ENODEV;
+}
+
+#endif /* CONFIG_P2SB is not set */
+
+#endif /* _PLATFORM_DATA_X86_P2SB_H */
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v5 2/8] pinctrl: intel: Check against matching data instead of ACPI companion
  2022-05-10 15:14 [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Andy Shevchenko
  2022-05-10 15:14 ` [PATCH v5 1/8] platform/x86/intel: Add Primary to Sideband (P2SB) bridge support Andy Shevchenko
@ 2022-05-10 15:14 ` Andy Shevchenko
  2022-05-10 15:14 ` [PATCH v5 3/8] mfd: lpc_ich: Factor out lpc_ich_enable_spi_write() Andy Shevchenko
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2022-05-10 15:14 UTC (permalink / raw)
  To: Tony Luck, Andy Shevchenko, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Lee Jones, Łukasz Bartosik, Hans de Goede,
	Linus Walleij, Jonathan Yong, linux-kernel, linux-edac,
	linux-i2c, linux-gpio, platform-driver-x86
  Cc: Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross, Henning Schild

In some cases we may get a platform device that has ACPI companion
which is different to the pin control described in the ACPI tables.
This is primarily happens when device is instantiated by board file.

In order to allow this device being enumerated, refactor
intel_pinctrl_get_soc_data() to check the matching data instead of
ACPI companion.

Reported-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Henning Schild <henning.schild@siemens.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/pinctrl/intel/pinctrl-intel.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
index 826d494f3cc6..48f55991ae8c 100644
--- a/drivers/pinctrl/intel/pinctrl-intel.c
+++ b/drivers/pinctrl/intel/pinctrl-intel.c
@@ -1626,16 +1626,14 @@ EXPORT_SYMBOL_GPL(intel_pinctrl_probe_by_uid);
 
 const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_device *pdev)
 {
+	const struct intel_pinctrl_soc_data * const *table;
 	const struct intel_pinctrl_soc_data *data = NULL;
-	const struct intel_pinctrl_soc_data **table;
-	struct acpi_device *adev;
-	unsigned int i;
 
-	adev = ACPI_COMPANION(&pdev->dev);
-	if (adev) {
-		const void *match = device_get_match_data(&pdev->dev);
+	table = device_get_match_data(&pdev->dev);
+	if (table) {
+		struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
+		unsigned int i;
 
-		table = (const struct intel_pinctrl_soc_data **)match;
 		for (i = 0; table[i]; i++) {
 			if (!strcmp(adev->pnp.unique_id, table[i]->uid)) {
 				data = table[i];
@@ -1649,7 +1647,7 @@ const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_
 		if (!id)
 			return ERR_PTR(-ENODEV);
 
-		table = (const struct intel_pinctrl_soc_data **)id->driver_data;
+		table = (const struct intel_pinctrl_soc_data * const *)id->driver_data;
 		data = table[pdev->id];
 	}
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v5 3/8] mfd: lpc_ich: Factor out lpc_ich_enable_spi_write()
  2022-05-10 15:14 [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Andy Shevchenko
  2022-05-10 15:14 ` [PATCH v5 1/8] platform/x86/intel: Add Primary to Sideband (P2SB) bridge support Andy Shevchenko
  2022-05-10 15:14 ` [PATCH v5 2/8] pinctrl: intel: Check against matching data instead of ACPI companion Andy Shevchenko
@ 2022-05-10 15:14 ` Andy Shevchenko
  2022-05-10 15:14 ` [PATCH v5 4/8] mfd: lpc_ich: Switch to generic p2sb_bar() Andy Shevchenko
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2022-05-10 15:14 UTC (permalink / raw)
  To: Tony Luck, Andy Shevchenko, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Lee Jones, Łukasz Bartosik, Hans de Goede,
	Linus Walleij, Jonathan Yong, linux-kernel, linux-edac,
	linux-i2c, linux-gpio, platform-driver-x86
  Cc: Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross, Henning Schild

Factor out duplicate code to lpc_ich_enable_spi_write() helper function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Henning Schild <henning.schild@siemens.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/lpc_ich.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c
index 9ffab9aafd81..d9175cb8a2d5 100644
--- a/drivers/mfd/lpc_ich.c
+++ b/drivers/mfd/lpc_ich.c
@@ -1100,35 +1100,32 @@ static bool lpc_ich_byt_set_writeable(void __iomem *base, void *data)
 	return val & BYT_BCR_WPD;
 }
 
-static bool lpc_ich_lpt_set_writeable(void __iomem *base, void *data)
+static bool lpc_ich_set_writeable(struct pci_bus *bus, unsigned int devfn)
 {
-	struct pci_dev *pdev = data;
 	u32 bcr;
 
-	pci_read_config_dword(pdev, BCR, &bcr);
+	pci_bus_read_config_dword(bus, devfn, BCR, &bcr);
 	if (!(bcr & BCR_WPD)) {
 		bcr |= BCR_WPD;
-		pci_write_config_dword(pdev, BCR, bcr);
-		pci_read_config_dword(pdev, BCR, &bcr);
+		pci_bus_write_config_dword(bus, devfn, BCR, bcr);
+		pci_bus_read_config_dword(bus, devfn, BCR, &bcr);
 	}
 
 	return bcr & BCR_WPD;
 }
 
-static bool lpc_ich_bxt_set_writeable(void __iomem *base, void *data)
+static bool lpc_ich_lpt_set_writeable(void __iomem *base, void *data)
 {
-	unsigned int spi = PCI_DEVFN(13, 2);
-	struct pci_bus *bus = data;
-	u32 bcr;
+	struct pci_dev *pdev = data;
 
-	pci_bus_read_config_dword(bus, spi, BCR, &bcr);
-	if (!(bcr & BCR_WPD)) {
-		bcr |= BCR_WPD;
-		pci_bus_write_config_dword(bus, spi, BCR, bcr);
-		pci_bus_read_config_dword(bus, spi, BCR, &bcr);
-	}
+	return lpc_ich_set_writeable(pdev->bus, pdev->devfn);
+}
 
-	return bcr & BCR_WPD;
+static bool lpc_ich_bxt_set_writeable(void __iomem *base, void *data)
+{
+	struct pci_dev *pdev = data;
+
+	return lpc_ich_set_writeable(pdev->bus, PCI_DEVFN(13, 2));
 }
 
 static int lpc_ich_init_spi(struct pci_dev *dev)
@@ -1185,7 +1182,7 @@ static int lpc_ich_init_spi(struct pci_dev *dev)
 			res->end = res->start + SPIBASE_APL_SZ - 1;
 
 			info->set_writeable = lpc_ich_bxt_set_writeable;
-			info->data = bus;
+			info->data = dev;
 		}
 
 		pci_bus_write_config_byte(bus, p2sb, 0xe1, 0x1);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v5 4/8] mfd: lpc_ich: Switch to generic p2sb_bar()
  2022-05-10 15:14 [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Andy Shevchenko
                   ` (2 preceding siblings ...)
  2022-05-10 15:14 ` [PATCH v5 3/8] mfd: lpc_ich: Factor out lpc_ich_enable_spi_write() Andy Shevchenko
@ 2022-05-10 15:14 ` Andy Shevchenko
  2022-05-10 15:14 ` [PATCH v5 5/8] mfd: lpc_ich: Add support for pinctrl in non-ACPI system Andy Shevchenko
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2022-05-10 15:14 UTC (permalink / raw)
  To: Tony Luck, Andy Shevchenko, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Lee Jones, Łukasz Bartosik, Hans de Goede,
	Linus Walleij, Jonathan Yong, linux-kernel, linux-edac,
	linux-i2c, linux-gpio, platform-driver-x86
  Cc: Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross, Henning Schild

Instead of open coding p2sb_bar() functionality we are going to
use generic library. There is one more user en route.

This is more than just a clean-up. It also fixes a potential issue
seen when SPI BAR is 64-bit. The current code works if and only if
the PCI BAR of the hidden device is inside 4G address space. In case
when firmware decides to go above 4G, we will get a wrong address.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Henning Schild <henning.schild@siemens.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/Kconfig   |  1 +
 drivers/mfd/lpc_ich.c | 27 ++++++++-------------------
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 3b59456f5545..9566341de470 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -572,6 +572,7 @@ config LPC_ICH
 	tristate "Intel ICH LPC"
 	depends on PCI
 	select MFD_CORE
+	select 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 d9175cb8a2d5..e360651c5406 100644
--- a/drivers/mfd/lpc_ich.c
+++ b/drivers/mfd/lpc_ich.c
@@ -45,6 +45,7 @@
 #include <linux/mfd/core.h>
 #include <linux/mfd/lpc_ich.h>
 #include <linux/platform_data/itco_wdt.h>
+#include <linux/platform_data/x86/p2sb.h>
 
 #define ACPIBASE		0x40
 #define ACPIBASE_GPE_OFF	0x28
@@ -71,8 +72,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
@@ -1134,6 +1133,7 @@ static int lpc_ich_init_spi(struct pci_dev *dev)
 	struct resource *res = &intel_spi_res[0];
 	struct intel_spi_boardinfo *info;
 	u32 spi_base, rcba;
+	int ret;
 
 	info = devm_kzalloc(&dev->dev, sizeof(*info), GFP_KERNEL);
 	if (!info)
@@ -1164,30 +1164,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;
-
+	case INTEL_SPI_BXT:
 		/*
 		 * 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;
-
-			info->set_writeable = lpc_ich_bxt_set_writeable;
-			info->data = dev;
-		}
+		ret = p2sb_bar(dev->bus, PCI_DEVFN(13, 2), res);
+		if (ret)
+			return ret;
 
-		pci_bus_write_config_byte(bus, p2sb, 0xe1, 0x1);
+		info->set_writeable = lpc_ich_bxt_set_writeable;
+		info->data = dev;
 		break;
-	}
 
 	default:
 		return -EINVAL;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v5 5/8] mfd: lpc_ich: Add support for pinctrl in non-ACPI system
  2022-05-10 15:14 [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Andy Shevchenko
                   ` (3 preceding siblings ...)
  2022-05-10 15:14 ` [PATCH v5 4/8] mfd: lpc_ich: Switch to generic p2sb_bar() Andy Shevchenko
@ 2022-05-10 15:14 ` Andy Shevchenko
  2022-05-12  9:53   ` Lee Jones
  2022-05-10 15:14 ` [PATCH v5 6/8] i2c: i801: convert to use common P2SB accessor Andy Shevchenko
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 17+ messages in thread
From: Andy Shevchenko @ 2022-05-10 15:14 UTC (permalink / raw)
  To: Tony Luck, Andy Shevchenko, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Lee Jones, Łukasz Bartosik, Hans de Goede,
	Linus Walleij, Jonathan Yong, linux-kernel, linux-edac,
	linux-i2c, linux-gpio, platform-driver-x86
  Cc: Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross, Tan Jui Nee, Henning Schild

From: Tan Jui Nee <jui.nee.tan@intel.com>

Add support for non-ACPI systems, such as system that uses
Advanced Boot Loader (ABL) whereby a platform device has to be created
in order to bind with pin control and GPIO.

At the moment, Intel Apollo Lake In-Vehicle Infotainment (IVI) system
requires a driver to hide and unhide P2SB to lookup P2SB BAR and pass
the PCI BAR address to GPIO.

Signed-off-by: Tan Jui Nee <jui.nee.tan@intel.com>
Co-developed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Henning Schild <henning.schild@siemens.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/mfd/lpc_ich.c | 105 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 104 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c
index e360651c5406..650951f89f1c 100644
--- a/drivers/mfd/lpc_ich.c
+++ b/drivers/mfd/lpc_ich.c
@@ -8,7 +8,8 @@
  *  Configuration Registers.
  *
  *  This driver is derived from lpc_sch.
-
+ *
+ *  Copyright (c) 2017, 2021-2022 Intel Corporation
  *  Copyright (c) 2011 Extreme Engineering Solution, Inc.
  *  Author: Aaron Sierra <asierra@xes-inc.com>
  *
@@ -42,6 +43,7 @@
 #include <linux/errno.h>
 #include <linux/acpi.h>
 #include <linux/pci.h>
+#include <linux/pinctrl/pinctrl.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/lpc_ich.h>
 #include <linux/platform_data/itco_wdt.h>
@@ -142,6 +144,73 @@ static struct mfd_cell lpc_ich_gpio_cell = {
 	.ignore_resource_conflicts = true,
 };
 
+#define APL_GPIO_NORTH		0
+#define APL_GPIO_NORTHWEST	1
+#define APL_GPIO_WEST		2
+#define APL_GPIO_SOUTHWEST	3
+#define APL_GPIO_NR_DEVICES	4
+
+/* Offset data for Apollo Lake GPIO controllers */
+static resource_size_t apl_gpio_offsets[APL_GPIO_NR_DEVICES] = {
+	[APL_GPIO_NORTH]	= 0xc50000,
+	[APL_GPIO_NORTHWEST]	= 0xc40000,
+	[APL_GPIO_WEST]		= 0xc70000,
+	[APL_GPIO_SOUTHWEST]	= 0xc00000,
+};
+
+#define APL_GPIO_RESOURCE_SIZE		0x1000
+
+#define APL_GPIO_IRQ			14
+
+static struct resource apl_gpio_resources[APL_GPIO_NR_DEVICES][2] = {
+	[APL_GPIO_NORTH] = {
+		DEFINE_RES_MEM(0, 0),
+		DEFINE_RES_IRQ(APL_GPIO_IRQ),
+	},
+	[APL_GPIO_NORTHWEST] = {
+		DEFINE_RES_MEM(0, 0),
+		DEFINE_RES_IRQ(APL_GPIO_IRQ),
+	},
+	[APL_GPIO_WEST] = {
+		DEFINE_RES_MEM(0, 0),
+		DEFINE_RES_IRQ(APL_GPIO_IRQ),
+	},
+	[APL_GPIO_SOUTHWEST] = {
+		DEFINE_RES_MEM(0, 0),
+		DEFINE_RES_IRQ(APL_GPIO_IRQ),
+	},
+};
+
+static const struct mfd_cell apl_gpio_devices[APL_GPIO_NR_DEVICES] = {
+	[APL_GPIO_NORTH] = {
+		.name = "apollolake-pinctrl",
+		.id = APL_GPIO_NORTH,
+		.num_resources = ARRAY_SIZE(apl_gpio_resources[APL_GPIO_NORTH]),
+		.resources = apl_gpio_resources[APL_GPIO_NORTH],
+		.ignore_resource_conflicts = true,
+	},
+	[APL_GPIO_NORTHWEST] = {
+		.name = "apollolake-pinctrl",
+		.id = APL_GPIO_NORTHWEST,
+		.num_resources = ARRAY_SIZE(apl_gpio_resources[APL_GPIO_NORTHWEST]),
+		.resources = apl_gpio_resources[APL_GPIO_NORTHWEST],
+		.ignore_resource_conflicts = true,
+	},
+	[APL_GPIO_WEST] = {
+		.name = "apollolake-pinctrl",
+		.id = APL_GPIO_WEST,
+		.num_resources = ARRAY_SIZE(apl_gpio_resources[APL_GPIO_WEST]),
+		.resources = apl_gpio_resources[APL_GPIO_WEST],
+		.ignore_resource_conflicts = true,
+	},
+	[APL_GPIO_SOUTHWEST] = {
+		.name = "apollolake-pinctrl",
+		.id = APL_GPIO_SOUTHWEST,
+		.num_resources = ARRAY_SIZE(apl_gpio_resources[APL_GPIO_SOUTHWEST]),
+		.resources = apl_gpio_resources[APL_GPIO_SOUTHWEST],
+		.ignore_resource_conflicts = true,
+	},
+};
 
 static struct mfd_cell lpc_ich_spi_cell = {
 	.name = "intel-spi",
@@ -1085,6 +1154,34 @@ static int lpc_ich_init_wdt(struct pci_dev *dev)
 	return ret;
 }
 
+static int lpc_ich_init_pinctrl(struct pci_dev *dev)
+{
+	struct resource base;
+	unsigned int i;
+	int ret;
+
+	/* Check, if GPIO has been exported as an ACPI device */
+	if (acpi_dev_present("INT3452", NULL, -1))
+		return -EEXIST;
+
+	ret = p2sb_bar(dev->bus, 0, &base);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < ARRAY_SIZE(apl_gpio_devices); i++) {
+		struct resource *mem = &apl_gpio_resources[i][0];
+		resource_size_t offset = apl_gpio_offsets[i];
+
+		/* Fill MEM resource */
+		mem->start = base.start + offset;
+		mem->end = base.start + offset + APL_GPIO_RESOURCE_SIZE - 1;
+		mem->flags = base.flags;
+	}
+
+	return mfd_add_devices(&dev->dev, 0, apl_gpio_devices,
+			       ARRAY_SIZE(apl_gpio_devices), NULL, 0, NULL);
+}
+
 static bool lpc_ich_byt_set_writeable(void __iomem *base, void *data)
 {
 	u32 val;
@@ -1235,6 +1332,12 @@ static int lpc_ich_probe(struct pci_dev *dev,
 			cell_added = true;
 	}
 
+	if (priv->chipset == LPC_APL) {
+		ret = lpc_ich_init_pinctrl(dev);
+		if (!ret)
+			cell_added = true;
+	}
+
 	if (lpc_chipset_info[priv->chipset].spi_type) {
 		ret = lpc_ich_init_spi(dev);
 		if (!ret)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v5 6/8] i2c: i801: convert to use common P2SB accessor
  2022-05-10 15:14 [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Andy Shevchenko
                   ` (4 preceding siblings ...)
  2022-05-10 15:14 ` [PATCH v5 5/8] mfd: lpc_ich: Add support for pinctrl in non-ACPI system Andy Shevchenko
@ 2022-05-10 15:14 ` Andy Shevchenko
  2022-05-10 15:14 ` [PATCH v5 7/8] EDAC, pnd2: Use proper I/O accessors and address space annotation Andy Shevchenko
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2022-05-10 15:14 UTC (permalink / raw)
  To: Tony Luck, Andy Shevchenko, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Lee Jones, Łukasz Bartosik, Hans de Goede,
	Linus Walleij, Jonathan Yong, linux-kernel, linux-edac,
	linux-i2c, linux-gpio, platform-driver-x86
  Cc: Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross, Henning Schild

Since we have a common P2SB accessor in tree we may use it instead of
open coded variants.

Replace custom code by p2sb_bar() call.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Henning Schild <henning.schild@siemens.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Acked-by: Wolfram Sang <wsa@kernel.org>
---
 drivers/i2c/busses/Kconfig        |  1 +
 drivers/i2c/busses/i2c-i801.c     | 39 +++++++------------------------
 drivers/platform/x86/intel/p2sb.c |  6 +++++
 3 files changed, 16 insertions(+), 30 deletions(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index a1bae59208e3..4d0a195ca3ef 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -108,6 +108,7 @@ config I2C_HIX5HD2
 config I2C_I801
 	tristate "Intel 82801 (ICH/PCH)"
 	depends on PCI
+	select P2SB if X86
 	select CHECK_SIGNATURE if X86 && DMI
 	select I2C_SMBUS
 	help
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index ff706349bdfb..f7a0bb372e8e 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -111,6 +111,7 @@
 #include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/itco_wdt.h>
+#include <linux/platform_data/x86/p2sb.h>
 #include <linux/pm_runtime.h>
 #include <linux/mutex.h>
 
@@ -140,7 +141,6 @@
 #define TCOBASE		0x050
 #define TCOCTL		0x054
 
-#define SBREG_BAR		0x10
 #define SBREG_SMBCTRL		0xc6000c
 #define SBREG_SMBCTRL_DNV	0xcf000c
 
@@ -1482,45 +1482,24 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
 		.version = 4,
 	};
 	struct resource *res;
-	unsigned int devfn;
-	u64 base64_addr;
-	u32 base_addr;
-	u8 hidden;
+	int ret;
 
 	/*
 	 * We must access the NO_REBOOT bit over the Primary to Sideband
-	 * bridge (P2SB). The BIOS prevents the P2SB device from being
-	 * enumerated by the PCI subsystem, so we need to unhide/hide it
-	 * to lookup the P2SB BAR.
+	 * (P2SB) bridge.
 	 */
-	pci_lock_rescan_remove();
-
-	devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 1);
-
-	/* Unhide the P2SB device, if it is hidden */
-	pci_bus_read_config_byte(pci_dev->bus, devfn, 0xe1, &hidden);
-	if (hidden)
-		pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, 0x0);
-
-	pci_bus_read_config_dword(pci_dev->bus, devfn, SBREG_BAR, &base_addr);
-	base64_addr = base_addr & 0xfffffff0;
-
-	pci_bus_read_config_dword(pci_dev->bus, devfn, SBREG_BAR + 0x4, &base_addr);
-	base64_addr |= (u64)base_addr << 32;
-
-	/* Hide the P2SB device, if it was hidden before */
-	if (hidden)
-		pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, hidden);
-	pci_unlock_rescan_remove();
 
 	res = &tco_res[1];
+	ret = p2sb_bar(pci_dev->bus, 0, res);
+	if (ret)
+		return ERR_PTR(ret);
+
 	if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS)
-		res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL_DNV;
+		res->start += SBREG_SMBCTRL_DNV;
 	else
-		res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL;
+		res->start += SBREG_SMBCTRL;
 
 	res->end = res->start + 3;
-	res->flags = IORESOURCE_MEM;
 
 	return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1,
 					tco_res, 2, &pldata, sizeof(pldata));
diff --git a/drivers/platform/x86/intel/p2sb.c b/drivers/platform/x86/intel/p2sb.c
index b598ef14dbc6..fb2e141f3eb8 100644
--- a/drivers/platform/x86/intel/p2sb.c
+++ b/drivers/platform/x86/intel/p2sb.c
@@ -21,6 +21,12 @@
 
 static const struct x86_cpu_id p2sb_cpu_ids[] = {
 	X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT,	PCI_DEVFN(13, 0)),
+	X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_D,	PCI_DEVFN(31, 1)),
+	X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_D,	PCI_DEVFN(31, 1)),
+	X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE,		PCI_DEVFN(31, 1)),
+	X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE_L,		PCI_DEVFN(31, 1)),
+	X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE,		PCI_DEVFN(31, 1)),
+	X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_L,		PCI_DEVFN(31, 1)),
 	{}
 };
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v5 7/8] EDAC, pnd2: Use proper I/O accessors and address space annotation
  2022-05-10 15:14 [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Andy Shevchenko
                   ` (5 preceding siblings ...)
  2022-05-10 15:14 ` [PATCH v5 6/8] i2c: i801: convert to use common P2SB accessor Andy Shevchenko
@ 2022-05-10 15:14 ` Andy Shevchenko
  2022-05-10 15:14 ` [PATCH v5 8/8] EDAC, pnd2: convert to use common P2SB accessor Andy Shevchenko
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2022-05-10 15:14 UTC (permalink / raw)
  To: Tony Luck, Andy Shevchenko, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Lee Jones, Łukasz Bartosik, Hans de Goede,
	Linus Walleij, Jonathan Yong, linux-kernel, linux-edac,
	linux-i2c, linux-gpio, platform-driver-x86
  Cc: Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross, Henning Schild

The driver uses rather voodoo kind of castings and I/O accessors.
Replace it with proper __iomem annotation and readl()/readq() calls.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Henning Schild <henning.schild@siemens.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
---
 drivers/edac/pnd2_edac.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c
index c94ca1f790c4..7d1df120e24c 100644
--- a/drivers/edac/pnd2_edac.c
+++ b/drivers/edac/pnd2_edac.c
@@ -265,7 +265,7 @@ static u64 get_sideband_reg_base_addr(void)
 static int dnv_rd_reg(int port, int off, int op, void *data, size_t sz, char *name)
 {
 	struct pci_dev *pdev;
-	char *base;
+	void __iomem *base;
 	u64 addr;
 	unsigned long size;
 
@@ -297,8 +297,9 @@ static int dnv_rd_reg(int port, int off, int op, void *data, size_t sz, char *na
 			return -ENODEV;
 
 		if (sz == 8)
-			*(u32 *)(data + 4) = *(u32 *)(base + off + 4);
-		*(u32 *)data = *(u32 *)(base + off);
+			*(u64 *)data = readq(base + off);
+		else
+			*(u32 *)data = readl(base + off);
 
 		iounmap(base);
 	}
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v5 8/8] EDAC, pnd2: convert to use common P2SB accessor
  2022-05-10 15:14 [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Andy Shevchenko
                   ` (6 preceding siblings ...)
  2022-05-10 15:14 ` [PATCH v5 7/8] EDAC, pnd2: Use proper I/O accessors and address space annotation Andy Shevchenko
@ 2022-05-10 15:14 ` Andy Shevchenko
  2022-05-11 16:08 ` [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Hans de Goede
  2022-05-12  9:55 ` Lee Jones
  9 siblings, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2022-05-10 15:14 UTC (permalink / raw)
  To: Tony Luck, Andy Shevchenko, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Lee Jones, Łukasz Bartosik, Hans de Goede,
	Linus Walleij, Jonathan Yong, linux-kernel, linux-edac,
	linux-i2c, linux-gpio, platform-driver-x86
  Cc: Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross, Henning Schild

Since we have a common P2SB accessor in tree we may use it instead of
open coded variants.

Replace custom code by p2sb_bar() call.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Henning Schild <henning.schild@siemens.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
---
 drivers/edac/Kconfig     |  1 +
 drivers/edac/pnd2_edac.c | 55 ++++++++++++----------------------------
 2 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index d3e2477948c8..17562cf1fe97 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -263,6 +263,7 @@ config EDAC_I10NM
 config EDAC_PND2
 	tristate "Intel Pondicherry2"
 	depends on PCI && X86_64 && X86_MCE_INTEL
+	select P2SB if X86
 	help
 	  Support for error detection and correction on the Intel
 	  Pondicherry2 Integrated Memory Controller. This SoC IP is
diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c
index 7d1df120e24c..a20b299f1202 100644
--- a/drivers/edac/pnd2_edac.c
+++ b/drivers/edac/pnd2_edac.c
@@ -28,6 +28,8 @@
 #include <linux/bitmap.h>
 #include <linux/math64.h>
 #include <linux/mod_devicetable.h>
+#include <linux/platform_data/x86/p2sb.h>
+
 #include <asm/cpu_device_id.h>
 #include <asm/intel-family.h>
 #include <asm/processor.h>
@@ -232,42 +234,14 @@ static u64 get_mem_ctrl_hub_base_addr(void)
 	return U64_LSHIFT(hi.base, 32) | U64_LSHIFT(lo.base, 15);
 }
 
-static u64 get_sideband_reg_base_addr(void)
-{
-	struct pci_dev *pdev;
-	u32 hi, lo;
-	u8 hidden;
-
-	pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x19dd, NULL);
-	if (pdev) {
-		/* Unhide the P2SB device, if it's hidden */
-		pci_read_config_byte(pdev, 0xe1, &hidden);
-		if (hidden)
-			pci_write_config_byte(pdev, 0xe1, 0);
-
-		pci_read_config_dword(pdev, 0x10, &lo);
-		pci_read_config_dword(pdev, 0x14, &hi);
-		lo &= 0xfffffff0;
-
-		/* Hide the P2SB device, if it was hidden before */
-		if (hidden)
-			pci_write_config_byte(pdev, 0xe1, hidden);
-
-		pci_dev_put(pdev);
-		return (U64_LSHIFT(hi, 32) | U64_LSHIFT(lo, 0));
-	} else {
-		return 0xfd000000;
-	}
-}
-
 #define DNV_MCHBAR_SIZE  0x8000
 #define DNV_SB_PORT_SIZE 0x10000
 static int dnv_rd_reg(int port, int off, int op, void *data, size_t sz, char *name)
 {
 	struct pci_dev *pdev;
 	void __iomem *base;
-	u64 addr;
-	unsigned long size;
+	struct resource r;
+	int ret;
 
 	if (op == 4) {
 		pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x1980, NULL);
@@ -279,20 +253,23 @@ static int dnv_rd_reg(int port, int off, int op, void *data, size_t sz, char *na
 	} else {
 		/* MMIO via memory controller hub base address */
 		if (op == 0 && port == 0x4c) {
-			addr = get_mem_ctrl_hub_base_addr();
-			if (!addr)
+			memset(&r, 0, sizeof(r));
+
+			r.start = get_mem_ctrl_hub_base_addr();
+			if (!r.start)
 				return -ENODEV;
-			size = DNV_MCHBAR_SIZE;
+			r.end = r.start + DNV_MCHBAR_SIZE - 1;
 		} else {
 			/* MMIO via sideband register base address */
-			addr = get_sideband_reg_base_addr();
-			if (!addr)
-				return -ENODEV;
-			addr += (port << 16);
-			size = DNV_SB_PORT_SIZE;
+			ret = p2sb_bar(NULL, 0, &r);
+			if (ret)
+				return ret;
+
+			r.start += (port << 16);
+			r.end = r.start + DNV_SB_PORT_SIZE - 1;
 		}
 
-		base = ioremap((resource_size_t)addr, size);
+		base = ioremap(r.start, resource_size(&r));
 		if (!base)
 			return -ENODEV;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper
  2022-05-10 15:14 [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Andy Shevchenko
                   ` (7 preceding siblings ...)
  2022-05-10 15:14 ` [PATCH v5 8/8] EDAC, pnd2: convert to use common P2SB accessor Andy Shevchenko
@ 2022-05-11 16:08 ` Hans de Goede
  2022-05-11 18:01   ` Andy Shevchenko
  2022-05-12  9:55 ` Lee Jones
  9 siblings, 1 reply; 17+ messages in thread
From: Hans de Goede @ 2022-05-11 16:08 UTC (permalink / raw)
  To: Andy Shevchenko, Tony Luck, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Lee Jones, Łukasz Bartosik, Linus Walleij,
	Jonathan Yong, linux-kernel, linux-edac, linux-i2c, linux-gpio,
	platform-driver-x86
  Cc: Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross

Hi All,

On 5/10/22 17:14, Andy Shevchenko wrote:
> There are a few users and at least one more is coming (*1) that would
> like to utilize P2SB mechanism of hiding and unhiding a device from
> the PCI configuration space.
> 
> Here is the series to consolidate p2sb handling code for existing users
> and provide a generic way for new comer(s).
> 
> It also includes a patch to enable GPIO controllers on Apollo Lake
> when it's used with ABL bootloader w/o ACPI support (*2).
> 
> The patch that brings the helper ("platform/x86/intel: Add Primary to
> Sideband (P2SB) bridge support") has a commit message that sheds a light
> on what the P2SB is and why this is needed.
> 
> The changes made in v5 do not change the main idea and the functionality
> in a big scale. What we need is probably one more retest done by Henning
> (*3). I hope to have it merged to v5.19-rc1 that Siemens can develop
> their changes based on this series (*4).
> 
> I have tested this on Apollo Lake platform (I'm able to see SPI NOR and
> since we have an ACPI device for GPIO I do not see any attempts to recreate
> one).
> 
> *1) One in this series, and one is a recent merge of the Simatic IPC drivers
> *2) This patch can be postponed as Lee hasn't given his tag yet.
> *3) Henning gave his tag and I dared to used it even against changed patch 1
> *4) The changes were posted in between of v4 and v5 of this series, but need
>     more work.
> 
> Taking into account the *2) the series is ready to be merged via PDx86 tree.

I must admit I have lost track of all the Ack-s / Reviewed-by-s a bit.

So from the above I take it that the Ack-s resp. Reviewed-by-s on the
other non drivers/platform/x86 bits also signal an Ack to merge the entire
series through the pdx86 tree?

Lee, any chance you can take a look at patches 3-5 and give your Ack
for merging these through the pdx86 tree together with the rest?

Regards,

Hans


p.s.

Since this is mostly a cleanup series and since we are getting close
to the next merge-window I believe that it likely is best to merge
this after 5.19-rc1 has been released. I can then also provide
an immutable branch for other maintainers early on in the 5.19
cycle which should help to avoid merge conflicts.




> 
> Changes in v5:
> - rewritten patch 1 to use pci_scan_single_device() (Lukas, Bjorn)
> - rebased patch 2 on top of the new Intel SPI NOR codebase
> - fixed a potential bug and rewritten resource filling in patch 5 (Lee)
> - added many different tags in a few patches (Jean, Wolfram, Henning)
> 
> Changes in v4:
> - added tag to the entire series (Hans)
> - added tag to pin control patch (Mika)
> - dropped PCI core changes (PCI core doesn't want modifications to be made)
> - as a consequence of the above merged necessary bits into p2sb.c
> - added a check that p2sb is really hidden (Hans)
> - added EDAC patches (reviewed by maintainer internally)
> 
> Changes in v3:
> - resent with cover letter
> 
> Changes in v2:
> - added parentheses around bus in macros (Joe)
> - added tag (Jean)
> - fixed indentation and wrapping in the header (Christoph)
> - moved out of PCI realm to PDx86 as the best common denominator (Bjorn)
> - added a verbose commit message to explain P2SB thingy (Bjorn)
> - converted first parameter from pci_dev to pci_bus
> - made first two parameters (bus and devfn) optional (Henning, Lee)
> - added Intel pin control patch to the series (Henning, Mika)
> - fixed English style in the commit message of one of MFD patch (Lee)
> - added tags to my MFD LPC ICH patches (Lee)
> - used consistently (c) (Lee)
> - made indexing for MFD cell and resource arrays (Lee)
> - fixed the resource size in i801 (Jean)
> 
> Andy Shevchenko (6):
>   pinctrl: intel: Check against matching data instead of ACPI companion
>   mfd: lpc_ich: Factor out lpc_ich_enable_spi_write()
>   mfd: lpc_ich: Switch to generic p2sb_bar()
>   i2c: i801: convert to use common P2SB accessor
>   EDAC, pnd2: Use proper I/O accessors and address space annotation
>   EDAC, pnd2: convert to use common P2SB accessor
> 
> Jonathan Yong (1):
>   platform/x86/intel: Add Primary to Sideband (P2SB) bridge support
> 
> Tan Jui Nee (1):
>   mfd: lpc_ich: Add support for pinctrl in non-ACPI system
> 
>  drivers/edac/Kconfig                   |   1 +
>  drivers/edac/pnd2_edac.c               |  62 +++-------
>  drivers/i2c/busses/Kconfig             |   1 +
>  drivers/i2c/busses/i2c-i801.c          |  39 ++----
>  drivers/mfd/Kconfig                    |   1 +
>  drivers/mfd/lpc_ich.c                  | 161 +++++++++++++++++++------
>  drivers/pinctrl/intel/pinctrl-intel.c  |  14 +--
>  drivers/platform/x86/intel/Kconfig     |  12 ++
>  drivers/platform/x86/intel/Makefile    |   2 +
>  drivers/platform/x86/intel/p2sb.c      | 133 ++++++++++++++++++++
>  include/linux/platform_data/x86/p2sb.h |  28 +++++
>  11 files changed, 338 insertions(+), 116 deletions(-)
>  create mode 100644 drivers/platform/x86/intel/p2sb.c
>  create mode 100644 include/linux/platform_data/x86/p2sb.h
> 
> 
> base-commit: 3bf222d317a20170ee17f082626c1e0f83537e13


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper
  2022-05-11 16:08 ` [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Hans de Goede
@ 2022-05-11 18:01   ` Andy Shevchenko
  2022-05-12 10:00     ` Lee Jones
  0 siblings, 1 reply; 17+ messages in thread
From: Andy Shevchenko @ 2022-05-11 18:01 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Andy Shevchenko, Tony Luck, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Lee Jones, Łukasz Bartosik, Linus Walleij,
	Jonathan Yong, Linux Kernel Mailing List, linux-edac, linux-i2c,
	open list:GPIO SUBSYSTEM, Platform Driver, Borislav Petkov,
	Mauro Carvalho Chehab, James Morse, Robert Richter, Jean Delvare,
	Peter Tyser, Mika Westerberg, Andy Shevchenko, Mark Gross

On Wed, May 11, 2022 at 6:08 PM Hans de Goede <hdegoede@redhat.com> wrote:
> On 5/10/22 17:14, Andy Shevchenko wrote:

...

> I must admit I have lost track of all the Ack-s / Reviewed-by-s a bit.
>
> So from the above I take it that the Ack-s resp. Reviewed-by-s on the
> other non drivers/platform/x86 bits also signal an Ack to merge the entire
> series through the pdx86 tree?
>
> Lee, any chance you can take a look at patches 3-5 and give your Ack
> for merging these through the pdx86 tree together with the rest?

Actually I misinterpreted Lee's different tags again. Acked-by is
normal for routing MFD code via other subsystems, while
Acked-for-MFD-by is for Lee (scripts?) to route the code via MFD tree.
Lee, is it the correct interpretation now?

...

> p.s.
>
> Since this is mostly a cleanup series and since we are getting close
> to the next merge-window I believe that it likely is best to merge
> this after 5.19-rc1 has been released.

OK.

> I can then also provide
> an immutable branch for other maintainers early on in the 5.19
> cycle which should help to avoid merge conflicts.

I guess I will send a v6 anyway in order to attach Henning's series to mine.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v5 5/8] mfd: lpc_ich: Add support for pinctrl in non-ACPI system
  2022-05-10 15:14 ` [PATCH v5 5/8] mfd: lpc_ich: Add support for pinctrl in non-ACPI system Andy Shevchenko
@ 2022-05-12  9:53   ` Lee Jones
  0 siblings, 0 replies; 17+ messages in thread
From: Lee Jones @ 2022-05-12  9:53 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Tony Luck, Wolfram Sang, Jean Delvare, Heiner Kallweit,
	Łukasz Bartosik, Hans de Goede, Linus Walleij,
	Jonathan Yong, linux-kernel, linux-edac, linux-i2c, linux-gpio,
	platform-driver-x86, Borislav Petkov, Mauro Carvalho Chehab,
	James Morse, Robert Richter, Jean Delvare, Peter Tyser,
	Mika Westerberg, Andy Shevchenko, Mark Gross, Tan Jui Nee,
	Henning Schild

On Tue, 10 May 2022, Andy Shevchenko wrote:

> From: Tan Jui Nee <jui.nee.tan@intel.com>
> 
> Add support for non-ACPI systems, such as system that uses
> Advanced Boot Loader (ABL) whereby a platform device has to be created
> in order to bind with pin control and GPIO.
> 
> At the moment, Intel Apollo Lake In-Vehicle Infotainment (IVI) system
> requires a driver to hide and unhide P2SB to lookup P2SB BAR and pass
> the PCI BAR address to GPIO.
> 
> Signed-off-by: Tan Jui Nee <jui.nee.tan@intel.com>
> Co-developed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Tested-by: Henning Schild <henning.schild@siemens.com>
> Acked-by: Hans de Goede <hdegoede@redhat.com>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/mfd/lpc_ich.c | 105 +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 104 insertions(+), 1 deletion(-)

For my own reference (apply this as-is to your sign-off block):

  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper
  2022-05-10 15:14 [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Andy Shevchenko
                   ` (8 preceding siblings ...)
  2022-05-11 16:08 ` [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Hans de Goede
@ 2022-05-12  9:55 ` Lee Jones
  2022-05-12 10:45   ` Hans de Goede
  9 siblings, 1 reply; 17+ messages in thread
From: Lee Jones @ 2022-05-12  9:55 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Tony Luck, Wolfram Sang, Jean Delvare, Heiner Kallweit,
	Łukasz Bartosik, Hans de Goede, Linus Walleij,
	Jonathan Yong, linux-kernel, linux-edac, linux-i2c, linux-gpio,
	platform-driver-x86, Borislav Petkov, Mauro Carvalho Chehab,
	James Morse, Robert Richter, Jean Delvare, Peter Tyser,
	Mika Westerberg, Andy Shevchenko, Mark Gross

On Tue, 10 May 2022, Andy Shevchenko wrote:

> There are a few users and at least one more is coming (*1) that would
> like to utilize P2SB mechanism of hiding and unhiding a device from
> the PCI configuration space.
> 
> Here is the series to consolidate p2sb handling code for existing users
> and provide a generic way for new comer(s).
> 
> It also includes a patch to enable GPIO controllers on Apollo Lake
> when it's used with ABL bootloader w/o ACPI support (*2).
> 
> The patch that brings the helper ("platform/x86/intel: Add Primary to
> Sideband (P2SB) bridge support") has a commit message that sheds a light
> on what the P2SB is and why this is needed.
> 
> The changes made in v5 do not change the main idea and the functionality
> in a big scale. What we need is probably one more retest done by Henning
> (*3). I hope to have it merged to v5.19-rc1 that Siemens can develop
> their changes based on this series (*4).
> 
> I have tested this on Apollo Lake platform (I'm able to see SPI NOR and
> since we have an ACPI device for GPIO I do not see any attempts to recreate
> one).
> 
> *1) One in this series, and one is a recent merge of the Simatic IPC drivers
> *2) This patch can be postponed as Lee hasn't given his tag yet.
> *3) Henning gave his tag and I dared to used it even against changed patch 1
> *4) The changes were posted in between of v4 and v5 of this series, but need
>     more work.
> 
> Taking into account the *2) the series is ready to be merged via PDx86 tree.

If that happens you need to do 2 things:

1. Change all s/Acked-for-MFD-by/Acked-by/
2. Submit a pull-request that we can all pull from

Alternatively, I can apply this via MFD and do the same.

> Changes in v5:
> - rewritten patch 1 to use pci_scan_single_device() (Lukas, Bjorn)
> - rebased patch 2 on top of the new Intel SPI NOR codebase
> - fixed a potential bug and rewritten resource filling in patch 5 (Lee)
> - added many different tags in a few patches (Jean, Wolfram, Henning)
> 
> Changes in v4:
> - added tag to the entire series (Hans)
> - added tag to pin control patch (Mika)
> - dropped PCI core changes (PCI core doesn't want modifications to be made)
> - as a consequence of the above merged necessary bits into p2sb.c
> - added a check that p2sb is really hidden (Hans)
> - added EDAC patches (reviewed by maintainer internally)
> 
> Changes in v3:
> - resent with cover letter
> 
> Changes in v2:
> - added parentheses around bus in macros (Joe)
> - added tag (Jean)
> - fixed indentation and wrapping in the header (Christoph)
> - moved out of PCI realm to PDx86 as the best common denominator (Bjorn)
> - added a verbose commit message to explain P2SB thingy (Bjorn)
> - converted first parameter from pci_dev to pci_bus
> - made first two parameters (bus and devfn) optional (Henning, Lee)
> - added Intel pin control patch to the series (Henning, Mika)
> - fixed English style in the commit message of one of MFD patch (Lee)
> - added tags to my MFD LPC ICH patches (Lee)
> - used consistently (c) (Lee)
> - made indexing for MFD cell and resource arrays (Lee)
> - fixed the resource size in i801 (Jean)
> 
> Andy Shevchenko (6):
>   pinctrl: intel: Check against matching data instead of ACPI companion
>   mfd: lpc_ich: Factor out lpc_ich_enable_spi_write()
>   mfd: lpc_ich: Switch to generic p2sb_bar()
>   i2c: i801: convert to use common P2SB accessor
>   EDAC, pnd2: Use proper I/O accessors and address space annotation
>   EDAC, pnd2: convert to use common P2SB accessor
> 
> Jonathan Yong (1):
>   platform/x86/intel: Add Primary to Sideband (P2SB) bridge support
> 
> Tan Jui Nee (1):
>   mfd: lpc_ich: Add support for pinctrl in non-ACPI system
> 
>  drivers/edac/Kconfig                   |   1 +
>  drivers/edac/pnd2_edac.c               |  62 +++-------
>  drivers/i2c/busses/Kconfig             |   1 +
>  drivers/i2c/busses/i2c-i801.c          |  39 ++----
>  drivers/mfd/Kconfig                    |   1 +
>  drivers/mfd/lpc_ich.c                  | 161 +++++++++++++++++++------
>  drivers/pinctrl/intel/pinctrl-intel.c  |  14 +--
>  drivers/platform/x86/intel/Kconfig     |  12 ++
>  drivers/platform/x86/intel/Makefile    |   2 +
>  drivers/platform/x86/intel/p2sb.c      | 133 ++++++++++++++++++++
>  include/linux/platform_data/x86/p2sb.h |  28 +++++
>  11 files changed, 338 insertions(+), 116 deletions(-)
>  create mode 100644 drivers/platform/x86/intel/p2sb.c
>  create mode 100644 include/linux/platform_data/x86/p2sb.h
> 
> 
> base-commit: 3bf222d317a20170ee17f082626c1e0f83537e13

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper
  2022-05-11 18:01   ` Andy Shevchenko
@ 2022-05-12 10:00     ` Lee Jones
  2022-05-12 10:21       ` Andy Shevchenko
  0 siblings, 1 reply; 17+ messages in thread
From: Lee Jones @ 2022-05-12 10:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hans de Goede, Andy Shevchenko, Tony Luck, Wolfram Sang,
	Jean Delvare, Heiner Kallweit, Łukasz Bartosik,
	Linus Walleij, Jonathan Yong, Linux Kernel Mailing List,
	linux-edac, linux-i2c, open list:GPIO SUBSYSTEM, Platform Driver,
	Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross

On Wed, 11 May 2022, Andy Shevchenko wrote:

> On Wed, May 11, 2022 at 6:08 PM Hans de Goede <hdegoede@redhat.com> wrote:
> > On 5/10/22 17:14, Andy Shevchenko wrote:
> 
> ...
> 
> > I must admit I have lost track of all the Ack-s / Reviewed-by-s a bit.
> >
> > So from the above I take it that the Ack-s resp. Reviewed-by-s on the
> > other non drivers/platform/x86 bits also signal an Ack to merge the entire
> > series through the pdx86 tree?
> >
> > Lee, any chance you can take a look at patches 3-5 and give your Ack
> > for merging these through the pdx86 tree together with the rest?
> 
> Actually I misinterpreted Lee's different tags again. Acked-by is
> normal for routing MFD code via other subsystems, while
> Acked-for-MFD-by is for Lee (scripts?) to route the code via MFD tree.
> Lee, is it the correct interpretation now?

Yes, that is correct.

I just replied to your 0th patch (before I saw this, sorry).

> ...
> 
> > p.s.
> >
> > Since this is mostly a cleanup series and since we are getting close
> > to the next merge-window I believe that it likely is best to merge
> > this after 5.19-rc1 has been released.
> 
> OK.
> 
> > I can then also provide
> > an immutable branch for other maintainers early on in the 5.19
> > cycle which should help to avoid merge conflicts.
> 
> I guess I will send a v6 anyway in order to attach Henning's series to mine.
> 

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper
  2022-05-12 10:00     ` Lee Jones
@ 2022-05-12 10:21       ` Andy Shevchenko
  2022-05-12 16:04         ` Lee Jones
  0 siblings, 1 reply; 17+ messages in thread
From: Andy Shevchenko @ 2022-05-12 10:21 UTC (permalink / raw)
  To: Lee Jones
  Cc: Hans de Goede, Tony Luck, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Łukasz Bartosik, Linus Walleij,
	Jonathan Yong, Linux Kernel Mailing List, linux-edac, linux-i2c,
	open list:GPIO SUBSYSTEM, Platform Driver, Borislav Petkov,
	Mauro Carvalho Chehab, James Morse, Robert Richter, Jean Delvare,
	Peter Tyser, Mika Westerberg, Andy Shevchenko, Mark Gross

On Thu, May 12, 2022 at 11:00:38AM +0100, Lee Jones wrote:
> On Wed, 11 May 2022, Andy Shevchenko wrote:
> > On Wed, May 11, 2022 at 6:08 PM Hans de Goede <hdegoede@redhat.com> wrote:
> > > On 5/10/22 17:14, Andy Shevchenko wrote:

...

> > > I must admit I have lost track of all the Ack-s / Reviewed-by-s a bit.
> > >
> > > So from the above I take it that the Ack-s resp. Reviewed-by-s on the
> > > other non drivers/platform/x86 bits also signal an Ack to merge the entire
> > > series through the pdx86 tree?
> > >
> > > Lee, any chance you can take a look at patches 3-5 and give your Ack
> > > for merging these through the pdx86 tree together with the rest?
> > 
> > Actually I misinterpreted Lee's different tags again. Acked-by is
> > normal for routing MFD code via other subsystems, while
> > Acked-for-MFD-by is for Lee (scripts?) to route the code via MFD tree.
> > Lee, is it the correct interpretation now?
> 
> Yes, that is correct.

Thanks for clarification. I'm learning hard way :-)

> I just replied to your 0th patch (before I saw this, sorry).

Thanks for the tag.

So, it seems we all set to route this via MFD then. Do you think we can go?
Or do need to postpone this to be after v5.19-rc1?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper
  2022-05-12  9:55 ` Lee Jones
@ 2022-05-12 10:45   ` Hans de Goede
  0 siblings, 0 replies; 17+ messages in thread
From: Hans de Goede @ 2022-05-12 10:45 UTC (permalink / raw)
  To: Lee Jones, Andy Shevchenko
  Cc: Tony Luck, Wolfram Sang, Jean Delvare, Heiner Kallweit,
	Łukasz Bartosik, Linus Walleij, Jonathan Yong, linux-kernel,
	linux-edac, linux-i2c, linux-gpio, platform-driver-x86,
	Borislav Petkov, Mauro Carvalho Chehab, James Morse,
	Robert Richter, Jean Delvare, Peter Tyser, Mika Westerberg,
	Andy Shevchenko, Mark Gross

Hi,

On 5/12/22 11:55, Lee Jones wrote:
> On Tue, 10 May 2022, Andy Shevchenko wrote:
> 
>> There are a few users and at least one more is coming (*1) that would
>> like to utilize P2SB mechanism of hiding and unhiding a device from
>> the PCI configuration space.
>>
>> Here is the series to consolidate p2sb handling code for existing users
>> and provide a generic way for new comer(s).
>>
>> It also includes a patch to enable GPIO controllers on Apollo Lake
>> when it's used with ABL bootloader w/o ACPI support (*2).
>>
>> The patch that brings the helper ("platform/x86/intel: Add Primary to
>> Sideband (P2SB) bridge support") has a commit message that sheds a light
>> on what the P2SB is and why this is needed.
>>
>> The changes made in v5 do not change the main idea and the functionality
>> in a big scale. What we need is probably one more retest done by Henning
>> (*3). I hope to have it merged to v5.19-rc1 that Siemens can develop
>> their changes based on this series (*4).
>>
>> I have tested this on Apollo Lake platform (I'm able to see SPI NOR and
>> since we have an ACPI device for GPIO I do not see any attempts to recreate
>> one).
>>
>> *1) One in this series, and one is a recent merge of the Simatic IPC drivers
>> *2) This patch can be postponed as Lee hasn't given his tag yet.
>> *3) Henning gave his tag and I dared to used it even against changed patch 1
>> *4) The changes were posted in between of v4 and v5 of this series, but need
>>     more work.
>>
>> Taking into account the *2) the series is ready to be merged via PDx86 tree.
> 
> If that happens you need to do 2 things:
> 
> 1. Change all s/Acked-for-MFD-by/Acked-by/
> 2. Submit a pull-request that we can all pull from
> 
> Alternatively, I can apply this via MFD and do the same.

Applying this via MFD is fine with me and probably is the
logical thing to do since only 1/8 patches in the set is
a pdx86 patch and 3 patches are MFD patches.

Patch 1/8 already has my Acked-by for merging it through
the MFD tree.

Regards,

Hans


> 
>> Changes in v5:
>> - rewritten patch 1 to use pci_scan_single_device() (Lukas, Bjorn)
>> - rebased patch 2 on top of the new Intel SPI NOR codebase
>> - fixed a potential bug and rewritten resource filling in patch 5 (Lee)
>> - added many different tags in a few patches (Jean, Wolfram, Henning)
>>
>> Changes in v4:
>> - added tag to the entire series (Hans)
>> - added tag to pin control patch (Mika)
>> - dropped PCI core changes (PCI core doesn't want modifications to be made)
>> - as a consequence of the above merged necessary bits into p2sb.c
>> - added a check that p2sb is really hidden (Hans)
>> - added EDAC patches (reviewed by maintainer internally)
>>
>> Changes in v3:
>> - resent with cover letter
>>
>> Changes in v2:
>> - added parentheses around bus in macros (Joe)
>> - added tag (Jean)
>> - fixed indentation and wrapping in the header (Christoph)
>> - moved out of PCI realm to PDx86 as the best common denominator (Bjorn)
>> - added a verbose commit message to explain P2SB thingy (Bjorn)
>> - converted first parameter from pci_dev to pci_bus
>> - made first two parameters (bus and devfn) optional (Henning, Lee)
>> - added Intel pin control patch to the series (Henning, Mika)
>> - fixed English style in the commit message of one of MFD patch (Lee)
>> - added tags to my MFD LPC ICH patches (Lee)
>> - used consistently (c) (Lee)
>> - made indexing for MFD cell and resource arrays (Lee)
>> - fixed the resource size in i801 (Jean)
>>
>> Andy Shevchenko (6):
>>   pinctrl: intel: Check against matching data instead of ACPI companion
>>   mfd: lpc_ich: Factor out lpc_ich_enable_spi_write()
>>   mfd: lpc_ich: Switch to generic p2sb_bar()
>>   i2c: i801: convert to use common P2SB accessor
>>   EDAC, pnd2: Use proper I/O accessors and address space annotation
>>   EDAC, pnd2: convert to use common P2SB accessor
>>
>> Jonathan Yong (1):
>>   platform/x86/intel: Add Primary to Sideband (P2SB) bridge support
>>
>> Tan Jui Nee (1):
>>   mfd: lpc_ich: Add support for pinctrl in non-ACPI system
>>
>>  drivers/edac/Kconfig                   |   1 +
>>  drivers/edac/pnd2_edac.c               |  62 +++-------
>>  drivers/i2c/busses/Kconfig             |   1 +
>>  drivers/i2c/busses/i2c-i801.c          |  39 ++----
>>  drivers/mfd/Kconfig                    |   1 +
>>  drivers/mfd/lpc_ich.c                  | 161 +++++++++++++++++++------
>>  drivers/pinctrl/intel/pinctrl-intel.c  |  14 +--
>>  drivers/platform/x86/intel/Kconfig     |  12 ++
>>  drivers/platform/x86/intel/Makefile    |   2 +
>>  drivers/platform/x86/intel/p2sb.c      | 133 ++++++++++++++++++++
>>  include/linux/platform_data/x86/p2sb.h |  28 +++++
>>  11 files changed, 338 insertions(+), 116 deletions(-)
>>  create mode 100644 drivers/platform/x86/intel/p2sb.c
>>  create mode 100644 include/linux/platform_data/x86/p2sb.h
>>
>>
>> base-commit: 3bf222d317a20170ee17f082626c1e0f83537e13
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper
  2022-05-12 10:21       ` Andy Shevchenko
@ 2022-05-12 16:04         ` Lee Jones
  0 siblings, 0 replies; 17+ messages in thread
From: Lee Jones @ 2022-05-12 16:04 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hans de Goede, Tony Luck, Wolfram Sang, Jean Delvare,
	Heiner Kallweit, Łukasz Bartosik, Linus Walleij,
	Jonathan Yong, Linux Kernel Mailing List, linux-edac, linux-i2c,
	open list:GPIO SUBSYSTEM, Platform Driver, Borislav Petkov,
	Mauro Carvalho Chehab, James Morse, Robert Richter, Jean Delvare,
	Peter Tyser, Mika Westerberg, Andy Shevchenko, Mark Gross

On Thu, 12 May 2022, Andy Shevchenko wrote:

> On Thu, May 12, 2022 at 11:00:38AM +0100, Lee Jones wrote:
> > On Wed, 11 May 2022, Andy Shevchenko wrote:
> > > On Wed, May 11, 2022 at 6:08 PM Hans de Goede <hdegoede@redhat.com> wrote:
> > > > On 5/10/22 17:14, Andy Shevchenko wrote:
> 
> ...
> 
> > > > I must admit I have lost track of all the Ack-s / Reviewed-by-s a bit.
> > > >
> > > > So from the above I take it that the Ack-s resp. Reviewed-by-s on the
> > > > other non drivers/platform/x86 bits also signal an Ack to merge the entire
> > > > series through the pdx86 tree?
> > > >
> > > > Lee, any chance you can take a look at patches 3-5 and give your Ack
> > > > for merging these through the pdx86 tree together with the rest?
> > > 
> > > Actually I misinterpreted Lee's different tags again. Acked-by is
> > > normal for routing MFD code via other subsystems, while
> > > Acked-for-MFD-by is for Lee (scripts?) to route the code via MFD tree.
> > > Lee, is it the correct interpretation now?
> > 
> > Yes, that is correct.
> 
> Thanks for clarification. I'm learning hard way :-)
> 
> > I just replied to your 0th patch (before I saw this, sorry).
> 
> Thanks for the tag.
> 
> So, it seems we all set to route this via MFD then. Do you think we can go?
> Or do need to postpone this to be after v5.19-rc1?

I think Hans is correct.

I would like to see this soak before submitting directly to Mainline.

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-05-12 16:05 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 15:14 [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Andy Shevchenko
2022-05-10 15:14 ` [PATCH v5 1/8] platform/x86/intel: Add Primary to Sideband (P2SB) bridge support Andy Shevchenko
2022-05-10 15:14 ` [PATCH v5 2/8] pinctrl: intel: Check against matching data instead of ACPI companion Andy Shevchenko
2022-05-10 15:14 ` [PATCH v5 3/8] mfd: lpc_ich: Factor out lpc_ich_enable_spi_write() Andy Shevchenko
2022-05-10 15:14 ` [PATCH v5 4/8] mfd: lpc_ich: Switch to generic p2sb_bar() Andy Shevchenko
2022-05-10 15:14 ` [PATCH v5 5/8] mfd: lpc_ich: Add support for pinctrl in non-ACPI system Andy Shevchenko
2022-05-12  9:53   ` Lee Jones
2022-05-10 15:14 ` [PATCH v5 6/8] i2c: i801: convert to use common P2SB accessor Andy Shevchenko
2022-05-10 15:14 ` [PATCH v5 7/8] EDAC, pnd2: Use proper I/O accessors and address space annotation Andy Shevchenko
2022-05-10 15:14 ` [PATCH v5 8/8] EDAC, pnd2: convert to use common P2SB accessor Andy Shevchenko
2022-05-11 16:08 ` [PATCH v5 0/8] platform/x86: introduce p2sb_bar() helper Hans de Goede
2022-05-11 18:01   ` Andy Shevchenko
2022-05-12 10:00     ` Lee Jones
2022-05-12 10:21       ` Andy Shevchenko
2022-05-12 16:04         ` Lee Jones
2022-05-12  9:55 ` Lee Jones
2022-05-12 10:45   ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.