Skip to contentSkip to conversation

pinctrl/broxton: enable platform device in the absent of ACPI enumeration

PATCH Superseded Tan Jui Nee 5 participants 11 messages Jun 28, 2016 – Jul 14, 2016

Subsystems (4)

v5 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#1 lore raw

PATCH v5 1/3 x86/platform/p2sb: New Primary to Sideband bridge support driver for Intel SOC's

In reply to Tan Jui Nee

From: Andy Shevchenko <[email protected]>

There is already one and at least one more user coming which require an access to Primary to Sideband bridge (P2SB) in order to get IO or MMIO bar hidden by BIOS.
Create a driver to access P2SB for x86 devices.

---
Changes in V5:
- No change

Changes in V4:
- Move Kconfig option CONFIG_X86_INTEL_NON_ACPI from
[PATCH 2/3] x86/platform/p2sb: New Primary to Sideband bridge support driver for Intel SOC's to
[PATCH 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system since the config is used in latter patch.

Changes in V3:
- No change

Changes in V2:
- Add new config option CONFIG_X86_INTEL_NON_ACPI and "select PINCTRL" to fix kbuildbot error

 arch/x86/Kconfig                 |  4 ++
 arch/x86/include/asm/p2sb.h      | 27 +++++++++++
 arch/x86/platform/intel/Makefile |  1 +
 arch/x86/platform/intel/p2sb.c   | 99 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 131 insertions(+)
 create mode 100644 arch/x86/include/asm/p2sb.h
 create mode 100644 arch/x86/platform/intel/p2sb.c
arch/x86/Kconfig +4 -0
index d9a94da..d305d81 100644
@@ -604,6 +604,10 @@ config IOSF_MBI_DEBUG
 
 	  If you don't require the option or are in doubt, say N.
 
+config P2SB
+	tristate
+	depends on PCI
+
 config X86_RDC321X
 	bool "RDC R-321x SoC"
 	depends on X86_32
arch/x86/include/asm/p2sb.h new file +27 -0
new file mode 100644
index 0000000..686e07b
@@ -0,0 +1,27 @@
+/*
+ * Primary to Sideband bridge (P2SB) access support
+ */
+
+#ifndef P2SB_SYMS_H
+#define P2SB_SYMS_H
+
+#include <linux/ioport.h>
+#include <linux/pci.h>
+
+#if IS_ENABLED(CONFIG_P2SB)
+
+int p2sb_bar(struct pci_dev *pdev, unsigned int devfn,
+	struct resource *res);
+
+#else /* CONFIG_P2SB is not set */
+
+static inline
+int p2sb_bar(struct pci_dev *pdev, unsigned int devfn,
+	struct resource *res)
+{
+	return -ENODEV;
+}
+
+#endif /* CONFIG_P2SB */
+
+#endif /* P2SB_SYMS_H */
arch/x86/platform/intel/Makefile +1 -0
index b878032..dbf9f10 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_IOSF_MBI)			+= iosf_mbi.o
+obj-$(CONFIG_P2SB)			+= p2sb.o
arch/x86/platform/intel/p2sb.c new file +99 -0

99 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

PATCH v5 3/3 mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system

In reply to Tan Jui Nee

This driver uses the P2SB hide/unhide mechanism cooperatively to pass the PCI BAR address to the gpio platform driver.

---
Changes in V5:
- Split lpc-ich driver into two parts (lpc_ich-core and lpc_ich-apl). The file lpc_ich-apl.c introduces gpio platform driver in MFD.
- Rename Kconfig option CONFIG_X86_INTEL_NON_ACPI to CONFIG_X86_INTEL_APL so that it reflects actual product as suggested by Mika.

Changes in V4:
- Move Kconfig option CONFIG_X86_INTEL_NON_ACPI from
[PATCH 2/3] x86/platform/p2sb: New Primary to Sideband bridge support driver for Intel SOC's to
[PATCH 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system since the config is used in latter patch.
- Select CONFIG_P2SB when CONFIG_LPC_ICH is enabled.
- Remove #ifdef CONFIG_X86_INTEL_NON_ACPI and use
#if defined(CONFIG_X86_INTEL_NON_ACPI) when lpc_ich_misc is called
as suggested by Lee Jones.
- Use single dimensional array instead of 2D array for apl_gpio_io_res structure and use DEFINE_RES_IRQ for its IRQ resource.

Changes in V3:
- Simplify register addresses calculation and use DEFINE_RES_MEM_NAMED defines for apl_gpio_io_res structure
- Define magic number for P2SB PCI ID
- Replace switch-case with if-else since currently we have only one use case
- Only call mfd_add_devices() once for all gpio communities

Changes in V2:
- Add new config option CONFIG_X86_INTEL_NON_ACPI and "select PINCTRL" to fix kbuildbot error

 arch/x86/Kconfig            |   9 ++++
 drivers/mfd/Kconfig         |   3 +-
 drivers/mfd/Makefile        |   2 +-
 drivers/mfd/lpc_ich-apl.c   | 126 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/mfd/lpc_ich-core.c  |  11 ++++
 include/linux/mfd/lpc_ich.h |   7 +++
 6 files changed, 156 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mfd/lpc_ich-apl.c
arch/x86/Kconfig +9 -0
index d305d81..e1865c7 100644
@@ -498,6 +498,15 @@ config X86_GOLDFISH
 	 for Android development. Unless you are building for the Android
 	 Goldfish emulator say N here.
 
+config X86_INTEL_APL
+	bool "Non-ACPI support for Intel Apollo Lake platforms"
+	select PINCTRL
+	---help---
+	  Select this option to enable MMIO BAR access over the P2SB for
+	  non-ACPI Intel Apollo Lake SoC platforms. This driver uses the P2SB
+	  hide/unhide mechanism cooperatively to pass the PCI BAR address to
+	  the platform driver, currently GPIO.
+
 config X86_INTEL_CE
 	bool "CE4100 TV platform"
 	depends on PCI
drivers/mfd/Kconfig +2 -1
index 1bcf601..dc4e543 100644
@@ -369,8 +369,9 @@ config MFD_INTEL_QUARK_I2C_GPIO
 
 config LPC_ICH
 	tristate "Intel ICH LPC"
-	depends on PCI
+	depends on X86 && PCI
 	select MFD_CORE
+	select P2SB
 	help
 	  The LPC bridge function of the Intel ICH provides support for
 	  many functional units. This driver provides needed support for
drivers/mfd/Makefile +1 -1
index 1dfe5fb..7572c1f 100644
@@ -155,7 +155,7 @@ obj-$(CONFIG_PMIC_ADP5520)	+= adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)	+= kempld-core.o
 obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO)	+= intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)		+= lpc_sch.o
