1 From da11da943487e2f724f25d409bcaa1f099637c0b Mon Sep 17 00:00:00 2001
2 From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
3 Date: Sun, 13 Oct 2013 14:56:45 +0200
4 Subject: sf: add slim probe funtions for SPL
6 Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
8 --- a/drivers/mtd/spi/sf_probe.c
9 +++ b/drivers/mtd/spi/sf_probe.c
10 @@ -365,3 +365,58 @@ void spi_flash_free(struct spi_flash *fl
11 spi_free_slave(flash->spi);
15 +#ifdef CONFIG_SPI_SPL_SIMPLE
16 +int spl_spi_flash_probe(struct spi_flash *flash)
18 + struct spi_slave *spi;
22 + /* Setup spi_slave */
23 + spi = spi_setup_slave(CONFIG_SPL_SPI_BUS, CONFIG_SPL_SPI_CS,
24 + CONFIG_SPL_SPI_MAX_HZ, CONFIG_SPL_SPI_MODE);
26 + debug("SF: Failed to set up slave\n");
31 + ret = spi_claim_bus(spi);
33 + debug("SF: Failed to claim SPI bus: %d\n", ret);
37 + /* Read the ID codes */
38 + ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
40 + debug("SF: Failed to get idcodes\n");
44 + /* Validate params from spi_flash_params table */
46 + ret = spi_flash_validate_params(flash, idcode);
50 + /* Release spi bus */
51 + spi_release_bus(spi);
56 + spi_release_bus(spi);
58 + spi_free_slave(spi);
64 +void spl_spi_flash_free(struct spi_flash *flash)
66 + spi_free_slave(flash->spi);
69 --- a/include/spi_flash.h
70 +++ b/include/spi_flash.h
71 @@ -69,6 +69,9 @@ struct spi_flash *spi_flash_probe(unsign
72 unsigned int max_hz, unsigned int spi_mode);
73 void spi_flash_free(struct spi_flash *flash);
75 +int spl_spi_flash_probe(struct spi_flash *flash);
76 +void spl_spi_flash_free(struct spi_flash *flash);
78 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
79 size_t len, void *buf)