Merge tag 'xilinx-for-v2023.01-rc3' of https://source.denx.de/u-boot/custodians/u...
[platform/kernel/u-boot.git] / drivers / spi / tegra20_sflash.c
index 0e68d33..10e38cf 100644 (file)
@@ -8,7 +8,9 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <log.h>
 #include <time.h>
+#include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <asm/arch/clock.h>
@@ -16,6 +18,8 @@
 #include <asm/arch-tegra/clk_rst.h>
 #include <spi.h>
 #include <fdtdec.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
 #include "tegra_spi.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -84,13 +88,13 @@ int tegra20_sflash_cs_info(struct udevice *bus, unsigned int cs,
                return 0;
 }
 
-static int tegra20_sflash_ofdata_to_platdata(struct udevice *bus)
+static int tegra20_sflash_of_to_plat(struct udevice *bus)
 {
-       struct tegra_spi_platdata *plat = bus->platdata;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(bus);
 
-       plat->base = devfdt_get_addr(bus);
+       plat->base = dev_read_addr(bus);
        plat->periph_id = clock_decode_periph_id(bus);
 
        if (plat->periph_id == PERIPH_ID_NONE) {
@@ -113,7 +117,7 @@ static int tegra20_sflash_ofdata_to_platdata(struct udevice *bus)
 
 static int tegra20_sflash_probe(struct udevice *bus)
 {
-       struct tegra_spi_platdata *plat = dev_get_platdata(bus);
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
        struct tegra20_sflash_priv *priv = dev_get_priv(bus);
 
        priv->regs = (struct spi_regs *)plat->base;
@@ -170,7 +174,7 @@ static int tegra20_sflash_claim_bus(struct udevice *dev)
 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 tegra20_sflash_priv *priv = dev_get_priv(bus);
 
        /* If it's too soon to do another transaction, wait */
@@ -189,7 +193,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 tegra20_sflash_priv *priv = dev_get_priv(bus);
 
        /* CS is negated on Tegra, so drive a 0 to get a 1 */
@@ -214,7 +218,7 @@ static int tegra20_sflash_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;
@@ -311,7 +315,7 @@ static int tegra20_sflash_xfer(struct udevice *dev, unsigned int bitlen,
 
 static int tegra20_sflash_set_speed(struct udevice *bus, uint speed)
 {
-       struct tegra_spi_platdata *plat = bus->platdata;
+       struct tegra_spi_plat *plat = dev_get_plat(bus);
        struct tegra20_sflash_priv *priv = dev_get_priv(bus);
 
        if (speed > plat->frequency)
@@ -350,8 +354,8 @@ U_BOOT_DRIVER(tegra20_sflash) = {
        .id     = UCLASS_SPI,
        .of_match = tegra20_sflash_ids,
        .ops    = &tegra20_sflash_ops,
-       .ofdata_to_platdata = tegra20_sflash_ofdata_to_platdata,
-       .platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata),
-       .priv_auto_alloc_size = sizeof(struct tegra20_sflash_priv),
+       .of_to_plat = tegra20_sflash_of_to_plat,
+       .plat_auto      = sizeof(struct tegra_spi_plat),
+       .priv_auto      = sizeof(struct tegra20_sflash_priv),
        .probe  = tegra20_sflash_probe,
 };