ar71xx: build firmware image for the WNDR3700 v4 board
[openwrt/staging/wigyori.git] / package / boot / uboot-lantiq / patches / 0017-sf-add-init-function.patch
1 From aa9d5d64ca6441cb24e22dc3c1f707da62da2887 Mon Sep 17 00:00:00 2001
2 From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
3 Date: Tue, 6 Nov 2012 19:35:17 +0100
4 Subject: sf: add init function
5
6 Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
7
8 --- a/drivers/mtd/spi/spi_flash.c
9 +++ b/drivers/mtd/spi/spi_flash.c
10 @@ -482,3 +482,36 @@ void spi_flash_free(struct spi_flash *fl
11 spi_flash_free_spl(flash);
12 free(flash);
13 }
14 +
15 +#ifdef CONFIG_SPI_FLASH_MTD
16 +static int spi_flash_mtd_register(void)
17 +{
18 + struct spi_flash *flash;
19 + int err;
20 +
21 + flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
22 + CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
23 + if (!flash)
24 + return -1;
25 +
26 + err = spi_flash_mtd_init(flash);
27 + if (err)
28 + spi_flash_free(flash);
29 +
30 + return err;
31 +}
32 +#else
33 +static int spi_flash_mtd_register(void)
34 +{
35 + return 0;
36 +}
37 +#endif
38 +
39 +int spi_flash_init(void)
40 +{
41 + int err;
42 +
43 + err = spi_flash_mtd_register();
44 +
45 + return err;
46 +}
47 --- a/include/spi_flash.h
48 +++ b/include/spi_flash.h
49 @@ -51,6 +51,8 @@ struct spi_flash {
50 #endif
51 };
52
53 +int spi_flash_init(void);
54 +
55 struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
56 unsigned int max_hz, unsigned int spi_mode);
57 void spi_flash_free(struct spi_flash *flash);