kernel: update 3.18 to 3.18.14
[openwrt/openwrt.git] / target / linux / brcm47xx / patches-3.18 / 030-01-MIPS-BCM47XX-Get-rid-of-calls-to-KSEG1ADDR.patch
1 From 8d602dd0f984e8488ab891344ebdb6e1f3128c4a Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Wed, 3 Sep 2014 22:51:06 +0200
4 Subject: [PATCH 154/158] MIPS: BCM47XX: Get rid of calls to KSEG1ADDR
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 We should be using ioremap_nocache helper which handles remaps in a
10 smarter way.
11
12 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
13 Cc: linux-mips@linux-mips.org
14 Cc: Hauke Mehrtens <hauke@hauke-m.de>
15 Patchwork: http://patchwork.linux-mips.org/patch/7611/
16 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
17 ---
18 arch/mips/bcm47xx/nvram.c | 44 ++++++++++++++++++++++++++++++++------------
19 1 file changed, 32 insertions(+), 12 deletions(-)
20
21 --- a/arch/mips/bcm47xx/nvram.c
22 +++ b/arch/mips/bcm47xx/nvram.c
23 @@ -23,13 +23,13 @@
24 static char nvram_buf[NVRAM_SPACE];
25 static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000};
26
27 -static u32 find_nvram_size(u32 end)
28 +static u32 find_nvram_size(void __iomem *end)
29 {
30 - struct nvram_header *header;
31 + struct nvram_header __iomem *header;
32 int i;
33
34 for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
35 - header = (struct nvram_header *)KSEG1ADDR(end - nvram_sizes[i]);
36 + header = (struct nvram_header *)(end - nvram_sizes[i]);
37 if (header->magic == NVRAM_HEADER)
38 return nvram_sizes[i];
39 }
40 @@ -38,35 +38,39 @@ static u32 find_nvram_size(u32 end)
41 }
42
43 /* Probe for NVRAM header */
44 -static int nvram_find_and_copy(u32 base, u32 lim)
45 +static int nvram_find_and_copy(void __iomem *iobase, u32 lim)
46 {
47 - struct nvram_header *header;
48 + struct nvram_header __iomem *header;
49 int i;
50 u32 off;
51 u32 *src, *dst;
52 u32 size;
53
54 + if (nvram_buf[0]) {
55 + pr_warn("nvram already initialized\n");
56 + return -EEXIST;
57 + }
58 +
59 /* TODO: when nvram is on nand flash check for bad blocks first. */
60 off = FLASH_MIN;
61 while (off <= lim) {
62 /* Windowed flash access */
63 - size = find_nvram_size(base + off);
64 + size = find_nvram_size(iobase + off);
65 if (size) {
66 - header = (struct nvram_header *)KSEG1ADDR(base + off -
67 - size);
68 + header = (struct nvram_header *)(iobase + off - size);
69 goto found;
70 }
71 off <<= 1;
72 }
73
74 /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
75 - header = (struct nvram_header *) KSEG1ADDR(base + 4096);
76 + header = (struct nvram_header *)(iobase + 4096);
77 if (header->magic == NVRAM_HEADER) {
78 size = NVRAM_SPACE;
79 goto found;
80 }
81
82 - header = (struct nvram_header *) KSEG1ADDR(base + 1024);
83 + header = (struct nvram_header *)(iobase + 1024);
84 if (header->magic == NVRAM_HEADER) {
85 size = NVRAM_SPACE;
86 goto found;
87 @@ -94,6 +98,22 @@ found:
88 return 0;
89 }
90
91 +static int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
92 +{
93 + void __iomem *iobase;
94 + int err;
95 +
96 + iobase = ioremap_nocache(base, lim);
97 + if (!iobase)
98 + return -ENOMEM;
99 +
100 + err = nvram_find_and_copy(iobase, lim);
101 +
102 + iounmap(iobase);
103 +
104 + return err;
105 +}
106 +
107 #ifdef CONFIG_BCM47XX_SSB
108 static int nvram_init_ssb(void)
109 {
110 @@ -109,7 +129,7 @@ static int nvram_init_ssb(void)
111 return -ENXIO;
112 }
113
114 - return nvram_find_and_copy(base, lim);
115 + return bcm47xx_nvram_init_from_mem(base, lim);
116 }
117 #endif
118
119 @@ -139,7 +159,7 @@ static int nvram_init_bcma(void)
120 return -ENXIO;
121 }
122
123 - return nvram_find_and_copy(base, lim);
124 + return bcm47xx_nvram_init_from_mem(base, lim);
125 }
126 #endif
127