mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-29 10:08:59 +00:00
99545b4bb1
This target adds support for the Allwinner D1 RISC-V based SoCs. - RISC-V single-core T-Head C906 (RV64GCV) - Tensilica HiFi4 DSP - DDR2/DDR3 support - 10/100/1000M ethernet - usual peripherals like USB2, SPI, I2C, PWM, etc. Four boards are supported: - Dongshan Nezha STU - 512Mb RAM - ethernet - LicheePi RV Dock - 512Mb RAM - wireless-only (RTL8723DS) - MangoPi MQ-Pro - 512Mb RAM - there are pads available for an SPI flash - wireless-only (RTL8723DS) - Nezha D1 - 512Mb/1Gb/2Gb RAM - 256Mb NAND flash - ethernet, wireless Installation: Standard SD-card installation via dd-ing the generated image to an SD-card of at least 256Mb. Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
110 lines
3.4 KiB
Diff
110 lines
3.4 KiB
Diff
From dbc9e83cefe51d19877a4a7349ebbeafa31c0e06 Mon Sep 17 00:00:00 2001
|
|
From: Samuel Holland <samuel@sholland.org>
|
|
Date: Fri, 16 Jul 2021 21:33:16 -0500
|
|
Subject: [PATCH 075/117] spi: spi-sun6i: Use a struct for quirks
|
|
|
|
Signed-off-by: Samuel Holland <samuel@sholland.org>
|
|
---
|
|
drivers/spi/spi-sun6i.c | 32 ++++++++++++++++++++++----------
|
|
1 file changed, 22 insertions(+), 10 deletions(-)
|
|
|
|
--- a/drivers/spi/spi-sun6i.c
|
|
+++ b/drivers/spi/spi-sun6i.c
|
|
@@ -85,7 +85,12 @@
|
|
#define SUN6I_TXDATA_REG 0x200
|
|
#define SUN6I_RXDATA_REG 0x300
|
|
|
|
+struct sun6i_spi_quirks {
|
|
+ unsigned long fifo_depth;
|
|
+};
|
|
+
|
|
struct sun6i_spi {
|
|
+ const struct sun6i_spi_quirks *quirks;
|
|
struct spi_master *master;
|
|
void __iomem *base_addr;
|
|
dma_addr_t dma_addr_rx;
|
|
@@ -100,7 +105,6 @@ struct sun6i_spi {
|
|
const u8 *tx_buf;
|
|
u8 *rx_buf;
|
|
int len;
|
|
- unsigned long fifo_depth;
|
|
};
|
|
|
|
static inline u32 sun6i_spi_read(struct sun6i_spi *sspi, u32 reg)
|
|
@@ -157,7 +161,7 @@ static inline void sun6i_spi_fill_fifo(s
|
|
u8 byte;
|
|
|
|
/* See how much data we can fit */
|
|
- cnt = sspi->fifo_depth - sun6i_spi_get_tx_fifo_count(sspi);
|
|
+ cnt = sspi->quirks->fifo_depth - sun6i_spi_get_tx_fifo_count(sspi);
|
|
|
|
len = min((int)cnt, sspi->len);
|
|
|
|
@@ -300,14 +304,14 @@ static int sun6i_spi_transfer_one(struct
|
|
* the hardcoded value used in old generation of Allwinner
|
|
* SPI controller. (See spi-sun4i.c)
|
|
*/
|
|
- trig_level = sspi->fifo_depth / 4 * 3;
|
|
+ trig_level = sspi->quirks->fifo_depth / 4 * 3;
|
|
} else {
|
|
/*
|
|
* Setup FIFO DMA request trigger level
|
|
* We choose 1/2 of the full fifo depth, that value will
|
|
* be used as DMA burst length.
|
|
*/
|
|
- trig_level = sspi->fifo_depth / 2;
|
|
+ trig_level = sspi->quirks->fifo_depth / 2;
|
|
|
|
if (tfr->tx_buf)
|
|
reg |= SUN6I_FIFO_CTL_TF_DRQ_EN;
|
|
@@ -421,9 +425,9 @@ static int sun6i_spi_transfer_one(struct
|
|
reg = SUN6I_INT_CTL_TC;
|
|
|
|
if (!use_dma) {
|
|
- if (rx_len > sspi->fifo_depth)
|
|
+ if (rx_len > sspi->quirks->fifo_depth)
|
|
reg |= SUN6I_INT_CTL_RF_RDY;
|
|
- if (tx_len > sspi->fifo_depth)
|
|
+ if (tx_len > sspi->quirks->fifo_depth)
|
|
reg |= SUN6I_INT_CTL_TF_ERQ;
|
|
}
|
|
|
|
@@ -569,7 +573,7 @@ static bool sun6i_spi_can_dma(struct spi
|
|
* the fifo length we can just fill the fifo and wait for a single
|
|
* irq, so don't bother setting up dma
|
|
*/
|
|
- return xfer->len > sspi->fifo_depth;
|
|
+ return xfer->len > sspi->quirks->fifo_depth;
|
|
}
|
|
|
|
static int sun6i_spi_probe(struct platform_device *pdev)
|
|
@@ -608,7 +612,7 @@ static int sun6i_spi_probe(struct platfo
|
|
}
|
|
|
|
sspi->master = master;
|
|
- sspi->fifo_depth = (unsigned long)of_device_get_match_data(&pdev->dev);
|
|
+ sspi->quirks = of_device_get_match_data(&pdev->dev);
|
|
|
|
master->max_speed_hz = 100 * 1000 * 1000;
|
|
master->min_speed_hz = 3 * 1000;
|
|
@@ -723,9 +727,17 @@ static int sun6i_spi_remove(struct platf
|
|
return 0;
|
|
}
|
|
|
|
+static const struct sun6i_spi_quirks sun6i_a31_spi_quirks = {
|
|
+ .fifo_depth = SUN6I_FIFO_DEPTH,
|
|
+};
|
|
+
|
|
+static const struct sun6i_spi_quirks sun8i_h3_spi_quirks = {
|
|
+ .fifo_depth = SUN8I_FIFO_DEPTH,
|
|
+};
|
|
+
|
|
static const struct of_device_id sun6i_spi_match[] = {
|
|
- { .compatible = "allwinner,sun6i-a31-spi", .data = (void *)SUN6I_FIFO_DEPTH },
|
|
- { .compatible = "allwinner,sun8i-h3-spi", .data = (void *)SUN8I_FIFO_DEPTH },
|
|
+ { .compatible = "allwinner,sun6i-a31-spi", .data = &sun6i_a31_spi_quirks },
|
|
+ { .compatible = "allwinner,sun8i-h3-spi", .data = &sun8i_h3_spi_quirks },
|
|
{}
|
|
};
|
|
MODULE_DEVICE_TABLE(of, sun6i_spi_match);
|