Skip to content

Commit a52329a

Browse files
author
Boris Brezillon
committed
Merge tag 'spi-nor/for-4.14' of git://git.infradead.org/l2-mtd into mtd/next
From Cyrille: " This pull request contains the following notable changes: - add support to the JEDEC JESD216B specification (SFDP tables). - add support to the Intel Denverton SPI flash controller. - fix error recovery for Spansion/Cypress SPI NOR memories. - fix 4-byte address management for the Aspeed SPI controller. - add support to some Microchip SST26 memory parts - remove unneeded pinctrl header "
2 parents 5ffa70b + 18f7ce2 commit a52329a

8 files changed

Lines changed: 901 additions & 31 deletions

File tree

‎drivers/mtd/spi-nor/Kconfig‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ config SPI_NXP_SPIFI
8989
config SPI_INTEL_SPI
9090
tristate
9191

92+
config SPI_INTEL_SPI_PCI
93+
tristate "Intel PCH/PCU SPI flash PCI driver" if EXPERT
94+
depends on X86 && PCI
95+
select SPI_INTEL_SPI
96+
help
97+
This enables PCI support for the Intel PCH/PCU SPI controller in
98+
master mode. This controller is present in modern Intel hardware
99+
and is used to hold BIOS and other persistent settings. Using
100+
this driver it is possible to upgrade BIOS directly from Linux.
101+
102+
Say N here unless you know what you are doing. Overwriting the
103+
SPI flash may render the system unbootable.
104+
105+
To compile this driver as a module, choose M here: the module
106+
will be called intel-spi-pci.
107+
92108
config SPI_INTEL_SPI_PLATFORM
93109
tristate "Intel PCH/PCU SPI flash platform driver" if EXPERT
94110
depends on X86

‎drivers/mtd/spi-nor/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ obj-$(CONFIG_SPI_HISI_SFC) += hisi-sfc.o
77
obj-$(CONFIG_MTD_MT81xx_NOR) += mtk-quadspi.o
88
obj-$(CONFIG_SPI_NXP_SPIFI) += nxp-spifi.o
99
obj-$(CONFIG_SPI_INTEL_SPI) += intel-spi.o
10+
obj-$(CONFIG_SPI_INTEL_SPI_PCI) += intel-spi-pci.o
1011
obj-$(CONFIG_SPI_INTEL_SPI_PLATFORM) += intel-spi-platform.o
11-
obj-$(CONFIG_SPI_STM32_QUADSPI) += stm32-quadspi.o
12+
obj-$(CONFIG_SPI_STM32_QUADSPI) += stm32-quadspi.o

‎drivers/mtd/spi-nor/aspeed-smc.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -621,19 +621,18 @@ static void aspeed_smc_chip_set_type(struct aspeed_smc_chip *chip, int type)
621621
}
622622

623623
/*
624-
* The AST2500 FMC flash controller should be strapped by hardware, or
625-
* autodetected, but the AST2500 SPI flash needs to be set.
624+
* The first chip of the AST2500 FMC flash controller is strapped by
625+
* hardware, or autodetected, but other chips need to be set. Enforce
626+
* the 4B setting for all chips.
626627
*/
627628
static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip)
628629
{
629630
struct aspeed_smc_controller *controller = chip->controller;
630631
u32 reg;
631632

632-
if (chip->controller->info == &spi_2500_info) {
633-
reg = readl(controller->regs + CE_CONTROL_REG);
634-
reg |= 1 << chip->cs;
635-
writel(reg, controller->regs + CE_CONTROL_REG);
636-
}
633+
reg = readl(controller->regs + CE_CONTROL_REG);
634+
reg |= 1 << chip->cs;
635+
writel(reg, controller->regs + CE_CONTROL_REG);
637636
}
638637

639638
/*

‎drivers/mtd/spi-nor/atmel-quadspi.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
#include <linux/io.h>
3737
#include <linux/gpio.h>
38-
#include <linux/pinctrl/consumer.h>
3938

4039
/* QSPI register offsets */
4140
#define QSPI_CR 0x0000 /* Control Register */
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Intel PCH/PCU SPI flash PCI driver.
3+
*
4+
* Copyright (C) 2016, Intel Corporation
5+
* Author: Mika Westerberg <mika.westerberg@linux.intel.com>
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License version 2 as
9+
* published by the Free Software Foundation.
10+
*/
11+
12+
#include <linux/ioport.h>
13+
#include <linux/kernel.h>
14+
#include <linux/module.h>
15+
#include <linux/pci.h>
16+
17+
#include "intel-spi.h"
18+
19+
#define BCR 0xdc
20+
#define BCR_WPD BIT(0)
21+
22+
static const struct intel_spi_boardinfo bxt_info = {
23+
.type = INTEL_SPI_BXT,
24+
};
25+
26+
static int intel_spi_pci_probe(struct pci_dev *pdev,
27+
const struct pci_device_id *id)
28+
{
29+
struct intel_spi_boardinfo *info;
30+
struct intel_spi *ispi;
31+
u32 bcr;
32+
int ret;
33+
34+
ret = pcim_enable_device(pdev);
35+
if (ret)
36+
return ret;
37+
38+
info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info),
39+
GFP_KERNEL);
40+
if (!info)
41+
return -ENOMEM;
42+
43+
/* Try to make the chip read/write */
44+
pci_read_config_dword(pdev, BCR, &bcr);
45+
if (!(bcr & BCR_WPD)) {
46+
bcr |= BCR_WPD;
47+
pci_write_config_dword(pdev, BCR, bcr);
48+
pci_read_config_dword(pdev, BCR, &bcr);
49+
}
50+
info->writeable = !!(bcr & BCR_WPD);
51+
52+
ispi = intel_spi_probe(&pdev->dev, &pdev->resource[0], info);
53+
if (IS_ERR(ispi))
54+
return PTR_ERR(ispi);
55+
56+
pci_set_drvdata(pdev, ispi);
57+
return 0;
58+
}
59+
60+
static void intel_spi_pci_remove(struct pci_dev *pdev)
61+
{
62+
intel_spi_remove(pci_get_drvdata(pdev));
63+
}
64+
65+
static const struct pci_device_id intel_spi_pci_ids[] = {
66+
{ PCI_VDEVICE(INTEL, 0x19e0), (unsigned long)&bxt_info },
67+
{ },
68+
};
69+
MODULE_DEVICE_TABLE(pci, intel_spi_pci_ids);
70+
71+
static struct pci_driver intel_spi_pci_driver = {
72+
.name = "intel-spi",
73+
.id_table = intel_spi_pci_ids,
74+
.probe = intel_spi_pci_probe,
75+
.remove = intel_spi_pci_remove,
76+
};
77+
78+
module_pci_driver(intel_spi_pci_driver);
79+
80+
MODULE_DESCRIPTION("Intel PCH/PCU SPI flash PCI driver");
81+
MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
82+
MODULE_LICENSE("GPL v2");

‎drivers/mtd/spi-nor/mtk-quadspi.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <linux/mutex.h>
2525
#include <linux/of.h>
2626
#include <linux/of_device.h>
27-
#include <linux/pinctrl/consumer.h>
2827
#include <linux/platform_device.h>
2928
#include <linux/slab.h>
3029
#include <linux/mtd/mtd.h>

0 commit comments

Comments
 (0)