2 * Copyright (c) 2014 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
10 #include <spi_flash.h>
11 #include <dm/device-internal.h>
12 #include "sf_internal.h"
15 * TODO(sjg@chromium.org): This is an old-style function. We should remove
16 * it when all SPI flash drivers use dm
18 struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
19 unsigned int max_hz, unsigned int spi_mode)
23 if (spi_flash_probe_bus_cs(bus, cs, max_hz, spi_mode, &dev))
26 return dev->uclass_priv;
29 void spi_flash_free(struct spi_flash *flash)
31 spi_flash_remove(flash->spi->dev);
34 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
35 unsigned int max_hz, unsigned int spi_mode,
36 struct udevice **devp)
38 struct spi_slave *slave;
43 snprintf(name, sizeof(name), "%d:%d", busnum, cs);
45 ret = spi_get_bus_and_cs(busnum, cs, max_hz, spi_mode,
46 "spi_flash_std", str, &bus, &slave);
54 int spi_flash_remove(struct udevice *dev)
56 return device_remove(dev);
59 UCLASS_DRIVER(spi_flash) = {
60 .id = UCLASS_SPI_FLASH,
62 .per_device_auto_alloc_size = sizeof(struct spi_flash),