+// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2016 Jagan Teki <jteki@openedev.com>
* Christophe Ricard <christophe.ricard@gmail.com>
* Copyright (C) 2005, 2006 Nokia Corporation
*
* Modified by Ruslan Araslanov <ruslan.araslanov@vitecmm.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv)
{
unsigned int conf;
-
- spi_reset(priv->regs);
-
/*
* setup when switching from (reset default) slave mode
* to single-channel master mode
conf |= OMAP3_MCSPI_MODULCTRL_SINGLE;
writel(conf, &priv->regs->modulctrl);
-
- _omap3_spi_set_mode(priv);
- _omap3_spi_set_speed(priv);
}
#ifndef CONFIG_DM_SPI
{
struct omap3_spi_priv *priv = to_omap3_spi(slave);
+ spi_reset(priv->regs);
+
_omap3_spi_claim_bus(priv);
_omap3_spi_set_wordlen(priv);
_omap3_spi_set_mode(priv);
{
struct omap3_spi_priv *priv = to_omap3_spi(slave);
- /* Reset the SPI hardware */
- spi_reset(priv->regs);
+ writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl);
}
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
}
if (max_hz > OMAP3_MCSPI_MAX_FREQ) {
- printf("SPI error: unsupported frequency %i Hz. Max frequency is 48 Mhz\n", max_hz);
+ printf("SPI error: unsupported frequency %i Hz. Max frequency is 48 MHz\n",
+ max_hz);
return NULL;
}
struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
priv->cs = slave_plat->cs;
- priv->mode = slave_plat->mode;
priv->freq = slave_plat->max_hz;
+
_omap3_spi_claim_bus(priv);
return 0;
struct udevice *bus = dev->parent;
struct omap3_spi_priv *priv = dev_get_priv(bus);
- /* Reset the SPI hardware */
- spi_reset(priv->regs);
+ writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl);
return 0;
}
(struct omap2_mcspi_platform_config*)dev_get_driver_data(dev);
priv->regs = (struct mcspi *)(devfdt_get_addr(dev) + data->regs_offset);
- priv->pin_dir = fdtdec_get_uint(blob, node, "ti,pindir-d0-out-d1-in",
- MCSPI_PINDIR_D0_IN_D1_OUT);
+ if (fdtdec_get_bool(blob, node, "ti,pindir-d0-out-d1-in"))
+ priv->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN;
+ else
+ priv->pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT;
priv->wordlen = SPI_DEFAULT_WORDLEN;
+
+ spi_reset(priv->regs);
+
return 0;
}
return _spi_xfer(priv, bitlen, dout, din, flags);
}
-static int omap3_spi_set_speed(struct udevice *bus, unsigned int speed)
+static int omap3_spi_set_speed(struct udevice *dev, unsigned int speed)
{
+
+ struct omap3_spi_priv *priv = dev_get_priv(dev);
+
+ priv->freq = speed;
+ _omap3_spi_set_speed(priv);
+
return 0;
}
-static int omap3_spi_set_mode(struct udevice *bus, uint mode)
+static int omap3_spi_set_mode(struct udevice *dev, uint mode)
{
+ struct omap3_spi_priv *priv = dev_get_priv(dev);
+
+ priv->mode = mode;
+
+ _omap3_spi_set_mode(priv);
+
return 0;
}