Skip to content

Commit 064e8af

Browse files
committed
Merge existing fixes from spi/for-5.8
2 parents b3a9e3b + 27784a2 commit 064e8af

File tree

6 files changed

+52
-26
lines changed

6 files changed

+52
-26
lines changed

Documentation/devicetree/bindings/spi/amlogic,meson-gx-spicc.yaml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ properties:
3434
maxItems: 1
3535

3636
clocks:
37-
maxItems: 1
37+
minItems: 1
38+
maxItems: 2
39+
items:
40+
- description: controller register bus clock
41+
- description: baud rate generator and delay control clock
3842

3943
clock-names:
40-
description: input clock for the baud rate generator
41-
items:
42-
- const: core
44+
minItems: 1
45+
maxItems: 2
4346

4447
if:
4548
properties:
@@ -51,17 +54,22 @@ if:
5154
then:
5255
properties:
5356
clocks:
54-
contains:
55-
items:
56-
- description: controller register bus clock
57-
- description: baud rate generator and delay control clock
57+
minItems: 2
5858

5959
clock-names:
60-
minItems: 2
6160
items:
6261
- const: core
6362
- const: pclk
6463

64+
else:
65+
properties:
66+
clocks:
67+
maxItems: 1
68+
69+
clock-names:
70+
items:
71+
- const: core
72+
6573
required:
6674
- compatible
6775
- reg

drivers/spi/spi-fsl-dspi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,14 +588,14 @@ static void dspi_release_dma(struct fsl_dspi *dspi)
588588
return;
589589

590590
if (dma->chan_tx) {
591-
dma_unmap_single(dma->chan_tx->device->dev, dma->tx_dma_phys,
592-
dma_bufsize, DMA_TO_DEVICE);
591+
dma_free_coherent(dma->chan_tx->device->dev, dma_bufsize,
592+
dma->tx_dma_buf, dma->tx_dma_phys);
593593
dma_release_channel(dma->chan_tx);
594594
}
595595

596596
if (dma->chan_rx) {
597-
dma_unmap_single(dma->chan_rx->device->dev, dma->rx_dma_phys,
598-
dma_bufsize, DMA_FROM_DEVICE);
597+
dma_free_coherent(dma->chan_rx->device->dev, dma_bufsize,
598+
dma->rx_dma_buf, dma->rx_dma_phys);
599599
dma_release_channel(dma->chan_rx);
600600
}
601601
}

drivers/spi/spi-rspi.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179

180180
struct rspi_data {
181181
void __iomem *addr;
182-
u32 max_speed_hz;
182+
u32 speed_hz;
183183
struct spi_controller *ctlr;
184184
struct platform_device *pdev;
185185
wait_queue_head_t wait;
@@ -258,8 +258,7 @@ static int rspi_set_config_register(struct rspi_data *rspi, int access_size)
258258
rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR);
259259

260260
/* Sets transfer bit rate */
261-
spbr = DIV_ROUND_UP(clk_get_rate(rspi->clk),
262-
2 * rspi->max_speed_hz) - 1;
261+
spbr = DIV_ROUND_UP(clk_get_rate(rspi->clk), 2 * rspi->speed_hz) - 1;
263262
rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
264263

265264
/* Disable dummy transmission, set 16-bit word access, 1 frame */
@@ -299,14 +298,14 @@ static int rspi_rz_set_config_register(struct rspi_data *rspi, int access_size)
299298

300299
clksrc = clk_get_rate(rspi->clk);
301300
while (div < 3) {
302-
if (rspi->max_speed_hz >= clksrc/4) /* 4=(CLK/2)/2 */
301+
if (rspi->speed_hz >= clksrc/4) /* 4=(CLK/2)/2 */
303302
break;
304303
div++;
305304
clksrc /= 2;
306305
}
307306

308307
/* Sets transfer bit rate */
309-
spbr = DIV_ROUND_UP(clksrc, 2 * rspi->max_speed_hz) - 1;
308+
spbr = DIV_ROUND_UP(clksrc, 2 * rspi->speed_hz) - 1;
310309
rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
311310
rspi->spcmd |= div << 2;
312311

@@ -341,7 +340,7 @@ static int qspi_set_config_register(struct rspi_data *rspi, int access_size)
341340
rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR);
342341

