diff options
Diffstat (limited to 'drivers/spi')
| -rw-r--r-- | drivers/spi/mxc_spi.c | 8 | ||||
| -rw-r--r-- | drivers/spi/omap3_spi.c | 32 | ||||
| -rw-r--r-- | drivers/spi/zynq_qspi.c | 2 |
3 files changed, 20 insertions, 22 deletions
diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c index b77129cc317..0dccc38b82d 100644 --- a/drivers/spi/mxc_spi.c +++ b/drivers/spi/mxc_spi.c @@ -60,7 +60,7 @@ static inline struct mxc_spi_slave *to_mxc_spi_slave(struct spi_slave *slave) static void mxc_spi_cs_activate(struct mxc_spi_slave *mxcs) { if (CONFIG_IS_ENABLED(DM_SPI)) { - dm_gpio_set_value(&mxcs->ss, mxcs->ss_pol); + dm_gpio_set_value(&mxcs->ss, 1); } else { if (mxcs->gpio > 0) gpio_set_value(mxcs->gpio, mxcs->ss_pol); @@ -70,7 +70,7 @@ static void mxc_spi_cs_activate(struct mxc_spi_slave *mxcs) static void mxc_spi_cs_deactivate(struct mxc_spi_slave *mxcs) { if (CONFIG_IS_ENABLED(DM_SPI)) { - dm_gpio_set_value(&mxcs->ss, !(mxcs->ss_pol)); + dm_gpio_set_value(&mxcs->ss, 0); } else { if (mxcs->gpio > 0) gpio_set_value(mxcs->gpio, !(mxcs->ss_pol)); @@ -504,11 +504,11 @@ static int mxc_spi_probe(struct udevice *bus) return -EINVAL; } - plat->base = dev_get_addr(bus); + plat->base = devfdt_get_addr(bus); if (plat->base == FDT_ADDR_T_NONE) return -ENODEV; - ret = dm_gpio_set_value(&plat->ss, !(mxcs->ss_pol)); + ret = dm_gpio_set_value(&plat->ss, 0); if (ret) { dev_err(bus, "Setting cs error\n"); return ret; diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c index 4169abdef67..ecf54bb7148 100644 --- a/drivers/spi/omap3_spi.c +++ b/drivers/spi/omap3_spi.c @@ -443,9 +443,6 @@ static void spi_reset(struct mcspi *regs) 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 @@ -480,6 +477,8 @@ int spi_claim_bus(struct spi_slave *slave) { 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); @@ -492,8 +491,7 @@ void spi_release_bus(struct spi_slave *slave) { 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, @@ -590,6 +588,8 @@ 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->freq = slave_plat->max_hz; + _omap3_spi_claim_bus(priv); return 0; @@ -600,8 +600,7 @@ static int omap3_spi_release_bus(struct udevice *dev) 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; } @@ -634,6 +633,9 @@ static int omap3_spi_probe(struct udevice *dev) else priv->pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT; priv->wordlen = SPI_DEFAULT_WORDLEN; + + spi_reset(priv->regs); + return 0; } @@ -648,12 +650,10 @@ static int omap3_spi_xfer(struct udevice *dev, unsigned int bitlen, 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; + struct omap3_spi_priv *priv = dev_get_priv(dev); + + priv->freq = speed; _omap3_spi_set_speed(priv); return 0; @@ -661,12 +661,10 @@ static int omap3_spi_set_speed(struct udevice *dev, unsigned int speed) 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); + struct omap3_spi_priv *priv = dev_get_priv(dev); + + priv->mode = mode; - priv->cs = slave_plat->cs; - priv->mode = slave_plat->mode; _omap3_spi_set_mode(priv); return 0; diff --git a/drivers/spi/zynq_qspi.c b/drivers/spi/zynq_qspi.c index ee8796d470b..9ad1927a5d5 100644 --- a/drivers/spi/zynq_qspi.c +++ b/drivers/spi/zynq_qspi.c @@ -486,7 +486,7 @@ static int zynq_qspi_transfer(struct zynq_qspi_priv *priv) break; } - return 0; + return status; } static int zynq_qspi_claim_bus(struct udevice *dev) |