-lpc_ich-objs		:= lpc_ich-core.o
+lpc_ich-objs		:= lpc_ich-core.o lpc_ich-apl.o
 obj-$(CONFIG_LPC_ICH)		+= lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)	+= rdc321x-southbridge.o
 obj-$(CONFIG_MFD_JANZ_CMODIO)	+= janz-cmodio.o
drivers/mfd/lpc_ich-apl.c new file +126 -0

126 lines not on this page · raw message

drivers/mfd/lpc_ich-core.c +11 -0
index bd3aa45..1e957d4 100644
@@ -216,6 +216,7 @@ enum lpc_chipsets {
 	LPC_BRASWELL,	/* Braswell SoC */
 	LPC_LEWISBURG,	/* Lewisburg */
 	LPC_9S,		/* 9 Series */
+	LPC_APL,	/* Apollo Lake SoC */
 };
 
 static struct lpc_ich_info lpc_chipset_info[] = {
@@ -531,6 +532,10 @@ static struct lpc_ich_info lpc_chipset_info[] = {
 		.name = "9 Series",
 		.iTCO_version = 2,
 	},
+	[LPC_APL]  = {
+		.name = "Apollo Lake SoC",
+		.iTCO_version = 5,
+	},
 };
 
 /*
@@ -679,6 +684,7 @@ static const struct pci_device_id lpc_ich_ids[] = {
 	{ PCI_VDEVICE(INTEL, 0x3b14), LPC_3420},
 	{ PCI_VDEVICE(INTEL, 0x3b16), LPC_3450},
 	{ PCI_VDEVICE(INTEL, 0x5031), LPC_EP80579},
+	{ PCI_VDEVICE(INTEL, 0x5ae8), LPC_APL},
 	{ PCI_VDEVICE(INTEL, 0x8c40), LPC_LPT},
 	{ PCI_VDEVICE(INTEL, 0x8c41), LPC_LPT},
 	{ PCI_VDEVICE(INTEL, 0x8c42), LPC_LPT},
@@ -1093,6 +1099,11 @@ static int lpc_ich_probe(struct pci_dev *dev,
 			cell_added = true;
 	}
 
+	if (priv->chipset == LPC_APL) {
+		ret = lpc_ich_misc(dev);
+		if (!ret)
+			cell_added = true;
+	}
 	/*
 	 * We only care if at least one or none of the cells registered
 	 * successfully.
include/linux/mfd/lpc_ich.h +7 -0
index 2b300b4..c5d0adc 100644
@@ -43,4 +43,11 @@ struct lpc_ich_info {
 	u8 use_gpio;
 };
 
+#if defined(CONFIG_X86_INTEL_APL)
+int lpc_ich_misc(struct pci_dev *dev);
+#else
+static inline int lpc_ich_misc(struct pci_dev *dev)
+{ return -ENODEV; }
+#endif
+
 #endif
Signature · 1 line
1.9.1
#0 lore raw

v5 cover pinctrl/broxton: enable platform device in the absent of ACPI enumeration

Hi,
The patches are to cater the need for non-ACPI system whereby a platform device has to be created in order to bind with Apollo Lake Pinctrl GPIO platform driver.

The MMIO BAR is accessed over the Primary to Sideband bridge (P2SB). Since the BIOS prevents the P2SB device from being enumerated by the PCI subsystem, so we need to hide/unhide P2SB to lookup the P2SB BAR and pass the PCI BAR address to the gpio platform driver.

All these three patches have dependencies on each other.

Changes in V5:
- Split lpc-ich driver into two parts (lpc_ich-core and lpc_ich-apl). The file lpc_ich-apl.c introduces gpio platform driver in MFD.
- Rename Kconfig option CONFIG_X86_INTEL_NON_ACPI to CONFIG_X86_INTEL_APL so that it reflects actual product as suggested by Mika.
- The patch:
[PATCH] pinctrl/broxton: enable platform device in the absent of ACPI enumeration is removed in V5 patch-set as the patch is already applied in Linus' pinctrl tree.

Changes in V4:
- Move Kconfig option CONFIG_X86_INTEL_NON_ACPI from
[PATCH 2/3] x86/platform/p2sb: New Primary to Sideband bridge support driver for Intel SOC's to
[PATCH 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system since the config is used in latter patch.
- Select CONFIG_P2SB when CONFIG_LPC_ICH is enabled.
- Remove #ifdef CONFIG_X86_INTEL_NON_ACPI and use
#if defined(CONFIG_X86_INTEL_NON_ACPI) when lpc_ich_misc is called
as suggested by Lee Jones.
- Use single dimensional array instead of 2D array for apl_gpio_io_res structure and use DEFINE_RES_IRQ for its IRQ resource.

Changes in V3:
- Simplify register addresses calculation and use DEFINE_RES_MEM_NAMED defines for apl_gpio_io_res structure
- Define magic number for P2SB PCI ID
- Replace switch-case with if-else since currently we have only one use case
- Only call mfd_add_devices() once for all gpio communities

Changes in V2:
- Add new config option CONFIG_X86_INTEL_NON_ACPI and "select PINCTRL" to fix kbuildbot error

Andy Shevchenko (1):
x86/platform/p2sb: New Primary to Sideband bridge support driver for
Intel SOC's

Tan Jui Nee (2):
mfd: lpc_ich: Prepare to split lpc-ich driver
mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in
non-ACPI system

 arch/x86/Kconfig                 |   13 +
 arch/x86/include/asm/p2sb.h      |   27 +
 arch/x86/platform/intel/Makefile |    1 +
 arch/x86/platform/intel/p2sb.c   |   99 ++++
 drivers/mfd/Kconfig              |    3 +-
 drivers/mfd/Makefile             |    1 +
 drivers/mfd/lpc_ich-apl.c        |  126 +++++
 drivers/mfd/lpc_ich-core.c       | 1137 ++++++++++++++++++++++++++++++++++++++
 drivers/mfd/lpc_ich.c            | 1126 -------------------------------------
 include/linux/mfd/lpc_ich.h      |    7 +
 10 files changed, 1413 insertions(+), 1127 deletions(-)
 create mode 100644 arch/x86/include/asm/p2sb.h
 create mode 100644 arch/x86/platform/intel/p2sb.c
 create mode 100644 drivers/mfd/lpc_ich-apl.c
 create mode 100644 drivers/mfd/lpc_ich-core.c
 delete mode 100644 drivers/mfd/lpc_ich.c
Signature · 1 line
1.9.1
#2 lore raw

PATCH v5 2/3 mfd: lpc_ich: Prepare to split lpc-ich driver

This patch follows the example of mfd/wm831x and splits it into an interface independent core since it is growing quite fast with many table entries.

---
 drivers/mfd/Makefile       |    1 +
 drivers/mfd/lpc_ich-core.c | 1126 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/mfd/lpc_ich.c      | 1126 --------------------------------------------
 3 files changed, 1127 insertions(+), 1126 deletions(-)
 create mode 100644 drivers/mfd/lpc_ich-core.c
 delete mode 100644 drivers/mfd/lpc_ich.c
drivers/mfd/Makefile +1 -0
index 42a66e1..1dfe5fb 100644
@@ -155,6 +155,7 @@ obj-$(CONFIG_PMIC_ADP5520)	+= adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)	+= kempld-core.o
 obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO)	+= intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)		+= lpc_sch.o
+lpc_ich-objs		:= lpc_ich-core.o
 obj-$(CONFIG_LPC_ICH)		+= lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)	+= rdc321x-southbridge.o
 obj-$(CONFIG_MFD_JANZ_CMODIO)	+= janz-cmodio.o
drivers/mfd/lpc_ich-core.c new file +1126 -0

1,126 lines not on this page · raw message

drivers/mfd/lpc_ich.c deleted +0 -1126

1,126 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system

In reply to Tan Jui Nee

arch/x86/Kconfig config X86_GOLDFISH · line 509

Quoted 9 lines · Tan Jui Nee
arch/x86/Kconfig +9 -0
+config X86_INTEL_APL
+	bool "Non-ACPI support for Intel Apollo Lake platforms"
+	select PINCTRL
+	---help---
+	  Select this option to enable MMIO BAR access over the P2SB for
+	  non-ACPI Intel Apollo Lake SoC platforms. This driver uses the P2SB
+	  hide/unhide mechanism cooperatively to pass the PCI BAR address to
+	  the platform driver, currently GPIO.
+

Sorry but IMHO this still does not explain the option clearly enough. You are using this in some automotive IVI system with specialized bootloader, correct? Why not use that here instead?

Something along the lines of

config X86_INTEL_IVI
bool "Intel in-vehicle infotainment (IVI) systems used in cars"

#3 lore raw

Re: [PATCH v5 2/3] mfd: lpc_ich: Prepare to split lpc-ich driver

In reply to Tan Jui Nee
Quoted 3 lines · Tan Jui Nee

This patch follows the example of mfd/wm831x and splits it into an interface independent core since it is growing quite fast with many table entries.

I didn't see a split below. It is just a rename. And actually it would be better to indeed have rename as a separate change.

Quoted 6 lines
---
 drivers/mfd/Makefile       |    1 +
 drivers/mfd/lpc_ich-core.c | 1126 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/mfd/lpc_ich.c      | 1126 --------------------------------------------

It can't be reviewed in this form.
Please use parameters (-M, for example) to git format-patch.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system

In reply to Tan Jui Nee

drivers/mfd/Kconfig config MFD_INTEL_QUARK_I2C_GPIO · line 372

Quoted 11 lines · Tan Jui Nee

This driver uses the P2SB hide/unhide mechanism cooperatively to pass the PCI BAR address to the gpio platform driver.

drivers/mfd/Kconfig +1 -1
@@ -369,8 +369,9 @@ config MFD_INTEL_QUARK_I2C_GPIO
 
 config LPC_ICH
        tristate "Intel ICH LPC"
-       depends on PCI
+       depends on X86 && PCI

This might deserve to be a separate change. Lee, what is your opinion?

drivers/mfd/Kconfig config MFD_INTEL_QUARK_I2C_GPIO · line 374

Quoted 2 lines
drivers/mfd/Kconfig +1 -0
        select MFD_CORE
+       select P2SB

This is okay

drivers/mfd/Kconfig obj-$(CONFIG_PMIC_ADP5520) += adp5520.o · line 160

Quoted 8 lines
drivers/mfd/Kconfig +1 -1
@@ -155,7 +155,7 @@ obj-$(CONFIG_PMIC_ADP5520)  += adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)       += kempld-core.o
 obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO) += intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)          += lpc_sch.o
 
-lpc_ich-objs           := lpc_ich-core.o
+lpc_ich-objs           := lpc_ich-core.o lpc_ich-apl.o
 obj-$(CONFIG_LPC_ICH)          += lpc_ich.o

I don't know if there is any requirement, but what I see in other Makefiles is

obj-$(CONFIG_DRV_OPTION) = drv_name.o
drv_name-objs := main.o aux1.o

Perhaps you may do the same.

Quoted 9 lines
drivers/mfd/Kconfig +8 -0
+++ b/drivers/mfd/lpc_ich-apl.c
@@ -0,0 +1,126 @@
+/*
+ * Purpose: Create a platform device to bind with Intel Apollo Lake
+ * Pinctrl GPIO platform driver
+ * Copyright (C) 2016 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as

drivers/mfd/Kconfig

Quoted 10 lines
drivers/mfd/Kconfig +9 -0
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/mfd/core.h>
+#include <linux/mfd/lpc_ich.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <asm/p2sb.h>
+
 
+#if defined(CONFIG_X86_INTEL_APL)

And why you can't use

ifeq ($(CONFIG_...,y))
lpc_ich-objs += ...
endif

in the Makefile?

Quoted 100 lines
drivers/mfd/Kconfig +100 -0
+/* Offset data for Apollo Lake GPIO communities */
+#define APL_GPIO_SOUTHWEST_OFFSET      0xc00000
+#define APL_GPIO_NORTHWEST_OFFSET      0xc40000
+#define APL_GPIO_NORTH_OFFSET          0xc50000
+#define APL_GPIO_WEST_OFFSET           0xc70000
+
+#define APL_GPIO_SOUTHWEST_NPIN                43
+#define APL_GPIO_NORTHWEST_NPIN                77
+#define APL_GPIO_NORTH_NPIN            78
+#define APL_GPIO_WEST_NPIN             47
+
+#define APL_GPIO_IRQ 14
+
+#define PCI_IDSEL_P2SB 0x0d
+
+static struct resource apl_gpio_io_res[] = {
+       DEFINE_RES_MEM_NAMED(APL_GPIO_NORTH_OFFSET,
+               APL_GPIO_NORTH_NPIN * SZ_8, "apl_pinctrl_n"),
+       DEFINE_RES_MEM_NAMED(APL_GPIO_NORTHWEST_OFFSET,
+               APL_GPIO_NORTHWEST_NPIN * SZ_8, "apl_pinctrl_nw"),
+       DEFINE_RES_MEM_NAMED(APL_GPIO_WEST_OFFSET,
+               APL_GPIO_WEST_NPIN * SZ_8, "apl_pinctrl_w"),
+       DEFINE_RES_MEM_NAMED(APL_GPIO_SOUTHWEST_OFFSET,
+               APL_GPIO_SOUTHWEST_NPIN * SZ_8, "apl_pinctrl_sw"),
+       DEFINE_RES_IRQ(APL_GPIO_IRQ),
+};
+
+static struct pinctrl_pin_desc apl_pinctrl_pdata;
+
+static struct mfd_cell apl_gpio_devices[] = {
+       {
+               .name = "apl-pinctrl",
+               .id = 0,
+               .num_resources = ARRAY_SIZE(apl_gpio_io_res),
+               .resources = apl_gpio_io_res,
+               .pdata_size = sizeof(apl_pinctrl_pdata),
+               .platform_data = &apl_pinctrl_pdata,
+               .ignore_resource_conflicts = true,
+       },
+       {
+               .name = "apl-pinctrl",
+               .id = 1,
+               .num_resources = ARRAY_SIZE(apl_gpio_io_res),
+               .resources = apl_gpio_io_res,
+               .pdata_size = sizeof(apl_pinctrl_pdata),
+               .platform_data = &apl_pinctrl_pdata,
+               .ignore_resource_conflicts = true,
+       },
+       {
+               .name = "apl-pinctrl",
+               .id = 2,
+               .num_resources = ARRAY_SIZE(apl_gpio_io_res),
+               .resources = apl_gpio_io_res,
+               .pdata_size = sizeof(apl_pinctrl_pdata),
+               .platform_data = &apl_pinctrl_pdata,
+               .ignore_resource_conflicts = true,
+       },
+       {
+               .name = "apl-pinctrl",
+               .id = 3,
+               .num_resources = ARRAY_SIZE(apl_gpio_io_res),
+               .resources = apl_gpio_io_res,
+               .pdata_size = sizeof(apl_pinctrl_pdata),
+               .platform_data = &apl_pinctrl_pdata,
+               .ignore_resource_conflicts = true,
+       },
+};
+
+int lpc_ich_misc(struct pci_dev *dev)
+{
+       unsigned int apl_p2sb = PCI_DEVFN(PCI_IDSEL_P2SB, 0);
+       unsigned int i;
+       int ret;
+
+       /*
+        * Apollo lake, has not 1, but 4 gpio controllers,
+        * handle it a bit differently.
+        */
+
+       for (i = 0; i < ARRAY_SIZE(apl_gpio_io_res)-1; i++) {
+               struct resource *res = &apl_gpio_io_res[i];
+
+               apl_gpio_devices[i].resources = res;
+
+               /* Fill MEM resource */
+               ret = p2sb_bar(dev, apl_p2sb, res++);
+               if (ret)
+                       goto warn_continue;
+
+               apl_pinctrl_pdata.name = kasprintf(GFP_KERNEL, "%u",
+                       i + 1);
+       }
+
+       if (apl_pinctrl_pdata.name)
+               ret = mfd_add_devices(&dev->dev, apl_gpio_devices->id,
+                       apl_gpio_devices, ARRAY_SIZE(apl_gpio_devices),
+                               NULL, 0, NULL);
+       else
+               ret = -ENOMEM;
+

drivers/mfd/Kconfig

Quoted 10 lines
drivers/mfd/Kconfig +10 -0
+warn_continue:
+       if (ret)
+               dev_warn(&dev->dev,
+                       "Failed to add Apollo Lake GPIO %s: %d\n",
+                               apl_pinctrl_pdata.name, ret);
+
+       kfree(apl_pinctrl_pdata.name);
+       return 0;
+}
+#endif

