Lines Matching +full:spi +full:- +full:base
1 // SPDX-License-Identifier: GPL-2.0
3 // DFL bus driver for Altera SPI Master
19 #include <linux/io-64-nonatomic-lo-hi.h>
21 #include <linux/spi/spi.h>
22 #include <linux/spi/altera.h>
52 void __iomem *base = context; in indirect_bus_reg_read() local
56 writeq((reg >> 2) | INDIRECT_RD, base + INDIRECT_ADDR); in indirect_bus_reg_read()
59 while ((readq(base + INDIRECT_ADDR) & INDIRECT_RD) && in indirect_bus_reg_read()
65 return -ETIME; in indirect_bus_reg_read()
68 v = readq(base + INDIRECT_RD_DATA); in indirect_bus_reg_read()
78 void __iomem *base = context; in indirect_bus_reg_write() local
81 writeq(val, base + INDIRECT_WR_DATA); in indirect_bus_reg_write()
82 writeq((reg >> 2) | INDIRECT_WR, base + INDIRECT_ADDR); in indirect_bus_reg_write()
85 while ((readq(base + INDIRECT_ADDR) & INDIRECT_WR) && in indirect_bus_reg_write()
91 return -ETIME; in indirect_bus_reg_write()
107 static void config_spi_host(void __iomem *base, struct spi_controller *host) in config_spi_host() argument
111 v = readq(base + SPI_CORE_PARAMETER); in config_spi_host()
113 host->mode_bits = SPI_CS_HIGH; in config_spi_host()
115 host->mode_bits |= SPI_CPOL; in config_spi_host()
117 host->mode_bits |= SPI_CPHA; in config_spi_host()
119 host->num_chipselect = FIELD_GET(NUM_CHIPSELECT, v); in config_spi_host()
120 host->bits_per_word_mask = in config_spi_host()
127 struct device *dev = &dfl_dev->dev; in dfl_spi_altera_probe()
130 void __iomem *base; in dfl_spi_altera_probe() local
135 return -ENOMEM; in dfl_spi_altera_probe()
137 host->bus_num = -1; in dfl_spi_altera_probe()
141 hw->dev = dev; in dfl_spi_altera_probe()
143 base = devm_ioremap_resource(dev, &dfl_dev->mmio_res); in dfl_spi_altera_probe()
145 if (IS_ERR(base)) in dfl_spi_altera_probe()
146 return PTR_ERR(base); in dfl_spi_altera_probe()
148 config_spi_host(base, host); in dfl_spi_altera_probe()
150 host->num_chipselect, host->bits_per_word_mask, in dfl_spi_altera_probe()
151 host->mode_bits); in dfl_spi_altera_probe()
153 hw->regmap = devm_regmap_init(dev, NULL, base, &indirect_regbus_cfg); in dfl_spi_altera_probe()
154 if (IS_ERR(hw->regmap)) in dfl_spi_altera_probe()
155 return PTR_ERR(hw->regmap); in dfl_spi_altera_probe()
157 hw->irq = -EINVAL; in dfl_spi_altera_probe()
163 return dev_err_probe(dev, err, "%s failed to register spi host\n", in dfl_spi_altera_probe()
166 if (dfl_dev->revision == FME_FEATURE_REV_MAX10_SPI_N5010) in dfl_spi_altera_probe()
167 strscpy(board_info.modalias, "m10-n5010", SPI_NAME_SIZE); in dfl_spi_altera_probe()
169 strscpy(board_info.modalias, "m10-d5005", SPI_NAME_SIZE); in dfl_spi_altera_probe()
176 dev_err(dev, "%s failed to create SPI device: %s\n", in dfl_spi_altera_probe()
190 .name = "dfl-spi-altera",
199 MODULE_DESCRIPTION("DFL spi altera driver");