Lines Matching +full:dw +full:- +full:apb +full:- +full:ssi
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Memory-mapped interface driver for DW SPI Core
24 #include "spi-dw.h"
57 * Elba SoC does not use ssi, pin override is used for cs 0,1 and
61 * bit: |---3-------2-------1-------0
79 struct dw_spi *dws = spi_controller_get_devdata(spi->controller); in dw_spi_mscc_set_cs()
81 struct dw_spi_mscc *dwsmscc = dwsmmio->priv; in dw_spi_mscc_set_cs()
90 writel(sw_mode, dwsmscc->spi_mst + MSCC_SPI_MST_SW_MODE); in dw_spi_mscc_set_cs()
102 dwsmscc = devm_kzalloc(&pdev->dev, sizeof(*dwsmscc), GFP_KERNEL); in dw_spi_mscc_init()
104 return -ENOMEM; in dw_spi_mscc_init()
106 dwsmscc->spi_mst = devm_platform_ioremap_resource(pdev, 1); in dw_spi_mscc_init()
107 if (IS_ERR(dwsmscc->spi_mst)) { in dw_spi_mscc_init()
108 dev_err(&pdev->dev, "SPI_MST region map failed\n"); in dw_spi_mscc_init()
109 return PTR_ERR(dwsmscc->spi_mst); in dw_spi_mscc_init()
112 dwsmscc->syscon = syscon_regmap_lookup_by_compatible(cpu_syscon); in dw_spi_mscc_init()
113 if (IS_ERR(dwsmscc->syscon)) in dw_spi_mscc_init()
114 return PTR_ERR(dwsmscc->syscon); in dw_spi_mscc_init()
117 writel(0, dwsmscc->spi_mst + MSCC_SPI_MST_SW_MODE); in dw_spi_mscc_init()
120 regmap_update_bits(dwsmscc->syscon, MSCC_CPU_SYSTEM_CTRL_GENERAL_CTRL, in dw_spi_mscc_init()
124 dwsmmio->dws.set_cs = dw_spi_mscc_set_cs; in dw_spi_mscc_init()
125 dwsmmio->priv = dwsmscc; in dw_spi_mscc_init()
133 return dw_spi_mscc_init(pdev, dwsmmio, "mscc,ocelot-cpu-syscon", in dw_spi_mscc_ocelot_init()
140 return dw_spi_mscc_init(pdev, dwsmmio, "mscc,jaguar2-cpu-syscon", in dw_spi_mscc_jaguar2_init()
152 struct dw_spi *dws = spi_controller_get_devdata(spi->controller); in dw_spi_sparx5_set_cs()
154 struct dw_spi_mscc *dwsmscc = dwsmmio->priv; in dw_spi_sparx5_set_cs()
159 regmap_write(dwsmscc->syscon, SPARX5_FORCE_ENA, 1); in dw_spi_sparx5_set_cs()
161 regmap_write(dwsmscc->syscon, SPARX5_FORCE_VAL, ~BIT(cs)); in dw_spi_sparx5_set_cs()
166 regmap_write(dwsmscc->syscon, SPARX5_FORCE_VAL, ~0); in dw_spi_sparx5_set_cs()
170 regmap_write(dwsmscc->syscon, SPARX5_FORCE_ENA, 0); in dw_spi_sparx5_set_cs()
179 const char *syscon_name = "microchip,sparx5-cpu-syscon"; in dw_spi_mscc_sparx5_init()
180 struct device *dev = &pdev->dev; in dw_spi_mscc_sparx5_init()
185 return -EOPNOTSUPP; in dw_spi_mscc_sparx5_init()
190 return -ENOMEM; in dw_spi_mscc_sparx5_init()
192 dwsmscc->syscon = in dw_spi_mscc_sparx5_init()
194 if (IS_ERR(dwsmscc->syscon)) { in dw_spi_mscc_sparx5_init()
196 return PTR_ERR(dwsmscc->syscon); in dw_spi_mscc_sparx5_init()
199 dwsmmio->dws.set_cs = dw_spi_sparx5_set_cs; in dw_spi_mscc_sparx5_init()
200 dwsmmio->priv = dwsmscc; in dw_spi_mscc_sparx5_init()
208 dwsmmio->dws.caps = DW_SPI_CAP_CS_OVERRIDE; in dw_spi_alpine_init()
216 dw_spi_dma_setup_generic(&dwsmmio->dws); in dw_spi_pssi_init()
224 dwsmmio->dws.ip = DW_HSSI_ID; in dw_spi_hssi_init()
226 dw_spi_dma_setup_generic(&dwsmmio->dws); in dw_spi_hssi_init()
234 dwsmmio->dws.ip = DW_HSSI_ID; in dw_spi_intel_init()
240 * DMA-based mem ops are not configured for this device and are not tested.
246 * The Intel Mount Evans SoC's Integrated Management Complex DW in dw_spi_mountevans_imc_init()
252 dwsmmio->dws.fifo_len = 31; in dw_spi_mountevans_imc_init()
261 * The Canaan Kendryte K210 SoC DW apb_ssi v4 spi controller is in dw_spi_canaan_k210_init()
267 dwsmmio->dws.fifo_len = 31; in dw_spi_canaan_k210_init()
280 struct dw_spi *dws = spi_controller_get_devdata(spi->controller); in dw_spi_elba_set_cs()
282 struct regmap *syscon = dwsmmio->priv; in dw_spi_elba_set_cs()
290 * The DW SPI controller needs a native CS bit selected to start in dw_spi_elba_set_cs()
303 syscon = syscon_regmap_lookup_by_phandle(dev_of_node(&pdev->dev), in dw_spi_elba_init()
304 "amd,pensando-elba-syscon"); in dw_spi_elba_init()
306 return dev_err_probe(&pdev->dev, PTR_ERR(syscon), in dw_spi_elba_init()
309 dwsmmio->priv = syscon; in dw_spi_elba_init()
310 dwsmmio->dws.set_cs = dw_spi_elba_set_cs; in dw_spi_elba_init()
324 if (device_property_read_bool(&pdev->dev, "spi-slave")) { in dw_spi_mmio_probe()
325 dev_warn(&pdev->dev, "spi-slave is not yet supported\n"); in dw_spi_mmio_probe()
326 return -ENODEV; in dw_spi_mmio_probe()
329 dwsmmio = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_mmio), in dw_spi_mmio_probe()
332 return -ENOMEM; in dw_spi_mmio_probe()
334 dws = &dwsmmio->dws; in dw_spi_mmio_probe()
337 dws->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem); in dw_spi_mmio_probe()
338 if (IS_ERR(dws->regs)) in dw_spi_mmio_probe()
339 return PTR_ERR(dws->regs); in dw_spi_mmio_probe()
341 dws->paddr = mem->start; in dw_spi_mmio_probe()
343 dws->irq = platform_get_irq(pdev, 0); in dw_spi_mmio_probe()
344 if (dws->irq < 0) in dw_spi_mmio_probe()
345 return dws->irq; /* -ENXIO */ in dw_spi_mmio_probe()
347 dwsmmio->clk = devm_clk_get_enabled(&pdev->dev, NULL); in dw_spi_mmio_probe()
348 if (IS_ERR(dwsmmio->clk)) in dw_spi_mmio_probe()
349 return PTR_ERR(dwsmmio->clk); in dw_spi_mmio_probe()
352 dwsmmio->pclk = devm_clk_get_optional_enabled(&pdev->dev, "pclk"); in dw_spi_mmio_probe()
353 if (IS_ERR(dwsmmio->pclk)) in dw_spi_mmio_probe()
354 return PTR_ERR(dwsmmio->pclk); in dw_spi_mmio_probe()
357 dwsmmio->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, "spi"); in dw_spi_mmio_probe()
358 if (IS_ERR(dwsmmio->rstc)) in dw_spi_mmio_probe()
359 return PTR_ERR(dwsmmio->rstc); in dw_spi_mmio_probe()
361 reset_control_deassert(dwsmmio->rstc); in dw_spi_mmio_probe()
363 dws->bus_num = pdev->id; in dw_spi_mmio_probe()
365 dws->max_freq = clk_get_rate(dwsmmio->clk); in dw_spi_mmio_probe()
367 if (device_property_read_u32(&pdev->dev, "reg-io-width", in dw_spi_mmio_probe()
368 &dws->reg_io_width)) in dw_spi_mmio_probe()
369 dws->reg_io_width = 4; in dw_spi_mmio_probe()
371 /* Rely on the auto-detection if no property specified */ in dw_spi_mmio_probe()
372 device_property_read_u32(&pdev->dev, "num-cs", &dws->num_cs); in dw_spi_mmio_probe()
374 init_func = device_get_match_data(&pdev->dev); in dw_spi_mmio_probe()
381 pm_runtime_enable(&pdev->dev); in dw_spi_mmio_probe()
383 ret = dw_spi_add_host(&pdev->dev, dws); in dw_spi_mmio_probe()
391 pm_runtime_disable(&pdev->dev); in dw_spi_mmio_probe()
393 reset_control_assert(dwsmmio->rstc); in dw_spi_mmio_probe()
402 dw_spi_remove_host(&dwsmmio->dws); in dw_spi_mmio_remove()
403 pm_runtime_disable(&pdev->dev); in dw_spi_mmio_remove()
404 reset_control_assert(dwsmmio->rstc); in dw_spi_mmio_remove()
408 { .compatible = "snps,dw-apb-ssi", .data = dw_spi_pssi_init},
409 { .compatible = "mscc,ocelot-spi", .data = dw_spi_mscc_ocelot_init},
410 { .compatible = "mscc,jaguar2-spi", .data = dw_spi_mscc_jaguar2_init},
411 { .compatible = "amazon,alpine-dw-apb-ssi", .data = dw_spi_alpine_init},
412 { .compatible = "renesas,rzn1-spi", .data = dw_spi_pssi_init},
413 { .compatible = "snps,dwc-ssi-1.01a", .data = dw_spi_hssi_init},
414 { .compatible = "intel,keembay-ssi", .data = dw_spi_intel_init},
416 .compatible = "intel,mountevans-imc-ssi",
419 { .compatible = "microchip,sparx5-spi", dw_spi_mscc_sparx5_init},
420 { .compatible = "canaan,k210-spi", dw_spi_canaan_k210_init},
421 { .compatible = "amd,pensando-elba-spi", .data = dw_spi_elba_init},
445 MODULE_AUTHOR("Jean-Hugues Deschenes <jean-hugues.deschenes@octasic.com>");
446 MODULE_DESCRIPTION("Memory-mapped I/O interface driver for DW SPI Core");