aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neil@brown.name>2018-03-20 23:02:10 -0400
committerJames Hogan <jhogan@kernel.org>2018-03-21 20:06:30 -0400
commita63d706ea719190a79a6c769e898f70680044d3e (patch)
tree8a45b4e92f371322614cac40d06308b8c22ff8e2
parent891731f6a5dbe508d12443175a7e166a2fba616a (diff)
MIPS: ralink: Fix booting on MT7621
Since commit 3af5a67c86a3 ("MIPS: Fix early CM probing") the MT7621 has not been able to boot. This commit caused mips_cm_probe() to be called before mt7621.c::proc_soc_init(). prom_soc_init() has a comment explaining that mips_cm_probe() "wipes out the bootloader config" and means that configuration registers are no longer available. It has some code to re-enable this config. Before this re-enable code is run, the sysc register cannot be read, so when SYSC_REG_CHIP_NAME0 is read, a garbage value is returned and panic() is called. If we move the config-repair code to the top of prom_soc_init(), the registers can be read and boot can proceed. Very occasionally, the first register read after the reconfiguration returns garbage, so add a call to __sync(). Fixes: 3af5a67c86a3 ("MIPS: Fix early CM probing") Signed-off-by: NeilBrown <neil@brown.name> Reviewed-by: Matt Redfearn <matt.redfearn@mips.com> Cc: John Crispin <john@phrozen.org> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: linux-mips@linux-mips.org Cc: <stable@vger.kernel.org> # 4.5+ Patchwork: https://patchwork.linux-mips.org/patch/18859/ Signed-off-by: James Hogan <jhogan@kernel.org>
-rw-r--r--arch/mips/ralink/mt7621.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/arch/mips/ralink/mt7621.c b/arch/mips/ralink/mt7621.c
index 1b274742077d..d2718de60b9b 100644
--- a/arch/mips/ralink/mt7621.c
+++ b/arch/mips/ralink/mt7621.c
@@ -170,6 +170,28 @@ void prom_soc_init(struct ralink_soc_info *soc_info)
170 u32 n1; 170 u32 n1;
171 u32 rev; 171 u32 rev;
172 172
173 /* Early detection of CMP support */
174 mips_cm_probe();
175 mips_cpc_probe();
176
177 if (mips_cps_numiocu(0)) {
178 /*
179 * mips_cm_probe() wipes out bootloader
180 * config for CM regions and we have to configure them
181 * again. This SoC cannot talk to pamlbus devices
182 * witout proper iocu region set up.
183 *
184 * FIXME: it would be better to do this with values
185 * from DT, but we need this very early because
186 * without this we cannot talk to pretty much anything
187 * including serial.
188 */
189 write_gcr_reg0_base(MT7621_PALMBUS_BASE);
190 write_gcr_reg0_mask(~MT7621_PALMBUS_SIZE |
191 CM_GCR_REGn_MASK_CMTGT_IOCU0);
192 __sync();
193 }
194
173 n0 = __raw_readl(sysc + SYSC_REG_CHIP_NAME0); 195 n0 = __raw_readl(sysc + SYSC_REG_CHIP_NAME0);
174 n1 = __raw_readl(sysc + SYSC_REG_CHIP_NAME1); 196 n1 = __raw_readl(sysc + SYSC_REG_CHIP_NAME1);
175 197
@@ -194,26 +216,6 @@ void prom_soc_init(struct ralink_soc_info *soc_info)
194 216
195 rt2880_pinmux_data = mt7621_pinmux_data; 217 rt2880_pinmux_data = mt7621_pinmux_data;
196 218
197 /* Early detection of CMP support */
198 mips_cm_probe();
199 mips_cpc_probe();
200
201 if (mips_cps_numiocu(0)) {
202 /*
203 * mips_cm_probe() wipes out bootloader
204 * config for CM regions and we have to configure them
205 * again. This SoC cannot talk to pamlbus devices
206 * witout proper iocu region set up.
207 *
208 * FIXME: it would be better to do this with values
209 * from DT, but we need this very early because
210 * without this we cannot talk to pretty much anything
211 * including serial.
212 */
213 write_gcr_reg0_base(MT7621_PALMBUS_BASE);
214 write_gcr_reg0_mask(~MT7621_PALMBUS_SIZE |
215 CM_GCR_REGn_MASK_CMTGT_IOCU0);
216 }
217 219
218 if (!register_cps_smp_ops()) 220 if (!register_cps_smp_ops())
219 return; 221 return;