Merge branch 'master' of git://git.denx.de/u-boot-spi
[platform/kernel/u-boot.git] / drivers / spi / omap3_spi.c
index a149abe..c7fcf05 100644 (file)
@@ -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
@@ -464,11 +461,6 @@ static inline struct omap3_spi_priv *to_omap3_spi(struct spi_slave *slave)
        return container_of(slave, struct omap3_spi_priv, slave);
 }
 
-void spi_init(void)
-{
-       /* do nothing */
-}
-
 void spi_free_slave(struct spi_slave *slave)
 {
        struct omap3_spi_priv *priv = to_omap3_spi(slave);
@@ -480,6 +472,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 +486,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,
@@ -602,8 +595,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;
 }
@@ -636,6 +628,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;
 }
 
@@ -650,12 +645,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;
@@ -663,12 +656,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;