Regarding to the above I don't see Lee's comments addressed. Can you remind whar is the result of that discussion?

drivers/mfd/Kconfig

Quoted 5 lines
drivers/mfd/Kconfig +5 -0
+       if (priv->chipset == LPC_APL) {
+               ret = lpc_ich_misc(dev);
+               if (!ret)
+                       cell_added = true;
+       }

It might be better to call via pointer in the struct lpc_ich_info.

include/linux/mfd/lpc_ich.h struct lpc_ich_info { · line 50

Quoted 11 lines
include/linux/mfd/lpc_ich.h +5 -0
@@ -43,4 +43,11 @@ struct lpc_ich_info {
        u8 use_gpio;
 };
 
+#if defined(CONFIG_X86_INTEL_APL)
+int lpc_ich_misc(struct pci_dev *dev);
+#else
+static inline int lpc_ich_misc(struct pci_dev *dev)
+{ return -ENODEV; }

It could be one line, ...

include/linux/mfd/lpc_ich.h struct lpc_ich_info { · line 51

Quoted 1 line
include/linux/mfd/lpc_ich.h +1 -0
+#endif

...but the name of this function should not be so generic. What if tomorrow you will get one more module which needs one more function?

Moreover this is a part of internal driver interface, I would move this part into special header under drivers/mfd.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#10 lore raw

Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system

In reply to Tan Jui Nee
reproduce:

Hi,

[auto build test WARNING on ljones-mfd/for-mfd-next]
[also build test WARNING on v4.7-rc5 next-20160627]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Tan-Jui-Nee/x86-platform-p2sb-New-Primary-to-Sideband-bridge-support-driver-for-Intel-SOC-s/20160628-160704
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
config: x86_64-randconfig-s5-06281627 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

In file included from drivers/mfd/lpc_ich-apl.c:12:0:

>> include/linux/mfd/lpc_ich.h:49:39: warning: 'struct pci_dev' declared inside parameter list will not be visible outside of this definition or declaration

static inline int lpc_ich_misc(struct pci_dev *dev)
^~~~~~~

vim +49 include/linux/mfd/lpc_ich.h

    33		ICH_V9_GPIO,
    34		ICH_V10CORP_GPIO,
    35		ICH_V10CONS_GPIO,
    36		AVOTON_GPIO,
    37	};
    38	
    39	struct lpc_ich_info {
    40		char name[32];
    41		unsigned int iTCO_version;
    42		unsigned int gpio_version;
    43		u8 use_gpio;
    44	};
    45	
    46	#if defined(CONFIG_X86_INTEL_APL)
    47	int lpc_ich_misc(struct pci_dev *dev);
    48	#else
  > 49	static inline int lpc_ich_misc(struct pci_dev *dev)
    50	{ return -ENODEV; }
    51	#endif
    52	
    53	#endif

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#8 lore raw

Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system

In reply to Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Quoted 7 lines · Tan Jui Nee

This driver uses the P2SB hide/unhide mechanism cooperatively to pass the PCI BAR address to the gpio platform driver.

drivers/mfd/Kconfig +0 -0
@@ -369,8 +369,9 @@ config MFD_INTEL_QUARK_I2C_GPIO
 
Quoted 6 lines

drivers/mfd/Kconfig config MFD_INTEL_QUARK_I2C_GPIO · line 372

Quoted 4 lines
drivers/mfd/Kconfig +1 -1
 config LPC_ICH
        tristate "Intel ICH LPC"
-       depends on PCI
+       depends on X86 && PCI

This might deserve to be a separate change. Lee, what is your opinion?

I have no strong opinion. Keep it in if you like.

[...]

Quoted 5 lines
Quoted 4 lines
drivers/mfd/Kconfig +0 -0
@@ -155,7 +155,7 @@ obj-$(CONFIG_PMIC_ADP5520)  += adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)       += kempld-core.o
 obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO) += intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)          += lpc_sch.o
