]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/mtd/spi/sf_probe.c
spi_flash: Add spi_flash_probe_fdt() to locate SPI by FDT node
[karo-tx-uboot.git] / drivers / mtd / spi / sf_probe.c
index 9bb5a5f13a8ac7d044f043059946e1e63ff01e8b..ca127155b50182dda8ccc0b5c0106702a3f30ea0 100644 (file)
@@ -5,7 +5,7 @@
  * Copyright (C) 2010 Reinhard Meyer, EMK Elektronik
  * Copyright (C) 2013 Jagannadha Sutradharudu Teki, Xilinx Inc.
  *
- * Licensed under the GPL-2 or later.
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -46,6 +46,7 @@ static const struct spi_flash_params spi_flash_params_table[] = {
        {"AT45DB161D",     0x1f2600, 0x0,       64 * 1024,    32,              SECT_4K},
        {"AT45DB321D",     0x1f2700, 0x0,       64 * 1024,    64,              SECT_4K},
        {"AT45DB641D",     0x1f2800, 0x0,       64 * 1024,   128,              SECT_4K},
+       {"AT25DF321",      0x1f4701, 0x0,       64 * 1024,    64,              SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_EON            /* EON */
        {"EN25Q32B",       0x1c3016, 0x0,       64 * 1024,    64,                    0},
@@ -284,16 +285,13 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
 }
 #endif /* CONFIG_OF_CONTROL */
 
-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
-               unsigned int max_hz, unsigned int spi_mode)
+static struct spi_flash *spi_flash_probe_slave(struct spi_slave *spi)
 {
-       struct spi_slave *spi;
        struct spi_flash *flash = NULL;
        u8 idcode[5];
        int ret;
 
        /* Setup spi_slave */
-       spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
        if (!spi) {
                printf("SF: Failed to set up slave\n");
                return NULL;
@@ -357,6 +355,26 @@ err_claim_bus:
        return NULL;
 }
 
+struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
+               unsigned int max_hz, unsigned int spi_mode)
+{
+       struct spi_slave *spi;
+
+       spi = spi_setup_slave(bus, cs, max_hz, spi_mode);
+       return spi_flash_probe_slave(spi);
+}
+
+#ifdef CONFIG_OF_SPI_FLASH
+struct spi_flash *spi_flash_probe_fdt(const void *blob, int slave_node,
+                                     int spi_node)
+{
+       struct spi_slave *spi;
+
+       spi = spi_setup_slave_fdt(blob, slave_node, spi_node);
+       return spi_flash_probe_slave(spi);
+}
+#endif
+
 void spi_flash_free(struct spi_flash *flash)
 {
        spi_free_slave(flash->spi);