Commit 5c22af7e authored by Jan Kundrát's avatar Jan Kundrát Committed by Mark Brown

spi: orion: Prepare space for per-child options

Aggregating all options for a particular child underneath a common
struct looks cleaner compared to having a separate array for each
per-child option.
Signed-off-by: default avatarJan Kundrát <jan.kundrat@cesnet.cz>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 64aa3bd3
...@@ -90,6 +90,10 @@ struct orion_direct_acc { ...@@ -90,6 +90,10 @@ struct orion_direct_acc {
u32 size; u32 size;
}; };
struct orion_child_options {
struct orion_direct_acc direct_access;
};
struct orion_spi { struct orion_spi {
struct spi_master *master; struct spi_master *master;
void __iomem *base; void __iomem *base;
...@@ -98,7 +102,7 @@ struct orion_spi { ...@@ -98,7 +102,7 @@ struct orion_spi {
const struct orion_spi_dev *devdata; const struct orion_spi_dev *devdata;
int unused_hw_gpio; int unused_hw_gpio;
struct orion_direct_acc direct_access[ORION_NUM_CHIPSELECTS]; struct orion_child_options child[ORION_NUM_CHIPSELECTS];
}; };
static inline void __iomem *spi_reg(struct orion_spi *orion_spi, u32 reg) static inline void __iomem *spi_reg(struct orion_spi *orion_spi, u32 reg)
...@@ -436,7 +440,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -436,7 +440,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
* Use SPI direct write mode if base address is available. Otherwise * Use SPI direct write mode if base address is available. Otherwise
* fall back to PIO mode for this transfer. * fall back to PIO mode for this transfer.
*/ */
if ((orion_spi->direct_access[cs].vaddr) && (xfer->tx_buf) && if ((orion_spi->child[cs].direct_access.vaddr) && (xfer->tx_buf) &&
(word_len == 8)) { (word_len == 8)) {
unsigned int cnt = count / 4; unsigned int cnt = count / 4;
unsigned int rem = count % 4; unsigned int rem = count % 4;
...@@ -445,12 +449,12 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -445,12 +449,12 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
* Send the TX-data to the SPI device via the direct * Send the TX-data to the SPI device via the direct
* mapped address window * mapped address window
*/ */
iowrite32_rep(orion_spi->direct_access[cs].vaddr, iowrite32_rep(orion_spi->child[cs].direct_access.vaddr,
xfer->tx_buf, cnt); xfer->tx_buf, cnt);
if (rem) { if (rem) {
u32 *buf = (u32 *)xfer->tx_buf; u32 *buf = (u32 *)xfer->tx_buf;
iowrite8_rep(orion_spi->direct_access[cs].vaddr, iowrite8_rep(orion_spi->child[cs].direct_access.vaddr,
&buf[cnt], rem); &buf[cnt], rem);
} }
...@@ -707,14 +711,14 @@ static int orion_spi_probe(struct platform_device *pdev) ...@@ -707,14 +711,14 @@ static int orion_spi_probe(struct platform_device *pdev)
* This needs to get extended for the direct SPI-NOR / SPI-NAND * This needs to get extended for the direct SPI-NOR / SPI-NAND
* support, once this gets implemented. * support, once this gets implemented.
*/ */
spi->direct_access[cs].vaddr = devm_ioremap(&pdev->dev, spi->child[cs].direct_access.vaddr = devm_ioremap(&pdev->dev,
r->start, r->start,
PAGE_SIZE); PAGE_SIZE);
if (!spi->direct_access[cs].vaddr) { if (!spi->child[cs].direct_access.vaddr) {
status = -ENOMEM; status = -ENOMEM;
goto out_rel_axi_clk; goto out_rel_axi_clk;
} }
spi->direct_access[cs].size = PAGE_SIZE; spi->child[cs].direct_access.size = PAGE_SIZE;
dev_info(&pdev->dev, "CS%d configured for direct access\n", cs); dev_info(&pdev->dev, "CS%d configured for direct access\n", cs);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment