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 diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
9 index 2bba10c..380aa09 100644
10 --- a/drivers/mtd/spi/sf_probe.c
11 +++ b/drivers/mtd/spi/sf_probe.c
12 @@ -365,3 +365,58 @@ void spi_flash_free(struct spi_flash *flash)
13 spi_free_slave(flash->spi);
17 +#ifdef CONFIG_SPI_SPL_SIMPLE
18 +int spl_spi_flash_probe(struct spi_flash *flash)
20 + struct spi_slave *spi;
24 + /* Setup spi_slave */
25 + spi = spi_setup_slave(CONFIG_SPL_SPI_BUS, CONFIG_SPL_SPI_CS,
26 + CONFIG_SPL_SPI_MAX_HZ, CONFIG_SPL_SPI_MODE);
28 + debug("SF: Failed to set up slave\n");
33 + ret = spi_claim_bus(spi);
35 + debug("SF: Failed to claim SPI bus: %d\n", ret);
39 + /* Read the ID codes */
40 + ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
42 + debug("SF: Failed to get idcodes\n");
46 + /* Validate params from spi_flash_params table */
48 + ret = spi_flash_validate_params(flash, idcode);
52 + /* Release spi bus */
53 + spi_release_bus(spi);
58 + spi_release_bus(spi);
60 + spi_free_slave(spi);
66 +void spl_spi_flash_free(struct spi_flash *flash)
68 + spi_free_slave(flash->spi);
71 diff --git a/include/spi_flash.h b/include/spi_flash.h
72 index 25ca8f1..411dd1b 100644
73 --- a/include/spi_flash.h
74 +++ b/include/spi_flash.h
75 @@ -69,6 +69,9 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
76 unsigned int max_hz, unsigned int spi_mode);
77 void spi_flash_free(struct spi_flash *flash);
79 +int spl_spi_flash_probe(struct spi_flash *flash);
80 +void spl_spi_flash_free(struct spi_flash *flash);
82 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
83 size_t len, void *buf)