Quoted 8 lines

drivers/mfd/Kconfig obj-$(CONFIG_PMIC_ADP5520) += adp5520.o · line 159

Quoted 3 lines
drivers/mfd/Kconfig +1 -1
-lpc_ich-objs           := lpc_ich-core.o
+lpc_ich-objs           := lpc_ich-core.o lpc_ich-apl.o
 obj-$(CONFIG_LPC_ICH)          += lpc_ich.o

I don't know if there is any requirement, but what I see in other Makefiles is

obj-$(CONFIG_DRV_OPTION) = drv_name.o
drv_name-objs := main.o aux1.o

Yes, this is nicer.

Quoted 21 lines

Perhaps you may do the same.

Quoted 19 lines
drivers/mfd/Kconfig +17 -0
+++ b/drivers/mfd/lpc_ich-apl.c
@@ -0,0 +1,126 @@
+/*
+ * Purpose: Create a platform device to bind with Intel Apollo Lake
+ * Pinctrl GPIO platform driver
+ * Copyright (C) 2016 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/mfd/core.h>
+#include <linux/mfd/lpc_ich.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <asm/p2sb.h>
+
 
+#if defined(CONFIG_X86_INTEL_APL)

I'm not accepting this kind of #ifery in *.c files.

Quoted 7 lines

And why you can't use

ifeq ($(CONFIG_...,y))
lpc_ich-objs += ...
endif

in the Makefile?

[...]

Quoted 37 lines
Quoted 37 lines
drivers/mfd/Kconfig +37 -0
+int lpc_ich_misc(struct pci_dev *dev)
+{
+       unsigned int apl_p2sb = PCI_DEVFN(PCI_IDSEL_P2SB, 0);
+       unsigned int i;
+       int ret;
+
+       /*
+        * Apollo lake, has not 1, but 4 gpio controllers,
+        * handle it a bit differently.
+        */
+
+       for (i = 0; i < ARRAY_SIZE(apl_gpio_io_res)-1; i++) {
+               struct resource *res = &apl_gpio_io_res[i];
+
+               apl_gpio_devices[i].resources = res;
+
+               /* Fill MEM resource */
+               ret = p2sb_bar(dev, apl_p2sb, res++);
+               if (ret)
+                       goto warn_continue;
+
+               apl_pinctrl_pdata.name = kasprintf(GFP_KERNEL, "%u",
+                       i + 1);
+       }
+
+       if (apl_pinctrl_pdata.name)
+               ret = mfd_add_devices(&dev->dev, apl_gpio_devices->id,
+                       apl_gpio_devices, ARRAY_SIZE(apl_gpio_devices),
+                               NULL, 0, NULL);
+       else
+               ret = -ENOMEM;
+
+warn_continue:
+       if (ret)
+               dev_warn(&dev->dev,
+                       "Failed to add Apollo Lake GPIO %s: %d\n",
+                               apl_pinctrl_pdata.name, ret);
Quoted 8 lines

