1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018 Exceet Electronics GmbH
4 * Copyright (C) 2018 Bootlin
6 * Author: Boris Brezillon <boris.brezillon@bootlin.com>
11 #include <dm/devres.h>
12 #include <linux/dmaengine.h>
13 #include <linux/pm_runtime.h>
14 #include "internals.h"
23 #include <dm/device_compat.h>
24 #include <dm/devres.h>
25 #include <linux/bug.h>
30 * spi_controller_dma_map_mem_op_data() - DMA-map the buffer attached to a
32 * @ctlr: the SPI controller requesting this dma_map()
33 * @op: the memory operation containing the buffer to map
34 * @sgt: a pointer to a non-initialized sg_table that will be filled by this
37 * Some controllers might want to do DMA on the data buffer embedded in @op.
38 * This helper prepares everything for you and provides a ready-to-use
39 * sg_table. This function is not intended to be called from spi drivers.
40 * Only SPI controller drivers should use it.
41 * Note that the caller must ensure the memory region pointed by
42 * op->data.buf.{in,out} is DMA-able before calling this function.
44 * Return: 0 in case of success, a negative error code otherwise.
46 int spi_controller_dma_map_mem_op_data(struct spi_controller *ctlr,
47 const struct spi_mem_op *op,
50 struct device *dmadev;
55 if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx)
56 dmadev = ctlr->dma_tx->device->dev;
57 else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx)
58 dmadev = ctlr->dma_rx->device->dev;
60 dmadev = ctlr->dev.parent;
65 return spi_map_buf(ctlr, dmadev, sgt, op->data.buf.in, op->data.nbytes,
66 op->data.dir == SPI_MEM_DATA_IN ?
67 DMA_FROM_DEVICE : DMA_TO_DEVICE);
69 EXPORT_SYMBOL_GPL(spi_controller_dma_map_mem_op_data);
72 * spi_controller_dma_unmap_mem_op_data() - DMA-unmap the buffer attached to a
74 * @ctlr: the SPI controller requesting this dma_unmap()
75 * @op: the memory operation containing the buffer to unmap
76 * @sgt: a pointer to an sg_table previously initialized by
77 * spi_controller_dma_map_mem_op_data()
79 * Some controllers might want to do DMA on the data buffer embedded in @op.
80 * This helper prepares things so that the CPU can access the
81 * op->data.buf.{in,out} buffer again.
83 * This function is not intended to be called from SPI drivers. Only SPI
84 * controller drivers should use it.
86 * This function should be called after the DMA operation has finished and is
87 * only valid if the previous spi_controller_dma_map_mem_op_data() call
90 * Return: 0 in case of success, a negative error code otherwise.
92 void spi_controller_dma_unmap_mem_op_data(struct spi_controller *ctlr,
93 const struct spi_mem_op *op,
96 struct device *dmadev;
101 if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx)
102 dmadev = ctlr->dma_tx->device->dev;
103 else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx)
104 dmadev = ctlr->dma_rx->device->dev;
106 dmadev = ctlr->dev.parent;
108 spi_unmap_buf(ctlr, dmadev, sgt,
109 op->data.dir == SPI_MEM_DATA_IN ?
110 DMA_FROM_DEVICE : DMA_TO_DEVICE);
112 EXPORT_SYMBOL_GPL(spi_controller_dma_unmap_mem_op_data);
113 #endif /* __UBOOT__ */
115 static int spi_check_buswidth_req(struct spi_slave *slave, u8 buswidth, bool tx)
117 u32 mode = slave->mode;
124 if ((tx && (mode & (SPI_TX_DUAL | SPI_TX_QUAD))) ||
125 (!tx && (mode & (SPI_RX_DUAL | SPI_RX_QUAD))))
131 if ((tx && (mode & SPI_TX_QUAD)) ||
132 (!tx && (mode & SPI_RX_QUAD)))
137 if ((tx && (mode & SPI_TX_OCTAL)) ||
138 (!tx && (mode & SPI_RX_OCTAL)))
150 static bool spi_mem_check_buswidth(struct spi_slave *slave,
151 const struct spi_mem_op *op)
153 if (spi_check_buswidth_req(slave, op->cmd.buswidth, true))
156 if (op->addr.nbytes &&
157 spi_check_buswidth_req(slave, op->addr.buswidth, true))
160 if (op->dummy.nbytes &&
161 spi_check_buswidth_req(slave, op->dummy.buswidth, true))
164 if (op->data.dir != SPI_MEM_NO_DATA &&
165 spi_check_buswidth_req(slave, op->data.buswidth,
166 op->data.dir == SPI_MEM_DATA_OUT))
172 bool spi_mem_dtr_supports_op(struct spi_slave *slave,
173 const struct spi_mem_op *op)
175 if (op->cmd.buswidth == 8 && op->cmd.nbytes % 2)
178 if (op->addr.nbytes && op->addr.buswidth == 8 && op->addr.nbytes % 2)
181 if (op->dummy.nbytes && op->dummy.buswidth == 8 && op->dummy.nbytes % 2)
184 if (op->data.dir != SPI_MEM_NO_DATA &&
185 op->dummy.buswidth == 8 && op->data.nbytes % 2)
188 return spi_mem_check_buswidth(slave, op);
190 EXPORT_SYMBOL_GPL(spi_mem_dtr_supports_op);
192 bool spi_mem_default_supports_op(struct spi_slave *slave,
193 const struct spi_mem_op *op)
195 if (op->cmd.dtr || op->addr.dtr || op->dummy.dtr || op->data.dtr)
198 if (op->cmd.nbytes != 1)
201 return spi_mem_check_buswidth(slave, op);
203 EXPORT_SYMBOL_GPL(spi_mem_default_supports_op);
206 * spi_mem_supports_op() - Check if a memory device and the controller it is
207 * connected to support a specific memory operation
208 * @slave: the SPI device
209 * @op: the memory operation to check
211 * Some controllers are only supporting Single or Dual IOs, others might only
212 * support specific opcodes, or it can even be that the controller and device
213 * both support Quad IOs but the hardware prevents you from using it because
214 * only 2 IO lines are connected.
216 * This function checks whether a specific operation is supported.
218 * Return: true if @op is supported, false otherwise.
220 bool spi_mem_supports_op(struct spi_slave *slave,
221 const struct spi_mem_op *op)
223 struct udevice *bus = slave->dev->parent;
224 struct dm_spi_ops *ops = spi_get_ops(bus);
226 if (ops->mem_ops && ops->mem_ops->supports_op)
227 return ops->mem_ops->supports_op(slave, op);
229 return spi_mem_default_supports_op(slave, op);
231 EXPORT_SYMBOL_GPL(spi_mem_supports_op);
234 * spi_mem_exec_op() - Execute a memory operation
235 * @slave: the SPI device
236 * @op: the memory operation to execute
238 * Executes a memory operation.
240 * This function first checks that @op is supported and then tries to execute
243 * Return: 0 in case of success, a negative error code otherwise.
245 int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
247 struct udevice *bus = slave->dev->parent;
248 struct dm_spi_ops *ops = spi_get_ops(bus);
249 unsigned int pos = 0;
250 const u8 *tx_buf = NULL;
257 if (!spi_mem_supports_op(slave, op))
260 ret = spi_claim_bus(slave);
264 if (ops->mem_ops && ops->mem_ops->exec_op) {
267 * Flush the message queue before executing our SPI memory
268 * operation to prevent preemption of regular SPI transfers.
270 spi_flush_queue(ctlr);
272 if (ctlr->auto_runtime_pm) {
273 ret = pm_runtime_get_sync(ctlr->dev.parent);
276 "Failed to power device: %d\n",
282 mutex_lock(&ctlr->bus_lock_mutex);
283 mutex_lock(&ctlr->io_mutex);
285 ret = ops->mem_ops->exec_op(slave, op);
288 mutex_unlock(&ctlr->io_mutex);
289 mutex_unlock(&ctlr->bus_lock_mutex);
291 if (ctlr->auto_runtime_pm)
292 pm_runtime_put(ctlr->dev.parent);
296 * Some controllers only optimize specific paths (typically the
297 * read path) and expect the core to use the regular SPI
298 * interface in other cases.
300 if (!ret || ret != -ENOTSUPP) {
301 spi_release_bus(slave);
307 tmpbufsize = op->cmd.nbytes + op->addr.nbytes + op->dummy.nbytes;
310 * Allocate a buffer to transmit the CMD, ADDR cycles with kmalloc() so
311 * we're guaranteed that this buffer is DMA-able, as required by the
314 tmpbuf = kzalloc(tmpbufsize, GFP_KERNEL | GFP_DMA);
318 spi_message_init(&msg);
320 tmpbuf[0] = op->cmd.opcode;
321 xfers[xferpos].tx_buf = tmpbuf;
322 xfers[xferpos].len = op->cmd.nbytes;
323 xfers[xferpos].tx_nbits = op->cmd.buswidth;
324 spi_message_add_tail(&xfers[xferpos], &msg);
328 if (op->addr.nbytes) {
331 for (i = 0; i < op->addr.nbytes; i++)
332 tmpbuf[i + 1] = op->addr.val >>
333 (8 * (op->addr.nbytes - i - 1));
335 xfers[xferpos].tx_buf = tmpbuf + 1;
336 xfers[xferpos].len = op->addr.nbytes;
337 xfers[xferpos].tx_nbits = op->addr.buswidth;
338 spi_message_add_tail(&xfers[xferpos], &msg);
340 totalxferlen += op->addr.nbytes;
343 if (op->dummy.nbytes) {
344 memset(tmpbuf + op->addr.nbytes + 1, 0xff, op->dummy.nbytes);
345 xfers[xferpos].tx_buf = tmpbuf + op->addr.nbytes + 1;
346 xfers[xferpos].len = op->dummy.nbytes;
347 xfers[xferpos].tx_nbits = op->dummy.buswidth;
348 spi_message_add_tail(&xfers[xferpos], &msg);
350 totalxferlen += op->dummy.nbytes;
353 if (op->data.nbytes) {
354 if (op->data.dir == SPI_MEM_DATA_IN) {
355 xfers[xferpos].rx_buf = op->data.buf.in;
356 xfers[xferpos].rx_nbits = op->data.buswidth;
358 xfers[xferpos].tx_buf = op->data.buf.out;
359 xfers[xferpos].tx_nbits = op->data.buswidth;
362 xfers[xferpos].len = op->data.nbytes;
363 spi_message_add_tail(&xfers[xferpos], &msg);
365 totalxferlen += op->data.nbytes;
368 ret = spi_sync(slave, &msg);
375 if (msg.actual_length != totalxferlen)
379 if (op->data.nbytes) {
380 if (op->data.dir == SPI_MEM_DATA_IN)
381 rx_buf = op->data.buf.in;
383 tx_buf = op->data.buf.out;
386 op_len = op->cmd.nbytes + op->addr.nbytes + op->dummy.nbytes;
389 * Avoid using malloc() here so that we can use this code in SPL where
390 * simple malloc may be used. That implementation does not allow free()
391 * so repeated calls to this code can exhaust the space.
393 * The value of op_len is small, since it does not include the actual
394 * data being sent, only the op-code and address. In fact, it should be
395 * possible to just use a small fixed value here instead of op_len.
399 op_buf[pos++] = op->cmd.opcode;
401 if (op->addr.nbytes) {
402 for (i = 0; i < op->addr.nbytes; i++)
403 op_buf[pos + i] = op->addr.val >>
404 (8 * (op->addr.nbytes - i - 1));
406 pos += op->addr.nbytes;
409 if (op->dummy.nbytes)
410 memset(op_buf + pos, 0xff, op->dummy.nbytes);
412 /* 1st transfer: opcode + address + dummy cycles */
413 flag = SPI_XFER_BEGIN;
414 /* Make sure to set END bit if no tx or rx data messages follow */
415 if (!tx_buf && !rx_buf)
416 flag |= SPI_XFER_END;
418 ret = spi_xfer(slave, op_len * 8, op_buf, NULL, flag);
422 /* 2nd transfer: rx or tx data path */
423 if (tx_buf || rx_buf) {
424 ret = spi_xfer(slave, op->data.nbytes * 8, tx_buf,
425 rx_buf, SPI_XFER_END);
430 spi_release_bus(slave);
432 for (i = 0; i < pos; i++)
433 debug("%02x ", op_buf[i]);
435 tx_buf || rx_buf ? op->data.nbytes : 0,
436 tx_buf || rx_buf ? (tx_buf ? "out" : "in") : "-");
437 for (i = 0; i < op->data.nbytes; i++)
438 debug("%02x ", tx_buf ? tx_buf[i] : rx_buf[i]);
439 debug("[ret %d]\n", ret);
443 #endif /* __UBOOT__ */
447 EXPORT_SYMBOL_GPL(spi_mem_exec_op);
450 * spi_mem_adjust_op_size() - Adjust the data size of a SPI mem operation to
451 * match controller limitations
452 * @slave: the SPI device
453 * @op: the operation to adjust
455 * Some controllers have FIFO limitations and must split a data transfer
456 * operation into multiple ones, others require a specific alignment for
457 * optimized accesses. This function allows SPI mem drivers to split a single
458 * operation into multiple sub-operations when required.
460 * Return: a negative error code if the controller can't properly adjust @op,
461 * 0 otherwise. Note that @op->data.nbytes will be updated if @op
462 * can't be handled in a single step.
464 int spi_mem_adjust_op_size(struct spi_slave *slave, struct spi_mem_op *op)
466 struct udevice *bus = slave->dev->parent;
467 struct dm_spi_ops *ops = spi_get_ops(bus);
469 if (ops->mem_ops && ops->mem_ops->adjust_op_size)
470 return ops->mem_ops->adjust_op_size(slave, op);
472 if (!ops->mem_ops || !ops->mem_ops->exec_op) {
475 len = op->cmd.nbytes + op->addr.nbytes + op->dummy.nbytes;
476 if (slave->max_write_size && len > slave->max_write_size)
479 if (op->data.dir == SPI_MEM_DATA_IN) {
480 if (slave->max_read_size)
481 op->data.nbytes = min(op->data.nbytes,
482 slave->max_read_size);
483 } else if (slave->max_write_size) {
484 op->data.nbytes = min(op->data.nbytes,
485 slave->max_write_size - len);
488 if (!op->data.nbytes)
494 EXPORT_SYMBOL_GPL(spi_mem_adjust_op_size);
496 static ssize_t spi_mem_no_dirmap_read(struct spi_mem_dirmap_desc *desc,
497 u64 offs, size_t len, void *buf)
499 struct spi_mem_op op = desc->info.op_tmpl;
502 op.addr.val = desc->info.offset + offs;
503 op.data.buf.in = buf;
504 op.data.nbytes = len;
505 ret = spi_mem_adjust_op_size(desc->slave, &op);
509 ret = spi_mem_exec_op(desc->slave, &op);
513 return op.data.nbytes;
516 static ssize_t spi_mem_no_dirmap_write(struct spi_mem_dirmap_desc *desc,
517 u64 offs, size_t len, const void *buf)
519 struct spi_mem_op op = desc->info.op_tmpl;
522 op.addr.val = desc->info.offset + offs;
523 op.data.buf.out = buf;
524 op.data.nbytes = len;
525 ret = spi_mem_adjust_op_size(desc->slave, &op);
529 ret = spi_mem_exec_op(desc->slave, &op);
533 return op.data.nbytes;
537 * spi_mem_dirmap_create() - Create a direct mapping descriptor
538 * @mem: SPI mem device this direct mapping should be created for
539 * @info: direct mapping information
541 * This function is creating a direct mapping descriptor which can then be used
542 * to access the memory using spi_mem_dirmap_read() or spi_mem_dirmap_write().
543 * If the SPI controller driver does not support direct mapping, this function
544 * falls back to an implementation using spi_mem_exec_op(), so that the caller
545 * doesn't have to bother implementing a fallback on his own.
547 * Return: a valid pointer in case of success, and ERR_PTR() otherwise.
549 struct spi_mem_dirmap_desc *
550 spi_mem_dirmap_create(struct spi_slave *slave,
551 const struct spi_mem_dirmap_info *info)
553 struct udevice *bus = slave->dev->parent;
554 struct dm_spi_ops *ops = spi_get_ops(bus);
555 struct spi_mem_dirmap_desc *desc;
556 int ret = -EOPNOTSUPP;
558 /* Make sure the number of address cycles is between 1 and 8 bytes. */
559 if (!info->op_tmpl.addr.nbytes || info->op_tmpl.addr.nbytes > 8)
560 return ERR_PTR(-EINVAL);
562 /* data.dir should either be SPI_MEM_DATA_IN or SPI_MEM_DATA_OUT. */
563 if (info->op_tmpl.data.dir == SPI_MEM_NO_DATA)
564 return ERR_PTR(-EINVAL);
566 desc = kzalloc(sizeof(*desc), GFP_KERNEL);
568 return ERR_PTR(-ENOMEM);
572 if (ops->mem_ops && ops->mem_ops->dirmap_create)
573 ret = ops->mem_ops->dirmap_create(desc);
576 desc->nodirmap = true;
577 if (!spi_mem_supports_op(desc->slave, &desc->info.op_tmpl))
590 EXPORT_SYMBOL_GPL(spi_mem_dirmap_create);
593 * spi_mem_dirmap_destroy() - Destroy a direct mapping descriptor
594 * @desc: the direct mapping descriptor to destroy
596 * This function destroys a direct mapping descriptor previously created by
597 * spi_mem_dirmap_create().
599 void spi_mem_dirmap_destroy(struct spi_mem_dirmap_desc *desc)
601 struct udevice *bus = desc->slave->dev->parent;
602 struct dm_spi_ops *ops = spi_get_ops(bus);
604 if (!desc->nodirmap && ops->mem_ops && ops->mem_ops->dirmap_destroy)
605 ops->mem_ops->dirmap_destroy(desc);
609 EXPORT_SYMBOL_GPL(spi_mem_dirmap_destroy);
612 static void devm_spi_mem_dirmap_release(struct udevice *dev, void *res)
614 struct spi_mem_dirmap_desc *desc = *(struct spi_mem_dirmap_desc **)res;
616 spi_mem_dirmap_destroy(desc);
620 * devm_spi_mem_dirmap_create() - Create a direct mapping descriptor and attach
622 * @dev: device the dirmap desc will be attached to
623 * @mem: SPI mem device this direct mapping should be created for
624 * @info: direct mapping information
626 * devm_ variant of the spi_mem_dirmap_create() function. See
627 * spi_mem_dirmap_create() for more details.
629 * Return: a valid pointer in case of success, and ERR_PTR() otherwise.
631 struct spi_mem_dirmap_desc *
632 devm_spi_mem_dirmap_create(struct udevice *dev, struct spi_slave *slave,
633 const struct spi_mem_dirmap_info *info)
635 struct spi_mem_dirmap_desc **ptr, *desc;
637 ptr = devres_alloc(devm_spi_mem_dirmap_release, sizeof(*ptr),
640 return ERR_PTR(-ENOMEM);
642 desc = spi_mem_dirmap_create(slave, info);
647 devres_add(dev, ptr);
652 EXPORT_SYMBOL_GPL(devm_spi_mem_dirmap_create);
654 static int devm_spi_mem_dirmap_match(struct udevice *dev, void *res, void *data)
656 struct spi_mem_dirmap_desc **ptr = res;
658 if (WARN_ON(!ptr || !*ptr))
665 * devm_spi_mem_dirmap_destroy() - Destroy a direct mapping descriptor attached
667 * @dev: device the dirmap desc is attached to
668 * @desc: the direct mapping descriptor to destroy
670 * devm_ variant of the spi_mem_dirmap_destroy() function. See
671 * spi_mem_dirmap_destroy() for more details.
673 void devm_spi_mem_dirmap_destroy(struct udevice *dev,
674 struct spi_mem_dirmap_desc *desc)
676 devres_release(dev, devm_spi_mem_dirmap_release,
677 devm_spi_mem_dirmap_match, desc);
679 EXPORT_SYMBOL_GPL(devm_spi_mem_dirmap_destroy);
680 #endif /* __UBOOT__ */
683 * spi_mem_dirmap_read() - Read data through a direct mapping
684 * @desc: direct mapping descriptor
685 * @offs: offset to start reading from. Note that this is not an absolute
686 * offset, but the offset within the direct mapping which already has
688 * @len: length in bytes
689 * @buf: destination buffer. This buffer must be DMA-able
691 * This function reads data from a memory device using a direct mapping
692 * previously instantiated with spi_mem_dirmap_create().
694 * Return: the amount of data read from the memory device or a negative error
695 * code. Note that the returned size might be smaller than @len, and the caller
696 * is responsible for calling spi_mem_dirmap_read() again when that happens.
698 ssize_t spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc,
699 u64 offs, size_t len, void *buf)
701 struct udevice *bus = desc->slave->dev->parent;
702 struct dm_spi_ops *ops = spi_get_ops(bus);
705 if (desc->info.op_tmpl.data.dir != SPI_MEM_DATA_IN)
712 ret = spi_mem_no_dirmap_read(desc, offs, len, buf);
713 else if (ops->mem_ops && ops->mem_ops->dirmap_read)
714 ret = ops->mem_ops->dirmap_read(desc, offs, len, buf);
720 EXPORT_SYMBOL_GPL(spi_mem_dirmap_read);
723 * spi_mem_dirmap_write() - Write data through a direct mapping
724 * @desc: direct mapping descriptor
725 * @offs: offset to start writing from. Note that this is not an absolute
726 * offset, but the offset within the direct mapping which already has
728 * @len: length in bytes
729 * @buf: source buffer. This buffer must be DMA-able
731 * This function writes data to a memory device using a direct mapping
732 * previously instantiated with spi_mem_dirmap_create().
734 * Return: the amount of data written to the memory device or a negative error
735 * code. Note that the returned size might be smaller than @len, and the caller
736 * is responsible for calling spi_mem_dirmap_write() again when that happens.
738 ssize_t spi_mem_dirmap_write(struct spi_mem_dirmap_desc *desc,
739 u64 offs, size_t len, const void *buf)
741 struct udevice *bus = desc->slave->dev->parent;
742 struct dm_spi_ops *ops = spi_get_ops(bus);
745 if (desc->info.op_tmpl.data.dir != SPI_MEM_DATA_OUT)
752 ret = spi_mem_no_dirmap_write(desc, offs, len, buf);
753 else if (ops->mem_ops && ops->mem_ops->dirmap_write)
754 ret = ops->mem_ops->dirmap_write(desc, offs, len, buf);
760 EXPORT_SYMBOL_GPL(spi_mem_dirmap_write);
763 static inline struct spi_mem_driver *to_spi_mem_drv(struct device_driver *drv)
765 return container_of(drv, struct spi_mem_driver, spidrv.driver);
768 static int spi_mem_probe(struct spi_device *spi)
770 struct spi_mem_driver *memdrv = to_spi_mem_drv(spi->dev.driver);
773 mem = devm_kzalloc(&spi->dev, sizeof(*mem), GFP_KERNEL);
778 spi_set_drvdata(spi, mem);
780 return memdrv->probe(mem);
783 static int spi_mem_remove(struct spi_device *spi)
785 struct spi_mem_driver *memdrv = to_spi_mem_drv(spi->dev.driver);
786 struct spi_mem *mem = spi_get_drvdata(spi);
789 return memdrv->remove(mem);
794 static void spi_mem_shutdown(struct spi_device *spi)
796 struct spi_mem_driver *memdrv = to_spi_mem_drv(spi->dev.driver);
797 struct spi_mem *mem = spi_get_drvdata(spi);
799 if (memdrv->shutdown)
800 memdrv->shutdown(mem);
804 * spi_mem_driver_register_with_owner() - Register a SPI memory driver
805 * @memdrv: the SPI memory driver to register
806 * @owner: the owner of this driver
808 * Registers a SPI memory driver.
810 * Return: 0 in case of success, a negative error core otherwise.
813 int spi_mem_driver_register_with_owner(struct spi_mem_driver *memdrv,
814 struct module *owner)
816 memdrv->spidrv.probe = spi_mem_probe;
817 memdrv->spidrv.remove = spi_mem_remove;
818 memdrv->spidrv.shutdown = spi_mem_shutdown;
820 return __spi_register_driver(owner, &memdrv->spidrv);
822 EXPORT_SYMBOL_GPL(spi_mem_driver_register_with_owner);
825 * spi_mem_driver_unregister_with_owner() - Unregister a SPI memory driver
826 * @memdrv: the SPI memory driver to unregister
828 * Unregisters a SPI memory driver.
830 void spi_mem_driver_unregister(struct spi_mem_driver *memdrv)
832 spi_unregister_driver(&memdrv->spidrv);
834 EXPORT_SYMBOL_GPL(spi_mem_driver_unregister);
835 #endif /* __UBOOT__ */