gitignore: ignore patches in OpenWrt root directory
[openwrt/openwrt.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 --- 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);
12 free(flash);
13 }
14 +
15 +#ifdef CONFIG_SPI_SPL_SIMPLE
16 +int spl_spi_flash_probe(struct spi_flash *flash)
17 +{
18 + struct spi_slave *spi;
19 + u8 idcode[5];
20 + int ret;
21 +
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);
25 + if (!spi) {
26 + debug("SF: Failed to set up slave\n");
27 + return -1;
28 + }
29 +
30 + /* Claim spi bus */
31 + ret = spi_claim_bus(spi);
32 + if (ret) {
33 + debug("SF: Failed to claim SPI bus: %d\n", ret);
34 + goto err_claim_bus;
35 + }
36 +
37 + /* Read the ID codes */
38 + ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
39 + if (ret) {
40 + debug("SF: Failed to get idcodes\n");
41 + goto err_read_id;
42 + }
43 +
44 + /* Validate params from spi_flash_params table */
45 + flash->spi = spi;
46 + ret = spi_flash_validate_params(flash, idcode);
47 + if (ret)
48 + goto err_read_id;
49 +
50 + /* Release spi bus */
51 + spi_release_bus(spi);
52 +
53 + return 0;
54 +
55 +err_read_id:
56 + spi_release_bus(spi);
57 +err_claim_bus:
58 + spi_free_slave(spi);
59 + flash->spi = NULL;
60 +
61 + return ret;
62 +}
63 +
64 +void spl_spi_flash_free(struct spi_flash *flash)
65 +{
66 + spi_free_slave(flash->spi);
67 +}
68 +#endif
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);
74
75 +int spl_spi_flash_probe(struct spi_flash *flash);
76 +void spl_spi_flash_free(struct spi_flash *flash);
77 +
78 static inline int spi_flash_read(struct spi_flash *flash, u32 offset,
79 size_t len, void *buf)
80 {