drivers/mfd/Kconfig

Quoted 5 lines
drivers/mfd/Kconfig +5 -0
+
+       kfree(apl_pinctrl_pdata.name);
+       return 0;
+}
+#endif

Regarding to the above I don't see Lee's comments addressed. Can you remind whar is the result of that discussion?

I don't have time to do a full review now, but this does look nasty.

[...]

Quoted 6 lines
Quoted 5 lines
include/linux/mfd/lpc_ich.h +0 -0
@@ -43,4 +43,11 @@ struct lpc_ich_info {
        u8 use_gpio;
 };
Quoted 7 lines

include/linux/mfd/lpc_ich.h struct lpc_ich_info { · line 50

Quoted 5 lines
include/linux/mfd/lpc_ich.h +5 -0
+#if defined(CONFIG_X86_INTEL_APL)
+int lpc_ich_misc(struct pci_dev *dev);
+#else
+static inline int lpc_ich_misc(struct pci_dev *dev)
+{ return -ENODEV; }

It could be one line, ...

I don't want it in here at all.

Quoted 8 lines

include/linux/mfd/lpc_ich.h struct lpc_ich_info { · line 50

Quoted 1 line
include/linux/mfd/lpc_ich.h +1 -0
+#endif

...but the name of this function should not be so generic. What if tomorrow you will get one more module which needs one more function?

Moreover this is a part of internal driver interface, I would move this part into special header under drivers/mfd.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

RE: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system

Quoted 55 lines

-----Original Message-----
From: Lee Jones [mailto:[email protected]]
Sent: Tuesday, June 28, 2016 5:15 PM
To: Andy Shevchenko <[email protected]>
Cc: Tan, Jui Nee <[email protected]>; Mika Westerberg <[email protected]>; Krogerus, Heikki <[email protected]>; Andy Shevchenko <[email protected]>; Thomas Gleixner <[email protected]>; Ingo Molnar <[email protected]>; H. Peter Anvin <[email protected]>; [email protected]; [email protected]; Linus Walleij <[email protected]>; [email protected]; linux- [email protected]; Yong, Jonathan <[email protected]>; Yu, Ong Hock <[email protected]>; Voon, Weifeng <[email protected]>; Wan Mohamad, Wan Ahmad Zainie <[email protected]>
Subject: Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system

Quoted 1 line · Andy Shevchenko

On Tue, Jun 28, 2016 at 10:56 AM, Tan Jui Nee <[email protected]>

Quoted 7 lines · wrote:
Quoted 7 lines

This driver uses the P2SB hide/unhide mechanism cooperatively to pass the PCI BAR address to the gpio platform driver.

drivers/mfd/Kconfig +0 -0
@@ -369,8 +369,9 @@ config MFD_INTEL_QUARK_I2C_GPIO
 
Quoted 6 lines

drivers/mfd/Kconfig config MFD_INTEL_QUARK_I2C_GPIO · line 372

Quoted 4 lines
drivers/mfd/Kconfig +1 -1
 config LPC_ICH
        tristate "Intel ICH LPC"
-       depends on PCI
+       depends on X86 && PCI

This might deserve to be a separate change. Lee, what is your opinion?

I have no strong opinion. Keep it in if you like.

[...]

Quoted 3 lines

drivers/mfd/Kconfig obj-$(CONFIG_PMIC_ADP5520) += adp5520.o · line 156

Quoted 3 lines
drivers/mfd/Kconfig +0 -0
@@ -155,7 +155,7 @@ obj-$(CONFIG_PMIC_ADP5520)  += adp5520.o
 obj-$(CONFIG_MFD_KEMPLD)       += kempld-core.o
 obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO) +=

intel_quark_i2c_gpio.o

Quoted 9 lines

drivers/mfd/Kconfig obj-$(CONFIG_PMIC_ADP5520) += adp5520.o · line 160

Quoted 5 lines
drivers/mfd/Kconfig +1 -1
 obj-$(CONFIG_LPC_SCH)          += lpc_sch.o
 
-lpc_ich-objs           := lpc_ich-core.o
+lpc_ich-objs           := lpc_ich-core.o lpc_ich-apl.o
 obj-$(CONFIG_LPC_ICH)          += lpc_ich.o

I don't know if there is any requirement, but what I see in other Makefiles is

Quoted 7 lines
Quoted 2 lines

obj-$(CONFIG_DRV_OPTION) = drv_name.o
drv_name-objs := main.o aux1.o

Yes, this is nicer.

Quoted 1 line

Perhaps you may do the same.

Thanks for your comment. The changes will be applied in next patch-set.

Quoted 26 lines
Quoted 20 lines
Quoted 19 lines
drivers/mfd/Kconfig +18 -0
+++ b/drivers/mfd/lpc_ich-apl.c
@@ -0,0 +1,126 @@
+/*
+ * Purpose: Create a platform device to bind with Intel Apollo Lake
+ * Pinctrl GPIO platform driver
+ * Copyright (C) 2016 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+modify
+ * it under the terms of the GNU General Public License version 2
+as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/mfd/core.h>
+#include <linux/mfd/lpc_ich.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <asm/p2sb.h>
+
Quoted 1 line

drivers/mfd/Kconfig line 18

Quoted 1 line
drivers/mfd/Kconfig +1 -0
+#if defined(CONFIG_X86_INTEL_APL)

I'm not accepting this kind of #ifery in *.c files.

Quoted 2 lines

And why you can't use

Quoted 8 lines
Quoted 5 lines

ifeq ($(CONFIG_...,y))
lpc_ich-objs += ...
endif

in the Makefile?

[...]

Applied with Andy's suggestion and #ifery in *.c files will be removed in next patch-set.

Quoted 45 lines
Quoted 36 lines
Quoted 36 lines
drivers/mfd/Kconfig +36 -0
+int lpc_ich_misc(struct pci_dev *dev) {
+       unsigned int apl_p2sb = PCI_DEVFN(PCI_IDSEL_P2SB, 0);
+       unsigned int i;
+       int ret;
+
+       /*
+        * Apollo lake, has not 1, but 4 gpio controllers,
+        * handle it a bit differently.
+        */
+
+       for (i = 0; i < ARRAY_SIZE(apl_gpio_io_res)-1; i++) {
+               struct resource *res = &apl_gpio_io_res[i];
+
+               apl_gpio_devices[i].resources = res;
+
+               /* Fill MEM resource */
+               ret = p2sb_bar(dev, apl_p2sb, res++);
+               if (ret)
+                       goto warn_continue;
+
+               apl_pinctrl_pdata.name = kasprintf(GFP_KERNEL, "%u",
+                       i + 1);
+       }
+
+       if (apl_pinctrl_pdata.name)
+               ret = mfd_add_devices(&dev->dev, apl_gpio_devices->id,
+                       apl_gpio_devices, ARRAY_SIZE(apl_gpio_devices),
+                               NULL, 0, NULL);
+       else
+               ret = -ENOMEM;
+
+warn_continue:
+       if (ret)
+               dev_warn(&dev->dev,
+                       "Failed to add Apollo Lake GPIO %s: %d\n",
+                               apl_pinctrl_pdata.name, ret);
Quoted 8 lines

drivers/mfd/Kconfig

Quoted 5 lines
drivers/mfd/Kconfig +5 -0
+
+       kfree(apl_pinctrl_pdata.name);
+       return 0;
+}
+#endif

