X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fspi%2Fomap3_spi.c;h=4169abdef673131ca31f9973253a76bf25c01b91;hb=7da7ff54914ca58a289bd8e0fda6e7240c545826;hp=76d376ac44500eebc7b201f463ba0ee55259fb61;hpb=4f66e09bb9fbc47b73f67c3cc08ee2663e8fcdb1;p=u-boot diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c index 76d376ac44..4169abdef6 100644 --- a/drivers/spi/omap3_spi.c +++ b/drivers/spi/omap3_spi.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2016 Jagan Teki * Christophe Ricard @@ -13,8 +14,6 @@ * Copyright (C) 2005, 2006 Nokia Corporation * * Modified by Ruslan Araslanov - * - * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -456,9 +455,6 @@ static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv) conf |= OMAP3_MCSPI_MODULCTRL_SINGLE; writel(conf, &priv->regs->modulctrl); - - _omap3_spi_set_mode(priv); - _omap3_spi_set_speed(priv); } #ifndef CONFIG_DM_SPI @@ -548,7 +544,8 @@ 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; } @@ -568,7 +565,8 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, priv->freq = max_hz; priv->mode = mode; priv->wordlen = priv->slave.wordlen; -#ifdef CONFIG_OMAP3_SPI_D0_D1_SWAPPED +#if 0 + /* Please migrate to DM_SPI support for this feature. */ priv->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN; #endif @@ -592,8 +590,6 @@ static int omap3_spi_claim_bus(struct udevice *dev) 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; @@ -632,9 +628,11 @@ static int omap3_spi_probe(struct udevice *dev) struct omap2_mcspi_platform_config* data = (struct omap2_mcspi_platform_config*)dev_get_driver_data(dev); - priv->regs = (struct mcspi *)(dev_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); + priv->regs = (struct mcspi *)(devfdt_get_addr(dev) + data->regs_offset); + 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; return 0; } @@ -648,13 +646,29 @@ static int omap3_spi_xfer(struct udevice *dev, unsigned int bitlen, 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 udevice *bus = dev->parent; + struct omap3_spi_priv *priv = dev_get_priv(bus); + struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + + priv->cs = slave_plat->cs; + priv->freq = slave_plat->max_hz; + _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 udevice *bus = dev->parent; + struct omap3_spi_priv *priv = dev_get_priv(bus); + struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev); + + priv->cs = slave_plat->cs; + priv->mode = slave_plat->mode; + _omap3_spi_set_mode(priv); + return 0; }