uboot-lantiq: update to v2013.10
[openwrt/svn-archive/archive.git] / package / boot / uboot-lantiq / patches / 0004-sf-add-slim-probe-funtions-for-SPL.patch
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
5
6 Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
7
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);
14 free(flash);
15 }
16 +
17 +#ifdef CONFIG_SPI_SPL_SIMPLE
18 +int spl_spi_flash_probe(struct spi_flash *flash)
19 +{
20 + struct spi_slave *spi;
21 + u8 idcode[5];
22 + int ret;
23 +
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);
27 + if (!spi) {
28 + debug("SF: Failed to set up slave\n");
29 + return -1;
30 + }
31 +
32 + /* Claim spi bus */
33 + ret = spi_claim_bus(spi);
34 + if (ret) {
35 + debug("SF: Failed to claim SPI bus: %d\n", ret);
36 + goto err_claim_bus;
37 + }
38 +
39 + /* Read the ID codes */
40 + ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
41 + if (ret) {
42 + debug("SF: Failed to get idcodes\n");
43 + goto err_read_id;
44 + }
45 +
46 + /* Validate params from spi_flash_params table */
47 + flash->spi = spi;
48 + ret = spi_flash_validate_params(flash, idcode);
49 + if (ret)
50 + goto err_read_id;
51 +
52 + /* Release spi bus */
53 + spi_release_bus(spi);
54 +
55 + return 0;
56 +
57 +err_read_id:
58 + spi_release_bus(spi);
59 +err_claim_bus:
60 + spi_free_slave(spi);
61 + flash->spi = NULL;
62 +
63 + return ret;
64 +}
65 +
66 +void spl_spi_flash_free(struct spi_flash *flash)
67 +{
68 + spi_free_slave(flash->spi);
69 +}
70 +#endif
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);
78
79 +int spl_spi_flash_probe(struct spi_flash *flash);
80 +void spl_spi_flash_free(struct spi_flash *flash);
81 +
82 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
83 size_t len, void *buf)
84 {
85 --
86 1.8.3.2
87