Skip to content

Commit

Permalink
mtd: spi-nor: intel-spi: Convert to SPI MEM
Browse files Browse the repository at this point in the history
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: Mika Westerberg <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Mauro Lima <[email protected]>
Reviewed-by: Boris Brezillon <[email protected]>
Acked-by: Lee Jones <[email protected]>
Acked-by: Pratyush Yadav <[email protected]>
Reviewed-by: Tudor Ambarus <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
westeri authored and broonie committed Feb 14, 2022
1 parent cd149ef commit e23e5a0
Show file tree
Hide file tree
Showing 11 changed files with 628 additions and 371 deletions.
36 changes: 0 additions & 36 deletions drivers/mtd/spi-nor/controllers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 0 additions & 3 deletions drivers/mtd/spi-nor/controllers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 0 additions & 21 deletions drivers/mtd/spi-nor/controllers/intel-spi.h

This file was deleted.

39 changes: 39 additions & 0 deletions drivers/spi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions drivers/spi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*/

#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)
Expand Down Expand Up @@ -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);
Expand All @@ -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[] = {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,30 @@
/*
* Intel PCH/PCU SPI flash platform driver.
*
* Copyright (C) 2016, Intel Corporation
* Copyright (C) 2016 - 2022, Intel Corporation
* Author: Mika Westerberg <[email protected]>
*/

#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/platform_device.h>

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

static int intel_spi_platform_probe(struct platform_device *pdev)
{
struct intel_spi_boardinfo *info;
struct intel_spi *ispi;
struct resource *mem;

info = dev_get_platdata(&pdev->dev);
if (!info)
return -EINVAL;

mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ispi = intel_spi_probe(&pdev->dev, mem, info);
if (IS_ERR(ispi))
return PTR_ERR(ispi);

platform_set_drvdata(pdev, ispi);
return 0;
}

static int intel_spi_platform_remove(struct platform_device *pdev)
{
struct intel_spi *ispi = platform_get_drvdata(pdev);

return intel_spi_remove(ispi);
return intel_spi_probe(&pdev->dev, mem, info);
}

static struct platform_driver intel_spi_platform_driver = {
.probe = intel_spi_platform_probe,
.remove = intel_spi_platform_remove,
.driver = {
.name = "intel-spi",
},
Expand Down
Loading

0 comments on commit e23e5a0

Please sign in to comment.