Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Add support for Microchip CoreSPI Controller

Merge series from Prajna Rajendra Kumar <prajna.rajendrakumar@microchip.com>:

This patch series adds support for the Microchip FPGA CoreSPI "soft" IP
and documents its device tree bindings.

As preparation, the existing Microchip SPI driver is renamed to clearly
indicate that it supports only the Microchip PolarFire SoC "hard" controller.
Although it was originally named with the expectation that it might also
cover the FPGA CoreSPI "soft" IP, the register layouts differ significantly,
so separate drivers are required.

+635 -115
+68 -2
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml
··· 21 21 - microchip,mpfs-qspi 22 22 - microchip,pic64gx-qspi 23 23 - const: microchip,coreqspi-rtl-v2 24 - - const: microchip,coreqspi-rtl-v2 # FPGA QSPI 24 + - enum: 25 + - microchip,coreqspi-rtl-v2 # FPGA QSPI 26 + - microchip,corespi-rtl-v5 # FPGA CoreSPI 27 + - microchip,mpfs-spi 25 28 - items: 26 29 - const: microchip,pic64gx-spi 27 30 - const: microchip,mpfs-spi 28 - - const: microchip,mpfs-spi 29 31 30 32 reg: 31 33 maxItems: 1 ··· 40 38 41 39 clocks: 42 40 maxItems: 1 41 + 42 + microchip,apb-datawidth: 43 + description: APB bus data width in bits. 44 + $ref: /schemas/types.yaml#/definitions/uint32 45 + enum: [8, 16, 32] 46 + default: 8 47 + 48 + microchip,frame-size: 49 + description: | 50 + Number of bits per SPI frame, as configured in Libero. 51 + In Motorola and TI modes, this corresponds directly 52 + to the requested frame size. For NSC mode this is set 53 + to 9 + the required data frame size. 54 + $ref: /schemas/types.yaml#/definitions/uint32 55 + minimum: 4 56 + maximum: 32 57 + default: 8 58 + 59 + microchip,protocol-configuration: 60 + description: CoreSPI protocol selection. Determines operating mode 61 + $ref: /schemas/types.yaml#/definitions/string 62 + enum: 63 + - motorola 64 + - ti 65 + - nsc 66 + default: motorola 67 + 68 + microchip,motorola-mode: 69 + description: Motorola SPI mode selection 70 + $ref: /schemas/types.yaml#/definitions/uint32 71 + enum: [0, 1, 2, 3] 72 + default: 3 73 + 74 + microchip,ssel-active: 75 + description: | 76 + Keep SSEL asserted between frames when using the Motorola protocol. 77 + When present, the controller keeps SSEL active across contiguous 78 + transfers and deasserts only when the overall transfer completes. 79 + type: boolean 43 80 44 81 required: 45 82 - compatible ··· 111 70 properties: 112 71 num-cs: 113 72 maximum: 1 73 + 74 + - if: 75 + properties: 76 + compatible: 77 + contains: 78 + const: microchip,corespi-rtl-v5 79 + then: 80 + properties: 81 + num-cs: 82 + minimum: 1 83 + maximum: 8 84 + default: 8 85 + 86 + fifo-depth: 87 + minimum: 1 88 + maximum: 32 89 + default: 4 90 + 91 + else: 92 + properties: 93 + microchip,apb-datawidth: false 94 + microchip,frame-size: false 95 + microchip,protocol-configuration: false 96 + microchip,motorola-mode: false 97 + microchip,ssel-active: false 114 98 115 99 unevaluatedProperties: false 116 100
+19 -9
drivers/spi/Kconfig
··· 707 707 This enables master mode support for the SPIFC (SPI flash 708 708 controller) available in Amlogic Meson SoCs. 709 709 710 - config SPI_MICROCHIP_CORE 711 - tristate "Microchip FPGA SPI controllers" 712 - depends on SPI_MASTER 713 - help 714 - This enables the SPI driver for Microchip FPGA SPI controllers. 715 - Say Y or M here if you want to use the "hard" controllers on 716 - PolarFire SoC. 717 - If built as a module, it will be called spi-microchip-core. 718 - 719 710 config SPI_MICROCHIP_CORE_QSPI 720 711 tristate "Microchip FPGA QSPI controllers" 721 712 depends on SPI_MASTER ··· 715 724 Say Y or M here if you want to use the QSPI controllers on 716 725 PolarFire SoC. 717 726 If built as a module, it will be called spi-microchip-core-qspi. 727 + 728 + config SPI_MICROCHIP_CORE_SPI 729 + tristate "Microchip FPGA CoreSPI controller" 730 + depends on SPI_MASTER 731 + help 732 + This enables the SPI driver for Microchip FPGA CoreSPI controller. 733 + Say Y or M here if you want to use the "soft" controllers on 734 + PolarFire SoC. 735 + If built as a module, it will be called spi-microchip-core-spi. 718 736 719 737 config SPI_MT65XX 720 738 tristate "MediaTek SPI controller" ··· 871 871 This selects the ARM(R) AMBA(R) PrimeCell PL022 SSP 872 872 controller. If you have an embedded system with an AMBA(R) 873 873 bus and a PL022 controller, say Y or M here. 874 + 875 + config SPI_POLARFIRE_SOC 876 + 877 + tristate "Microchip FPGA SPI controllers" 878 + depends on SPI_MASTER && ARCH_MICROCHIP 879 + help 880 + This enables the SPI driver for Microchip FPGA SPI controllers. 881 + Say Y or M here if you want to use the "hard" controllers on 882 + PolarFire SoC. 883 + If built as a module, it will be called spi-mpfs. 874 884 875 885 config SPI_PPC4xx 876 886 tristate "PPC4xx SPI Controller"
+2 -1
drivers/spi/Makefile
··· 86 86 obj-$(CONFIG_SPI_LP8841_RTC) += spi-lp8841-rtc.o 87 87 obj-$(CONFIG_SPI_MESON_SPICC) += spi-meson-spicc.o 88 88 obj-$(CONFIG_SPI_MESON_SPIFC) += spi-meson-spifc.o 89 - obj-$(CONFIG_SPI_MICROCHIP_CORE) += spi-microchip-core.o 90 89 obj-$(CONFIG_SPI_MICROCHIP_CORE_QSPI) += spi-microchip-core-qspi.o 90 + obj-$(CONFIG_SPI_MICROCHIP_CORE_SPI) += spi-microchip-core-spi.o 91 91 obj-$(CONFIG_SPI_MPC512x_PSC) += spi-mpc512x-psc.o 92 92 obj-$(CONFIG_SPI_MPC52xx_PSC) += spi-mpc52xx-psc.o 93 93 obj-$(CONFIG_SPI_MPC52xx) += spi-mpc52xx.o ··· 97 97 obj-$(CONFIG_SPI_MTK_SNFI) += spi-mtk-snfi.o 98 98 obj-$(CONFIG_SPI_MXIC) += spi-mxic.o 99 99 obj-$(CONFIG_SPI_MXS) += spi-mxs.o 100 + obj-$(CONFIG_SPI_POLARFIRE_SOC) += spi-mpfs.o 100 101 obj-$(CONFIG_SPI_WPCM_FIU) += spi-wpcm-fiu.o 101 102 obj-$(CONFIG_SPI_NPCM_FIU) += spi-npcm-fiu.o 102 103 obj-$(CONFIG_SPI_NPCM_PSPI) += spi-npcm-pspi.o
+442
drivers/spi/spi-microchip-core-spi.c
··· 1 + // SPDX-License-Identifier: (GPL-2.0) 2 + // 3 + // Microchip CoreSPI controller driver 4 + // 5 + // Copyright (c) 2025 Microchip Technology Inc. and its subsidiaries 6 + // 7 + // Author: Prajna Rajendra Kumar <prajna.rajendrakumar@microchip.com> 8 + 9 + #include <linux/clk.h> 10 + #include <linux/delay.h> 11 + #include <linux/err.h> 12 + #include <linux/init.h> 13 + #include <linux/interrupt.h> 14 + #include <linux/io.h> 15 + #include <linux/module.h> 16 + #include <linux/of.h> 17 + #include <linux/platform_device.h> 18 + #include <linux/spi/spi.h> 19 + 20 + #define MCHP_CORESPI_MAX_CS (8) 21 + #define MCHP_CORESPI_DEFAULT_FIFO_DEPTH (4) 22 + #define MCHP_CORESPI_DEFAULT_MOTOROLA_MODE (3) 23 + 24 + #define MCHP_CORESPI_CONTROL_ENABLE BIT(0) 25 + #define MCHP_CORESPI_CONTROL_MASTER BIT(1) 26 + #define MCHP_CORESPI_CONTROL_TX_DATA_INT BIT(3) 27 + #define MCHP_CORESPI_CONTROL_RX_OVER_INT BIT(4) 28 + #define MCHP_CORESPI_CONTROL_TX_UNDER_INT BIT(5) 29 + #define MCHP_CORESPI_CONTROL_FRAMEURUN BIT(6) 30 + #define MCHP_CORESPI_CONTROL_OENOFF BIT(7) 31 + 32 + #define MCHP_CORESPI_STATUS_ACTIVE BIT(7) 33 + #define MCHP_CORESPI_STATUS_SSEL BIT(6) 34 + #define MCHP_CORESPI_STATUS_TXFIFO_UNDERFLOW BIT(5) 35 + #define MCHP_CORESPI_STATUS_RXFIFO_FULL BIT(4) 36 + #define MCHP_CORESPI_STATUS_TXFIFO_FULL BIT(3) 37 + #define MCHP_CORESPI_STATUS_RXFIFO_EMPTY BIT(2) 38 + #define MCHP_CORESPI_STATUS_DONE BIT(1) 39 + #define MCHP_CORESPI_STATUS_FIRSTFRAME BIT(0) 40 + 41 + #define MCHP_CORESPI_INT_TXDONE BIT(0) 42 + #define MCHP_CORESPI_INT_RX_CHANNEL_OVERFLOW BIT(2) 43 + #define MCHP_CORESPI_INT_TX_CHANNEL_UNDERRUN BIT(3) 44 + #define MCHP_CORESPI_INT_CMDINT BIT(4) 45 + #define MCHP_CORESPI_INT_SSEND BIT(5) 46 + #define MCHP_CORESPI_INT_DATA_RX BIT(6) 47 + #define MCHP_CORESPI_INT_TXRFM BIT(7) 48 + 49 + #define MCHP_CORESPI_CONTROL2_INTEN_TXRFMT BIT(7) 50 + #define MCHP_CORESPI_CONTROL2_INTEN_DATA_RX BIT(6) 51 + #define MCHP_CORESPI_CONTROL2_INTEN_SSEND BIT(5) 52 + #define MCHP_CORESPI_CONTROL2_INTEN_CMD BIT(4) 53 + 54 + #define INT_ENABLE_MASK (MCHP_CORESPI_CONTROL_TX_DATA_INT | MCHP_CORESPI_CONTROL_RX_OVER_INT | \ 55 + MCHP_CORESPI_CONTROL_TX_UNDER_INT) 56 + 57 + #define MCHP_CORESPI_REG_CONTROL (0x00) 58 + #define MCHP_CORESPI_REG_INTCLEAR (0x04) 59 + #define MCHP_CORESPI_REG_RXDATA (0x08) 60 + #define MCHP_CORESPI_REG_TXDATA (0x0c) 61 + #define MCHP_CORESPI_REG_INTMASK (0X10) 62 + #define MCHP_CORESPI_REG_INTRAW (0X14) 63 + #define MCHP_CORESPI_REG_CONTROL2 (0x18) 64 + #define MCHP_CORESPI_REG_COMMAND (0x1c) 65 + #define MCHP_CORESPI_REG_STAT (0x20) 66 + #define MCHP_CORESPI_REG_SSEL (0x24) 67 + #define MCHP_CORESPI_REG_TXDATA_LAST (0X28) 68 + #define MCHP_CORESPI_REG_CLK_DIV (0x2c) 69 + 70 + struct mchp_corespi { 71 + void __iomem *regs; 72 + struct clk *clk; 73 + const u8 *tx_buf; 74 + u8 *rx_buf; 75 + u32 clk_gen; 76 + int irq; 77 + int tx_len; 78 + int rx_len; 79 + u32 fifo_depth; 80 + }; 81 + 82 + static inline void mchp_corespi_disable(struct mchp_corespi *spi) 83 + { 84 + u8 control = readb(spi->regs + MCHP_CORESPI_REG_CONTROL); 85 + 86 + control &= ~MCHP_CORESPI_CONTROL_ENABLE; 87 + 88 + writeb(control, spi->regs + MCHP_CORESPI_REG_CONTROL); 89 + } 90 + 91 + static inline void mchp_corespi_read_fifo(struct mchp_corespi *spi, u32 fifo_max) 92 + { 93 + for (int i = 0; i < fifo_max; i++) { 94 + u32 data; 95 + 96 + while (readb(spi->regs + MCHP_CORESPI_REG_STAT) & 97 + MCHP_CORESPI_STATUS_RXFIFO_EMPTY) 98 + ; 99 + 100 + data = readb(spi->regs + MCHP_CORESPI_REG_RXDATA); 101 + 102 + spi->rx_len--; 103 + if (!spi->rx_buf) 104 + continue; 105 + 106 + *spi->rx_buf = data; 107 + 108 + spi->rx_buf++; 109 + } 110 + } 111 + 112 + static void mchp_corespi_enable_ints(struct mchp_corespi *spi) 113 + { 114 + u8 control = readb(spi->regs + MCHP_CORESPI_REG_CONTROL); 115 + 116 + control |= INT_ENABLE_MASK; 117 + writeb(control, spi->regs + MCHP_CORESPI_REG_CONTROL); 118 + } 119 + 120 + static void mchp_corespi_disable_ints(struct mchp_corespi *spi) 121 + { 122 + u8 control = readb(spi->regs + MCHP_CORESPI_REG_CONTROL); 123 + 124 + control &= ~INT_ENABLE_MASK; 125 + writeb(control, spi->regs + MCHP_CORESPI_REG_CONTROL); 126 + } 127 + 128 + static inline void mchp_corespi_write_fifo(struct mchp_corespi *spi, u32 fifo_max) 129 + { 130 + int i = 0; 131 + 132 + while ((i < fifo_max) && 133 + !(readb(spi->regs + MCHP_CORESPI_REG_STAT) & 134 + MCHP_CORESPI_STATUS_TXFIFO_FULL)) { 135 + u32 word; 136 + 137 + word = spi->tx_buf ? *spi->tx_buf : 0xaa; 138 + writeb(word, spi->regs + MCHP_CORESPI_REG_TXDATA); 139 + 140 + if (spi->tx_buf) 141 + spi->tx_buf++; 142 + 143 + i++; 144 + } 145 + 146 + spi->tx_len -= i; 147 + } 148 + 149 + static void mchp_corespi_set_cs(struct spi_device *spi, bool disable) 150 + { 151 + struct mchp_corespi *corespi = spi_controller_get_devdata(spi->controller); 152 + u32 reg; 153 + 154 + reg = readb(corespi->regs + MCHP_CORESPI_REG_SSEL); 155 + reg &= ~BIT(spi_get_chipselect(spi, 0)); 156 + reg |= !disable << spi_get_chipselect(spi, 0); 157 + 158 + writeb(reg, corespi->regs + MCHP_CORESPI_REG_SSEL); 159 + } 160 + 161 + static int mchp_corespi_setup(struct spi_device *spi) 162 + { 163 + u32 dev_mode = spi->mode & (SPI_CPOL | SPI_CPHA); 164 + 165 + if (spi_get_csgpiod(spi, 0)) 166 + return 0; 167 + 168 + if (spi->mode & (SPI_CS_HIGH)) { 169 + dev_err(&spi->dev, "unable to support active-high CS in Motorola mode\n"); 170 + return -EOPNOTSUPP; 171 + } 172 + 173 + if (dev_mode & ~spi->controller->mode_bits) { 174 + dev_err(&spi->dev, "incompatible CPOL/CPHA, must match controller's Motorola mode\n"); 175 + return -EINVAL; 176 + } 177 + 178 + return 0; 179 + } 180 + 181 + static void mchp_corespi_init(struct spi_controller *host, struct mchp_corespi *spi) 182 + { 183 + u8 control = readb(spi->regs + MCHP_CORESPI_REG_CONTROL); 184 + 185 + /* Master mode changes require core to be disabled.*/ 186 + control = (control & ~MCHP_CORESPI_CONTROL_ENABLE) | MCHP_CORESPI_CONTROL_MASTER; 187 + 188 + writeb(control, spi->regs + MCHP_CORESPI_REG_CONTROL); 189 + 190 + mchp_corespi_enable_ints(spi); 191 + 192 + control = readb(spi->regs + MCHP_CORESPI_REG_CONTROL); 193 + control |= MCHP_CORESPI_CONTROL_ENABLE; 194 + 195 + writeb(control, spi->regs + MCHP_CORESPI_REG_CONTROL); 196 + } 197 + 198 + static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id) 199 + { 200 + struct spi_controller *host = dev_id; 201 + struct mchp_corespi *spi = spi_controller_get_devdata(host); 202 + u8 intfield = readb(spi->regs + MCHP_CORESPI_REG_INTMASK) & 0xff; 203 + bool finalise = false; 204 + 205 + /* Interrupt line may be shared and not for us at all */ 206 + if (intfield == 0) 207 + return IRQ_NONE; 208 + 209 + if (intfield & MCHP_CORESPI_INT_TXDONE) 210 + writeb(MCHP_CORESPI_INT_TXDONE, spi->regs + MCHP_CORESPI_REG_INTCLEAR); 211 + 212 + if (intfield & MCHP_CORESPI_INT_RX_CHANNEL_OVERFLOW) { 213 + writeb(MCHP_CORESPI_INT_RX_CHANNEL_OVERFLOW, 214 + spi->regs + MCHP_CORESPI_REG_INTCLEAR); 215 + finalise = true; 216 + dev_err(&host->dev, 217 + "RX OVERFLOW: rxlen: %d, txlen: %d\n", 218 + spi->rx_len, spi->tx_len); 219 + } 220 + 221 + if (intfield & MCHP_CORESPI_INT_TX_CHANNEL_UNDERRUN) { 222 + writeb(MCHP_CORESPI_INT_TX_CHANNEL_UNDERRUN, 223 + spi->regs + MCHP_CORESPI_REG_INTCLEAR); 224 + finalise = true; 225 + dev_err(&host->dev, 226 + "TX UNDERFLOW: rxlen: %d, txlen: %d\n", 227 + spi->rx_len, spi->tx_len); 228 + } 229 + 230 + if (finalise) 231 + spi_finalize_current_transfer(host); 232 + 233 + return IRQ_HANDLED; 234 + } 235 + 236 + static int mchp_corespi_set_clk_div(struct mchp_corespi *spi, 237 + unsigned long target_hz) 238 + { 239 + unsigned long pclk_hz, spi_hz; 240 + u32 clk_div; 241 + 242 + /* Get peripheral clock rate */ 243 + pclk_hz = clk_get_rate(spi->clk); 244 + if (!pclk_hz) 245 + return -EINVAL; 246 + 247 + /* 248 + * Calculate clock rate generated by SPI master 249 + * Formula: SPICLK = PCLK / (2 * (CLK_DIV + 1)) 250 + */ 251 + clk_div = DIV_ROUND_UP(pclk_hz, 2 * target_hz) - 1; 252 + 253 + if (clk_div > 0xFF) 254 + return -EINVAL; 255 + 256 + spi_hz = pclk_hz / (2 * (clk_div + 1)); 257 + 258 + if (spi_hz > target_hz) 259 + return -EINVAL; 260 + 261 + writeb(clk_div, spi->regs + MCHP_CORESPI_REG_CLK_DIV); 262 + 263 + return 0; 264 + } 265 + 266 + static int mchp_corespi_transfer_one(struct spi_controller *host, 267 + struct spi_device *spi_dev, 268 + struct spi_transfer *xfer) 269 + { 270 + struct mchp_corespi *spi = spi_controller_get_devdata(host); 271 + int ret; 272 + 273 + ret = mchp_corespi_set_clk_div(spi, (unsigned long)xfer->speed_hz); 274 + if (ret) { 275 + dev_err(&host->dev, "failed to set clock divider for target %u Hz\n", 276 + xfer->speed_hz); 277 + return ret; 278 + } 279 + 280 + spi->tx_buf = xfer->tx_buf; 281 + spi->rx_buf = xfer->rx_buf; 282 + spi->tx_len = xfer->len; 283 + spi->rx_len = xfer->len; 284 + 285 + while (spi->tx_len) { 286 + int fifo_max = min_t(int, spi->tx_len, spi->fifo_depth); 287 + 288 + mchp_corespi_write_fifo(spi, fifo_max); 289 + mchp_corespi_read_fifo(spi, fifo_max); 290 + } 291 + 292 + spi_finalize_current_transfer(host); 293 + return 1; 294 + } 295 + 296 + static int mchp_corespi_probe(struct platform_device *pdev) 297 + { 298 + struct spi_controller *host; 299 + struct mchp_corespi *spi; 300 + struct resource *res; 301 + const char *protocol; 302 + u32 num_cs, mode, frame_size; 303 + bool assert_ssel; 304 + int ret = 0; 305 + 306 + host = devm_spi_alloc_host(&pdev->dev, sizeof(*spi)); 307 + if (!host) 308 + return dev_err_probe(&pdev->dev, -ENOMEM, 309 + "unable to allocate host for SPI controller\n"); 310 + 311 + platform_set_drvdata(pdev, host); 312 + 313 + if (of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs)) 314 + num_cs = MCHP_CORESPI_MAX_CS; 315 + 316 + /* 317 + * Protocol: CFG_MODE 318 + * CoreSPI can be configured for Motorola, TI or NSC. 319 + * The current driver supports only Motorola mode. 320 + */ 321 + ret = of_property_read_string(pdev->dev.of_node, "microchip,protocol-configuration", 322 + &protocol); 323 + if (strcmp(protocol, "motorola") != 0) 324 + return dev_err_probe(&pdev->dev, -EINVAL, 325 + "CoreSPI: protocol '%s' not supported by this driver\n", 326 + protocol); 327 + 328 + /* 329 + * Motorola mode (0-3): CFG_MOT_MODE 330 + * Mode is fixed in the IP configurator. 331 + */ 332 + ret = of_property_read_u32(pdev->dev.of_node, "microchip,motorola-mode", &mode); 333 + if (ret) 334 + mode = MCHP_CORESPI_DEFAULT_MOTOROLA_MODE; 335 + else if (mode > 3) 336 + return dev_err_probe(&pdev->dev, -EINVAL, 337 + "invalid 'microchip,motorola-mode' value %u\n", mode); 338 + 339 + /* 340 + * Frame size: CFG_FRAME_SIZE 341 + * The hardware allows frame sizes <= APB data width. 342 + * However, this driver currently only supports 8-bit frames. 343 + */ 344 + ret = of_property_read_u32(pdev->dev.of_node, "microchip,frame-size", &frame_size); 345 + if (!ret && frame_size != 8) 346 + return dev_err_probe(&pdev->dev, -EINVAL, 347 + "CoreSPI: frame size %u not supported by this driver\n", 348 + frame_size); 349 + 350 + /* 351 + * SSEL: CFG_MOT_SSEL 352 + * CoreSPI deasserts SSEL when the TX FIFO empties. 353 + * To prevent CS deassertion when TX FIFO drains, the ssel-active property 354 + * keeps CS asserted for the full SPI transfer. 355 + */ 356 + assert_ssel = of_property_read_bool(pdev->dev.of_node, "microchip,ssel-active"); 357 + if (!assert_ssel) 358 + return dev_err_probe(&pdev->dev, -EINVAL, 359 + "hardware must enable 'microchip,ssel-active' to keep CS asserted for the SPI transfer\n"); 360 + 361 + spi = spi_controller_get_devdata(host); 362 + 363 + host->num_chipselect = num_cs; 364 + host->mode_bits = mode; 365 + host->setup = mchp_corespi_setup; 366 + host->use_gpio_descriptors = true; 367 + host->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32); 368 + host->transfer_one = mchp_corespi_transfer_one; 369 + host->set_cs = mchp_corespi_set_cs; 370 + host->dev.of_node = pdev->dev.of_node; 371 + 372 + ret = of_property_read_u32(pdev->dev.of_node, "fifo-depth", &spi->fifo_depth); 373 + if (ret) 374 + spi->fifo_depth = MCHP_CORESPI_DEFAULT_FIFO_DEPTH; 375 + 376 + spi->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 377 + if (IS_ERR(spi->regs)) 378 + return PTR_ERR(spi->regs); 379 + 380 + spi->irq = platform_get_irq(pdev, 0); 381 + if (spi->irq < 0) 382 + return spi->irq; 383 + 384 + ret = devm_request_irq(&pdev->dev, spi->irq, mchp_corespi_interrupt, 385 + IRQF_SHARED, dev_name(&pdev->dev), host); 386 + if (ret) 387 + return dev_err_probe(&pdev->dev, ret, 388 + "could not request irq\n"); 389 + 390 + spi->clk = devm_clk_get_enabled(&pdev->dev, NULL); 391 + if (IS_ERR(spi->clk)) 392 + return dev_err_probe(&pdev->dev, PTR_ERR(spi->clk), 393 + "could not get clk\n"); 394 + 395 + mchp_corespi_init(host, spi); 396 + 397 + ret = devm_spi_register_controller(&pdev->dev, host); 398 + if (ret) { 399 + mchp_corespi_disable(spi); 400 + return dev_err_probe(&pdev->dev, ret, 401 + "unable to register host for CoreSPI controller\n"); 402 + } 403 + 404 + return 0; 405 + } 406 + 407 + static void mchp_corespi_remove(struct platform_device *pdev) 408 + { 409 + struct spi_controller *host = platform_get_drvdata(pdev); 410 + struct mchp_corespi *spi = spi_controller_get_devdata(host); 411 + 412 + mchp_corespi_disable_ints(spi); 413 + mchp_corespi_disable(spi); 414 + } 415 + 416 + #define MICROCHIP_SPI_PM_OPS (NULL) 417 + 418 + /* 419 + * Platform driver data structure 420 + */ 421 + 422 + #if defined(CONFIG_OF) 423 + static const struct of_device_id mchp_corespi_dt_ids[] = { 424 + { .compatible = "microchip,corespi-rtl-v5" }, 425 + { /* sentinel */ } 426 + }; 427 + MODULE_DEVICE_TABLE(of, mchp_corespi_dt_ids); 428 + #endif 429 + 430 + static struct platform_driver mchp_corespi_driver = { 431 + .probe = mchp_corespi_probe, 432 + .driver = { 433 + .name = "microchip-corespi", 434 + .pm = MICROCHIP_SPI_PM_OPS, 435 + .of_match_table = of_match_ptr(mchp_corespi_dt_ids), 436 + }, 437 + .remove = mchp_corespi_remove, 438 + }; 439 + module_platform_driver(mchp_corespi_driver); 440 + MODULE_DESCRIPTION("Microchip CoreSPI controller driver"); 441 + MODULE_AUTHOR("Prajna Rajendra Kumar <prajna.rajendrakumar@microchip.com>"); 442 + MODULE_LICENSE("GPL");
+104 -103
drivers/spi/spi-microchip-core.c drivers/spi/spi-mpfs.c
··· 99 99 #define REG_CTRL2 (0x48) 100 100 #define REG_FRAMESUP (0x50) 101 101 102 - struct mchp_corespi { 102 + struct mpfs_spi { 103 103 void __iomem *regs; 104 104 struct clk *clk; 105 105 const u8 *tx_buf; ··· 113 113 int n_bytes; 114 114 }; 115 115 116 - static inline u32 mchp_corespi_read(struct mchp_corespi *spi, unsigned int reg) 116 + static inline u32 mpfs_spi_read(struct mpfs_spi *spi, unsigned int reg) 117 117 { 118 118 return readl(spi->regs + reg); 119 119 } 120 120 121 - static inline void mchp_corespi_write(struct mchp_corespi *spi, unsigned int reg, u32 val) 121 + static inline void mpfs_spi_write(struct mpfs_spi *spi, unsigned int reg, u32 val) 122 122 { 123 123 writel(val, spi->regs + reg); 124 124 } 125 125 126 - static inline void mchp_corespi_disable(struct mchp_corespi *spi) 126 + static inline void mpfs_spi_disable(struct mpfs_spi *spi) 127 127 { 128 - u32 control = mchp_corespi_read(spi, REG_CONTROL); 128 + u32 control = mpfs_spi_read(spi, REG_CONTROL); 129 129 130 130 control &= ~CONTROL_ENABLE; 131 131 132 - mchp_corespi_write(spi, REG_CONTROL, control); 132 + mpfs_spi_write(spi, REG_CONTROL, control); 133 133 } 134 134 135 - static inline void mchp_corespi_read_fifo(struct mchp_corespi *spi, int fifo_max) 135 + static inline void mpfs_spi_read_fifo(struct mpfs_spi *spi, int fifo_max) 136 136 { 137 137 for (int i = 0; i < fifo_max; i++) { 138 138 u32 data; 139 139 140 - while (mchp_corespi_read(spi, REG_STATUS) & STATUS_RXFIFO_EMPTY) 140 + while (mpfs_spi_read(spi, REG_STATUS) & STATUS_RXFIFO_EMPTY) 141 141 ; 142 142 143 - data = mchp_corespi_read(spi, REG_RX_DATA); 143 + data = mpfs_spi_read(spi, REG_RX_DATA); 144 144 145 145 spi->rx_len -= spi->n_bytes; 146 146 ··· 158 158 } 159 159 } 160 160 161 - static void mchp_corespi_enable_ints(struct mchp_corespi *spi) 161 + static void mpfs_spi_enable_ints(struct mpfs_spi *spi) 162 162 { 163 - u32 control = mchp_corespi_read(spi, REG_CONTROL); 163 + u32 control = mpfs_spi_read(spi, REG_CONTROL); 164 164 165 165 control |= INT_ENABLE_MASK; 166 - mchp_corespi_write(spi, REG_CONTROL, control); 166 + mpfs_spi_write(spi, REG_CONTROL, control); 167 167 } 168 168 169 - static void mchp_corespi_disable_ints(struct mchp_corespi *spi) 169 + static void mpfs_spi_disable_ints(struct mpfs_spi *spi) 170 170 { 171 - u32 control = mchp_corespi_read(spi, REG_CONTROL); 171 + u32 control = mpfs_spi_read(spi, REG_CONTROL); 172 172 173 173 control &= ~INT_ENABLE_MASK; 174 - mchp_corespi_write(spi, REG_CONTROL, control); 174 + mpfs_spi_write(spi, REG_CONTROL, control); 175 175 } 176 176 177 - static inline void mchp_corespi_set_xfer_size(struct mchp_corespi *spi, int len) 177 + static inline void mpfs_spi_set_xfer_size(struct mpfs_spi *spi, int len) 178 178 { 179 179 u32 control; 180 180 u32 lenpart; 181 - u32 frames = mchp_corespi_read(spi, REG_FRAMESUP); 181 + u32 frames = mpfs_spi_read(spi, REG_FRAMESUP); 182 182 183 183 /* 184 184 * Writing to FRAMECNT in REG_CONTROL will reset the frame count, taking 185 185 * a shortcut requires an explicit clear. 186 186 */ 187 187 if (frames == len) { 188 - mchp_corespi_write(spi, REG_COMMAND, COMMAND_CLRFRAMECNT); 188 + mpfs_spi_write(spi, REG_COMMAND, COMMAND_CLRFRAMECNT); 189 189 return; 190 190 } 191 191 ··· 208 208 * that matches the documentation. 209 209 */ 210 210 lenpart = len & 0xffff; 211 - control = mchp_corespi_read(spi, REG_CONTROL); 211 + control = mpfs_spi_read(spi, REG_CONTROL); 212 212 control &= ~CONTROL_FRAMECNT_MASK; 213 213 control |= lenpart << CONTROL_FRAMECNT_SHIFT; 214 - mchp_corespi_write(spi, REG_CONTROL, control); 215 - mchp_corespi_write(spi, REG_FRAMESUP, len); 214 + mpfs_spi_write(spi, REG_CONTROL, control); 215 + mpfs_spi_write(spi, REG_FRAMESUP, len); 216 216 } 217 217 218 - static inline void mchp_corespi_write_fifo(struct mchp_corespi *spi, int fifo_max) 218 + static inline void mpfs_spi_write_fifo(struct mpfs_spi *spi, int fifo_max) 219 219 { 220 220 int i = 0; 221 221 222 - mchp_corespi_set_xfer_size(spi, fifo_max); 222 + mpfs_spi_set_xfer_size(spi, fifo_max); 223 223 224 - while ((i < fifo_max) && !(mchp_corespi_read(spi, REG_STATUS) & STATUS_TXFIFO_FULL)) { 224 + while ((i < fifo_max) && !(mpfs_spi_read(spi, REG_STATUS) & STATUS_TXFIFO_FULL)) { 225 225 u32 word; 226 226 227 227 if (spi->n_bytes == 4) ··· 231 231 else 232 232 word = spi->tx_buf ? *spi->tx_buf : 0xaa; 233 233 234 - mchp_corespi_write(spi, REG_TX_DATA, word); 234 + mpfs_spi_write(spi, REG_TX_DATA, word); 235 235 if (spi->tx_buf) 236 236 spi->tx_buf += spi->n_bytes; 237 237 i++; ··· 240 240 spi->tx_len -= i * spi->n_bytes; 241 241 } 242 242 243 - static inline void mchp_corespi_set_framesize(struct mchp_corespi *spi, int bt) 243 + static inline void mpfs_spi_set_framesize(struct mpfs_spi *spi, int bt) 244 244 { 245 - u32 frame_size = mchp_corespi_read(spi, REG_FRAME_SIZE); 245 + u32 frame_size = mpfs_spi_read(spi, REG_FRAME_SIZE); 246 246 u32 control; 247 247 248 248 if ((frame_size & FRAME_SIZE_MASK) == bt) ··· 252 252 * Disable the SPI controller. Writes to the frame size have 253 253 * no effect when the controller is enabled. 254 254 */ 255 - control = mchp_corespi_read(spi, REG_CONTROL); 255 + control = mpfs_spi_read(spi, REG_CONTROL); 256 256 control &= ~CONTROL_ENABLE; 257 - mchp_corespi_write(spi, REG_CONTROL, control); 257 + mpfs_spi_write(spi, REG_CONTROL, control); 258 258 259 - mchp_corespi_write(spi, REG_FRAME_SIZE, bt); 259 + mpfs_spi_write(spi, REG_FRAME_SIZE, bt); 260 260 261 261 control |= CONTROL_ENABLE; 262 - mchp_corespi_write(spi, REG_CONTROL, control); 262 + mpfs_spi_write(spi, REG_CONTROL, control); 263 263 } 264 264 265 - static void mchp_corespi_set_cs(struct spi_device *spi, bool disable) 265 + static void mpfs_spi_set_cs(struct spi_device *spi, bool disable) 266 266 { 267 267 u32 reg; 268 - struct mchp_corespi *corespi = spi_controller_get_devdata(spi->controller); 268 + struct mpfs_spi *mspi = spi_controller_get_devdata(spi->controller); 269 269 270 - reg = mchp_corespi_read(corespi, REG_SLAVE_SELECT); 270 + reg = mpfs_spi_read(mspi, REG_SLAVE_SELECT); 271 271 reg &= ~BIT(spi_get_chipselect(spi, 0)); 272 272 reg |= !disable << spi_get_chipselect(spi, 0); 273 - corespi->pending_slave_select = reg; 273 + mspi->pending_slave_select = reg; 274 274 275 275 /* 276 276 * Only deassert chip select immediately. Writing to some registers ··· 281 281 * doesn't see any spurious clock transitions whilst CS is enabled. 282 282 */ 283 283 if (((spi->mode & SPI_CS_HIGH) == 0) == disable) 284 - mchp_corespi_write(corespi, REG_SLAVE_SELECT, reg); 284 + mpfs_spi_write(mspi, REG_SLAVE_SELECT, reg); 285 285 } 286 286 287 - static int mchp_corespi_setup(struct spi_device *spi) 287 + static int mpfs_spi_setup(struct spi_device *spi) 288 288 { 289 - struct mchp_corespi *corespi = spi_controller_get_devdata(spi->controller); 289 + struct mpfs_spi *mspi = spi_controller_get_devdata(spi->controller); 290 290 u32 reg; 291 291 292 292 if (spi_is_csgpiod(spi)) ··· 298 298 * driving their select line low. 299 299 */ 300 300 if (spi->mode & SPI_CS_HIGH) { 301 - reg = mchp_corespi_read(corespi, REG_SLAVE_SELECT); 301 + reg = mpfs_spi_read(mspi, REG_SLAVE_SELECT); 302 302 reg |= BIT(spi_get_chipselect(spi, 0)); 303 - corespi->pending_slave_select = reg; 304 - mchp_corespi_write(corespi, REG_SLAVE_SELECT, reg); 303 + mspi->pending_slave_select = reg; 304 + mpfs_spi_write(mspi, REG_SLAVE_SELECT, reg); 305 305 } 306 306 return 0; 307 307 } 308 308 309 - static void mchp_corespi_init(struct spi_controller *host, struct mchp_corespi *spi) 309 + static void mpfs_spi_init(struct spi_controller *host, struct mpfs_spi *spi) 310 310 { 311 311 unsigned long clk_hz; 312 - u32 control = mchp_corespi_read(spi, REG_CONTROL); 312 + u32 control = mpfs_spi_read(spi, REG_CONTROL); 313 313 314 314 control &= ~CONTROL_ENABLE; 315 - mchp_corespi_write(spi, REG_CONTROL, control); 315 + mpfs_spi_write(spi, REG_CONTROL, control); 316 316 317 317 control |= CONTROL_MASTER; 318 318 control &= ~CONTROL_MODE_MASK; ··· 328 328 */ 329 329 control |= CONTROL_SPS | CONTROL_BIGFIFO; 330 330 331 - mchp_corespi_write(spi, REG_CONTROL, control); 331 + mpfs_spi_write(spi, REG_CONTROL, control); 332 332 333 - mchp_corespi_set_framesize(spi, DEFAULT_FRAMESIZE); 333 + mpfs_spi_set_framesize(spi, DEFAULT_FRAMESIZE); 334 334 335 335 /* max. possible spi clock rate is the apb clock rate */ 336 336 clk_hz = clk_get_rate(spi->clk); 337 337 host->max_speed_hz = clk_hz; 338 338 339 - mchp_corespi_enable_ints(spi); 339 + mpfs_spi_enable_ints(spi); 340 340 341 341 /* 342 342 * It is required to enable direct mode, otherwise control over the chip ··· 344 344 * can deal with active high targets. 345 345 */ 346 346 spi->pending_slave_select = SSELOUT | SSEL_DIRECT; 347 - mchp_corespi_write(spi, REG_SLAVE_SELECT, spi->pending_slave_select); 347 + mpfs_spi_write(spi, REG_SLAVE_SELECT, spi->pending_slave_select); 348 348 349 - control = mchp_corespi_read(spi, REG_CONTROL); 349 + control = mpfs_spi_read(spi, REG_CONTROL); 350 350 351 351 control &= ~CONTROL_RESET; 352 352 control |= CONTROL_ENABLE; 353 353 354 - mchp_corespi_write(spi, REG_CONTROL, control); 354 + mpfs_spi_write(spi, REG_CONTROL, control); 355 355 } 356 356 357 - static inline void mchp_corespi_set_clk_gen(struct mchp_corespi *spi) 357 + static inline void mpfs_spi_set_clk_gen(struct mpfs_spi *spi) 358 358 { 359 359 u32 control; 360 360 361 - control = mchp_corespi_read(spi, REG_CONTROL); 361 + control = mpfs_spi_read(spi, REG_CONTROL); 362 362 if (spi->clk_mode) 363 363 control |= CONTROL_CLKMODE; 364 364 else 365 365 control &= ~CONTROL_CLKMODE; 366 366 367 - mchp_corespi_write(spi, REG_CLK_GEN, spi->clk_gen); 368 - mchp_corespi_write(spi, REG_CONTROL, control); 367 + mpfs_spi_write(spi, REG_CLK_GEN, spi->clk_gen); 368 + mpfs_spi_write(spi, REG_CONTROL, control); 369 369 } 370 370 371 - static inline void mchp_corespi_set_mode(struct mchp_corespi *spi, unsigned int mode) 371 + static inline void mpfs_spi_set_mode(struct mpfs_spi *spi, unsigned int mode) 372 372 { 373 373 u32 mode_val; 374 - u32 control = mchp_corespi_read(spi, REG_CONTROL); 374 + u32 control = mpfs_spi_read(spi, REG_CONTROL); 375 375 376 376 switch (mode & SPI_MODE_X_MASK) { 377 377 case SPI_MODE_0: ··· 394 394 */ 395 395 396 396 control &= ~CONTROL_ENABLE; 397 - mchp_corespi_write(spi, REG_CONTROL, control); 397 + mpfs_spi_write(spi, REG_CONTROL, control); 398 398 399 399 control &= ~(SPI_MODE_X_MASK << MODE_X_MASK_SHIFT); 400 400 control |= mode_val; 401 401 402 - mchp_corespi_write(spi, REG_CONTROL, control); 402 + mpfs_spi_write(spi, REG_CONTROL, control); 403 403 404 404 control |= CONTROL_ENABLE; 405 - mchp_corespi_write(spi, REG_CONTROL, control); 405 + mpfs_spi_write(spi, REG_CONTROL, control); 406 406 } 407 407 408 - static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id) 408 + static irqreturn_t mpfs_spi_interrupt(int irq, void *dev_id) 409 409 { 410 410 struct spi_controller *host = dev_id; 411 - struct mchp_corespi *spi = spi_controller_get_devdata(host); 412 - u32 intfield = mchp_corespi_read(spi, REG_MIS) & 0xf; 411 + struct mpfs_spi *spi = spi_controller_get_devdata(host); 412 + u32 intfield = mpfs_spi_read(spi, REG_MIS) & 0xf; 413 413 bool finalise = false; 414 414 415 415 /* Interrupt line may be shared and not for us at all */ ··· 417 417 return IRQ_NONE; 418 418 419 419 if (intfield & INT_RX_CHANNEL_OVERFLOW) { 420 - mchp_corespi_write(spi, REG_INT_CLEAR, INT_RX_CHANNEL_OVERFLOW); 420 + mpfs_spi_write(spi, REG_INT_CLEAR, INT_RX_CHANNEL_OVERFLOW); 421 421 finalise = true; 422 422 dev_err(&host->dev, 423 423 "%s: RX OVERFLOW: rxlen: %d, txlen: %d\n", __func__, ··· 425 425 } 426 426 427 427 if (intfield & INT_TX_CHANNEL_UNDERRUN) { 428 - mchp_corespi_write(spi, REG_INT_CLEAR, INT_TX_CHANNEL_UNDERRUN); 428 + mpfs_spi_write(spi, REG_INT_CLEAR, INT_TX_CHANNEL_UNDERRUN); 429 429 finalise = true; 430 430 dev_err(&host->dev, 431 431 "%s: TX UNDERFLOW: rxlen: %d, txlen: %d\n", __func__, ··· 438 438 return IRQ_HANDLED; 439 439 } 440 440 441 - static int mchp_corespi_calculate_clkgen(struct mchp_corespi *spi, 442 - unsigned long target_hz) 441 + static int mpfs_spi_calculate_clkgen(struct mpfs_spi *spi, 442 + unsigned long target_hz) 443 443 { 444 444 unsigned long clk_hz, spi_hz, clk_gen; 445 445 ··· 475 475 return 0; 476 476 } 477 477 478 - static int mchp_corespi_transfer_one(struct spi_controller *host, 479 - struct spi_device *spi_dev, 480 - struct spi_transfer *xfer) 478 + static int mpfs_spi_transfer_one(struct spi_controller *host, 479 + struct spi_device *spi_dev, 480 + struct spi_transfer *xfer) 481 481 { 482 - struct mchp_corespi *spi = spi_controller_get_devdata(host); 482 + struct mpfs_spi *spi = spi_controller_get_devdata(host); 483 483 int ret; 484 484 485 - ret = mchp_corespi_calculate_clkgen(spi, (unsigned long)xfer->speed_hz); 485 + ret = mpfs_spi_calculate_clkgen(spi, (unsigned long)xfer->speed_hz); 486 486 if (ret) { 487 487 dev_err(&host->dev, "failed to set clk_gen for target %u Hz\n", xfer->speed_hz); 488 488 return ret; 489 489 } 490 490 491 - mchp_corespi_set_clk_gen(spi); 491 + mpfs_spi_set_clk_gen(spi); 492 492 493 493 spi->tx_buf = xfer->tx_buf; 494 494 spi->rx_buf = xfer->rx_buf; ··· 496 496 spi->rx_len = xfer->len; 497 497 spi->n_bytes = roundup_pow_of_two(DIV_ROUND_UP(xfer->bits_per_word, BITS_PER_BYTE)); 498 498 499 - mchp_corespi_set_framesize(spi, xfer->bits_per_word); 499 + mpfs_spi_set_framesize(spi, xfer->bits_per_word); 500 500 501 - mchp_corespi_write(spi, REG_COMMAND, COMMAND_RXFIFORST | COMMAND_TXFIFORST); 501 + mpfs_spi_write(spi, REG_COMMAND, COMMAND_RXFIFORST | COMMAND_TXFIFORST); 502 502 503 - mchp_corespi_write(spi, REG_SLAVE_SELECT, spi->pending_slave_select); 503 + mpfs_spi_write(spi, REG_SLAVE_SELECT, spi->pending_slave_select); 504 504 505 505 while (spi->tx_len) { 506 506 int fifo_max = DIV_ROUND_UP(min(spi->tx_len, FIFO_DEPTH), spi->n_bytes); 507 507 508 - mchp_corespi_write_fifo(spi, fifo_max); 509 - mchp_corespi_read_fifo(spi, fifo_max); 508 + mpfs_spi_write_fifo(spi, fifo_max); 509 + mpfs_spi_read_fifo(spi, fifo_max); 510 510 } 511 511 512 512 spi_finalize_current_transfer(host); 513 513 return 1; 514 514 } 515 515 516 - static int mchp_corespi_prepare_message(struct spi_controller *host, 517 - struct spi_message *msg) 516 + static int mpfs_spi_prepare_message(struct spi_controller *host, 517 + struct spi_message *msg) 518 518 { 519 519 struct spi_device *spi_dev = msg->spi; 520 - struct mchp_corespi *spi = spi_controller_get_devdata(host); 520 + struct mpfs_spi *spi = spi_controller_get_devdata(host); 521 521 522 - mchp_corespi_set_mode(spi, spi_dev->mode); 522 + mpfs_spi_set_mode(spi, spi_dev->mode); 523 523 524 524 return 0; 525 525 } 526 526 527 - static int mchp_corespi_probe(struct platform_device *pdev) 527 + static int mpfs_spi_probe(struct platform_device *pdev) 528 528 { 529 529 struct spi_controller *host; 530 - struct mchp_corespi *spi; 530 + struct mpfs_spi *spi; 531 531 struct resource *res; 532 532 u32 num_cs; 533 533 int ret = 0; 534 534 535 535 host = devm_spi_alloc_host(&pdev->dev, sizeof(*spi)); 536 536 if (!host) 537 - return -ENOMEM; 537 + return dev_err_probe(&pdev->dev, -ENOMEM, 538 + "unable to allocate host for SPI controller\n"); 538 539 539 540 platform_set_drvdata(pdev, host); 540 541 ··· 545 544 host->num_chipselect = num_cs; 546 545 host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 547 546 host->use_gpio_descriptors = true; 548 - host->setup = mchp_corespi_setup; 547 + host->setup = mpfs_spi_setup; 549 548 host->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); 550 - host->transfer_one = mchp_corespi_transfer_one; 551 - host->prepare_message = mchp_corespi_prepare_message; 552 - host->set_cs = mchp_corespi_set_cs; 549 + host->transfer_one = mpfs_spi_transfer_one; 550 + host->prepare_message = mpfs_spi_prepare_message; 551 + host->set_cs = mpfs_spi_set_cs; 553 552 host->dev.of_node = pdev->dev.of_node; 554 553 555 554 spi = spi_controller_get_devdata(host); ··· 562 561 if (spi->irq < 0) 563 562 return spi->irq; 564 563 565 - ret = devm_request_irq(&pdev->dev, spi->irq, mchp_corespi_interrupt, 564 + ret = devm_request_irq(&pdev->dev, spi->irq, mpfs_spi_interrupt, 566 565 IRQF_SHARED, dev_name(&pdev->dev), host); 567 566 if (ret) 568 567 return dev_err_probe(&pdev->dev, ret, ··· 573 572 return dev_err_probe(&pdev->dev, PTR_ERR(spi->clk), 574 573 "could not get clk\n"); 575 574 576 - mchp_corespi_init(host, spi); 575 + mpfs_spi_init(host, spi); 577 576 578 577 ret = devm_spi_register_controller(&pdev->dev, host); 579 578 if (ret) { 580 - mchp_corespi_disable(spi); 579 + mpfs_spi_disable(spi); 581 580 return dev_err_probe(&pdev->dev, ret, 582 581 "unable to register host for SPI controller\n"); 583 582 } ··· 587 586 return 0; 588 587 } 589 588 590 - static void mchp_corespi_remove(struct platform_device *pdev) 589 + static void mpfs_spi_remove(struct platform_device *pdev) 591 590 { 592 591 struct spi_controller *host = platform_get_drvdata(pdev); 593 - struct mchp_corespi *spi = spi_controller_get_devdata(host); 592 + struct mpfs_spi *spi = spi_controller_get_devdata(host); 594 593 595 - mchp_corespi_disable_ints(spi); 596 - mchp_corespi_disable(spi); 594 + mpfs_spi_disable_ints(spi); 595 + mpfs_spi_disable(spi); 597 596 } 598 597 599 598 #define MICROCHIP_SPI_PM_OPS (NULL) ··· 603 602 */ 604 603 605 604 #if defined(CONFIG_OF) 606 - static const struct of_device_id mchp_corespi_dt_ids[] = { 605 + static const struct of_device_id mpfs_spi_dt_ids[] = { 607 606 { .compatible = "microchip,mpfs-spi" }, 608 607 { /* sentinel */ } 609 608 }; 610 - MODULE_DEVICE_TABLE(of, mchp_corespi_dt_ids); 609 + MODULE_DEVICE_TABLE(of, mpfs_spi_dt_ids); 611 610 #endif 612 611 613 - static struct platform_driver mchp_corespi_driver = { 614 - .probe = mchp_corespi_probe, 612 + static struct platform_driver mpfs_spi_driver = { 613 + .probe = mpfs_spi_probe, 615 614 .driver = { 616 - .name = "microchip-corespi", 615 + .name = "microchip-spi", 617 616 .pm = MICROCHIP_SPI_PM_OPS, 618 - .of_match_table = of_match_ptr(mchp_corespi_dt_ids), 617 + .of_match_table = of_match_ptr(mpfs_spi_dt_ids), 619 618 }, 620 - .remove = mchp_corespi_remove, 619 + .remove = mpfs_spi_remove, 621 620 }; 622 - module_platform_driver(mchp_corespi_driver); 621 + module_platform_driver(mpfs_spi_driver); 623 622 MODULE_DESCRIPTION("Microchip coreSPI SPI controller driver"); 624 623 MODULE_AUTHOR("Daire McNamara <daire.mcnamara@microchip.com>"); 625 624 MODULE_AUTHOR("Conor Dooley <conor.dooley@microchip.com>");