Regarding to the above I don't see Lee's comments addressed. Can you remind whar is the result of that discussion?

Quoted 4 lines

I don't have time to do a full review now, but this does look nasty.

[...]

I would greatly appreciate to have your feedback on that. I have make minor changes, something like below:
...

	for (i = 0; i < ARRAY_SIZE(apl_gpio_io_res)-1; i++) {
		struct resource *res = &apl_gpio_io_res[i];

		apl_gpio_devices[i].resources = res;

		/* Fill MEM resource */
		ret = p2sb_bar(dev, apl_p2sb, res++);
		if (ret)
			goto warn_continue;

		apl_pinctrl_pdata.name = kasprintf(GFP_KERNEL, "%u",
			i + 1);
		if (apl_pinctrl_pdata.name == NULL) {
			ret = -ENOMEM;
			goto warn_continue;
		}
	}

	ret = mfd_add_devices(&dev->dev, 0,
		apl_gpio_devices, ARRAY_SIZE(apl_gpio_devices),
			NULL, 0, NULL);

warn_continue:
...
I have tested this on Intel Apollo Lake platform and it works fine.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
include/linux/mfd/lpc_ich.h +0 -0
@@ -43,4 +43,11 @@ struct lpc_ich_info {
        u8 use_gpio;
 };
