diff options
author | Jan Kundrát <jan.kundrat@cesnet.cz> | 2018-02-10 06:20:23 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-02-15 10:19:58 -0500 |
commit | 5c22af7eeb265413b80eb8e03ae708e1b222728c (patch) | |
tree | 60f602d5a632cbbf050715017c563ab7a1f321da | |
parent | 64aa3bd32c2679ed51401cb32fe6b387a1e6b51b (diff) |
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: Jan Kundrát <jan.kundrat@cesnet.cz>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spi-orion.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index ca52300baeb1..d01a6adc726e 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c | |||
@@ -90,6 +90,10 @@ struct orion_direct_acc { | |||
90 | u32 size; | 90 | u32 size; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | struct orion_child_options { | ||
94 | struct orion_direct_acc direct_access; | ||
95 | }; | ||
96 | |||
93 | struct orion_spi { | 97 | struct orion_spi { |
94 | struct spi_master *master; | 98 | struct spi_master *master; |
95 | void __iomem *base; | 99 | void __iomem *base; |
@@ -98,7 +102,7 @@ struct orion_spi { | |||
98 | const struct orion_spi_dev *devdata; | 102 | const struct orion_spi_dev *devdata; |
99 | int unused_hw_gpio; | 103 | int unused_hw_gpio; |
100 | 104 | ||
101 | struct orion_direct_acc direct_access[ORION_NUM_CHIPSELECTS]; | 105 | struct orion_child_options child[ORION_NUM_CHIPSELECTS]; |
102 | }; | 106 | }; |
103 | 107 | ||
104 | static inline void __iomem *spi_reg(struct orion_spi *orion_spi, u32 reg) | 108 | 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 | * Use SPI direct write mode if base address is available. Otherwise | 440 | * Use SPI direct write mode if base address is available. Otherwise |
437 | * fall back to PIO mode for this transfer. | 441 | * fall back to PIO mode for this transfer. |
438 | */ | 442 | */ |
439 | if ((orion_spi->direct_access[cs].vaddr) && (xfer->tx_buf) && | 443 | if ((orion_spi->child[cs].direct_access.vaddr) && (xfer->tx_buf) && |
440 | (word_len == 8)) { | 444 | (word_len == 8)) { |
441 | unsigned int cnt = count / 4; | 445 | unsigned int cnt = count / 4; |
442 | unsigned int rem = count % 4; | 446 | unsigned int rem = count % 4; |
@@ -445,12 +449,12 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) | |||
445 | * Send the TX-data to the SPI device via the direct | 449 | * Send the TX-data to the SPI device via the direct |
446 | * mapped address window | 450 | * mapped address window |
447 | */ | 451 | */ |
448 | iowrite32_rep(orion_spi->direct_access[cs].vaddr, | 452 | iowrite32_rep(orion_spi->child[cs].direct_access.vaddr, |
449 | xfer->tx_buf, cnt); | 453 | xfer->tx_buf, cnt); |
450 | if (rem) { | 454 | if (rem) { |
451 | u32 *buf = (u32 *)xfer->tx_buf; | 455 | u32 *buf = (u32 *)xfer->tx_buf; |
452 | 456 | ||
453 | iowrite8_rep(orion_spi->direct_access[cs].vaddr, | 457 | iowrite8_rep(orion_spi->child[cs].direct_access.vaddr, |
454 | &buf[cnt], rem); | 458 | &buf[cnt], rem); |
455 | } | 459 | } |
456 | 460 | ||
@@ -707,14 +711,14 @@ static int orion_spi_probe(struct platform_device *pdev) | |||
707 | * This needs to get extended for the direct SPI-NOR / SPI-NAND | 711 | * This needs to get extended for the direct SPI-NOR / SPI-NAND |
708 | * support, once this gets implemented. | 712 | * support, once this gets implemented. |
709 | */ | 713 | */ |
710 | spi->direct_access[cs].vaddr = devm_ioremap(&pdev->dev, | 714 | spi->child[cs].direct_access.vaddr = devm_ioremap(&pdev->dev, |
711 | r->start, | 715 | r->start, |
712 | PAGE_SIZE); | 716 | PAGE_SIZE); |
713 | if (!spi->direct_access[cs].vaddr) { | 717 | if (!spi->child[cs].direct_access.vaddr) { |
714 | status = -ENOMEM; | 718 | status = -ENOMEM; |
715 | goto out_rel_axi_clk; | 719 | goto out_rel_axi_clk; |
716 | } | 720 | } |
717 | spi->direct_access[cs].size = PAGE_SIZE; | 721 | spi->child[cs].direct_access.size = PAGE_SIZE; |
718 | 722 | ||
719 | dev_info(&pdev->dev, "CS%d configured for direct access\n", cs); | 723 | dev_info(&pdev->dev, "CS%d configured for direct access\n", cs); |
720 | } | 724 | } |