Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 2 | /* |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 3 | * Copyright (C) 2016 Jagan Teki <jteki@openedev.com> |
| 4 | * Christophe Ricard <christophe.ricard@gmail.com> |
| 5 | * |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 6 | * Copyright (C) 2010 Dirk Behme <dirk.behme@googlemail.com> |
| 7 | * |
| 8 | * Driver for McSPI controller on OMAP3. Based on davinci_spi.c |
| 9 | * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ |
| 10 | * |
| 11 | * Copyright (C) 2007 Atmel Corporation |
| 12 | * |
| 13 | * Parts taken from linux/drivers/spi/omap2_mcspi.c |
| 14 | * Copyright (C) 2005, 2006 Nokia Corporation |
| 15 | * |
| 16 | * Modified by Ruslan Araslanov <ruslan.araslanov@vitecmm.com> |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | #include <common.h> |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 20 | #include <dm.h> |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 21 | #include <spi.h> |
| 22 | #include <malloc.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 23 | #include <asm/global_data.h> |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 24 | #include <asm/io.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 25 | #include <linux/bitops.h> |
Faiz Abbas | 618ba9f | 2020-09-14 12:11:15 +0530 | [diff] [blame] | 26 | #include <omap3_spi.h> |
Jagan Teki | c2cca6c | 2016-03-01 15:16:20 +0100 | [diff] [blame] | 27 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 28 | DECLARE_GLOBAL_DATA_PTR; |
| 29 | |
Martin Hejnfelt | d74ea96 | 2016-05-19 09:11:58 +0200 | [diff] [blame] | 30 | struct omap2_mcspi_platform_config { |
| 31 | unsigned int regs_offset; |
| 32 | }; |
| 33 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 34 | struct omap3_spi_priv { |
Jagan Teki | c2cca6c | 2016-03-01 15:16:20 +0100 | [diff] [blame] | 35 | struct mcspi *regs; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 36 | unsigned int cs; |
Jagan Teki | c2cca6c | 2016-03-01 15:16:20 +0100 | [diff] [blame] | 37 | unsigned int freq; |
| 38 | unsigned int mode; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 39 | unsigned int wordlen; |
| 40 | unsigned int pin_dir:1; |
Vignesh Raghavendra | ab34b89 | 2020-11-29 12:53:05 +0530 | [diff] [blame] | 41 | |
| 42 | bool bus_claimed; |
Jagan Teki | c2cca6c | 2016-03-01 15:16:20 +0100 | [diff] [blame] | 43 | }; |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 44 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 45 | static void omap3_spi_write_chconf(struct omap3_spi_priv *priv, int val) |
Jagan Teki | c2cca6c | 2016-03-01 15:16:20 +0100 | [diff] [blame] | 46 | { |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 47 | writel(val, &priv->regs->channel[priv->cs].chconf); |
ajoy | 260ab20 | 2012-11-17 21:10:15 +0000 | [diff] [blame] | 48 | /* Flash post writes to make immediate effect */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 49 | readl(&priv->regs->channel[priv->cs].chconf); |
ajoy | 260ab20 | 2012-11-17 21:10:15 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 52 | static void omap3_spi_set_enable(struct omap3_spi_priv *priv, int enable) |
ajoy | 260ab20 | 2012-11-17 21:10:15 +0000 | [diff] [blame] | 53 | { |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 54 | writel(enable, &priv->regs->channel[priv->cs].chctrl); |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 55 | /* Flash post writes to make immediate effect */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 56 | readl(&priv->regs->channel[priv->cs].chctrl); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 57 | } |
| 58 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 59 | static int omap3_spi_write(struct omap3_spi_priv *priv, unsigned int len, |
Jagan Teki | 40a55df | 2016-03-01 15:16:21 +0100 | [diff] [blame] | 60 | const void *txp, unsigned long flags) |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 61 | { |
David Dueck | a11b2a6 | 2015-04-01 14:20:24 +0200 | [diff] [blame] | 62 | ulong start; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 63 | int i, chconf; |
| 64 | |
| 65 | chconf = readl(&priv->regs->channel[priv->cs].chconf); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 66 | |
ajoy | 260ab20 | 2012-11-17 21:10:15 +0000 | [diff] [blame] | 67 | /* Enable the channel */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 68 | omap3_spi_set_enable(priv, OMAP3_MCSPI_CHCTRL_EN); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 69 | |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 70 | chconf &= ~(OMAP3_MCSPI_CHCONF_TRM_MASK | OMAP3_MCSPI_CHCONF_WL_MASK); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 71 | chconf |= (priv->wordlen - 1) << 7; |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 72 | chconf |= OMAP3_MCSPI_CHCONF_TRM_TX_ONLY; |
| 73 | chconf |= OMAP3_MCSPI_CHCONF_FORCE; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 74 | omap3_spi_write_chconf(priv, chconf); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 75 | |
| 76 | for (i = 0; i < len; i++) { |
| 77 | /* wait till TX register is empty (TXS == 1) */ |
David Dueck | a11b2a6 | 2015-04-01 14:20:24 +0200 | [diff] [blame] | 78 | start = get_timer(0); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 79 | while (!(readl(&priv->regs->channel[priv->cs].chstat) & |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 80 | OMAP3_MCSPI_CHSTAT_TXS)) { |
David Dueck | a11b2a6 | 2015-04-01 14:20:24 +0200 | [diff] [blame] | 81 | if (get_timer(start) > SPI_WAIT_TIMEOUT) { |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 82 | printf("SPI TXS timed out, status=0x%08x\n", |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 83 | readl(&priv->regs->channel[priv->cs].chstat)); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 84 | return -1; |
| 85 | } |
| 86 | } |
| 87 | /* Write the data */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 88 | unsigned int *tx = &priv->regs->channel[priv->cs].tx; |
| 89 | if (priv->wordlen > 16) |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 90 | writel(((u32 *)txp)[i], tx); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 91 | else if (priv->wordlen > 8) |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 92 | writel(((u16 *)txp)[i], tx); |
| 93 | else |
| 94 | writel(((u8 *)txp)[i], tx); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 95 | } |
| 96 | |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 97 | /* wait to finish of transfer */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 98 | while ((readl(&priv->regs->channel[priv->cs].chstat) & |
| 99 | (OMAP3_MCSPI_CHSTAT_EOT | OMAP3_MCSPI_CHSTAT_TXS)) != |
| 100 | (OMAP3_MCSPI_CHSTAT_EOT | OMAP3_MCSPI_CHSTAT_TXS)) |
| 101 | ; |
ajoy | 260ab20 | 2012-11-17 21:10:15 +0000 | [diff] [blame] | 102 | |
| 103 | /* Disable the channel otherwise the next immediate RX will get affected */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 104 | omap3_spi_set_enable(priv, OMAP3_MCSPI_CHCTRL_DIS); |
ajoy | 260ab20 | 2012-11-17 21:10:15 +0000 | [diff] [blame] | 105 | |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 106 | if (flags & SPI_XFER_END) { |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 107 | |
| 108 | chconf &= ~OMAP3_MCSPI_CHCONF_FORCE; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 109 | omap3_spi_write_chconf(priv, chconf); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 110 | } |
| 111 | return 0; |
| 112 | } |
| 113 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 114 | static int omap3_spi_read(struct omap3_spi_priv *priv, unsigned int len, |
Jagan Teki | 40a55df | 2016-03-01 15:16:21 +0100 | [diff] [blame] | 115 | void *rxp, unsigned long flags) |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 116 | { |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 117 | int i, chconf; |
David Dueck | a11b2a6 | 2015-04-01 14:20:24 +0200 | [diff] [blame] | 118 | ulong start; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 119 | |
| 120 | chconf = readl(&priv->regs->channel[priv->cs].chconf); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 121 | |
ajoy | 260ab20 | 2012-11-17 21:10:15 +0000 | [diff] [blame] | 122 | /* Enable the channel */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 123 | omap3_spi_set_enable(priv, OMAP3_MCSPI_CHCTRL_EN); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 124 | |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 125 | chconf &= ~(OMAP3_MCSPI_CHCONF_TRM_MASK | OMAP3_MCSPI_CHCONF_WL_MASK); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 126 | chconf |= (priv->wordlen - 1) << 7; |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 127 | chconf |= OMAP3_MCSPI_CHCONF_TRM_RX_ONLY; |
| 128 | chconf |= OMAP3_MCSPI_CHCONF_FORCE; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 129 | omap3_spi_write_chconf(priv, chconf); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 130 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 131 | writel(0, &priv->regs->channel[priv->cs].tx); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 132 | |
| 133 | for (i = 0; i < len; i++) { |
David Dueck | a11b2a6 | 2015-04-01 14:20:24 +0200 | [diff] [blame] | 134 | start = get_timer(0); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 135 | /* Wait till RX register contains data (RXS == 1) */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 136 | while (!(readl(&priv->regs->channel[priv->cs].chstat) & |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 137 | OMAP3_MCSPI_CHSTAT_RXS)) { |
David Dueck | a11b2a6 | 2015-04-01 14:20:24 +0200 | [diff] [blame] | 138 | if (get_timer(start) > SPI_WAIT_TIMEOUT) { |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 139 | printf("SPI RXS timed out, status=0x%08x\n", |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 140 | readl(&priv->regs->channel[priv->cs].chstat)); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 141 | return -1; |
| 142 | } |
| 143 | } |
ajoy | 260ab20 | 2012-11-17 21:10:15 +0000 | [diff] [blame] | 144 | |
| 145 | /* Disable the channel to prevent furher receiving */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 146 | if (i == (len - 1)) |
| 147 | omap3_spi_set_enable(priv, OMAP3_MCSPI_CHCTRL_DIS); |
ajoy | 260ab20 | 2012-11-17 21:10:15 +0000 | [diff] [blame] | 148 | |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 149 | /* Read the data */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 150 | unsigned int *rx = &priv->regs->channel[priv->cs].rx; |
| 151 | if (priv->wordlen > 16) |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 152 | ((u32 *)rxp)[i] = readl(rx); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 153 | else if (priv->wordlen > 8) |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 154 | ((u16 *)rxp)[i] = (u16)readl(rx); |
| 155 | else |
| 156 | ((u8 *)rxp)[i] = (u8)readl(rx); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | if (flags & SPI_XFER_END) { |
| 160 | chconf &= ~OMAP3_MCSPI_CHCONF_FORCE; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 161 | omap3_spi_write_chconf(priv, chconf); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | return 0; |
| 165 | } |
| 166 | |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 167 | /*McSPI Transmit Receive Mode*/ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 168 | static int omap3_spi_txrx(struct omap3_spi_priv *priv, unsigned int len, |
Jagan Teki | 40a55df | 2016-03-01 15:16:21 +0100 | [diff] [blame] | 169 | const void *txp, void *rxp, unsigned long flags) |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 170 | { |
David Dueck | a11b2a6 | 2015-04-01 14:20:24 +0200 | [diff] [blame] | 171 | ulong start; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 172 | int chconf, i = 0; |
| 173 | |
| 174 | chconf = readl(&priv->regs->channel[priv->cs].chconf); |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 175 | |
| 176 | /*Enable SPI channel*/ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 177 | omap3_spi_set_enable(priv, OMAP3_MCSPI_CHCTRL_EN); |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 178 | |
| 179 | /*set TRANSMIT-RECEIVE Mode*/ |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 180 | chconf &= ~(OMAP3_MCSPI_CHCONF_TRM_MASK | OMAP3_MCSPI_CHCONF_WL_MASK); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 181 | chconf |= (priv->wordlen - 1) << 7; |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 182 | chconf |= OMAP3_MCSPI_CHCONF_FORCE; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 183 | omap3_spi_write_chconf(priv, chconf); |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 184 | |
| 185 | /*Shift in and out 1 byte at time*/ |
| 186 | for (i=0; i < len; i++){ |
| 187 | /* Write: wait for TX empty (TXS == 1)*/ |
David Dueck | a11b2a6 | 2015-04-01 14:20:24 +0200 | [diff] [blame] | 188 | start = get_timer(0); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 189 | while (!(readl(&priv->regs->channel[priv->cs].chstat) & |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 190 | OMAP3_MCSPI_CHSTAT_TXS)) { |
David Dueck | a11b2a6 | 2015-04-01 14:20:24 +0200 | [diff] [blame] | 191 | if (get_timer(start) > SPI_WAIT_TIMEOUT) { |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 192 | printf("SPI TXS timed out, status=0x%08x\n", |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 193 | readl(&priv->regs->channel[priv->cs].chstat)); |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 194 | return -1; |
| 195 | } |
| 196 | } |
| 197 | /* Write the data */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 198 | unsigned int *tx = &priv->regs->channel[priv->cs].tx; |
| 199 | if (priv->wordlen > 16) |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 200 | writel(((u32 *)txp)[i], tx); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 201 | else if (priv->wordlen > 8) |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 202 | writel(((u16 *)txp)[i], tx); |
| 203 | else |
| 204 | writel(((u8 *)txp)[i], tx); |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 205 | |
| 206 | /*Read: wait for RX containing data (RXS == 1)*/ |
David Dueck | a11b2a6 | 2015-04-01 14:20:24 +0200 | [diff] [blame] | 207 | start = get_timer(0); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 208 | while (!(readl(&priv->regs->channel[priv->cs].chstat) & |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 209 | OMAP3_MCSPI_CHSTAT_RXS)) { |
David Dueck | a11b2a6 | 2015-04-01 14:20:24 +0200 | [diff] [blame] | 210 | if (get_timer(start) > SPI_WAIT_TIMEOUT) { |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 211 | printf("SPI RXS timed out, status=0x%08x\n", |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 212 | readl(&priv->regs->channel[priv->cs].chstat)); |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 213 | return -1; |
| 214 | } |
| 215 | } |
| 216 | /* Read the data */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 217 | unsigned int *rx = &priv->regs->channel[priv->cs].rx; |
| 218 | if (priv->wordlen > 16) |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 219 | ((u32 *)rxp)[i] = readl(rx); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 220 | else if (priv->wordlen > 8) |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 221 | ((u16 *)rxp)[i] = (u16)readl(rx); |
| 222 | else |
| 223 | ((u8 *)rxp)[i] = (u8)readl(rx); |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 224 | } |
ajoy | 260ab20 | 2012-11-17 21:10:15 +0000 | [diff] [blame] | 225 | /* Disable the channel */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 226 | omap3_spi_set_enable(priv, OMAP3_MCSPI_CHCTRL_DIS); |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 227 | |
| 228 | /*if transfer must be terminated disable the channel*/ |
| 229 | if (flags & SPI_XFER_END) { |
| 230 | chconf &= ~OMAP3_MCSPI_CHCONF_FORCE; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 231 | omap3_spi_write_chconf(priv, chconf); |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | return 0; |
| 235 | } |
| 236 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 237 | static int _spi_xfer(struct omap3_spi_priv *priv, unsigned int bitlen, |
| 238 | const void *dout, void *din, unsigned long flags) |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 239 | { |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 240 | unsigned int len; |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 241 | int ret = -1; |
| 242 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 243 | if (priv->wordlen < 4 || priv->wordlen > 32) { |
| 244 | printf("omap3_spi: invalid wordlen %d\n", priv->wordlen); |
Nikita Kiryanov | 18dd07c | 2013-10-16 17:23:25 +0300 | [diff] [blame] | 245 | return -1; |
| 246 | } |
| 247 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 248 | if (bitlen % priv->wordlen) |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 249 | return -1; |
| 250 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 251 | len = bitlen / priv->wordlen; |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 252 | |
| 253 | if (bitlen == 0) { /* only change CS */ |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 254 | int chconf = readl(&priv->regs->channel[priv->cs].chconf); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 255 | |
| 256 | if (flags & SPI_XFER_BEGIN) { |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 257 | omap3_spi_set_enable(priv, OMAP3_MCSPI_CHCTRL_EN); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 258 | chconf |= OMAP3_MCSPI_CHCONF_FORCE; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 259 | omap3_spi_write_chconf(priv, chconf); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 260 | } |
| 261 | if (flags & SPI_XFER_END) { |
| 262 | chconf &= ~OMAP3_MCSPI_CHCONF_FORCE; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 263 | omap3_spi_write_chconf(priv, chconf); |
| 264 | omap3_spi_set_enable(priv, OMAP3_MCSPI_CHCTRL_DIS); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 265 | } |
| 266 | ret = 0; |
| 267 | } else { |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 268 | if (dout != NULL && din != NULL) |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 269 | ret = omap3_spi_txrx(priv, len, dout, din, flags); |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 270 | else if (dout != NULL) |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 271 | ret = omap3_spi_write(priv, len, dout, flags); |
jacopo mondi | fe8793e | 2011-03-02 05:13:22 +0000 | [diff] [blame] | 272 | else if (din != NULL) |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 273 | ret = omap3_spi_read(priv, len, din, flags); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 274 | } |
| 275 | return ret; |
| 276 | } |
| 277 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 278 | static void _omap3_spi_set_speed(struct omap3_spi_priv *priv) |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 279 | { |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 280 | uint32_t confr, div = 0; |
| 281 | |
| 282 | confr = readl(&priv->regs->channel[priv->cs].chconf); |
| 283 | |
| 284 | /* Calculate clock divisor. Valid range: 0x0 - 0xC ( /1 - /4096 ) */ |
| 285 | if (priv->freq) { |
| 286 | while (div <= 0xC && (OMAP3_MCSPI_MAX_FREQ / (1 << div)) |
| 287 | > priv->freq) |
| 288 | div++; |
| 289 | } else { |
| 290 | div = 0xC; |
| 291 | } |
| 292 | |
| 293 | /* set clock divisor */ |
| 294 | confr &= ~OMAP3_MCSPI_CHCONF_CLKD_MASK; |
| 295 | confr |= div << 2; |
| 296 | |
| 297 | omap3_spi_write_chconf(priv, confr); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 298 | } |
| 299 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 300 | static void _omap3_spi_set_mode(struct omap3_spi_priv *priv) |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 301 | { |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 302 | uint32_t confr; |
| 303 | |
| 304 | confr = readl(&priv->regs->channel[priv->cs].chconf); |
| 305 | |
| 306 | /* standard 4-wire master mode: SCK, MOSI/out, MISO/in, nCS |
| 307 | * REVISIT: this controller could support SPI_3WIRE mode. |
| 308 | */ |
| 309 | if (priv->pin_dir == MCSPI_PINDIR_D0_IN_D1_OUT) { |
| 310 | confr &= ~(OMAP3_MCSPI_CHCONF_IS|OMAP3_MCSPI_CHCONF_DPE1); |
| 311 | confr |= OMAP3_MCSPI_CHCONF_DPE0; |
| 312 | } else { |
| 313 | confr &= ~OMAP3_MCSPI_CHCONF_DPE0; |
| 314 | confr |= OMAP3_MCSPI_CHCONF_IS|OMAP3_MCSPI_CHCONF_DPE1; |
| 315 | } |
| 316 | |
| 317 | /* set SPI mode 0..3 */ |
| 318 | confr &= ~(OMAP3_MCSPI_CHCONF_POL | OMAP3_MCSPI_CHCONF_PHA); |
| 319 | if (priv->mode & SPI_CPHA) |
| 320 | confr |= OMAP3_MCSPI_CHCONF_PHA; |
| 321 | if (priv->mode & SPI_CPOL) |
| 322 | confr |= OMAP3_MCSPI_CHCONF_POL; |
| 323 | |
| 324 | /* set chipselect polarity; manage with FORCE */ |
| 325 | if (!(priv->mode & SPI_CS_HIGH)) |
| 326 | confr |= OMAP3_MCSPI_CHCONF_EPOL; /* active-low; normal */ |
| 327 | else |
| 328 | confr &= ~OMAP3_MCSPI_CHCONF_EPOL; |
| 329 | |
| 330 | /* Transmit & receive mode */ |
| 331 | confr &= ~OMAP3_MCSPI_CHCONF_TRM_MASK; |
| 332 | |
| 333 | omap3_spi_write_chconf(priv, confr); |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 334 | } |
| 335 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 336 | static void _omap3_spi_set_wordlen(struct omap3_spi_priv *priv) |
Dirk Behme | 78cd9ac | 2010-12-11 11:01:00 -0500 | [diff] [blame] | 337 | { |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 338 | unsigned int confr; |
| 339 | |
| 340 | /* McSPI individual channel configuration */ |
David Rivshin | 7aacc91 | 2019-02-18 18:04:29 -0500 | [diff] [blame] | 341 | confr = readl(&priv->regs->channel[priv->cs].chconf); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 342 | |
| 343 | /* wordlength */ |
| 344 | confr &= ~OMAP3_MCSPI_CHCONF_WL_MASK; |
| 345 | confr |= (priv->wordlen - 1) << 7; |
| 346 | |
| 347 | omap3_spi_write_chconf(priv, confr); |
| 348 | } |
| 349 | |
| 350 | static void spi_reset(struct mcspi *regs) |
| 351 | { |
| 352 | unsigned int tmp; |
| 353 | |
| 354 | writel(OMAP3_MCSPI_SYSCONFIG_SOFTRESET, ®s->sysconfig); |
| 355 | do { |
| 356 | tmp = readl(®s->sysstatus); |
| 357 | } while (!(tmp & OMAP3_MCSPI_SYSSTATUS_RESETDONE)); |
| 358 | |
| 359 | writel(OMAP3_MCSPI_SYSCONFIG_AUTOIDLE | |
| 360 | OMAP3_MCSPI_SYSCONFIG_ENAWAKEUP | |
| 361 | OMAP3_MCSPI_SYSCONFIG_SMARTIDLE, ®s->sysconfig); |
| 362 | |
| 363 | writel(OMAP3_MCSPI_WAKEUPENABLE_WKEN, ®s->wakeupenable); |
| 364 | } |
| 365 | |
| 366 | static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv) |
| 367 | { |
| 368 | unsigned int conf; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 369 | /* |
| 370 | * setup when switching from (reset default) slave mode |
| 371 | * to single-channel master mode |
| 372 | */ |
| 373 | conf = readl(&priv->regs->modulctrl); |
| 374 | conf &= ~(OMAP3_MCSPI_MODULCTRL_STEST | OMAP3_MCSPI_MODULCTRL_MS); |
| 375 | conf |= OMAP3_MCSPI_MODULCTRL_SINGLE; |
| 376 | |
| 377 | writel(conf, &priv->regs->modulctrl); |
Vignesh Raghavendra | ab34b89 | 2020-11-29 12:53:05 +0530 | [diff] [blame] | 378 | |
| 379 | priv->bus_claimed = true; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 380 | } |
| 381 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 382 | static int omap3_spi_claim_bus(struct udevice *dev) |
| 383 | { |
| 384 | struct udevice *bus = dev->parent; |
| 385 | struct omap3_spi_priv *priv = dev_get_priv(bus); |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 386 | struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 387 | |
| 388 | priv->cs = slave_plat->cs; |
Vignesh Raghavendra | ab34b89 | 2020-11-29 12:53:05 +0530 | [diff] [blame] | 389 | if (!priv->freq) |
| 390 | priv->freq = slave_plat->max_hz; |
Hannes Schmelzer | 9e77880 | 2018-06-02 08:06:47 +0200 | [diff] [blame] | 391 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 392 | _omap3_spi_claim_bus(priv); |
Vignesh Raghavendra | ab34b89 | 2020-11-29 12:53:05 +0530 | [diff] [blame] | 393 | _omap3_spi_set_speed(priv); |
| 394 | _omap3_spi_set_mode(priv); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 395 | |
| 396 | return 0; |
| 397 | } |
| 398 | |
| 399 | static int omap3_spi_release_bus(struct udevice *dev) |
| 400 | { |
| 401 | struct udevice *bus = dev->parent; |
| 402 | struct omap3_spi_priv *priv = dev_get_priv(bus); |
| 403 | |
Hannes Schmelzer | 202f9a4 | 2018-06-26 16:08:39 +0200 | [diff] [blame] | 404 | writel(OMAP3_MCSPI_MODULCTRL_MS, &priv->regs->modulctrl); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 405 | |
Vignesh Raghavendra | ab34b89 | 2020-11-29 12:53:05 +0530 | [diff] [blame] | 406 | priv->bus_claimed = false; |
| 407 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | static int omap3_spi_set_wordlen(struct udevice *dev, unsigned int wordlen) |
| 412 | { |
| 413 | struct udevice *bus = dev->parent; |
| 414 | struct omap3_spi_priv *priv = dev_get_priv(bus); |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 415 | struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 416 | |
| 417 | priv->cs = slave_plat->cs; |
| 418 | priv->wordlen = wordlen; |
| 419 | _omap3_spi_set_wordlen(priv); |
| 420 | |
| 421 | return 0; |
| 422 | } |
| 423 | |
| 424 | static int omap3_spi_probe(struct udevice *dev) |
| 425 | { |
| 426 | struct omap3_spi_priv *priv = dev_get_priv(dev); |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 427 | struct omap3_spi_plat *plat = dev_get_plat(dev); |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 428 | |
Faiz Abbas | 12b2fb2 | 2020-09-14 12:11:16 +0530 | [diff] [blame] | 429 | priv->regs = plat->regs; |
| 430 | priv->pin_dir = plat->pin_dir; |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 431 | priv->wordlen = SPI_DEFAULT_WORDLEN; |
Hannes Schmelzer | 202f9a4 | 2018-06-26 16:08:39 +0200 | [diff] [blame] | 432 | |
| 433 | spi_reset(priv->regs); |
| 434 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 435 | return 0; |
| 436 | } |
| 437 | |
| 438 | static int omap3_spi_xfer(struct udevice *dev, unsigned int bitlen, |
| 439 | const void *dout, void *din, unsigned long flags) |
| 440 | { |
| 441 | struct udevice *bus = dev->parent; |
| 442 | struct omap3_spi_priv *priv = dev_get_priv(bus); |
| 443 | |
| 444 | return _spi_xfer(priv, bitlen, dout, din, flags); |
| 445 | } |
| 446 | |
Jagan Teki | 55865a9 | 2018-03-14 23:07:31 +0530 | [diff] [blame] | 447 | static int omap3_spi_set_speed(struct udevice *dev, unsigned int speed) |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 448 | { |
Jagan Teki | 96a95ee | 2018-03-07 10:30:45 +0530 | [diff] [blame] | 449 | |
Hannes Schmelzer | 7e4f833 | 2018-06-02 08:06:48 +0200 | [diff] [blame] | 450 | struct omap3_spi_priv *priv = dev_get_priv(dev); |
| 451 | |
| 452 | priv->freq = speed; |
Vignesh Raghavendra | ab34b89 | 2020-11-29 12:53:05 +0530 | [diff] [blame] | 453 | if (priv->bus_claimed) |
| 454 | _omap3_spi_set_speed(priv); |
Jagan Teki | 96a95ee | 2018-03-07 10:30:45 +0530 | [diff] [blame] | 455 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 456 | return 0; |
| 457 | } |
| 458 | |
Jagan Teki | 55865a9 | 2018-03-14 23:07:31 +0530 | [diff] [blame] | 459 | static int omap3_spi_set_mode(struct udevice *dev, uint mode) |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 460 | { |
Hannes Schmelzer | 7e4f833 | 2018-06-02 08:06:48 +0200 | [diff] [blame] | 461 | struct omap3_spi_priv *priv = dev_get_priv(dev); |
| 462 | |
| 463 | priv->mode = mode; |
Jagan Teki | 96a95ee | 2018-03-07 10:30:45 +0530 | [diff] [blame] | 464 | |
Vignesh Raghavendra | ab34b89 | 2020-11-29 12:53:05 +0530 | [diff] [blame] | 465 | if (priv->bus_claimed) |
| 466 | _omap3_spi_set_mode(priv); |
Jagan Teki | 96a95ee | 2018-03-07 10:30:45 +0530 | [diff] [blame] | 467 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 468 | return 0; |
| 469 | } |
| 470 | |
| 471 | static const struct dm_spi_ops omap3_spi_ops = { |
| 472 | .claim_bus = omap3_spi_claim_bus, |
| 473 | .release_bus = omap3_spi_release_bus, |
| 474 | .set_wordlen = omap3_spi_set_wordlen, |
| 475 | .xfer = omap3_spi_xfer, |
| 476 | .set_speed = omap3_spi_set_speed, |
| 477 | .set_mode = omap3_spi_set_mode, |
| 478 | /* |
| 479 | * cs_info is not needed, since we require all chip selects to be |
| 480 | * in the device tree explicitly |
| 481 | */ |
| 482 | }; |
| 483 | |
Faiz Abbas | 12b2fb2 | 2020-09-14 12:11:16 +0530 | [diff] [blame] | 484 | #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) |
Martin Hejnfelt | d74ea96 | 2016-05-19 09:11:58 +0200 | [diff] [blame] | 485 | static struct omap2_mcspi_platform_config omap2_pdata = { |
| 486 | .regs_offset = 0, |
| 487 | }; |
| 488 | |
| 489 | static struct omap2_mcspi_platform_config omap4_pdata = { |
| 490 | .regs_offset = OMAP4_MCSPI_REG_OFFSET, |
| 491 | }; |
| 492 | |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 493 | static int omap3_spi_of_to_plat(struct udevice *dev) |
Faiz Abbas | 12b2fb2 | 2020-09-14 12:11:16 +0530 | [diff] [blame] | 494 | { |
| 495 | struct omap2_mcspi_platform_config *data = |
| 496 | (struct omap2_mcspi_platform_config *)dev_get_driver_data(dev); |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 497 | struct omap3_spi_plat *plat = dev_get_plat(dev); |
Faiz Abbas | 12b2fb2 | 2020-09-14 12:11:16 +0530 | [diff] [blame] | 498 | |
| 499 | plat->regs = (struct mcspi *)(dev_read_addr(dev) + data->regs_offset); |
| 500 | |
| 501 | if (dev_read_bool(dev, "ti,pindir-d0-out-d1-in")) |
| 502 | plat->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN; |
| 503 | else |
| 504 | plat->pin_dir = MCSPI_PINDIR_D0_IN_D1_OUT; |
| 505 | |
| 506 | return 0; |
| 507 | } |
| 508 | |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 509 | static const struct udevice_id omap3_spi_ids[] = { |
Martin Hejnfelt | d74ea96 | 2016-05-19 09:11:58 +0200 | [diff] [blame] | 510 | { .compatible = "ti,omap2-mcspi", .data = (ulong)&omap2_pdata }, |
| 511 | { .compatible = "ti,omap4-mcspi", .data = (ulong)&omap4_pdata }, |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 512 | { } |
| 513 | }; |
Faiz Abbas | 12b2fb2 | 2020-09-14 12:11:16 +0530 | [diff] [blame] | 514 | #endif |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 515 | U_BOOT_DRIVER(omap3_spi) = { |
| 516 | .name = "omap3_spi", |
| 517 | .id = UCLASS_SPI, |
Faiz Abbas | 12b2fb2 | 2020-09-14 12:11:16 +0530 | [diff] [blame] | 518 | .flags = DM_FLAG_PRE_RELOC, |
| 519 | #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 520 | .of_match = omap3_spi_ids, |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 521 | .of_to_plat = omap3_spi_of_to_plat, |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 522 | .plat_auto = sizeof(struct omap3_spi_plat), |
Faiz Abbas | 12b2fb2 | 2020-09-14 12:11:16 +0530 | [diff] [blame] | 523 | #endif |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 524 | .probe = omap3_spi_probe, |
| 525 | .ops = &omap3_spi_ops, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 526 | .priv_auto = sizeof(struct omap3_spi_priv), |
Jagan Teki | ea17242 | 2016-03-14 22:41:24 +0530 | [diff] [blame] | 527 | }; |