343342
/* Sets transfer bit rate */
344-
spbr = DIV_ROUND_UP(clk_get_rate(rspi->clk), 2 * rspi->max_speed_hz);
343+
spbr = DIV_ROUND_UP(clk_get_rate(rspi->clk), 2 * rspi->speed_hz);
345344
rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
346345

347346
/* Disable dummy transmission, set byte access */
@@ -949,9 +948,24 @@ static int rspi_prepare_message(struct spi_controller *ctlr,
949948
{
950949
struct rspi_data *rspi = spi_controller_get_devdata(ctlr);
951950
struct spi_device *spi = msg->spi;
951+
const struct spi_transfer *xfer;
952952
int ret;
953953

954-
rspi->max_speed_hz = spi->max_speed_hz;
954+
/*
955+
* As the Bit Rate Register must not be changed while the device is
956+
* active, all transfers in a message must use the same bit rate.
957+
* In theory, the sequencer could be enabled, and each Command Register
958+
* could divide the base bit rate by a different value.
959+
* However, most RSPI variants do not have Transfer Data Length
960+
* Multiplier Setting Registers, so each sequence step would be limited
961+
* to a single word, making this feature unsuitable for large
962+
* transfers, which would gain most from it.
963+
*/
964+
rspi->speed_hz = spi->max_speed_hz;
965+
list_for_each_entry(xfer, &msg->transfers, transfer_list) {
966+
if (xfer->speed_hz < rspi->speed_hz)
967+
rspi->speed_hz = xfer->speed_hz;
968+
}
955969

956970
rspi->spcmd = SPCMD_SSLKP;
957971
if (spi->mode & SPI_CPOL)

drivers/spi/spi-sprd-adi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ static int sprd_adi_restart_handler(struct notifier_block *this,
389389
sprd_adi_write(sadi, sadi->slave_pbase + REG_WDG_CTRL, val);
390390

391391
/* Load the watchdog timeout value, 50ms is always enough. */
392+
sprd_adi_write(sadi, sadi->slave_pbase + REG_WDG_LOAD_HIGH, 0);
392393
sprd_adi_write(sadi, sadi->slave_pbase + REG_WDG_LOAD_LOW,
393394
WDG_LOAD_VAL & WDG_LOAD_MASK);
394-
sprd_adi_write(sadi, sadi->slave_pbase + REG_WDG_LOAD_HIGH, 0);
395395

396396
/* Start the watchdog to reset system */
397397
sprd_adi_read(sadi, sadi->slave_pbase + REG_WDG_CTRL, &val);

include/uapi/linux/spi/spidev.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
#define SPI_TX_QUAD 0x200
4949
#define SPI_RX_DUAL 0x400
5050
#define SPI_RX_QUAD 0x800
51+
#define SPI_CS_WORD 0x1000
52+
#define SPI_TX_OCTAL 0x2000
53+
#define SPI_RX_OCTAL 0x4000
54+
#define SPI_3WIRE_HIZ 0x8000
5155

5256
/*---------------------------------------------------------------------------*/
5357

tools/spi/spidev_test.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int transfer_size;
4747
static int iterations;
4848
static int interval = 5; /* interval in seconds for showing transfer rate */
4949

50-
uint8_t default_tx[] = {
50+
static uint8_t default_tx[] = {
5151
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
5252
0x40, 0x00, 0x00, 0x00, 0x00, 0x95,
5353
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@@ -56,8 +56,8 @@ uint8_t default_tx[] = {
5656
0xF0, 0x0D,
5757
};
5858

59-
uint8_t default_rx[ARRAY_SIZE(default_tx)] = {0, };
60-
char *input_tx;
59+
static uint8_t default_rx[ARRAY_SIZE(default_tx)] = {0, };
60+
static char *input_tx;
6161

6262
static void hex_dump(const void *src, size_t length, size_t line_size,
6363
char *prefix)
@@ -461,8 +461,8 @@ int main(int argc, char *argv[])
461461
pabort("can't get max speed hz");
462462

463463
printf("spi mode: 0x%x\n", mode);
464-
printf("bits per word: %d\n", bits);
465-
printf("max speed: %d Hz (%d KHz)\n", speed, speed/1000);
464+
printf("bits per word: %u\n", bits);
465+
printf("max speed: %u Hz (%u kHz)\n", speed, speed/1000);
466466

467467
if (input_tx)
468468
transfer_escaped_string(fd, input_tx);

0 commit comments

Comments
 (0)