Unverified Commit e23e5a05 authored by Mika Westerberg's avatar Mika Westerberg Committed by Mark Brown
Browse files

mtd: spi-nor: intel-spi: Convert to SPI MEM



The preferred way to implement SPI-NOR controller drivers is through SPI
subsubsystem utilizing the SPI MEM core functions. This converts the
Intel SPI flash controller driver over the SPI MEM by moving the driver
from SPI-NOR subsystem to SPI subsystem and in one go make it use the
SPI MEM functions. The driver name will be changed from intel-spi to
spi-intel to match the convention used in the SPI subsystem.

Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarMauro Lima <mauro.lima@eclypsium.com>
Reviewed-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Acked-by: default avatarLee Jones <lee.jones@linaro.org>
Acked-by: default avatarPratyush Yadav <p.yadav@ti.com>
Reviewed-by: default avatarTudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20220209122706.42439-3-mika.westerberg@linux.intel.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent cd149eff
Loading
Loading
Loading
Loading
+0 −36
Original line number Diff line number Diff line
@@ -26,39 +26,3 @@ config SPI_NXP_SPIFI
	  SPIFI is a specialized controller for connecting serial SPI
	  Flash. Enable this option if you have a device with a SPIFI
	  controller and want to access the Flash as a mtd device.

config SPI_INTEL_SPI
	tristate

config SPI_INTEL_SPI_PCI
	tristate "Intel PCH/PCU SPI flash PCI driver (DANGEROUS)"
	depends on X86 && PCI
	select SPI_INTEL_SPI
	help
	  This enables PCI support for the Intel PCH/PCU SPI controller in
	  master mode. This controller is present in modern Intel hardware
	  and is used to hold BIOS and other persistent settings. Using
	  this driver it is possible to upgrade BIOS directly from Linux.

	  Say N here unless you know what you are doing. Overwriting the
	  SPI flash may render the system unbootable.

	  To compile this driver as a module, choose M here: the module
	  will be called intel-spi-pci.

config SPI_INTEL_SPI_PLATFORM
	tristate "Intel PCH/PCU SPI flash platform driver (DANGEROUS)"
	depends on X86
	select SPI_INTEL_SPI
	help
	  This enables platform support for the Intel PCH/PCU SPI
	  controller in master mode. This controller is present in modern
	  Intel hardware and is used to hold BIOS and other persistent
	  settings. Using this driver it is possible to upgrade BIOS
	  directly from Linux.

	  Say N here unless you know what you are doing. Overwriting the
	  SPI flash may render the system unbootable.

	  To compile this driver as a module, choose M here: the module
	  will be called intel-spi-platform.
+0 −3
Original line number Diff line number Diff line
@@ -2,6 +2,3 @@
obj-$(CONFIG_SPI_ASPEED_SMC)	+= aspeed-smc.o
obj-$(CONFIG_SPI_HISI_SFC)	+= hisi-sfc.o
obj-$(CONFIG_SPI_NXP_SPIFI)	+= nxp-spifi.o
obj-$(CONFIG_SPI_INTEL_SPI)	+= intel-spi.o
obj-$(CONFIG_SPI_INTEL_SPI_PCI)	+= intel-spi-pci.o
obj-$(CONFIG_SPI_INTEL_SPI_PLATFORM)	+= intel-spi-platform.o
+39 −0
Original line number Diff line number Diff line
@@ -427,6 +427,45 @@ config SPI_INGENIC
	  To compile this driver as a module, choose M here: the module
	  will be called spi-ingenic.

config SPI_INTEL
	tristate

config SPI_INTEL_PCI
	tristate "Intel PCH/PCU SPI flash PCI driver (DANGEROUS)"
	depends on PCI
	depends on X86 || COMPILE_TEST
	depends on SPI_MEM
	select SPI_INTEL
	help
	  This enables PCI support for the Intel PCH/PCU SPI controller in
	  master mode. This controller is present in modern Intel hardware
	  and is used to hold BIOS and other persistent settings. Using
	  this driver it is possible to upgrade BIOS directly from Linux.

	  Say N here unless you know what you are doing. Overwriting the
	  SPI flash may render the system unbootable.

	  To compile this driver as a module, choose M here: the module
	  will be called spi-intel-pci.