Quoted 8 lines
Quoted 5 lines

include/linux/mfd/lpc_ich.h struct lpc_ich_info { · line 47

Quoted 3 lines
include/linux/mfd/lpc_ich.h +3 -0
+#if defined(CONFIG_X86_INTEL_APL)
+int lpc_ich_misc(struct pci_dev *dev); #else static inline int
+lpc_ich_misc(struct pci_dev *dev) { return -ENODEV; }

It could be one line, ...

I don't want it in here at all.

lpc_ich_misc() function will be moved from .../include/linux/mfd/lpc_ich.h to .../drivers/mfd/lpc_ich-apl.h.
lpc_ich-apl.h is a newly created file, which is something like this:

	#if IS_ENABLED(CONFIG_X86_INTEL_IVI)
	int lpc_ich_apl_gpio(struct pci_dev *dev, enum lpc_chipsets chipset);
	#else /* CONFIG_X86_INTEL_IVI is not set */
	static inline int lpc_ich_apl_gpio(struct pci_dev *dev, enum lpc_chipsets chipset)
	{
		return -ENODEV;
	}
	#endif

Is this acceptable?

Quoted 5 lines
Quoted 5 lines

include/linux/mfd/lpc_ich.h struct lpc_ich_info { · line 48

Quoted 1 line
include/linux/mfd/lpc_ich.h +1 -0
+#endif

...but the name of this function should not be so generic. What if tomorrow you will get one more module which needs one more function?

Rename lpc_ich_misc() to lpc_ich_apl_gpio().

Quoted 4 lines
Quoted 3 lines

Moreover this is a part of internal driver interface, I would move this part into special header under drivers/mfd.

Thanks for pointing that out.
The function lpc_ich_misc() will be renamed to lpc_ich_apl_gpio() in next patch-set.

Quoted 4 lines

--
Lee Jones

Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source
software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
#6 lore raw

RE: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system

In reply to Mika Westerberg
Quoted 32 lines

-----Original Message-----
From: Mika Westerberg [mailto:[email protected]]
Sent: Tuesday, June 28, 2016 4:19 PM
To: Tan, Jui Nee <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; Yong, Jonathan <[email protected]>; Yu, Ong Hock <[email protected]>; Voon, Weifeng <[email protected]>; Wan Mohamad, Wan Ahmad Zainie <[email protected]>
Subject: Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system

arch/x86/Kconfig config X86_GOLDFISH

Quoted 7 lines · Tan Jui Nee
arch/x86/Kconfig +7 -0
+config X86_INTEL_APL
+	bool "Non-ACPI support for Intel Apollo Lake platforms"
+	select PINCTRL
+	---help---
+	  Select this option to enable MMIO BAR access over the P2SB for
+	  non-ACPI Intel Apollo Lake SoC platforms. This driver uses the P2SB
+	  hide/unhide mechanism cooperatively to pass the PCI BAR address

to

arch/x86/Kconfig config X86_GOLDFISH · line 509

Quoted 2 lines
arch/x86/Kconfig +2 -0
+	  the platform driver, currently GPIO.
+

Sorry but IMHO this still does not explain the option clearly enough. You are using this in some automotive IVI system with specialized bootloader, correct? Why not use that here instead?

Quoted 4 lines

Something along the lines of

config X86_INTEL_IVI
bool "Intel in-vehicle infotainment (IVI) systems used in cars"

Thanks for your comments. The changes will be applied in next patch-set.