blob: f078973531c1d960e5635a485e50c42170b45d80 [file] [log] [blame]
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +00001/*
2 * (C) Copyright 2012 SAMSUNG Electronics
3 * Padmavathi Venna <padma.v@samsung.com>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +00006 */
7
8#include <common.h>
Simon Glassca7eafe2014-10-13 23:42:01 -06009#include <dm.h>
10#include <errno.h>
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000011#include <malloc.h>
12#include <spi.h>
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +000013#include <fdtdec.h>
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000014#include <asm/arch/clk.h>
15#include <asm/arch/clock.h>
16#include <asm/arch/cpu.h>
17#include <asm/arch/gpio.h>
18#include <asm/arch/pinmux.h>
19#include <asm/arch-exynos/spi.h>
20#include <asm/io.h>
21
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +000022DECLARE_GLOBAL_DATA_PTR;
23
Simon Glassca7eafe2014-10-13 23:42:01 -060024struct exynos_spi_platdata {
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000025 enum periph_id periph_id;
26 s32 frequency; /* Default clock frequency, -1 for none */
27 struct exynos_spi *regs;
Rajeshwari Shindeab46adb2013-10-08 16:20:04 +053028 uint deactivate_delay_us; /* Delay to wait after deactivate */
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000029};
30
Simon Glassca7eafe2014-10-13 23:42:01 -060031struct exynos_spi_priv {
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000032 struct exynos_spi *regs;
33 unsigned int freq; /* Default frequency */
34 unsigned int mode;
35 enum periph_id periph_id; /* Peripheral ID for this device */
36 unsigned int fifo_size;
Rajeshwari Shinde813637c2013-05-28 20:10:38 +000037 int skip_preamble;
Rajeshwari Shindeab46adb2013-10-08 16:20:04 +053038 ulong last_transaction_us; /* Time of last transaction end */
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000039};
40
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000041/**
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000042 * Flush spi tx, rx fifos and reset the SPI controller
43 *
Simon Glassca7eafe2014-10-13 23:42:01 -060044 * @param regs Pointer to SPI registers
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000045 */
Simon Glassca7eafe2014-10-13 23:42:01 -060046static void spi_flush_fifo(struct exynos_spi *regs)
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000047{
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000048 clrsetbits_le32(&regs->ch_cfg, SPI_CH_HS_EN, SPI_CH_RST);
49 clrbits_le32(&regs->ch_cfg, SPI_CH_RST);
50 setbits_le32(&regs->ch_cfg, SPI_TX_CH_ON | SPI_RX_CH_ON);
51}
52
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000053static void spi_get_fifo_levels(struct exynos_spi *regs,
54 int *rx_lvl, int *tx_lvl)
55{
56 uint32_t spi_sts = readl(&regs->spi_sts);
57
58 *rx_lvl = (spi_sts >> SPI_RX_LVL_OFFSET) & SPI_FIFO_LVL_MASK;
59 *tx_lvl = (spi_sts >> SPI_TX_LVL_OFFSET) & SPI_FIFO_LVL_MASK;
60}
61
62/**
63 * If there's something to transfer, do a software reset and set a
64 * transaction size.
65 *
66 * @param regs SPI peripheral registers
67 * @param count Number of bytes to transfer
Rajeshwari Shindeffc74612013-10-08 16:20:06 +053068 * @param step Number of bytes to transfer in each packet (1 or 4)
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000069 */
Rajeshwari Shindeffc74612013-10-08 16:20:06 +053070static void spi_request_bytes(struct exynos_spi *regs, int count, int step)
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000071{
Simon Glassca7eafe2014-10-13 23:42:01 -060072 debug("%s: regs=%p, count=%d, step=%d\n", __func__, regs, count, step);
73
Rajeshwari Shindeffc74612013-10-08 16:20:06 +053074 /* For word address we need to swap bytes */
75 if (step == 4) {
76 setbits_le32(&regs->mode_cfg,
77 SPI_MODE_CH_WIDTH_WORD | SPI_MODE_BUS_WIDTH_WORD);
78 count /= 4;
79 setbits_le32(&regs->swap_cfg, SPI_TX_SWAP_EN | SPI_RX_SWAP_EN |
80 SPI_TX_BYTE_SWAP | SPI_RX_BYTE_SWAP |
81 SPI_TX_HWORD_SWAP | SPI_RX_HWORD_SWAP);
82 } else {
83 /* Select byte access and clear the swap configuration */
84 clrbits_le32(&regs->mode_cfg,
85 SPI_MODE_CH_WIDTH_WORD | SPI_MODE_BUS_WIDTH_WORD);
86 writel(0, &regs->swap_cfg);
87 }
88
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000089 assert(count && count < (1 << 16));
90 setbits_le32(&regs->ch_cfg, SPI_CH_RST);
91 clrbits_le32(&regs->ch_cfg, SPI_CH_RST);
Rajeshwari Shindeffc74612013-10-08 16:20:06 +053092
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000093 writel(count | SPI_PACKET_CNT_EN, &regs->pkt_cnt);
94}
95
Simon Glassca7eafe2014-10-13 23:42:01 -060096static int spi_rx_tx(struct exynos_spi_priv *priv, int todo,
Rajeshwari Shinde813637c2013-05-28 20:10:38 +000097 void **dinp, void const **doutp, unsigned long flags)
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +000098{
Simon Glassca7eafe2014-10-13 23:42:01 -060099 struct exynos_spi *regs = priv->regs;
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000100 uchar *rxp = *dinp;
101 const uchar *txp = *doutp;
102 int rx_lvl, tx_lvl;
103 uint out_bytes, in_bytes;
Rajeshwari Shinde813637c2013-05-28 20:10:38 +0000104 int toread;
105 unsigned start = get_timer(0);
106 int stopping;
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530107 int step;
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000108
109 out_bytes = in_bytes = todo;
110
Simon Glassca7eafe2014-10-13 23:42:01 -0600111 stopping = priv->skip_preamble && (flags & SPI_XFER_END) &&
112 !(priv->mode & SPI_SLAVE);
Rajeshwari Shinde813637c2013-05-28 20:10:38 +0000113
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000114 /*
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530115 * Try to transfer words if we can. This helps read performance at
116 * SPI clock speeds above about 20MHz.
117 */
118 step = 1;
119 if (!((todo | (uintptr_t)rxp | (uintptr_t)txp) & 3) &&
Simon Glassca7eafe2014-10-13 23:42:01 -0600120 !priv->skip_preamble)
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530121 step = 4;
122
123 /*
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000124 * If there's something to send, do a software reset and set a
125 * transaction size.
126 */
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530127 spi_request_bytes(regs, todo, step);
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000128
129 /*
130 * Bytes are transmitted/received in pairs. Wait to receive all the
131 * data because then transmission will be done as well.
132 */
Rajeshwari Shinde813637c2013-05-28 20:10:38 +0000133 toread = in_bytes;
134
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000135 while (in_bytes) {
136 int temp;
137
138 /* Keep the fifos full/empty. */
139 spi_get_fifo_levels(regs, &rx_lvl, &tx_lvl);
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530140
141 /*
142 * Don't completely fill the txfifo, since we don't want our
143 * rxfifo to overflow, and it may already contain data.
144 */
Simon Glassca7eafe2014-10-13 23:42:01 -0600145 while (tx_lvl < priv->fifo_size/2 && out_bytes) {
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530146 if (!txp)
147 temp = -1;
148 else if (step == 4)
149 temp = *(uint32_t *)txp;
150 else
151 temp = *txp;
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000152 writel(temp, &regs->tx_data);
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530153 out_bytes -= step;
154 if (txp)
155 txp += step;
156 tx_lvl += step;
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000157 }
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530158 if (rx_lvl >= step) {
159 while (rx_lvl >= step) {
Rajeshwari Shinde0c0faef2013-10-08 16:20:05 +0530160 temp = readl(&regs->rx_data);
Simon Glassca7eafe2014-10-13 23:42:01 -0600161 if (priv->skip_preamble) {
Rajeshwari Shinde0c0faef2013-10-08 16:20:05 +0530162 if (temp == SPI_PREAMBLE_END_BYTE) {
Simon Glassca7eafe2014-10-13 23:42:01 -0600163 priv->skip_preamble = 0;
Rajeshwari Shinde0c0faef2013-10-08 16:20:05 +0530164 stopping = 0;
165 }
166 } else {
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530167 if (rxp || stopping) {
Akshay Saraswat8613bed2014-06-18 17:52:41 +0530168 if (step == 4)
169 *(uint32_t *)rxp = temp;
170 else
171 *rxp = temp;
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530172 rxp += step;
173 }
174 in_bytes -= step;
Rajeshwari Shinde813637c2013-05-28 20:10:38 +0000175 }
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530176 toread -= step;
177 rx_lvl -= step;
178 }
Rajeshwari Shinde813637c2013-05-28 20:10:38 +0000179 } else if (!toread) {
180 /*
181 * We have run out of input data, but haven't read
182 * enough bytes after the preamble yet. Read some more,
183 * and make sure that we transmit dummy bytes too, to
184 * keep things going.
185 */
186 assert(!out_bytes);
187 out_bytes = in_bytes;
188 toread = in_bytes;
189 txp = NULL;
Rajeshwari Shindeffc74612013-10-08 16:20:06 +0530190 spi_request_bytes(regs, toread, step);
Rajeshwari Shinde813637c2013-05-28 20:10:38 +0000191 }
Simon Glassca7eafe2014-10-13 23:42:01 -0600192 if (priv->skip_preamble && get_timer(start) > 100) {
Rajeshwari Shinde813637c2013-05-28 20:10:38 +0000193 printf("SPI timeout: in_bytes=%d, out_bytes=%d, ",
194 in_bytes, out_bytes);
195 return -1;
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000196 }
197 }
Rajeshwari Shinde813637c2013-05-28 20:10:38 +0000198
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000199 *dinp = rxp;
200 *doutp = txp;
Rajeshwari Shinde813637c2013-05-28 20:10:38 +0000201
202 return 0;
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000203}
204
205/**
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000206 * Activate the CS by driving it LOW
207 *
208 * @param slave Pointer to spi_slave to which controller has to
209 * communicate with
210 */
Simon Glassca7eafe2014-10-13 23:42:01 -0600211static void spi_cs_activate(struct udevice *dev)
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000212{
Simon Glassca7eafe2014-10-13 23:42:01 -0600213 struct udevice *bus = dev->parent;
214 struct exynos_spi_platdata *pdata = dev_get_platdata(bus);
215 struct exynos_spi_priv *priv = dev_get_priv(bus);
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000216
Rajeshwari Shindeab46adb2013-10-08 16:20:04 +0530217 /* If it's too soon to do another transaction, wait */
Simon Glassca7eafe2014-10-13 23:42:01 -0600218 if (pdata->deactivate_delay_us &&
219 priv->last_transaction_us) {
Rajeshwari Shindeab46adb2013-10-08 16:20:04 +0530220 ulong delay_us; /* The delay completed so far */
Simon Glassca7eafe2014-10-13 23:42:01 -0600221 delay_us = timer_get_us() - priv->last_transaction_us;
222 if (delay_us < pdata->deactivate_delay_us)
223 udelay(pdata->deactivate_delay_us - delay_us);
Rajeshwari Shindeab46adb2013-10-08 16:20:04 +0530224 }
225
Simon Glassca7eafe2014-10-13 23:42:01 -0600226 clrbits_le32(&priv->regs->cs_reg, SPI_SLAVE_SIG_INACT);
227 debug("Activate CS, bus '%s'\n", bus->name);
228 priv->skip_preamble = priv->mode & SPI_PREAMBLE;
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000229}
230
231/**
232 * Deactivate the CS by driving it HIGH
233 *
234 * @param slave Pointer to spi_slave to which controller has to
235 * communicate with
236 */
Simon Glassca7eafe2014-10-13 23:42:01 -0600237static void spi_cs_deactivate(struct udevice *dev)
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000238{
Simon Glassca7eafe2014-10-13 23:42:01 -0600239 struct udevice *bus = dev->parent;
240 struct exynos_spi_platdata *pdata = dev_get_platdata(bus);
241 struct exynos_spi_priv *priv = dev_get_priv(bus);
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000242
Simon Glassca7eafe2014-10-13 23:42:01 -0600243 setbits_le32(&priv->regs->cs_reg, SPI_SLAVE_SIG_INACT);
Simon Glassa193ed02014-07-07 10:16:38 -0600244
245 /* Remember time of this transaction so we can honour the bus delay */
Simon Glassca7eafe2014-10-13 23:42:01 -0600246 if (pdata->deactivate_delay_us)
247 priv->last_transaction_us = timer_get_us();
Simon Glassa193ed02014-07-07 10:16:38 -0600248
Simon Glassca7eafe2014-10-13 23:42:01 -0600249 debug("Deactivate CS, bus '%s'\n", bus->name);
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000250}
251
Simon Glassca7eafe2014-10-13 23:42:01 -0600252static int exynos_spi_ofdata_to_platdata(struct udevice *bus)
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000253{
Simon Glassca7eafe2014-10-13 23:42:01 -0600254 struct exynos_spi_platdata *plat = bus->platdata;
255 const void *blob = gd->fdt_blob;
256 int node = bus->of_offset;
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000257
Simon Glassca7eafe2014-10-13 23:42:01 -0600258 plat->regs = (struct exynos_spi *)fdtdec_get_addr(blob, node, "reg");
259 plat->periph_id = pinmux_decode_periph_id(blob, node);
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000260
Simon Glassca7eafe2014-10-13 23:42:01 -0600261 if (plat->periph_id == PERIPH_ID_NONE) {
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000262 debug("%s: Invalid peripheral ID %d\n", __func__,
Simon Glassca7eafe2014-10-13 23:42:01 -0600263 plat->periph_id);
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000264 return -FDT_ERR_NOTFOUND;
265 }
266
267 /* Use 500KHz as a suitable default */
Simon Glassca7eafe2014-10-13 23:42:01 -0600268 plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency",
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000269 500000);
Simon Glassca7eafe2014-10-13 23:42:01 -0600270 plat->deactivate_delay_us = fdtdec_get_int(blob, node,
Rajeshwari Shindeab46adb2013-10-08 16:20:04 +0530271 "spi-deactivate-delay", 0);
Simon Glassca7eafe2014-10-13 23:42:01 -0600272 debug("%s: regs=%p, periph_id=%d, max-frequency=%d, deactivate_delay=%d\n",
273 __func__, plat->regs, plat->periph_id, plat->frequency,
274 plat->deactivate_delay_us);
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000275
276 return 0;
277}
278
Simon Glassca7eafe2014-10-13 23:42:01 -0600279static int exynos_spi_probe(struct udevice *bus)
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000280{
Simon Glassca7eafe2014-10-13 23:42:01 -0600281 struct exynos_spi_platdata *plat = dev_get_platdata(bus);
282 struct exynos_spi_priv *priv = dev_get_priv(bus);
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000283
Simon Glassca7eafe2014-10-13 23:42:01 -0600284 priv->regs = plat->regs;
285 if (plat->periph_id == PERIPH_ID_SPI1 ||
286 plat->periph_id == PERIPH_ID_SPI2)
287 priv->fifo_size = 64;
288 else
289 priv->fifo_size = 256;
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000290
Simon Glassca7eafe2014-10-13 23:42:01 -0600291 priv->skip_preamble = 0;
292 priv->last_transaction_us = timer_get_us();
293 priv->freq = plat->frequency;
294 priv->periph_id = plat->periph_id;
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000295
Simon Glassca7eafe2014-10-13 23:42:01 -0600296 return 0;
297}
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000298
Simon Glassca7eafe2014-10-13 23:42:01 -0600299static int exynos_spi_claim_bus(struct udevice *bus)
300{
301 struct exynos_spi_priv *priv = dev_get_priv(bus);
302
303 exynos_pinmux_config(priv->periph_id, PINMUX_FLAG_NONE);
304 spi_flush_fifo(priv->regs);
305
306 writel(SPI_FB_DELAY_180, &priv->regs->fb_clk);
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000307
308 return 0;
309}
310
Simon Glassca7eafe2014-10-13 23:42:01 -0600311static int exynos_spi_release_bus(struct udevice *bus)
Hung-ying Tyan00391232013-05-15 18:27:30 +0800312{
Simon Glassca7eafe2014-10-13 23:42:01 -0600313 struct exynos_spi_priv *priv = dev_get_priv(bus);
Hung-ying Tyan00391232013-05-15 18:27:30 +0800314
Simon Glassca7eafe2014-10-13 23:42:01 -0600315 spi_flush_fifo(priv->regs);
316
317 return 0;
318}
319
320static int exynos_spi_xfer(struct udevice *dev, unsigned int bitlen,
321 const void *dout, void *din, unsigned long flags)
322{
323 struct udevice *bus = dev->parent;
324 struct exynos_spi_priv *priv = dev_get_priv(bus);
325 int upto, todo;
326 int bytelen;
327 int ret = 0;
328
329 /* spi core configured to do 8 bit transfers */
330 if (bitlen % 8) {
331 debug("Non byte aligned SPI transfer.\n");
332 return -1;
Hung-ying Tyan00391232013-05-15 18:27:30 +0800333 }
334
Simon Glassca7eafe2014-10-13 23:42:01 -0600335 /* Start the transaction, if necessary. */
336 if ((flags & SPI_XFER_BEGIN))
337 spi_cs_activate(dev);
338
339 /*
340 * Exynos SPI limits each transfer to 65535 transfers. To keep
341 * things simple, allow a maximum of 65532 bytes. We could allow
342 * more in word mode, but the performance difference is small.
343 */
344 bytelen = bitlen / 8;
345 for (upto = 0; !ret && upto < bytelen; upto += todo) {
346 todo = min(bytelen - upto, (1 << 16) - 4);
347 ret = spi_rx_tx(priv, todo, &din, &dout, flags);
348 if (ret)
349 break;
350 }
351
352 /* Stop the transaction, if necessary. */
353 if ((flags & SPI_XFER_END) && !(priv->mode & SPI_SLAVE)) {
354 spi_cs_deactivate(dev);
355 if (priv->skip_preamble) {
356 assert(!priv->skip_preamble);
357 debug("Failed to complete premable transaction\n");
358 ret = -1;
359 }
360 }
361
362 return ret;
363}
364
365static int exynos_spi_set_speed(struct udevice *bus, uint speed)
366{
367 struct exynos_spi_platdata *plat = bus->platdata;
368 struct exynos_spi_priv *priv = dev_get_priv(bus);
369 int ret;
370
371 if (speed > plat->frequency)
372 speed = plat->frequency;
373 ret = set_spi_clk(priv->periph_id, speed);
374 if (ret)
375 return ret;
376 priv->freq = speed;
377 debug("%s: regs=%p, speed=%d\n", __func__, priv->regs, priv->freq);
378
379 return 0;
Hung-ying Tyan00391232013-05-15 18:27:30 +0800380}
381
Simon Glassca7eafe2014-10-13 23:42:01 -0600382static int exynos_spi_set_mode(struct udevice *bus, uint mode)
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000383{
Simon Glassca7eafe2014-10-13 23:42:01 -0600384 struct exynos_spi_priv *priv = dev_get_priv(bus);
385 uint32_t reg;
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000386
Simon Glassca7eafe2014-10-13 23:42:01 -0600387 reg = readl(&priv->regs->ch_cfg);
388 reg &= ~(SPI_CH_CPHA_B | SPI_CH_CPOL_L);
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000389
Simon Glassca7eafe2014-10-13 23:42:01 -0600390 if (mode & SPI_CPHA)
391 reg |= SPI_CH_CPHA_B;
Rajeshwari Shinde64ef8a32012-12-26 20:03:23 +0000392
Simon Glassca7eafe2014-10-13 23:42:01 -0600393 if (mode & SPI_CPOL)
394 reg |= SPI_CH_CPOL_L;
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000395
Simon Glassca7eafe2014-10-13 23:42:01 -0600396 writel(reg, &priv->regs->ch_cfg);
397 priv->mode = mode;
398 debug("%s: regs=%p, mode=%d\n", __func__, priv->regs, priv->mode);
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000399
Simon Glassca7eafe2014-10-13 23:42:01 -0600400 return 0;
Rajeshwari Shindeba3b8932012-11-02 01:15:36 +0000401}
Simon Glassca7eafe2014-10-13 23:42:01 -0600402
403static const struct dm_spi_ops exynos_spi_ops = {
404 .claim_bus = exynos_spi_claim_bus,
405 .release_bus = exynos_spi_release_bus,
406 .xfer = exynos_spi_xfer,
407 .set_speed = exynos_spi_set_speed,
408 .set_mode = exynos_spi_set_mode,
409 /*
410 * cs_info is not needed, since we require all chip selects to be
411 * in the device tree explicitly
412 */
413};
414
415static const struct udevice_id exynos_spi_ids[] = {
416 { .compatible = "samsung,exynos-spi" },
417 { }
418};
419
420U_BOOT_DRIVER(exynos_spi) = {
421 .name = "exynos_spi",
422 .id = UCLASS_SPI,
423 .of_match = exynos_spi_ids,
424 .ops = &exynos_spi_ops,
425 .ofdata_to_platdata = exynos_spi_ofdata_to_platdata,
426 .platdata_auto_alloc_size = sizeof(struct exynos_spi_platdata),
427 .priv_auto_alloc_size = sizeof(struct exynos_spi_priv),
428 .per_child_auto_alloc_size = sizeof(struct spi_slave),
429 .probe = exynos_spi_probe,
430};