Commit b299947a authored by Joey Gouly's avatar Joey Gouly
Browse files

WIP: poll instead of interrupts


Signed-off-by: Joey Gouly's avatarJoey Gouly <joey.gouly@arm.com>
parent be7ca458
......@@ -33,6 +33,7 @@
#define REG_CLKDIV_MIN 2
#define REG_CLKDIV_MAX 2047
#define REG_RXCNT 0x34
#define REG_CLKIDLE 0x38
#define REG_TXCNT 0x4C
#define REG_FIFO_LEVEL 0x10C
#define REG_FIFO_LEVEL_TX GENMASK(15, 8)
......@@ -79,6 +80,7 @@ static void apple_spimc_fill_tx(struct apple_spimc *spi, unsigned int tx_avail)
}
}
#if 0
static irqreturn_t apple_spimc_irq(int irq, void *dev_id)
{
struct apple_spimc *spi = dev_id;
......@@ -101,6 +103,7 @@ static irqreturn_t apple_spimc_irq(int irq, void *dev_id)
return IRQ_HANDLED;
}
#endif
static int apple_spimc_clock(struct apple_spimc *spi, u32 speed)
{
......@@ -108,6 +111,7 @@ static int apple_spimc_clock(struct apple_spimc *spi, u32 speed)
writel_relaxed(0, spi->base + REG_CLKCFG);
writel_relaxed(clkdiv, spi->base + REG_CLKDIV);
writel_relaxed(0, spi->base + REG_CLKIDLE);
writel_relaxed(REG_CLKCFG_ENABLE, spi->base + REG_CLKCFG);
return 0;
}
......@@ -130,12 +134,22 @@ static int apple_spimc_transfer_one(struct spi_controller *ctlr, struct spi_devi
writel_relaxed(REG_CONFIG_SET | REG_CONFIG_PIOEN, spi->base + REG_CONFIG);
avail = readl_relaxed(spi->base + REG_FIFO_LEVEL);
rx_avail = FIELD_GET(REG_FIFO_LEVEL_RX, avail);
tx_avail = FIELD_GET(REG_FIFO_LEVEL_TX, avail);
apple_spimc_drain_rx(spi, rx_avail);
apple_spimc_fill_tx(spi, tx_avail);
while (spi->tx_len > 0 || spi->rx_len > 0) {
avail = readl_relaxed(spi->base + REG_FIFO_LEVEL);
rx_avail = FIELD_GET(REG_FIFO_LEVEL_RX, avail);
tx_avail = FIELD_GET(REG_FIFO_LEVEL_TX, avail);
apple_spimc_fill_tx(spi, tx_avail);
apple_spimc_drain_rx(spi, rx_avail);
}
writel_relaxed(REG_CONFIG_SET, spi->base + REG_CONFIG);
status = readl(spi->base + REG_STATUS);
writel(status, spi->base + REG_STATUS);
spi_finalize_current_transfer(ctlr);
return 0;
#if 0
if (spi->tx_len || spi->rx_len) {
// start IRQ
config = readl_relaxed(spi->base + REG_CONFIG);
......@@ -151,6 +165,7 @@ static int apple_spimc_transfer_one(struct spi_controller *ctlr, struct spi_devi
spi_finalize_current_transfer(ctlr);
return 0;
}
#endif
}
static int apple_spimc_probe(struct platform_device *pdev)
......@@ -205,9 +220,11 @@ static int apple_spimc_probe(struct platform_device *pdev)
if (irq < 0)
return irq;
#if 0
ret = devm_request_irq(&pdev->dev, irq, apple_spimc_irq, 0, dev_name(&pdev->dev), spi);
if (ret < 0)
return ret;
#endif
ret = devm_spi_register_controller(&pdev->dev, master);
......
Supports Markdown
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