Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2006 Ben Warren, Qstreams Networks Inc. |
Stefan Roese | 88fbf93 | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 4 | * With help from the common/soft_spi and arch/powerpc/cpu/mpc8260 drivers |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Rasmus Villemoes | 1534031 | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 8 | #include <clk.h> |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | #include <errno.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 11 | #include <log.h> |
Haavard Skinnemoen | d74084a | 2008-05-16 11:10:31 +0200 | [diff] [blame] | 12 | #include <malloc.h> |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 13 | #include <spi.h> |
| 14 | #include <asm/mpc8xxx_spi.h> |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 15 | #include <asm-generic/gpio.h> |
Rasmus Villemoes | d4e78c3 | 2020-04-20 16:13:41 +0200 | [diff] [blame] | 16 | #include <dm/device_compat.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 17 | #include <linux/bitops.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 18 | #include <linux/delay.h> |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 19 | |
Mario Six | 10f300a | 2019-04-29 01:58:41 +0530 | [diff] [blame] | 20 | enum { |
| 21 | SPI_EV_NE = BIT(31 - 22), /* Receiver Not Empty */ |
| 22 | SPI_EV_NF = BIT(31 - 23), /* Transmitter Not Full */ |
| 23 | }; |
| 24 | |
| 25 | enum { |
| 26 | SPI_MODE_LOOP = BIT(31 - 1), /* Loopback mode */ |
| 27 | SPI_MODE_CI = BIT(31 - 2), /* Clock invert */ |
| 28 | SPI_MODE_CP = BIT(31 - 3), /* Clock phase */ |
| 29 | SPI_MODE_DIV16 = BIT(31 - 4), /* Divide clock source by 16 */ |
| 30 | SPI_MODE_REV = BIT(31 - 5), /* Reverse mode - MSB first */ |
| 31 | SPI_MODE_MS = BIT(31 - 6), /* Always master */ |
| 32 | SPI_MODE_EN = BIT(31 - 7), /* Enable interface */ |
| 33 | |
| 34 | SPI_MODE_LEN_MASK = 0xf00000, |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 35 | SPI_MODE_LEN_SHIFT = 20, |
Rasmus Villemoes | 1534031 | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 36 | SPI_MODE_PM_SHIFT = 16, |
Mario Six | 10f300a | 2019-04-29 01:58:41 +0530 | [diff] [blame] | 37 | SPI_MODE_PM_MASK = 0xf0000, |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 38 | |
Mario Six | 10f300a | 2019-04-29 01:58:41 +0530 | [diff] [blame] | 39 | SPI_COM_LST = BIT(31 - 9), |
| 40 | }; |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 41 | |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 42 | struct mpc8xxx_priv { |
| 43 | spi8xxx_t *spi; |
| 44 | struct gpio_desc gpios[16]; |
Rasmus Villemoes | d31ec8b | 2020-02-11 15:20:24 +0000 | [diff] [blame] | 45 | int cs_count; |
Rasmus Villemoes | 1534031 | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 46 | ulong clk_rate; |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 47 | }; |
| 48 | |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 49 | #define SPI_TIMEOUT 1000 |
| 50 | |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 51 | static int mpc8xxx_spi_ofdata_to_platdata(struct udevice *dev) |
Haavard Skinnemoen | d74084a | 2008-05-16 11:10:31 +0200 | [diff] [blame] | 52 | { |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 53 | struct mpc8xxx_priv *priv = dev_get_priv(dev); |
Rasmus Villemoes | 1534031 | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 54 | struct clk clk; |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 55 | int ret; |
| 56 | |
| 57 | priv->spi = (spi8xxx_t *)dev_read_addr(dev); |
| 58 | |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 59 | ret = gpio_request_list_by_name(dev, "gpios", priv->gpios, |
| 60 | ARRAY_SIZE(priv->gpios), GPIOD_IS_OUT | GPIOD_ACTIVE_LOW); |
| 61 | if (ret < 0) |
| 62 | return -EINVAL; |
| 63 | |
Rasmus Villemoes | d31ec8b | 2020-02-11 15:20:24 +0000 | [diff] [blame] | 64 | priv->cs_count = ret; |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 65 | |
Rasmus Villemoes | 1534031 | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 66 | ret = clk_get_by_index(dev, 0, &clk); |
| 67 | if (ret) { |
| 68 | dev_err(dev, "%s: clock not defined\n", __func__); |
| 69 | return ret; |
| 70 | } |
| 71 | |
| 72 | priv->clk_rate = clk_get_rate(&clk); |
| 73 | if (!priv->clk_rate) { |
| 74 | dev_err(dev, "%s: failed to get clock rate\n", __func__); |
| 75 | return -EINVAL; |
| 76 | } |
| 77 | |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 78 | return 0; |
Haavard Skinnemoen | d74084a | 2008-05-16 11:10:31 +0200 | [diff] [blame] | 79 | } |
| 80 | |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 81 | static int mpc8xxx_spi_probe(struct udevice *dev) |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 82 | { |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 83 | struct mpc8xxx_priv *priv = dev_get_priv(dev); |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 84 | spi8xxx_t *spi = priv->spi; |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 85 | |
Kim Phillips | b8e2520 | 2008-01-17 12:48:00 -0600 | [diff] [blame] | 86 | /* |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 87 | * SPI pins on the MPC83xx are not muxed, so all we do is initialize |
| 88 | * some registers |
Kim Phillips | b8e2520 | 2008-01-17 12:48:00 -0600 | [diff] [blame] | 89 | */ |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 90 | out_be32(&priv->spi->mode, SPI_MODE_REV | SPI_MODE_MS); |
| 91 | |
| 92 | /* set len to 8 bits */ |
| 93 | setbits_be32(&spi->mode, (8 - 1) << SPI_MODE_LEN_SHIFT); |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 94 | |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 95 | setbits_be32(&spi->mode, SPI_MODE_EN); |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 96 | |
Mario Six | 4d3082b | 2019-04-29 01:58:37 +0530 | [diff] [blame] | 97 | /* Clear all SPI events */ |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 98 | setbits_be32(&priv->spi->event, 0xffffffff); |
Mario Six | 4d3082b | 2019-04-29 01:58:37 +0530 | [diff] [blame] | 99 | /* Mask all SPI interrupts */ |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 100 | clrbits_be32(&priv->spi->mask, 0xffffffff); |
Mario Six | 4d3082b | 2019-04-29 01:58:37 +0530 | [diff] [blame] | 101 | /* LST bit doesn't do anything, so disregard */ |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 102 | out_be32(&priv->spi->com, 0); |
| 103 | |
| 104 | return 0; |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 105 | } |
| 106 | |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 107 | static void mpc8xxx_spi_cs_activate(struct udevice *dev) |
Haavard Skinnemoen | d74084a | 2008-05-16 11:10:31 +0200 | [diff] [blame] | 108 | { |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 109 | struct mpc8xxx_priv *priv = dev_get_priv(dev->parent); |
| 110 | struct dm_spi_slave_platdata *platdata = dev_get_parent_platdata(dev); |
| 111 | |
| 112 | dm_gpio_set_dir_flags(&priv->gpios[platdata->cs], GPIOD_IS_OUT); |
| 113 | dm_gpio_set_value(&priv->gpios[platdata->cs], 0); |
Haavard Skinnemoen | d74084a | 2008-05-16 11:10:31 +0200 | [diff] [blame] | 114 | } |
| 115 | |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 116 | static void mpc8xxx_spi_cs_deactivate(struct udevice *dev) |
Haavard Skinnemoen | d74084a | 2008-05-16 11:10:31 +0200 | [diff] [blame] | 117 | { |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 118 | struct mpc8xxx_priv *priv = dev_get_priv(dev->parent); |
| 119 | struct dm_spi_slave_platdata *platdata = dev_get_parent_platdata(dev); |
| 120 | |
| 121 | dm_gpio_set_dir_flags(&priv->gpios[platdata->cs], GPIOD_IS_OUT); |
| 122 | dm_gpio_set_value(&priv->gpios[platdata->cs], 1); |
Haavard Skinnemoen | d74084a | 2008-05-16 11:10:31 +0200 | [diff] [blame] | 123 | } |
| 124 | |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 125 | static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen, |
| 126 | const void *dout, void *din, ulong flags) |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 127 | { |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 128 | struct udevice *bus = dev->parent; |
| 129 | struct mpc8xxx_priv *priv = dev_get_priv(bus); |
| 130 | spi8xxx_t *spi = priv->spi; |
| 131 | struct dm_spi_slave_platdata *platdata = dev_get_parent_platdata(dev); |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 132 | u32 tmpdin = 0, tmpdout = 0, n; |
| 133 | const u8 *cout = dout; |
| 134 | u8 *cin = din; |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 135 | |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 136 | debug("%s: slave %s:%u dout %08X din %08X bitlen %u\n", __func__, |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 137 | bus->name, platdata->cs, (uint)dout, (uint)din, bitlen); |
Rasmus Villemoes | d31ec8b | 2020-02-11 15:20:24 +0000 | [diff] [blame] | 138 | if (platdata->cs >= priv->cs_count) { |
| 139 | dev_err(dev, "chip select index %d too large (cs_count=%d)\n", |
| 140 | platdata->cs, priv->cs_count); |
| 141 | return -EINVAL; |
| 142 | } |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 143 | if (bitlen % 8) { |
| 144 | printf("*** spi_xfer: bitlen must be multiple of 8\n"); |
| 145 | return -ENOTSUPP; |
| 146 | } |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 147 | |
Haavard Skinnemoen | d74084a | 2008-05-16 11:10:31 +0200 | [diff] [blame] | 148 | if (flags & SPI_XFER_BEGIN) |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 149 | mpc8xxx_spi_cs_activate(dev); |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 150 | |
Mario Six | 4d3082b | 2019-04-29 01:58:37 +0530 | [diff] [blame] | 151 | /* Clear all SPI events */ |
Mario Six | dee9949 | 2019-04-29 01:58:42 +0530 | [diff] [blame] | 152 | setbits_be32(&spi->event, 0xffffffff); |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 153 | n = bitlen / 8; |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 154 | |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 155 | /* Handle data in 8-bit chunks */ |
| 156 | while (n--) { |
Mario Six | 9083b13 | 2019-04-29 01:58:52 +0530 | [diff] [blame] | 157 | ulong start; |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 158 | |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 159 | if (cout) |
| 160 | tmpdout = *cout++; |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 161 | |
Mario Six | 4d3082b | 2019-04-29 01:58:37 +0530 | [diff] [blame] | 162 | /* Write the data out */ |
Mario Six | dee9949 | 2019-04-29 01:58:42 +0530 | [diff] [blame] | 163 | out_be32(&spi->tx, tmpdout); |
Mario Six | 4d3082b | 2019-04-29 01:58:37 +0530 | [diff] [blame] | 164 | |
Mario Six | f9d5ca2 | 2019-04-29 01:58:40 +0530 | [diff] [blame] | 165 | debug("*** %s: ... %08x written\n", __func__, tmpdout); |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 166 | |
Kim Phillips | b8e2520 | 2008-01-17 12:48:00 -0600 | [diff] [blame] | 167 | /* |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 168 | * Wait for SPI transmit to get out |
| 169 | * or time out (1 second = 1000 ms) |
| 170 | * The NE event must be read and cleared first |
Kim Phillips | b8e2520 | 2008-01-17 12:48:00 -0600 | [diff] [blame] | 171 | */ |
Mario Six | 9083b13 | 2019-04-29 01:58:52 +0530 | [diff] [blame] | 172 | start = get_timer(0); |
| 173 | do { |
Mario Six | 8d684ec | 2019-04-29 01:58:46 +0530 | [diff] [blame] | 174 | u32 event = in_be32(&spi->event); |
Mario Six | 4b671e1 | 2019-04-29 01:58:44 +0530 | [diff] [blame] | 175 | bool have_ne = event & SPI_EV_NE; |
| 176 | bool have_nf = event & SPI_EV_NF; |
| 177 | |
Mario Six | 2afedfe | 2019-04-29 01:58:45 +0530 | [diff] [blame] | 178 | if (!have_ne) |
| 179 | continue; |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 180 | |
Mario Six | 2afedfe | 2019-04-29 01:58:45 +0530 | [diff] [blame] | 181 | tmpdin = in_be32(&spi->rx); |
| 182 | setbits_be32(&spi->event, SPI_EV_NE); |
| 183 | |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 184 | if (cin) |
| 185 | *cin++ = tmpdin; |
Mario Six | 2afedfe | 2019-04-29 01:58:45 +0530 | [diff] [blame] | 186 | |
Kim Phillips | b8e2520 | 2008-01-17 12:48:00 -0600 | [diff] [blame] | 187 | /* |
| 188 | * Only bail when we've had both NE and NF events. |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 189 | * This will cause timeouts on RO devices, so maybe |
| 190 | * in the future put an arbitrary delay after writing |
Kim Phillips | b8e2520 | 2008-01-17 12:48:00 -0600 | [diff] [blame] | 191 | * the device. Arbitrary delays suck, though... |
| 192 | */ |
Mario Six | 2afedfe | 2019-04-29 01:58:45 +0530 | [diff] [blame] | 193 | if (have_nf) |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 194 | break; |
Mario Six | 9083b13 | 2019-04-29 01:58:52 +0530 | [diff] [blame] | 195 | |
| 196 | mdelay(1); |
| 197 | } while (get_timer(start) < SPI_TIMEOUT); |
Mario Six | 2afedfe | 2019-04-29 01:58:45 +0530 | [diff] [blame] | 198 | |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 199 | if (get_timer(start) >= SPI_TIMEOUT) { |
Mario Six | f9d5ca2 | 2019-04-29 01:58:40 +0530 | [diff] [blame] | 200 | debug("*** %s: Time out during SPI transfer\n", |
| 201 | __func__); |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 202 | return -ETIMEDOUT; |
| 203 | } |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 204 | |
Mario Six | f9d5ca2 | 2019-04-29 01:58:40 +0530 | [diff] [blame] | 205 | debug("*** %s: transfer ended. Value=%08x\n", __func__, tmpdin); |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 206 | } |
| 207 | |
Haavard Skinnemoen | d74084a | 2008-05-16 11:10:31 +0200 | [diff] [blame] | 208 | if (flags & SPI_XFER_END) |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 209 | mpc8xxx_spi_cs_deactivate(dev); |
| 210 | |
| 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | static int mpc8xxx_spi_set_speed(struct udevice *dev, uint speed) |
| 215 | { |
Rasmus Villemoes | 1534031 | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 216 | struct mpc8xxx_priv *priv = dev_get_priv(dev); |
| 217 | spi8xxx_t *spi = priv->spi; |
| 218 | u32 bits, mask, div16, pm; |
| 219 | u32 mode; |
| 220 | ulong clk; |
| 221 | |
| 222 | clk = priv->clk_rate; |
| 223 | if (clk / 64 > speed) { |
| 224 | div16 = SPI_MODE_DIV16; |
| 225 | clk /= 16; |
| 226 | } else { |
| 227 | div16 = 0; |
| 228 | } |
| 229 | pm = (clk - 1)/(4*speed) + 1; |
| 230 | if (pm > 16) { |
| 231 | dev_err(dev, "requested speed %u too small\n", speed); |
| 232 | return -EINVAL; |
| 233 | } |
| 234 | pm--; |
| 235 | |
| 236 | bits = div16 | (pm << SPI_MODE_PM_SHIFT); |
| 237 | mask = SPI_MODE_DIV16 | SPI_MODE_PM_MASK; |
| 238 | mode = in_be32(&spi->mode); |
| 239 | if ((mode & mask) != bits) { |
| 240 | /* Must clear mode[EN] while changing speed. */ |
| 241 | mode &= ~(mask | SPI_MODE_EN); |
| 242 | out_be32(&spi->mode, mode); |
| 243 | mode |= bits; |
| 244 | out_be32(&spi->mode, mode); |
| 245 | mode |= SPI_MODE_EN; |
| 246 | out_be32(&spi->mode, mode); |
| 247 | } |
| 248 | |
| 249 | debug("requested speed %u, set speed to %lu/(%s4*%u) == %lu\n", |
| 250 | speed, priv->clk_rate, div16 ? "16*" : "", pm + 1, |
| 251 | clk/(4*(pm + 1))); |
| 252 | |
Rasmus Villemoes | 379e25d | 2020-02-11 15:20:25 +0000 | [diff] [blame] | 253 | return 0; |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 254 | } |
Kim Phillips | b8e2520 | 2008-01-17 12:48:00 -0600 | [diff] [blame] | 255 | |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 256 | static int mpc8xxx_spi_set_mode(struct udevice *dev, uint mode) |
| 257 | { |
| 258 | /* TODO(mario.six@gdsys.cc): Using SPI_CPHA (for clock phase) and |
| 259 | * SPI_CPOL (for clock polarity) should work |
| 260 | */ |
Ben Warren | 7efe927 | 2008-01-16 22:37:35 -0500 | [diff] [blame] | 261 | return 0; |
| 262 | } |
Jagan Teki | 52515d5 | 2019-04-29 01:58:53 +0530 | [diff] [blame] | 263 | |
| 264 | static const struct dm_spi_ops mpc8xxx_spi_ops = { |
| 265 | .xfer = mpc8xxx_spi_xfer, |
| 266 | .set_speed = mpc8xxx_spi_set_speed, |
| 267 | .set_mode = mpc8xxx_spi_set_mode, |
| 268 | /* |
| 269 | * cs_info is not needed, since we require all chip selects to be |
| 270 | * in the device tree explicitly |
| 271 | */ |
| 272 | }; |
| 273 | |
| 274 | static const struct udevice_id mpc8xxx_spi_ids[] = { |
| 275 | { .compatible = "fsl,spi" }, |
| 276 | { } |
| 277 | }; |
| 278 | |
| 279 | U_BOOT_DRIVER(mpc8xxx_spi) = { |
| 280 | .name = "mpc8xxx_spi", |
| 281 | .id = UCLASS_SPI, |
| 282 | .of_match = mpc8xxx_spi_ids, |
| 283 | .ops = &mpc8xxx_spi_ops, |
| 284 | .ofdata_to_platdata = mpc8xxx_spi_ofdata_to_platdata, |
| 285 | .probe = mpc8xxx_spi_probe, |
| 286 | .priv_auto_alloc_size = sizeof(struct mpc8xxx_priv), |
| 287 | }; |