Thomas Gleixner | 75a6faf | 2019-06-01 10:08:37 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 2 | /* |
Grant Likely | ca632f5 | 2011-06-06 01:16:30 -0600 | [diff] [blame] | 3 | * Memory-mapped interface driver for DW SPI Core |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 4 | * |
| 5 | * Copyright (c) 2010, Octasic semiconductor. |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/clk.h> |
Jamie Iles | 50c01fc | 2011-01-11 12:43:52 +0000 | [diff] [blame] | 9 | #include <linux/err.h> |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 10 | #include <linux/platform_device.h> |
Jarkko Nikula | b9fc2d2 | 2019-10-18 16:21:29 +0300 | [diff] [blame] | 11 | #include <linux/pm_runtime.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 13 | #include <linux/spi/spi.h> |
Grant Likely | 568a60e | 2011-02-28 12:47:12 -0700 | [diff] [blame] | 14 | #include <linux/scatterlist.h> |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 15 | #include <linux/mfd/syscon.h> |
Paul Gortmaker | d7614de | 2011-07-03 15:44:29 -0400 | [diff] [blame] | 16 | #include <linux/module.h> |
Steffen Trumtrar | 22dae17 | 2014-06-13 15:36:18 +0200 | [diff] [blame] | 17 | #include <linux/of.h> |
Steffen Trumtrar | 22dae17 | 2014-06-13 15:36:18 +0200 | [diff] [blame] | 18 | #include <linux/of_platform.h> |
Jay Fang | 32215a6 | 2018-12-03 11:15:50 +0800 | [diff] [blame] | 19 | #include <linux/acpi.h> |
Andy Shevchenko | 9899995 | 2015-10-14 23:12:25 +0300 | [diff] [blame] | 20 | #include <linux/property.h> |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 21 | #include <linux/regmap.h> |
Grant Likely | 568a60e | 2011-02-28 12:47:12 -0700 | [diff] [blame] | 22 | |
Grant Likely | ca632f5 | 2011-06-06 01:16:30 -0600 | [diff] [blame] | 23 | #include "spi-dw.h" |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 24 | |
| 25 | #define DRIVER_NAME "dw_spi_mmio" |
| 26 | |
| 27 | struct dw_spi_mmio { |
Jean-Hugues Deschenes | 0a4c1d7 | 2010-01-21 09:55:42 -0700 | [diff] [blame] | 28 | struct dw_spi dws; |
| 29 | struct clk *clk; |
Phil Edworthy | 560ee7e | 2019-03-19 15:52:07 +0000 | [diff] [blame] | 30 | struct clk *pclk; |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 31 | void *priv; |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 32 | }; |
| 33 | |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 34 | #define MSCC_CPU_SYSTEM_CTRL_GENERAL_CTRL 0x24 |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 35 | #define OCELOT_IF_SI_OWNER_OFFSET 4 |
Alexandre Belloni | be17ee0 | 2018-08-29 14:45:48 +0200 | [diff] [blame] | 36 | #define JAGUAR2_IF_SI_OWNER_OFFSET 6 |
Alexandre Belloni | c1d8b08 | 2018-08-31 13:40:46 +0200 | [diff] [blame] | 37 | #define MSCC_IF_SI_OWNER_MASK GENMASK(1, 0) |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 38 | #define MSCC_IF_SI_OWNER_SISL 0 |
| 39 | #define MSCC_IF_SI_OWNER_SIBM 1 |
| 40 | #define MSCC_IF_SI_OWNER_SIMC 2 |
| 41 | |
| 42 | #define MSCC_SPI_MST_SW_MODE 0x14 |
| 43 | #define MSCC_SPI_MST_SW_MODE_SW_PIN_CTRL_MODE BIT(13) |
| 44 | #define MSCC_SPI_MST_SW_MODE_SW_SPI_CS(x) (x << 5) |
| 45 | |
Wan Ahmad Zainie | f423779 | 2020-05-05 21:06:16 +0800 | [diff] [blame] | 46 | /* |
| 47 | * For Keem Bay, CTRLR0[31] is used to select controller mode. |
| 48 | * 0: SSI is slave |
| 49 | * 1: SSI is master |
| 50 | */ |
| 51 | #define KEEMBAY_CTRLR0_SSIC_IS_MST BIT(31) |
| 52 | |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 53 | struct dw_spi_mscc { |
| 54 | struct regmap *syscon; |
| 55 | void __iomem *spi_mst; |
| 56 | }; |
| 57 | |
| 58 | /* |
| 59 | * The Designware SPI controller (referred to as master in the documentation) |
| 60 | * automatically deasserts chip select when the tx fifo is empty. The chip |
| 61 | * selects then needs to be either driven as GPIOs or, for the first 4 using the |
| 62 | * the SPI boot controller registers. the final chip select is an OR gate |
| 63 | * between the Designware SPI controller and the SPI boot controller. |
| 64 | */ |
| 65 | static void dw_spi_mscc_set_cs(struct spi_device *spi, bool enable) |
| 66 | { |
| 67 | struct dw_spi *dws = spi_master_get_devdata(spi->master); |
| 68 | struct dw_spi_mmio *dwsmmio = container_of(dws, struct dw_spi_mmio, dws); |
| 69 | struct dw_spi_mscc *dwsmscc = dwsmmio->priv; |
| 70 | u32 cs = spi->chip_select; |
| 71 | |
| 72 | if (cs < 4) { |
| 73 | u32 sw_mode = MSCC_SPI_MST_SW_MODE_SW_PIN_CTRL_MODE; |
| 74 | |
| 75 | if (!enable) |
| 76 | sw_mode |= MSCC_SPI_MST_SW_MODE_SW_SPI_CS(BIT(cs)); |
| 77 | |
| 78 | writel(sw_mode, dwsmscc->spi_mst + MSCC_SPI_MST_SW_MODE); |
| 79 | } |
| 80 | |
| 81 | dw_spi_set_cs(spi, enable); |
| 82 | } |
| 83 | |
| 84 | static int dw_spi_mscc_init(struct platform_device *pdev, |
Alexandre Belloni | be17ee0 | 2018-08-29 14:45:48 +0200 | [diff] [blame] | 85 | struct dw_spi_mmio *dwsmmio, |
| 86 | const char *cpu_syscon, u32 if_si_owner_offset) |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 87 | { |
| 88 | struct dw_spi_mscc *dwsmscc; |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 89 | |
| 90 | dwsmscc = devm_kzalloc(&pdev->dev, sizeof(*dwsmscc), GFP_KERNEL); |
| 91 | if (!dwsmscc) |
| 92 | return -ENOMEM; |
| 93 | |
YueHaibing | 5cc6fdc | 2019-09-04 21:58:54 +0800 | [diff] [blame] | 94 | dwsmscc->spi_mst = devm_platform_ioremap_resource(pdev, 1); |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 95 | if (IS_ERR(dwsmscc->spi_mst)) { |
| 96 | dev_err(&pdev->dev, "SPI_MST region map failed\n"); |
| 97 | return PTR_ERR(dwsmscc->spi_mst); |
| 98 | } |
| 99 | |
Alexandre Belloni | be17ee0 | 2018-08-29 14:45:48 +0200 | [diff] [blame] | 100 | dwsmscc->syscon = syscon_regmap_lookup_by_compatible(cpu_syscon); |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 101 | if (IS_ERR(dwsmscc->syscon)) |
| 102 | return PTR_ERR(dwsmscc->syscon); |
| 103 | |
| 104 | /* Deassert all CS */ |
| 105 | writel(0, dwsmscc->spi_mst + MSCC_SPI_MST_SW_MODE); |
| 106 | |
| 107 | /* Select the owner of the SI interface */ |
| 108 | regmap_update_bits(dwsmscc->syscon, MSCC_CPU_SYSTEM_CTRL_GENERAL_CTRL, |
Alexandre Belloni | c1d8b08 | 2018-08-31 13:40:46 +0200 | [diff] [blame] | 109 | MSCC_IF_SI_OWNER_MASK << if_si_owner_offset, |
Alexandre Belloni | be17ee0 | 2018-08-29 14:45:48 +0200 | [diff] [blame] | 110 | MSCC_IF_SI_OWNER_SIMC << if_si_owner_offset); |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 111 | |
| 112 | dwsmmio->dws.set_cs = dw_spi_mscc_set_cs; |
| 113 | dwsmmio->priv = dwsmscc; |
| 114 | |
Wan Ahmad Zainie | c4eadee | 2020-05-05 21:06:13 +0800 | [diff] [blame] | 115 | /* Register hook to configure CTRLR0 */ |
| 116 | dwsmmio->dws.update_cr0 = dw_spi_update_cr0; |
| 117 | |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 118 | return 0; |
| 119 | } |
| 120 | |
Alexandre Belloni | be17ee0 | 2018-08-29 14:45:48 +0200 | [diff] [blame] | 121 | static int dw_spi_mscc_ocelot_init(struct platform_device *pdev, |
| 122 | struct dw_spi_mmio *dwsmmio) |
| 123 | { |
| 124 | return dw_spi_mscc_init(pdev, dwsmmio, "mscc,ocelot-cpu-syscon", |
| 125 | OCELOT_IF_SI_OWNER_OFFSET); |
| 126 | } |
| 127 | |
| 128 | static int dw_spi_mscc_jaguar2_init(struct platform_device *pdev, |
| 129 | struct dw_spi_mmio *dwsmmio) |
| 130 | { |
| 131 | return dw_spi_mscc_init(pdev, dwsmmio, "mscc,jaguar2-cpu-syscon", |
| 132 | JAGUAR2_IF_SI_OWNER_OFFSET); |
| 133 | } |
| 134 | |
Talel Shenhar | f2d7047 | 2018-10-11 14:20:07 +0300 | [diff] [blame] | 135 | static int dw_spi_alpine_init(struct platform_device *pdev, |
| 136 | struct dw_spi_mmio *dwsmmio) |
| 137 | { |
| 138 | dwsmmio->dws.cs_override = 1; |
| 139 | |
Wan Ahmad Zainie | c4eadee | 2020-05-05 21:06:13 +0800 | [diff] [blame] | 140 | /* Register hook to configure CTRLR0 */ |
| 141 | dwsmmio->dws.update_cr0 = dw_spi_update_cr0; |
| 142 | |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | static int dw_spi_dw_apb_init(struct platform_device *pdev, |
| 147 | struct dw_spi_mmio *dwsmmio) |
| 148 | { |
| 149 | /* Register hook to configure CTRLR0 */ |
| 150 | dwsmmio->dws.update_cr0 = dw_spi_update_cr0; |
| 151 | |
Serge Semin | 0fdad59 | 2020-05-29 16:12:03 +0300 | [diff] [blame^] | 152 | dw_spi_dma_setup_generic(&dwsmmio->dws); |
| 153 | |
Talel Shenhar | f2d7047 | 2018-10-11 14:20:07 +0300 | [diff] [blame] | 154 | return 0; |
| 155 | } |
| 156 | |
Wan Ahmad Zainie | e539f43 | 2020-05-05 21:06:14 +0800 | [diff] [blame] | 157 | static int dw_spi_dwc_ssi_init(struct platform_device *pdev, |
| 158 | struct dw_spi_mmio *dwsmmio) |
| 159 | { |
| 160 | /* Register hook to configure CTRLR0 */ |
| 161 | dwsmmio->dws.update_cr0 = dw_spi_update_cr0_v1_01a; |
| 162 | |
Serge Semin | 0fdad59 | 2020-05-29 16:12:03 +0300 | [diff] [blame^] | 163 | dw_spi_dma_setup_generic(&dwsmmio->dws); |
| 164 | |
Wan Ahmad Zainie | e539f43 | 2020-05-05 21:06:14 +0800 | [diff] [blame] | 165 | return 0; |
| 166 | } |
| 167 | |
Wan Ahmad Zainie | f423779 | 2020-05-05 21:06:16 +0800 | [diff] [blame] | 168 | static u32 dw_spi_update_cr0_keembay(struct spi_controller *master, |
| 169 | struct spi_device *spi, |
| 170 | struct spi_transfer *transfer) |
| 171 | { |
| 172 | u32 cr0 = dw_spi_update_cr0_v1_01a(master, spi, transfer); |
| 173 | |
| 174 | return cr0 | KEEMBAY_CTRLR0_SSIC_IS_MST; |
| 175 | } |
| 176 | |
| 177 | static int dw_spi_keembay_init(struct platform_device *pdev, |
| 178 | struct dw_spi_mmio *dwsmmio) |
| 179 | { |
| 180 | /* Register hook to configure CTRLR0 */ |
| 181 | dwsmmio->dws.update_cr0 = dw_spi_update_cr0_keembay; |
| 182 | |
| 183 | return 0; |
| 184 | } |
| 185 | |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 186 | static int dw_spi_mmio_probe(struct platform_device *pdev) |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 187 | { |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 188 | int (*init_func)(struct platform_device *pdev, |
| 189 | struct dw_spi_mmio *dwsmmio); |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 190 | struct dw_spi_mmio *dwsmmio; |
Serge Semin | 77810d4 | 2020-05-15 13:47:50 +0300 | [diff] [blame] | 191 | struct resource *mem; |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 192 | struct dw_spi *dws; |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 193 | int ret; |
Steffen Trumtrar | 22dae17 | 2014-06-13 15:36:18 +0200 | [diff] [blame] | 194 | int num_cs; |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 195 | |
Baruch Siach | 04f421e | 2013-12-30 20:30:44 +0200 | [diff] [blame] | 196 | dwsmmio = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_mmio), |
| 197 | GFP_KERNEL); |
| 198 | if (!dwsmmio) |
| 199 | return -ENOMEM; |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 200 | |
| 201 | dws = &dwsmmio->dws; |
| 202 | |
| 203 | /* Get basic io resource and map it */ |
Serge Semin | 77810d4 | 2020-05-15 13:47:50 +0300 | [diff] [blame] | 204 | dws->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem); |
Andy Shevchenko | afb7f565 | 2020-05-12 14:03:15 +0300 | [diff] [blame] | 205 | if (IS_ERR(dws->regs)) |
Baruch Siach | 04f421e | 2013-12-30 20:30:44 +0200 | [diff] [blame] | 206 | return PTR_ERR(dws->regs); |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 207 | |
Serge Semin | 77810d4 | 2020-05-15 13:47:50 +0300 | [diff] [blame] | 208 | dws->paddr = mem->start; |
| 209 | |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 210 | dws->irq = platform_get_irq(pdev, 0); |
Stephen Boyd | 6b8ac10 | 2019-07-30 11:15:41 -0700 | [diff] [blame] | 211 | if (dws->irq < 0) |
Baruch Siach | 04f421e | 2013-12-30 20:30:44 +0200 | [diff] [blame] | 212 | return dws->irq; /* -ENXIO */ |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 213 | |
Baruch Siach | 04f421e | 2013-12-30 20:30:44 +0200 | [diff] [blame] | 214 | dwsmmio->clk = devm_clk_get(&pdev->dev, NULL); |
| 215 | if (IS_ERR(dwsmmio->clk)) |
| 216 | return PTR_ERR(dwsmmio->clk); |
Baruch Siach | 020fe3f | 2013-12-30 20:30:45 +0200 | [diff] [blame] | 217 | ret = clk_prepare_enable(dwsmmio->clk); |
Baruch Siach | 04f421e | 2013-12-30 20:30:44 +0200 | [diff] [blame] | 218 | if (ret) |
| 219 | return ret; |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 220 | |
Phil Edworthy | 560ee7e | 2019-03-19 15:52:07 +0000 | [diff] [blame] | 221 | /* Optional clock needed to access the registers */ |
| 222 | dwsmmio->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); |
Andy Shevchenko | 3da9834 | 2019-07-10 14:42:43 +0300 | [diff] [blame] | 223 | if (IS_ERR(dwsmmio->pclk)) { |
| 224 | ret = PTR_ERR(dwsmmio->pclk); |
| 225 | goto out_clk; |
| 226 | } |
Phil Edworthy | 560ee7e | 2019-03-19 15:52:07 +0000 | [diff] [blame] | 227 | ret = clk_prepare_enable(dwsmmio->pclk); |
| 228 | if (ret) |
| 229 | goto out_clk; |
| 230 | |
Baruch Siach | 2418991e | 2014-01-26 10:14:32 +0200 | [diff] [blame] | 231 | dws->bus_num = pdev->id; |
Steffen Trumtrar | 22dae17 | 2014-06-13 15:36:18 +0200 | [diff] [blame] | 232 | |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 233 | dws->max_freq = clk_get_rate(dwsmmio->clk); |
| 234 | |
Andy Shevchenko | 9899995 | 2015-10-14 23:12:25 +0300 | [diff] [blame] | 235 | device_property_read_u32(&pdev->dev, "reg-io-width", &dws->reg_io_width); |
Michael van der Westhuizen | c4fe57f | 2015-08-18 22:21:53 +0200 | [diff] [blame] | 236 | |
Steffen Trumtrar | 22dae17 | 2014-06-13 15:36:18 +0200 | [diff] [blame] | 237 | num_cs = 4; |
| 238 | |
Andy Shevchenko | 9899995 | 2015-10-14 23:12:25 +0300 | [diff] [blame] | 239 | device_property_read_u32(&pdev->dev, "num-cs", &num_cs); |
Steffen Trumtrar | 22dae17 | 2014-06-13 15:36:18 +0200 | [diff] [blame] | 240 | |
| 241 | dws->num_cs = num_cs; |
| 242 | |
Alexandre Belloni | c2c25cc | 2018-07-27 21:53:56 +0200 | [diff] [blame] | 243 | init_func = device_get_match_data(&pdev->dev); |
| 244 | if (init_func) { |
| 245 | ret = init_func(pdev, dwsmmio); |
| 246 | if (ret) |
| 247 | goto out; |
| 248 | } |
| 249 | |
Jarkko Nikula | b9fc2d2 | 2019-10-18 16:21:29 +0300 | [diff] [blame] | 250 | pm_runtime_enable(&pdev->dev); |
| 251 | |
Baruch Siach | 04f421e | 2013-12-30 20:30:44 +0200 | [diff] [blame] | 252 | ret = dw_spi_add_host(&pdev->dev, dws); |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 253 | if (ret) |
Baruch Siach | 04f421e | 2013-12-30 20:30:44 +0200 | [diff] [blame] | 254 | goto out; |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 255 | |
| 256 | platform_set_drvdata(pdev, dwsmmio); |
| 257 | return 0; |
| 258 | |
Baruch Siach | 04f421e | 2013-12-30 20:30:44 +0200 | [diff] [blame] | 259 | out: |
Jarkko Nikula | b9fc2d2 | 2019-10-18 16:21:29 +0300 | [diff] [blame] | 260 | pm_runtime_disable(&pdev->dev); |
Phil Edworthy | 560ee7e | 2019-03-19 15:52:07 +0000 | [diff] [blame] | 261 | clk_disable_unprepare(dwsmmio->pclk); |
| 262 | out_clk: |
Baruch Siach | 020fe3f | 2013-12-30 20:30:45 +0200 | [diff] [blame] | 263 | clk_disable_unprepare(dwsmmio->clk); |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 264 | return ret; |
| 265 | } |
| 266 | |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 267 | static int dw_spi_mmio_remove(struct platform_device *pdev) |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 268 | { |
| 269 | struct dw_spi_mmio *dwsmmio = platform_get_drvdata(pdev); |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 270 | |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 271 | dw_spi_remove_host(&dwsmmio->dws); |
Jarkko Nikula | b9fc2d2 | 2019-10-18 16:21:29 +0300 | [diff] [blame] | 272 | pm_runtime_disable(&pdev->dev); |
Phil Edworthy | 560ee7e | 2019-03-19 15:52:07 +0000 | [diff] [blame] | 273 | clk_disable_unprepare(dwsmmio->pclk); |
Marek Vasut | 400c18e | 2017-04-18 20:09:06 +0200 | [diff] [blame] | 274 | clk_disable_unprepare(dwsmmio->clk); |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 275 | |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 276 | return 0; |
| 277 | } |
| 278 | |
Steffen Trumtrar | 22dae17 | 2014-06-13 15:36:18 +0200 | [diff] [blame] | 279 | static const struct of_device_id dw_spi_mmio_of_match[] = { |
Wan Ahmad Zainie | c4eadee | 2020-05-05 21:06:13 +0800 | [diff] [blame] | 280 | { .compatible = "snps,dw-apb-ssi", .data = dw_spi_dw_apb_init}, |
Alexandre Belloni | be17ee0 | 2018-08-29 14:45:48 +0200 | [diff] [blame] | 281 | { .compatible = "mscc,ocelot-spi", .data = dw_spi_mscc_ocelot_init}, |
| 282 | { .compatible = "mscc,jaguar2-spi", .data = dw_spi_mscc_jaguar2_init}, |
Talel Shenhar | f2d7047 | 2018-10-11 14:20:07 +0300 | [diff] [blame] | 283 | { .compatible = "amazon,alpine-dw-apb-ssi", .data = dw_spi_alpine_init}, |
Wan Ahmad Zainie | c4eadee | 2020-05-05 21:06:13 +0800 | [diff] [blame] | 284 | { .compatible = "renesas,rzn1-spi", .data = dw_spi_dw_apb_init}, |
Wan Ahmad Zainie | e539f43 | 2020-05-05 21:06:14 +0800 | [diff] [blame] | 285 | { .compatible = "snps,dwc-ssi-1.01a", .data = dw_spi_dwc_ssi_init}, |
Wan Ahmad Zainie | f423779 | 2020-05-05 21:06:16 +0800 | [diff] [blame] | 286 | { .compatible = "intel,keembay-ssi", .data = dw_spi_keembay_init}, |
Steffen Trumtrar | 22dae17 | 2014-06-13 15:36:18 +0200 | [diff] [blame] | 287 | { /* end of table */} |
| 288 | }; |
| 289 | MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match); |
| 290 | |
Jay Fang | 4dd227a | 2020-05-09 10:29:51 +0800 | [diff] [blame] | 291 | #ifdef CONFIG_ACPI |
Jay Fang | 32215a6 | 2018-12-03 11:15:50 +0800 | [diff] [blame] | 292 | static const struct acpi_device_id dw_spi_mmio_acpi_match[] = { |
Wan Ahmad Zainie | c4eadee | 2020-05-05 21:06:13 +0800 | [diff] [blame] | 293 | {"HISI0173", (kernel_ulong_t)dw_spi_dw_apb_init}, |
Jay Fang | 32215a6 | 2018-12-03 11:15:50 +0800 | [diff] [blame] | 294 | {}, |
| 295 | }; |
| 296 | MODULE_DEVICE_TABLE(acpi, dw_spi_mmio_acpi_match); |
Jay Fang | 4dd227a | 2020-05-09 10:29:51 +0800 | [diff] [blame] | 297 | #endif |
Jay Fang | 32215a6 | 2018-12-03 11:15:50 +0800 | [diff] [blame] | 298 | |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 299 | static struct platform_driver dw_spi_mmio_driver = { |
Grant Likely | 940ab88 | 2011-10-05 11:29:49 -0600 | [diff] [blame] | 300 | .probe = dw_spi_mmio_probe, |
Grant Likely | fd4a319 | 2012-12-07 16:57:14 +0000 | [diff] [blame] | 301 | .remove = dw_spi_mmio_remove, |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 302 | .driver = { |
| 303 | .name = DRIVER_NAME, |
Steffen Trumtrar | 22dae17 | 2014-06-13 15:36:18 +0200 | [diff] [blame] | 304 | .of_match_table = dw_spi_mmio_of_match, |
Jay Fang | 32215a6 | 2018-12-03 11:15:50 +0800 | [diff] [blame] | 305 | .acpi_match_table = ACPI_PTR(dw_spi_mmio_acpi_match), |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 306 | }, |
| 307 | }; |
Grant Likely | 940ab88 | 2011-10-05 11:29:49 -0600 | [diff] [blame] | 308 | module_platform_driver(dw_spi_mmio_driver); |
Jean-Hugues Deschenes | f7b6fd6 | 2010-01-21 07:46:42 -0700 | [diff] [blame] | 309 | |
| 310 | MODULE_AUTHOR("Jean-Hugues Deschenes <jean-hugues.deschenes@octasic.com>"); |
| 311 | MODULE_DESCRIPTION("Memory-mapped I/O interface driver for DW SPI Core"); |
| 312 | MODULE_LICENSE("GPL v2"); |