]> Git Repo - u-boot.git/blobdiff - drivers/spi/ti_qspi.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[u-boot.git] / drivers / spi / ti_qspi.c
index 0db0de8f1bf1aa963a69c712a1be695bc8eeb107..99acb108823edb222d1954790f11b15d6f19f27a 100644 (file)
@@ -9,6 +9,7 @@
 #include <cpu_func.h>
 #include <log.h>
 #include <asm/cache.h>
+#include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/arch/omap.h>
 #include <malloc.h>
@@ -29,7 +30,8 @@ DECLARE_GLOBAL_DATA_PTR;
 
 /* ti qpsi register bit masks */
 #define QSPI_TIMEOUT                    2000000
-#define QSPI_FCLK                      192000000
+/* AM4372: QSPI gets SPI_GCLK from PRCM unit as PER_CLKOUTM2 divided by 4. */
+#define QSPI_FCLK                       (192000000 / 4)
 #define QSPI_DRA7XX_FCLK                76800000
 #define QSPI_WLEN_MAX_BITS             128
 #define QSPI_WLEN_MAX_BYTES            (QSPI_WLEN_MAX_BITS >> 3)
@@ -154,7 +156,7 @@ static void ti_qspi_ctrl_mode_mmap(void *ctrl_mod_mmap, int cs, bool enable)
 static int ti_qspi_xfer(struct udevice *dev, unsigned int bitlen,
                        const void *dout, void *din, unsigned long flags)
 {
-       struct dm_spi_slave_platdata *slave = dev_get_parent_platdata(dev);
+       struct dm_spi_slave_plat *slave = dev_get_parent_plat(dev);
        struct ti_qspi_priv *priv;
        struct udevice *bus;
        uint words = bitlen >> 3; /* fixed 8-bit word length */
@@ -323,7 +325,7 @@ static int ti_qspi_set_mode(struct udevice *bus, uint mode)
 static int ti_qspi_exec_mem_op(struct spi_slave *slave,
                               const struct spi_mem_op *op)
 {
-       struct dm_spi_slave_platdata *slave_plat;
+       struct dm_spi_slave_plat *slave_plat;
        struct ti_qspi_priv *priv;
        struct udevice *bus;
        u32 from = 0;
@@ -331,7 +333,7 @@ static int ti_qspi_exec_mem_op(struct spi_slave *slave,
 
        bus = slave->dev->parent;
        priv = dev_get_priv(bus);
-       slave_plat = dev_get_parent_platdata(slave->dev);
+       slave_plat = dev_get_parent_plat(slave->dev);
 
        /* Only optimize read path. */
        if (!op->data.nbytes || op->data.dir != SPI_MEM_DATA_IN ||
@@ -355,7 +357,7 @@ static int ti_qspi_exec_mem_op(struct spi_slave *slave,
 
 static int ti_qspi_claim_bus(struct udevice *dev)
 {
-       struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
+       struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev);
        struct ti_qspi_priv *priv;
        struct udevice *bus;
 
@@ -384,7 +386,7 @@ static int ti_qspi_claim_bus(struct udevice *dev)
 
 static int ti_qspi_release_bus(struct udevice *dev)
 {
-       struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
+       struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev);
        struct ti_qspi_priv *priv;
        struct udevice *bus;
 
@@ -452,7 +454,7 @@ static void *map_syscon_chipselects(struct udevice *bus)
 #endif
 }
 
-static int ti_qspi_ofdata_to_platdata(struct udevice *bus)
+static int ti_qspi_of_to_plat(struct udevice *bus)
 {
        struct ti_qspi_priv *priv = dev_get_priv(bus);
        const void *blob = gd->fdt_blob;
@@ -461,14 +463,14 @@ static int ti_qspi_ofdata_to_platdata(struct udevice *bus)
        fdt_addr_t mmap_size;
 
        priv->ctrl_mod_mmap = map_syscon_chipselects(bus);
-       priv->base = map_physmem(devfdt_get_addr(bus),
+       priv->base = map_physmem(dev_read_addr(bus),
                                 sizeof(struct ti_qspi_regs), MAP_NOCACHE);
        mmap_addr = devfdt_get_addr_size_index(bus, 1, &mmap_size);
        priv->memory_map = map_physmem(mmap_addr, mmap_size, MAP_NOCACHE);
        priv->mmap_size = mmap_size;
 
-       priv->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", -1);
-       if (priv->max_hz < 0) {
+       priv->max_hz = dev_read_u32_default(bus, "spi-max-frequency", 0);
+       if (!priv->max_hz) {
                debug("Error: Max frequency missing\n");
                return -ENODEV;
        }
@@ -504,7 +506,7 @@ U_BOOT_DRIVER(ti_qspi) = {
        .id     = UCLASS_SPI,
        .of_match = ti_qspi_ids,
        .ops    = &ti_qspi_ops,
-       .ofdata_to_platdata = ti_qspi_ofdata_to_platdata,
-       .priv_auto_alloc_size = sizeof(struct ti_qspi_priv),
+       .of_to_plat = ti_qspi_of_to_plat,
+       .priv_auto      = sizeof(struct ti_qspi_priv),
        .probe  = ti_qspi_probe,
 };
This page took 0.027211 seconds and 4 git commands to generate.