brcm47xx: group MIPS BCM47XX backported patches by source kernel
[openwrt/svn-archive/archive.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 diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
22 index 2bed73a..e07976b 100644
23 --- a/arch/mips/bcm47xx/nvram.c
24 +++ b/arch/mips/bcm47xx/nvram.c
25 @@ -23,13 +23,13 @@
26 static char nvram_buf[NVRAM_SPACE];
27 static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000};
28
29 -static u32 find_nvram_size(u32 end)
30 +static u32 find_nvram_size(void __iomem *end)
31 {
32 - struct nvram_header *header;
33 + struct nvram_header __iomem *header;
34 int i;
35
36 for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
37 - header = (struct nvram_header *)KSEG1ADDR(end - nvram_sizes[i]);
38 + header = (struct nvram_header *)(end - nvram_sizes[i]);
39 if (header->magic == NVRAM_HEADER)
40 return nvram_sizes[i];
41 }
42 @@ -38,35 +38,39 @@ static u32 find_nvram_size(u32 end)
43 }
44
45 /* Probe for NVRAM header */
46 -static int nvram_find_and_copy(u32 base, u32 lim)
47 +static int nvram_find_and_copy(void __iomem *iobase, u32 lim)
48 {
49 - struct nvram_header *header;
50 + struct nvram_header __iomem *header;
51 int i;
52 u32 off;
53 u32 *src, *dst;
54 u32 size;
55
56 + if (nvram_buf[0]) {
57 + pr_warn("nvram already initialized\n");
58 + return -EEXIST;
59 + }
60 +
61 /* TODO: when nvram is on nand flash check for bad blocks first. */
62 off = FLASH_MIN;
63 while (off <= lim) {
64 /* Windowed flash access */
65 - size = find_nvram_size(base + off);
66 + size = find_nvram_size(iobase + off);
67 if (size) {
68 - header = (struct nvram_header *)KSEG1ADDR(base + off -
69 - size);
70 + header = (struct nvram_header *)(iobase + off - size);
71 goto found;
72 }
73 off <<= 1;
74 }
75
76 /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
77 - header = (struct nvram_header *) KSEG1ADDR(base + 4096);
78 + header = (struct nvram_header *)(iobase + 4096);
79 if (header->magic == NVRAM_HEADER) {
80 size = NVRAM_SPACE;
81 goto found;
82 }
83
84 - header = (struct nvram_header *) KSEG1ADDR(base + 1024);
85 + header = (struct nvram_header *)(iobase + 1024);
86 if (header->magic == NVRAM_HEADER) {
87 size = NVRAM_SPACE;
88 goto found;
89 @@ -94,6 +98,22 @@ found:
90 return 0;
91 }
92
93 +static int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
94 +{
95 + void __iomem *iobase;
96 + int err;
97 +
98 + iobase = ioremap_nocache(base, lim);
99 + if (!iobase)
100 + return -ENOMEM;
101 +
102 + err = nvram_find_and_copy(iobase, lim);
103 +
104 + iounmap(iobase);
105 +
106 + return err;
107 +}
108 +
109 #ifdef CONFIG_BCM47XX_SSB
110 static int nvram_init_ssb(void)
111 {
112 @@ -109,7 +129,7 @@ static int nvram_init_ssb(void)
113 return -ENXIO;
114 }
115
116 - return nvram_find_and_copy(base, lim);
117 + return bcm47xx_nvram_init_from_mem(base, lim);
118 }
119 #endif
120
121 @@ -139,7 +159,7 @@ static int nvram_init_bcma(void)
122 return -ENXIO;
123 }
124
125 - return nvram_find_and_copy(base, lim);
126 + return bcm47xx_nvram_init_from_mem(base, lim);
127 }
128 #endif
129
130 --
131 1.8.4.5
132