forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mtd: spi-nor / spi / MFD: Convert intel-spi to SPI MEM
Merge series from Mika Westerberg <[email protected]>: Based on discussion on the patch I sent some time ago here: http://lists.infradead.org/pipermail/linux-mtd/2021-June/086867.html it turns out that the preferred way to deal with the SPI flash controller drivers is through SPI MEM which is part of Linux SPI subsystem. This series does that for the intel-spi driver. This also renames the driver to follow the convention used in the SPI subsystem. The first patch improves the write protection handling to be slightly more safer. The following two patches do the conversion itself. Note the Intel SPI flash controller only allows commands such as read, write and so on and it internally uses whatever addressing etc. it figured from the SFDP on the flash device. base-commit: e783362
- Loading branch information
Showing
14 changed files
with
719 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ Memory Technology Device (MTD) | |
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
intel-spi | ||
spi-intel | ||
nand_ecc | ||
spi-nor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,34 +2,48 @@ | |
/* | ||
* 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) | ||
|
||
static bool intel_spi_pci_set_writeable(void __iomem *base, void *data) | ||
{ | ||
struct pci_dev *pdev = data; | ||
u32 bcr; | ||
|
||
/* Try to make the chip read/write */ | ||
pci_read_config_dword(pdev, BCR, &bcr); | ||
if (!(bcr & BCR_WPD)) { | ||
bcr |= BCR_WPD; | ||
pci_write_config_dword(pdev, BCR, bcr); | ||
pci_read_config_dword(pdev, BCR, &bcr); | ||
} | ||
|
||
return bcr & BCR_WPD; | ||
} | ||
|
||
static const struct intel_spi_boardinfo bxt_info = { | ||
.type = INTEL_SPI_BXT, | ||
.set_writeable = intel_spi_pci_set_writeable, | ||
}; | ||
|
||
static const struct intel_spi_boardinfo cnl_info = { | ||
.type = INTEL_SPI_CNL, | ||
.set_writeable = intel_spi_pci_set_writeable, | ||
}; | ||
|
||
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; | ||
u32 bcr; | ||
int ret; | ||
|
||
ret = pcim_enable_device(pdev); | ||
|
@@ -41,26 +55,8 @@ static int intel_spi_pci_probe(struct pci_dev *pdev, | |
if (!info) | ||
return -ENOMEM; | ||
|
||
/* Try to make the chip read/write */ | ||
pci_read_config_dword(pdev, BCR, &bcr); | ||
if (!(bcr & BCR_WPD)) { | ||
bcr |= BCR_WPD; | ||
pci_write_config_dword(pdev, BCR, bcr); | ||
pci_read_config_dword(pdev, BCR, &bcr); | ||
} | ||
info->writeable = !!(bcr & BCR_WPD); | ||
|
||
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)); | ||
info->data = pdev; | ||
return intel_spi_probe(&pdev->dev, &pdev->resource[0], info); | ||
} | ||
|
||
static const struct pci_device_id intel_spi_pci_ids[] = { | ||
|
@@ -89,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); | ||
|
Oops, something went wrong.