config SPI_INTEL_PLATFORM
	tristate "Intel PCH/PCU SPI flash platform driver (DANGEROUS)"
	depends on X86 || COMPILE_TEST
	depends on SPI_MEM
	select SPI_INTEL
	help
	  This enables platform support for the Intel PCH/PCU SPI
	  controller in master mode. This controller is present in modern
	  Intel hardware and is used to hold BIOS and other persistent
	  settings. Using this driver it is possible to upgrade BIOS
	  directly from Linux.

	  Say N here unless you know what you are doing. Overwriting the
	  SPI flash may render the system unbootable.

	  To compile this driver as a module, choose M here: the module
	  will be called spi-intel-platform.

config SPI_JCORE
	tristate "J-Core SPI Master"
	depends on OF && (SUPERH || COMPILE_TEST)
+3 −0
Original line number Diff line number Diff line
@@ -61,6 +61,9 @@ obj-$(CONFIG_SPI_HISI_SFC_V3XX) += spi-hisi-sfc-v3xx.o
obj-$(CONFIG_SPI_IMG_SPFI)		+= spi-img-spfi.o
obj-$(CONFIG_SPI_IMX)			+= spi-imx.o
obj-$(CONFIG_SPI_INGENIC)		+= spi-ingenic.o
obj-$(CONFIG_SPI_INTEL)			+= spi-intel.o
obj-$(CONFIG_SPI_INTEL_PCI)		+= spi-intel-pci.o
obj-$(CONFIG_SPI_INTEL_PLATFORM)	+= spi-intel-platform.o
obj-$(CONFIG_SPI_LANTIQ_SSC)		+= spi-lantiq-ssc.o
obj-$(CONFIG_SPI_JCORE)			+= spi-jcore.o
obj-$(CONFIG_SPI_LM70_LLP)		+= spi-lm70llp.o
+3 −17
Original line number Diff line number Diff line
@@ -2,16 +2,14 @@
/*
 * Intel PCH/PCU SPI flash PCI driver.
 *
 * Copyright (C) 2016, Intel Corporation
 * Copyright (C) 2016 - 2022, Intel Corporation
 * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
 */

#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>

#include "intel-spi.h"
#include "spi-intel.h"

#define BCR		0xdc
#define BCR_WPD		BIT(0)
@@ -46,7 +44,6 @@ static int intel_spi_pci_probe(struct pci_dev *pdev,
			       const struct pci_device_id *id)
{
	struct intel_spi_boardinfo *info;
	struct intel_spi *ispi;
	int ret;

	ret = pcim_enable_device(pdev);
@@ -59,17 +56,7 @@ static int intel_spi_pci_probe(struct pci_dev *pdev,
		return -ENOMEM;

	info->data = pdev;
	ispi = intel_spi_probe(&pdev->dev, &pdev->resource[0], info);
	if (IS_ERR(ispi))
		return PTR_ERR(ispi);

	pci_set_drvdata(pdev, ispi);
	return 0;
}

static void intel_spi_pci_remove(struct pci_dev *pdev)
{
	intel_spi_remove(pci_get_drvdata(pdev));
	return intel_spi_probe(&pdev->dev, &pdev->resource[0], info);
}

static const struct pci_device_id intel_spi_pci_ids[] = {
@@ -98,7 +85,6 @@ static struct pci_driver intel_spi_pci_driver = {
	.name = "intel-spi",
	.id_table = intel_spi_pci_ids,
	.probe = intel_spi_pci_probe,
	.remove = intel_spi_pci_remove,
};

module_pci_driver(intel_spi_pci_driver);
Loading