aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-mvebu/board-v7.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-mvebu/board-v7.c')
-rw-r--r--arch/arm/mach-mvebu/board-v7.c73
1 files changed, 7 insertions, 66 deletions
diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c
index bc52231dfd1c..89a139ed7d5b 100644
--- a/arch/arm/mach-mvebu/board-v7.c
+++ b/arch/arm/mach-mvebu/board-v7.c
@@ -174,76 +174,12 @@ static void __init i2c_quirk(void)
174 return; 174 return;
175} 175}
176 176
177#define A375_Z1_THERMAL_FIXUP_OFFSET 0xc
178
179static void __init thermal_quirk(void)
180{
181 struct device_node *np;
182 u32 dev, rev;
183 int res;
184
185 /*
186 * The early SoC Z1 revision needs a quirk to be applied in order
187 * for the thermal controller to work properly. This quirk breaks
188 * the thermal support if applied on a SoC that doesn't need it,
189 * so we enforce the SoC revision to be known.
190 */
191 res = mvebu_get_soc_id(&dev, &rev);
192 if (res < 0 || (res == 0 && rev > ARMADA_375_Z1_REV))
193 return;
194
195 for_each_compatible_node(np, NULL, "marvell,armada375-thermal") {
196 struct property *prop;
197 __be32 newval, *newprop, *oldprop;
198 int len;
199
200 /*
201 * The register offset is at a wrong location. This quirk
202 * creates a new reg property as a clone of the previous
203 * one and corrects the offset.
204 */
205 oldprop = (__be32 *)of_get_property(np, "reg", &len);
206 if (!oldprop)
207 continue;
208
209 /* Create a duplicate of the 'reg' property */
210 prop = kzalloc(sizeof(*prop), GFP_KERNEL);
211 prop->length = len;
212 prop->name = kstrdup("reg", GFP_KERNEL);
213 prop->value = kzalloc(len, GFP_KERNEL);
214 memcpy(prop->value, oldprop, len);
215
216 /* Fixup the register offset of the second entry */
217 oldprop += 2;
218 newprop = (__be32 *)prop->value + 2;
219 newval = cpu_to_be32(be32_to_cpu(*oldprop) -
220 A375_Z1_THERMAL_FIXUP_OFFSET);
221 *newprop = newval;
222 of_update_property(np, prop);
223
224 /*
225 * The thermal controller needs some quirk too, so let's change
226 * the compatible string to reflect this and allow the driver
227 * the take the necessary action.
228 */
229 prop = kzalloc(sizeof(*prop), GFP_KERNEL);
230 prop->name = kstrdup("compatible", GFP_KERNEL);
231 prop->length = sizeof("marvell,armada375-z1-thermal");
232 prop->value = kstrdup("marvell,armada375-z1-thermal",
233 GFP_KERNEL);
234 of_update_property(np, prop);
235 }
236 return;
237}
238
239static void __init mvebu_dt_init(void) 177static void __init mvebu_dt_init(void)
240{ 178{
241 if (of_machine_is_compatible("plathome,openblocks-ax3-4")) 179 if (of_machine_is_compatible("marvell,armadaxp"))
242 i2c_quirk(); 180 i2c_quirk();
243 if (of_machine_is_compatible("marvell,a375-db")) { 181 if (of_machine_is_compatible("marvell,a375-db"))
244 external_abort_quirk(); 182 external_abort_quirk();
245 thermal_quirk();
246 }
247 183
248 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 184 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
249} 185}
@@ -256,6 +192,11 @@ static const char * const armada_370_xp_dt_compat[] = {
256DT_MACHINE_START(ARMADA_370_XP_DT, "Marvell Armada 370/XP (Device Tree)") 192DT_MACHINE_START(ARMADA_370_XP_DT, "Marvell Armada 370/XP (Device Tree)")
257 .l2c_aux_val = 0, 193 .l2c_aux_val = 0,
258 .l2c_aux_mask = ~0, 194 .l2c_aux_mask = ~0,
195/*
196 * The following field (.smp) is still needed to ensure backward
197 * compatibility with old Device Trees that were not specifying the
198 * cpus enable-method property.
199 */
259 .smp = smp_ops(armada_xp_smp_ops), 200 .smp = smp_ops(armada_xp_smp_ops),
260 .init_machine = mvebu_dt_init, 201 .init_machine = mvebu_dt_init,
261 .init_irq = mvebu_init_irq, 202 .init_irq = mvebu_init_irq,