]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spi: tegra20: Add support for mode selection
authorMirza Krak <mirza.krak@hostmobility.com>
Tue, 8 Sep 2015 08:30:49 +0000 (10:30 +0200)
committerJagan Teki <jteki@openedev.com>
Sun, 11 Oct 2015 11:13:06 +0000 (16:43 +0530)
Respect the mode passed in set_mode ops.

Signed-off-by: Mirza Krak <mirza.krak@hostmobility.com>
Reviewed-by: Jagan Teki <jteki@openedev.com>
drivers/spi/tegra20_slink.c

index fbb665b86f3f3faa4d2cd4dcbcca21c0da799790..144716fd91f68fad2b2e528b9ac5c9ab20e22ad1 100644 (file)
@@ -36,6 +36,11 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SLINK_CMD_ENB                  (1 << 31)
 #define SLINK_CMD_GO                   (1 << 30)
 #define SLINK_CMD_M_S                  (1 << 28)
+#define SLINK_CMD_IDLE_SCLK_DRIVE_LOW  (0 << 24)
+#define SLINK_CMD_IDLE_SCLK_DRIVE_HIGH (1 << 24)
+#define SLINK_CMD_IDLE_SCLK_PULL_LOW   (2 << 24)
+#define SLINK_CMD_IDLE_SCLK_PULL_HIGH  (3 << 24)
+#define SLINK_CMD_IDLE_SCLK_MASK       (3 << 24)
 #define SLINK_CMD_CK_SDA               (1 << 21)
 #define SLINK_CMD_CS_POL               (1 << 13)
 #define SLINK_CMD_CS_VAL               (1 << 12)
@@ -331,6 +336,22 @@ static int tegra30_spi_set_speed(struct udevice *bus, uint speed)
 static int tegra30_spi_set_mode(struct udevice *bus, uint mode)
 {
        struct tegra30_spi_priv *priv = dev_get_priv(bus);
+       struct spi_regs *regs = priv->regs;
+       u32 reg;
+
+       reg = readl(&regs->command);
+
+       /* Set CPOL and CPHA */
+       reg &= ~(SLINK_CMD_IDLE_SCLK_MASK | SLINK_CMD_CK_SDA);
+       if (mode & SPI_CPHA)
+               reg |= SLINK_CMD_CK_SDA;
+
+       if (mode & SPI_CPOL)
+               reg |= SLINK_CMD_IDLE_SCLK_DRIVE_HIGH;
+       else
+               reg |= SLINK_CMD_IDLE_SCLK_DRIVE_LOW;
+
+       writel(reg, &regs->command);
 
        priv->mode = mode;
        debug("%s: regs=%p, mode=%d\n", __func__, priv->regs, priv->mode);