spi: aspeed: Workaround AST2500 limitations
authorCédric Le Goater <clg@kaod.org>
Mon, 9 May 2022 17:56:11 +0000 (19:56 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 16 May 2022 11:59:18 +0000 (12:59 +0100)
It is not possible to configure a full 128MB window for a chip of the
same size on the AST2500 SPI controller. For this case, the maximum
window size is restricted to 120MB for CE0.

Reviewed-by: Joel Stanley <joel@jms.id.au>
Tested-by: Joel Stanley <joel@jms.id.au>
Tested-by: Tao Ren <rentao.bupt@gmail.com>
Tested-by: Jae Hyun Yoo <quic_jaehyoo@quicinc.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Link: https://lore.kernel.org/r/20220509175616.1089346-7-clg@kaod.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-aspeed-smc.c

index 0aff42e20b8dc9fb723ff3974653516bb01f1b97..d2b3342c133ed0f373c4f8b9fcd4baac1fb2a217 100644 (file)
@@ -451,6 +451,8 @@ static int aspeed_spi_set_window(struct aspeed_spi *aspi,
  * - ioremap each window, not strictly necessary since the overall window
  *   is correct.
  */
+static const struct aspeed_spi_data ast2500_spi_data;
+
 static int aspeed_spi_chip_adjust_window(struct aspeed_spi_chip *chip,
                                         u32 local_offset, u32 size)
 {
@@ -459,6 +461,16 @@ static int aspeed_spi_chip_adjust_window(struct aspeed_spi_chip *chip,
        struct aspeed_spi_window *win = &windows[chip->cs];
        int ret;
 
+       /*
+        * Due to an HW issue on the AST2500 SPI controller, the CE0
+        * window size should be smaller than the maximum 128MB.
+        */
+       if (aspi->data == &ast2500_spi_data && chip->cs == 0 && size == SZ_128M) {
+               size = 120 << 20;
+               dev_info(aspi->dev, "CE%d window resized to %dMB (AST2500 HW quirk)",
+                        chip->cs, size >> 20);
+       }
+
        aspeed_spi_get_windows(aspi, windows);
 
        /* Adjust this chip window */