Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1432599 > unrolled thread
| Started by | Tan Jui Nee <jui.nee.tan@intel.com> |
|---|---|
| First post | 2016-06-28 10:00 +0200 |
| Last post | 2016-06-28 10:30 +0200 |
| Articles | 8 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH v5 0/3] pinctrl/broxton: enable platform device in the absent of ACPI enumeration Tan Jui Nee <jui.nee.tan@intel.com> - 2016-06-28 10:00 +0200
[PATCH v5 1/3] x86/platform/p2sb: New Primary to Sideband bridge support driver for Intel SOC's Tan Jui Nee <jui.nee.tan@intel.com> - 2016-06-28 10:00 +0200
[PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system Tan Jui Nee <jui.nee.tan@intel.com> - 2016-06-28 10:00 +0200
Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system Mika Westerberg <mika.westerberg@linux.intel.com> - 2016-06-28 10:20 +0200
Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-06-28 11:00 +0200
Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system Lee Jones <lee.jones@linaro.org> - 2016-06-28 11:20 +0200
Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system kbuild test robot <lkp@intel.com> - 2016-06-28 11:00 +0200
Re: [PATCH v5 2/3] mfd: lpc_ich: Prepare to split lpc-ich driver Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-06-28 10:30 +0200
| From | Tan Jui Nee <jui.nee.tan@intel.com> |
|---|---|
| Date | 2016-06-28 10:00 +0200 |
| Subject | [PATCH v5 0/3] pinctrl/broxton: enable platform device in the absent of ACPI enumeration |
| Message-ID | <rOW66-3XK-27@gated-at.bofh.it> |
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
--
1.9.1
[toc] | [next] | [standalone]
| From | Tan Jui Nee <jui.nee.tan@intel.com> |
|---|---|
| Date | 2016-06-28 10:00 +0200 |
| Subject | [PATCH v5 1/3] x86/platform/p2sb: New Primary to Sideband bridge support driver for Intel SOC's |
| Message-ID | <rOW66-3XK-29@gated-at.bofh.it> |
| In reply to | #1432599 |
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
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.
Signed-off-by: Yong, Jonathan <jonathan.yong@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
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
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d9a94da..d305d81 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -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
diff --git a/arch/x86/include/asm/p2sb.h b/arch/x86/include/asm/p2sb.h
new file mode 100644
index 0000000..686e07b
--- /dev/null
+++ b/arch/x86/include/asm/p2sb.h
@@ -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 */
diff --git a/arch/x86/platform/intel/Makefile b/arch/x86/platform/intel/Makefile
index b878032..dbf9f10 100644
--- a/arch/x86/platform/intel/Makefile
+++ b/arch/x86/platform/intel/Makefile
@@ -1 +1,2 @@
obj-$(CONFIG_IOSF_MBI) += iosf_mbi.o
+obj-$(CONFIG_P2SB) += p2sb.o
diff --git a/arch/x86/platform/intel/p2sb.c b/arch/x86/platform/intel/p2sb.c
new file mode 100644
index 0000000..8be47a4
--- /dev/null
+++ b/arch/x86/platform/intel/p2sb.c
@@ -0,0 +1,99 @@
+/*
+ * Primary to Sideband bridge (P2SB) driver
+ *
+ * Copyright (c) 2016, Intel Corporation.
+ *
+ * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+ * Jonathan Yong <jonathan.yong@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#include <linux/ioport.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/spinlock.h>
+
+#include <asm/p2sb.h>
+
+#define SBREG_BAR 0x10
+#define SBREG_HIDE 0xe1
+
+static DEFINE_SPINLOCK(p2sb_spinlock);
+
+/*
+ * p2sb_bar - Get Primary to Sideband bridge (P2SB) BAR
+ * @pdev: PCI device to get PCI bus to communicate with
+ * @devfn: PCI device and function to communicate with
+ * @res: resources 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 P2SB BAR.
+ *
+ * Locking is handled by spinlock - cannot sleep.
+ *
+ * Return:
+ * 0 on success or appropriate errno value on error.
+ */
+int p2sb_bar(struct pci_dev *pdev, unsigned int devfn,
+ struct resource *res)
+{
+ u32 base_addr;
+ u64 base64_addr;
+ unsigned long flags;
+
+ if (!res)
+ return -EINVAL;
+
+ spin_lock(&p2sb_spinlock);
+
+ /* Unhide the P2SB device */
+ pci_bus_write_config_byte(pdev->bus, devfn, SBREG_HIDE, 0x00);
+
+ /* Check if device present */
+ pci_bus_read_config_dword(pdev->bus, devfn, 0, &base_addr);
+ if (base_addr == 0xffffffff || base_addr == 0x00000000) {
+ spin_unlock(&p2sb_spinlock);
+ dev_warn(&pdev->dev, "P2SB device access disabled by BIOS?\n");
+ return -ENODEV;
+ }
+
+ /* Get IO or MMIO BAR */
+ pci_bus_read_config_dword(pdev->bus, devfn, SBREG_BAR, &base_addr);
+ if ((base_addr & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) {
+ flags = IORESOURCE_IO;
+ base64_addr = base_addr & PCI_BASE_ADDRESS_IO_MASK;
+ } else {
+ flags = IORESOURCE_MEM;
+ base64_addr = base_addr & PCI_BASE_ADDRESS_MEM_MASK;
+ if (base_addr & PCI_BASE_ADDRESS_MEM_TYPE_64) {
+ flags |= IORESOURCE_MEM_64;
+ pci_bus_read_config_dword(pdev->bus, devfn,
+ SBREG_BAR + 4, &base_addr);
+ base64_addr |= (u64)base_addr << 32;
+ }
+ }
+
+ /* Hide the P2SB device */
+ pci_bus_write_config_byte(pdev->bus, devfn, SBREG_HIDE, 0x01);
+
+ spin_unlock(&p2sb_spinlock);
+
+ /* User provides prefilled resources */
+ res->start += (resource_size_t)base64_addr;
+ res->end += (resource_size_t)base64_addr;
+ res->flags = flags;
+
+ return 0;
+}
+EXPORT_SYMBOL(p2sb_bar);
+
+MODULE_LICENSE("GPL");
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Tan Jui Nee <jui.nee.tan@intel.com> |
|---|---|
| Date | 2016-06-28 10:00 +0200 |
| Subject | [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system |
| Message-ID | <rOW66-3XK-41@gated-at.bofh.it> |
| In reply to | #1432599 |
This driver uses the P2SB hide/unhide mechanism cooperatively
to pass the PCI BAR address to the gpio platform driver.
Signed-off-by: Tan Jui Nee <jui.nee.tan@intel.com>
---
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
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d305d81..e1865c7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -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
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 1bcf601..dc4e543 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -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
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 1dfe5fb..7572c1f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -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
diff --git a/drivers/mfd/lpc_ich-apl.c b/drivers/mfd/lpc_ich-apl.c
new file mode 100644
index 0000000..544e83a
--- /dev/null
+++ 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)
+/* 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;
+
+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
diff --git a/drivers/mfd/lpc_ich-core.c b/drivers/mfd/lpc_ich-core.c
index bd3aa45..1e957d4 100644
--- a/drivers/mfd/lpc_ich-core.c
+++ b/drivers/mfd/lpc_ich-core.c
@@ -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.
diff --git a/include/linux/mfd/lpc_ich.h b/include/linux/mfd/lpc_ich.h
index 2b300b4..c5d0adc 100644
--- a/include/linux/mfd/lpc_ich.h
+++ b/include/linux/mfd/lpc_ich.h
@@ -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
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Mika Westerberg <mika.westerberg@linux.intel.com> |
|---|---|
| Date | 2016-06-28 10:20 +0200 |
| Subject | Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system |
| Message-ID | <rOWpr-4kK-13@gated-at.bofh.it> |
| In reply to | #1432602 |
On Tue, Jun 28, 2016 at 03:56:48PM +0800, Tan Jui Nee wrote:
> +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"
[toc] | [prev] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2016-06-28 11:00 +0200 |
| Subject | Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system |
| Message-ID | <rOX2a-4Ab-13@gated-at.bofh.it> |
| In reply to | #1432602 |
On Tue, Jun 28, 2016 at 10:56 AM, Tan Jui Nee <jui.nee.tan@intel.com> wrote:
> This driver uses the P2SB hide/unhide mechanism cooperatively
> to pass the PCI BAR address to the gpio platform driver.
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -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?
> select MFD_CORE
> + select P2SB
This is okay
> @@ -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.
> +++ 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)
And why you can't use
ifeq ($(CONFIG_...,y))
lpc_ich-objs += ...
endif
in the Makefile?
> +/* 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;
> +
> +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?
> + 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.
> --- a/include/linux/mfd/lpc_ich.h
> +++ b/include/linux/mfd/lpc_ich.h
> @@ -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, ...
> +#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.
--
With Best Regards,
Andy Shevchenko
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2016-06-28 11:20 +0200 |
| Subject | Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system |
| Message-ID | <rOXlw-4Xa-9@gated-at.bofh.it> |
| In reply to | #1432655 |
On Tue, 28 Jun 2016, Andy Shevchenko wrote:
> On Tue, Jun 28, 2016 at 10:56 AM, Tan Jui Nee <jui.nee.tan@intel.com> wrote:
> > This driver uses the P2SB hide/unhide mechanism cooperatively
> > to pass the PCI BAR address to the gpio platform driver.
>
> > --- a/drivers/mfd/Kconfig
> > +++ b/drivers/mfd/Kconfig
> > @@ -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?
I have no strong opinion. Keep it in if you like.
[...]
> > @@ -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
Yes, this is nicer.
> Perhaps you may do the same.
> > +++ 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.
> And why you can't use
>
> ifeq ($(CONFIG_...,y))
> lpc_ich-objs += ...
> endif
>
> in the Makefile?
[...]
> > +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);
> > +
> > + 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.
[...]
> > --- a/include/linux/mfd/lpc_ich.h
> > +++ b/include/linux/mfd/lpc_ich.h
> > @@ -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, ...
I don't want it in here at all.
> > +#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.
>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
[toc] | [prev] | [next] | [standalone]
| From | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2016-06-28 11:00 +0200 |
| Subject | Re: [PATCH v5 3/3] mfd: lpc_ich: Add support for Intel Apollo Lake GPIO pinctrl in non-ACPI system |
| Message-ID | <rOX2a-4Ab-37@gated-at.bofh.it> |
| In reply to | #1432602 |
[Multipart message — attachments visible in raw view] — view raw
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
[toc] | [prev] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2016-06-28 10:30 +0200 |
| Subject | Re: [PATCH v5 2/3] mfd: lpc_ich: Prepare to split lpc-ich driver |
| Message-ID | <rOWz8-4op-19@gated-at.bofh.it> |
| In reply to | #1432599 |
On Tue, Jun 28, 2016 at 10:56 AM, Tan Jui Nee <jui.nee.tan@intel.com> wrote: > 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. > > Signed-off-by: Tan Jui Nee <jui.nee.tan@intel.com> > --- > 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. -- With Best Regards, Andy Shevchenko
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web