spi: cadence_qspi: Add support for Versal NET platform
[platform/kernel/u-boot.git] / drivers / spi / tegra114_spi.c
index faf609b..f0256d8 100644 (file)
@@ -1,17 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * NVIDIA Tegra SPI controller (T114 and later)
  *
  * Copyright (c) 2010-2013 NVIDIA Corporation
- *
- * SPDX-License-Identifier:    GPL-2.0
  */
 
 #include <common.h>
 #include <dm.h>
+#include <log.h>
+#include <time.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch-tegra/clk_rst.h>
 #include <spi.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
 #include "tegra_spi.h"
 
 /* COMMAND1 */
@@ -94,9 +97,9 @@ struct tegra114_spi_priv {
        int last_transaction_us;
 };
 
-static int tegra114_spi_ofdata_to_platdata(struct udevice *bus)
+static int tegra114_spi_of_to_plat(struct udevice *bus)
 {
-       struct tegra_spi_platdata *plat = bus->platdata;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
 
        plat->base = dev_read_addr(bus);
        plat->periph_id = clock_decode_periph_id(bus);
@@ -121,7 +124,7 @@ static int tegra114_spi_ofdata_to_platdata(struct udevice *bus)
 
 static int tegra114_spi_probe(struct udevice *bus)
 {
-       struct tegra_spi_platdata *plat = dev_get_platdata(bus);
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
        struct tegra114_spi_priv *priv = dev_get_priv(bus);
        struct spi_regs *regs;
        ulong rate;
@@ -178,7 +181,7 @@ static int tegra114_spi_probe(struct udevice *bus)
 static void spi_cs_activate(struct udevice *dev)
 {
        struct udevice *bus = dev->parent;
-       struct tegra_spi_platdata *pdata = dev_get_platdata(bus);
+       struct tegra_spi_plat *pdata = dev_get_plat(bus);
        struct tegra114_spi_priv *priv = dev_get_priv(bus);
 
        /* If it's too soon to do another transaction, wait */
@@ -202,7 +205,7 @@ static void spi_cs_activate(struct udevice *dev)
 static void spi_cs_deactivate(struct udevice *dev)
 {
        struct udevice *bus = dev->parent;
-       struct tegra_spi_platdata *pdata = dev_get_platdata(bus);
+       struct tegra_spi_plat *pdata = dev_get_plat(bus);
        struct tegra114_spi_priv *priv = dev_get_priv(bus);
 
        setbits_le32(&priv->regs->command1, SPI_CMD1_CS_SW_VAL);
@@ -228,7 +231,7 @@ static int tegra114_spi_xfer(struct udevice *dev, unsigned int bitlen,
        int ret;
 
        debug("%s: slave %u:%u dout %p din %p bitlen %u\n",
-             __func__, bus->seq, spi_chip_select(dev), dout, din, bitlen);
+             __func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen);
        if (bitlen % 8)
                return -1;
        num_bytes = bitlen / 8;
@@ -349,7 +352,7 @@ static int tegra114_spi_xfer(struct udevice *dev, unsigned int bitlen,
 
 static int tegra114_spi_set_speed(struct udevice *bus, uint speed)
 {
-       struct tegra_spi_platdata *plat = bus->platdata;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
        struct tegra114_spi_priv *priv = dev_get_priv(bus);
 
        if (speed > plat->frequency)
@@ -390,8 +393,8 @@ U_BOOT_DRIVER(tegra114_spi) = {
        .id     = UCLASS_SPI,
        .of_match = tegra114_spi_ids,
        .ops    = &tegra114_spi_ops,
-       .ofdata_to_platdata = tegra114_spi_ofdata_to_platdata,
-       .platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata),
-       .priv_auto_alloc_size = sizeof(struct tegra114_spi_priv),
+       .of_to_plat = tegra114_spi_of_to_plat,
+       .plat_auto      = sizeof(struct tegra_spi_plat),
+       .priv_auto      = sizeof(struct tegra114_spi_priv),
        .probe  = tegra114_spi_probe,
 };