xref: /freebsd/sys/arm/freescale/imx/imx6_machdep.c (revision fdafd315ad0d0f28a11b9fb4476a9ab059c62b92)
1034e9ed6SIan Lepore /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3af3dc4a7SPedro F. Giffuni  *
4034e9ed6SIan Lepore  * Copyright (c) 2013 Ian Lepore <ian@freebsd.org>
5034e9ed6SIan Lepore  * All rights reserved.
6034e9ed6SIan Lepore  *
7034e9ed6SIan Lepore  * Redistribution and use in source and binary forms, with or without
8034e9ed6SIan Lepore  * modification, are permitted provided that the following conditions
9034e9ed6SIan Lepore  * are met:
10034e9ed6SIan Lepore  * 1. Redistributions of source code must retain the above copyright
11034e9ed6SIan Lepore  *    notice, this list of conditions and the following disclaimer.
12034e9ed6SIan Lepore  * 2. Redistributions in binary form must reproduce the above copyright
13034e9ed6SIan Lepore  *    notice, this list of conditions and the following disclaimer in the
14034e9ed6SIan Lepore  *    documentation and/or other materials provided with the distribution.
15034e9ed6SIan Lepore  *
16034e9ed6SIan Lepore  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17034e9ed6SIan Lepore  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18034e9ed6SIan Lepore  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19034e9ed6SIan Lepore  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20034e9ed6SIan Lepore  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21034e9ed6SIan Lepore  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22034e9ed6SIan Lepore  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23034e9ed6SIan Lepore  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24034e9ed6SIan Lepore  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25034e9ed6SIan Lepore  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26034e9ed6SIan Lepore  * SUCH DAMAGE.
27034e9ed6SIan Lepore  */
28034e9ed6SIan Lepore 
29034e9ed6SIan Lepore #include "opt_platform.h"
30034e9ed6SIan Lepore 
31034e9ed6SIan Lepore #include <sys/param.h>
32034e9ed6SIan Lepore #include <sys/systm.h>
33034e9ed6SIan Lepore #include <sys/bus.h>
34034e9ed6SIan Lepore #include <sys/reboot.h>
3530b72b68SRuslan Bukin #include <sys/devmap.h>
36034e9ed6SIan Lepore 
37034e9ed6SIan Lepore #include <vm/vm.h>
3813a98c85SIan Lepore 
3913a98c85SIan Lepore #include <machine/bus.h>
40952ded80SIan Lepore #include <machine/intr.h>
4181acdf3fSIan Lepore #include <machine/machdep.h>
42ef7eac43SAndrew Turner #include <machine/platformvar.h>
4313a98c85SIan Lepore 
44a3ff7ef6SIan Lepore #include <arm/arm/mpcore_timervar.h>
45034e9ed6SIan Lepore #include <arm/freescale/imx/imx6_anatopreg.h>
46034e9ed6SIan Lepore #include <arm/freescale/imx/imx6_anatopvar.h>
47034e9ed6SIan Lepore #include <arm/freescale/imx/imx_machdep.h>
48034e9ed6SIan Lepore 
49952ded80SIan Lepore #include <dev/fdt/fdt_common.h>
50952ded80SIan Lepore #include <dev/ofw/openfirm.h>
51952ded80SIan Lepore 
523185adf0SAndrew Turner #include <arm/freescale/imx/imx6_machdep.h>
530960989fSAndrew Turner 
54ef7eac43SAndrew Turner #include "platform_if.h"
5575f48c23SAndrew Turner #include "platform_pl310_if.h"
56ef7eac43SAndrew Turner 
57ba9f40caSAndrew Turner static platform_attach_t imx6_attach;
58ba9f40caSAndrew Turner static platform_devmap_init_t imx6_devmap_init;
59ba9f40caSAndrew Turner static platform_late_init_t imx6_late_init;
60ba9f40caSAndrew Turner static platform_cpu_reset_t imx6_cpu_reset;
61ba9f40caSAndrew Turner 
62e28fbecaSIan Lepore /*
63e28fbecaSIan Lepore  * Fix FDT data related to interrupts.
64e28fbecaSIan Lepore  *
65e28fbecaSIan Lepore  * Driven by the needs of linux and its drivers (as always), the published FDT
66e28fbecaSIan Lepore  * data for imx6 now sets the interrupt parent for most devices to the GPC
67e28fbecaSIan Lepore  * interrupt controller, which is for use when the chip is in deep-sleep mode.
68e28fbecaSIan Lepore  * We don't support deep sleep or have a GPC-PIC driver; we need all interrupts
69e28fbecaSIan Lepore  * to be handled by the GIC.
70e28fbecaSIan Lepore  *
71e28fbecaSIan Lepore  * Luckily, the change to the FDT data was to assign the GPC as the interrupt
72e28fbecaSIan Lepore  * parent for the soc node and letting that get inherited by all other devices
73e28fbecaSIan Lepore  * (except a few that directly name GIC as their interrupt parent).  So we can
74e28fbecaSIan Lepore  * set the world right by just changing the interrupt-parent property of the soc
75e28fbecaSIan Lepore  * node to refer to GIC instead of GPC.  This will get us by until we write our
76e28fbecaSIan Lepore  * own GPC driver (or until linux changes its mind and the FDT data again).
77e28fbecaSIan Lepore  *
782814e686SIan Lepore  * 2020/11/25: The tempmon and pmu nodes are siblings (not children) of the soc
792814e686SIan Lepore  * node, so for them to use interrupts we need to apply the same fix as we do
802814e686SIan Lepore  * for the soc node.
812814e686SIan Lepore  *
82e28fbecaSIan Lepore  * We validate that we have data that looks like we expect before changing it:
83e28fbecaSIan Lepore  *  - SOC node exists and has GPC as its interrupt parent.
84e28fbecaSIan Lepore  *  - GPC node exists and has GIC as its interrupt parent.
8508efd2cdSIan Lepore  *  - GIC node exists and is its own interrupt parent or has no parent.
86e28fbecaSIan Lepore  *
87e28fbecaSIan Lepore  * This applies to all models of imx6.  Luckily all of them have the devices
88db4fcadfSConrad Meyer  * involved at the same addresses on the same buses, so we don't need any
89e28fbecaSIan Lepore  * per-soc logic.  We handle this at platform attach time rather than via the
90e28fbecaSIan Lepore  * fdt_fixup_table, because the latter requires matching on the FDT "model"
91e28fbecaSIan Lepore  * property, and this applies to all boards including those not yet invented.
9207fca7acSIan Lepore  *
9307fca7acSIan Lepore  * This just in:  as of the import of dts files from linux 4.15 on 2018-02-10,
9407fca7acSIan Lepore  * they appear to have applied a new style rule to the dts which forbids leading
9507fca7acSIan Lepore  * zeroes in the @address qualifiers on node names.  Since we have to find those
9607fca7acSIan Lepore  * nodes by string matching we now have to search for both flavors of each node
9707fca7acSIan Lepore  * name involved.
98e28fbecaSIan Lepore  */
992814e686SIan Lepore 
1002814e686SIan Lepore static void
fix_node_iparent(const char * nodepath,phandle_t gpcxref,phandle_t gicxref)1012814e686SIan Lepore fix_node_iparent(const char* nodepath, phandle_t gpcxref, phandle_t gicxref)
1022814e686SIan Lepore {
1032814e686SIan Lepore 	static const char *propname = "interrupt-parent";
1042814e686SIan Lepore 	phandle_t node, iparent;
1052814e686SIan Lepore 
1062814e686SIan Lepore 	if ((node = OF_finddevice(nodepath)) == -1)
1072814e686SIan Lepore 		return;
1082814e686SIan Lepore 	if (OF_getencprop(node, propname, &iparent, sizeof(iparent)) <= 0)
1092814e686SIan Lepore 		return;
1102814e686SIan Lepore 	if (iparent != gpcxref)
1112814e686SIan Lepore 		return;
1122814e686SIan Lepore 
1132814e686SIan Lepore 	OF_setprop(node, propname, &gicxref, sizeof(gicxref));
1142814e686SIan Lepore }
1152814e686SIan Lepore 
116e28fbecaSIan Lepore static void
fix_fdt_interrupt_data(void)117e28fbecaSIan Lepore fix_fdt_interrupt_data(void)
118e28fbecaSIan Lepore {
119e28fbecaSIan Lepore 	phandle_t gicipar, gicnode, gicxref;
120e28fbecaSIan Lepore 	phandle_t gpcipar, gpcnode, gpcxref;
121e28fbecaSIan Lepore 	int result;
122e28fbecaSIan Lepore 
12308efd2cdSIan Lepore 	/* GIC node may be child of soc node, or appear directly at root. */
124e28fbecaSIan Lepore 	gicnode = OF_finddevice("/soc/interrupt-controller@00a01000");
12507fca7acSIan Lepore 	if (gicnode == -1)
12607fca7acSIan Lepore 		gicnode = OF_finddevice("/soc/interrupt-controller@a01000");
12708efd2cdSIan Lepore 	if (gicnode == -1) {
12808efd2cdSIan Lepore 		gicnode = OF_finddevice("/interrupt-controller@00a01000");
129e28fbecaSIan Lepore 		if (gicnode == -1)
13007fca7acSIan Lepore 			gicnode = OF_finddevice("/interrupt-controller@a01000");
13107fca7acSIan Lepore 		if (gicnode == -1)
132e28fbecaSIan Lepore 			return;
13308efd2cdSIan Lepore 	}
13408efd2cdSIan Lepore 	gicxref = OF_xref_from_node(gicnode);
13508efd2cdSIan Lepore 
13608efd2cdSIan Lepore 	/* If gic node has no parent, pretend it is its own parent. */
137e28fbecaSIan Lepore 	result = OF_getencprop(gicnode, "interrupt-parent", &gicipar,
138e28fbecaSIan Lepore 	    sizeof(gicipar));
139e28fbecaSIan Lepore 	if (result <= 0)
14008efd2cdSIan Lepore 		gicipar = gicxref;
141e28fbecaSIan Lepore 
142e28fbecaSIan Lepore 	gpcnode = OF_finddevice("/soc/aips-bus@02000000/gpc@020dc000");
143e28fbecaSIan Lepore 	if (gpcnode == -1)
14407fca7acSIan Lepore 		gpcnode = OF_finddevice("/soc/aips-bus@2000000/gpc@20dc000");
14507fca7acSIan Lepore 	if (gpcnode == -1)
146c76b8bdaSAndreas Tobler 		gpcnode = OF_finddevice("/soc/bus@2000000/gpc@20dc000");
147c76b8bdaSAndreas Tobler 	if (gpcnode == -1)
148e28fbecaSIan Lepore 		return;
149e28fbecaSIan Lepore 	result = OF_getencprop(gpcnode, "interrupt-parent", &gpcipar,
150e28fbecaSIan Lepore 	    sizeof(gpcipar));
151e28fbecaSIan Lepore 	if (result <= 0)
152e28fbecaSIan Lepore 		return;
153e28fbecaSIan Lepore 	gpcxref = OF_xref_from_node(gpcnode);
154e28fbecaSIan Lepore 
1552814e686SIan Lepore 	if (gpcipar != gicxref || gicipar != gicxref)
156e28fbecaSIan Lepore 		return;
157e28fbecaSIan Lepore 
158e28fbecaSIan Lepore 	gicxref = cpu_to_fdt32(gicxref);
1592814e686SIan Lepore 	fix_node_iparent("/soc", gpcxref, gicxref);
1602814e686SIan Lepore 	fix_node_iparent("/pmu", gpcxref, gicxref);
1612814e686SIan Lepore 	fix_node_iparent("/tempmon", gpcxref, gicxref);
162e28fbecaSIan Lepore }
163e28fbecaSIan Lepore 
1647887a5a1SIan Lepore static void
fix_fdt_iomuxc_data(void)1657887a5a1SIan Lepore fix_fdt_iomuxc_data(void)
1667887a5a1SIan Lepore {
1677887a5a1SIan Lepore 	phandle_t node;
1687887a5a1SIan Lepore 
1697887a5a1SIan Lepore 	/*
1707887a5a1SIan Lepore 	 * The linux dts defines two nodes with the same mmio address range,
1717887a5a1SIan Lepore 	 * iomuxc-gpr and the regular iomuxc.  The -grp node is a simple_mfd and
1727887a5a1SIan Lepore 	 * a syscon, but it only has access to a small subset of the iomuxc
1737887a5a1SIan Lepore 	 * registers, so it can't serve as the accessor for the iomuxc driver's
1747887a5a1SIan Lepore 	 * register IO.  But right now, the simple_mfd driver attaches first,
1757887a5a1SIan Lepore 	 * preventing the real iomuxc driver from allocating its mmio register
1767887a5a1SIan Lepore 	 * range because it partially overlaps with the -gpr range.
1777887a5a1SIan Lepore 	 *
1787887a5a1SIan Lepore 	 * For now, by far the easiest thing to do to keep imx6 working is to
1797887a5a1SIan Lepore 	 * just disable the iomuxc-gpr node because we don't have a driver for
1807887a5a1SIan Lepore 	 * it anyway, we just need to prevent attachment of simple_mfd.
1817887a5a1SIan Lepore 	 *
1827887a5a1SIan Lepore 	 * If we ever write a -gpr driver, this code should probably switch to
1837887a5a1SIan Lepore 	 * modifying the reg property so that the range covers all the iomuxc
1847887a5a1SIan Lepore 	 * regs, then the -gpr driver can be a regular syscon driver that iomuxc
1857887a5a1SIan Lepore 	 * uses for register access.
1867887a5a1SIan Lepore 	 */
1877887a5a1SIan Lepore 	node = OF_finddevice("/soc/aips-bus@2000000/iomuxc-gpr@20e0000");
188c76b8bdaSAndreas Tobler 	if (node == -1)
189c76b8bdaSAndreas Tobler 	    node = OF_finddevice("/soc/bus@2000000/iomuxc-gpr@20e0000");
1907887a5a1SIan Lepore 	if (node != -1)
1917887a5a1SIan Lepore 		OF_setprop(node, "status", "disabled", sizeof("disabled"));
1927887a5a1SIan Lepore }
1937887a5a1SIan Lepore 
194ef7eac43SAndrew Turner static int
imx6_attach(platform_t plat)195ef7eac43SAndrew Turner imx6_attach(platform_t plat)
19681acdf3fSIan Lepore {
197e28fbecaSIan Lepore 
198e28fbecaSIan Lepore 	/* Fix soc interrupt-parent property. */
199e28fbecaSIan Lepore 	fix_fdt_interrupt_data();
200e28fbecaSIan Lepore 
2017887a5a1SIan Lepore 	/* Fix iomuxc-gpr and iomuxc nodes both using the same mmio range. */
2027887a5a1SIan Lepore 	fix_fdt_iomuxc_data();
2037887a5a1SIan Lepore 
204a3ff7ef6SIan Lepore 	/* Inform the MPCore timer driver that its clock is variable. */
205a3ff7ef6SIan Lepore 	arm_tmr_change_frequency(ARM_TMR_FREQUENCY_VARIES);
206ef7eac43SAndrew Turner 
207ef7eac43SAndrew Turner 	return (0);
20881acdf3fSIan Lepore }
20981acdf3fSIan Lepore 
210ef7eac43SAndrew Turner static void
imx6_late_init(platform_t plat)211ef7eac43SAndrew Turner imx6_late_init(platform_t plat)
21281acdf3fSIan Lepore {
213bd6b2f9bSIan Lepore 	const uint32_t IMX6_WDOG_SR_PHYS = 0x020bc004;
214bd6b2f9bSIan Lepore 
215bd6b2f9bSIan Lepore 	imx_wdog_init_last_reset(IMX6_WDOG_SR_PHYS);
21681acdf3fSIan Lepore }
21781acdf3fSIan Lepore 
218034e9ed6SIan Lepore /*
21981acdf3fSIan Lepore  * Set up static device mappings.
220034e9ed6SIan Lepore  *
221034e9ed6SIan Lepore  * This attempts to cover the most-used devices with 1MB section mappings, which
222034e9ed6SIan Lepore  * is good for performance (uses fewer TLB entries for device access).
223034e9ed6SIan Lepore  *
224034e9ed6SIan Lepore  * ARMMP covers the interrupt controller, MPCore timers, global timer, and the
225034e9ed6SIan Lepore  * L2 cache controller.  Most of the 1MB range is unused reserved space.
226034e9ed6SIan Lepore  *
227034e9ed6SIan Lepore  * AIPS1/AIPS2 cover most of the on-chip devices such as uart, spi, i2c, etc.
228034e9ed6SIan Lepore  *
229034e9ed6SIan Lepore  * Notably not mapped right now are HDMI, GPU, and other devices below ARMMP in
230034e9ed6SIan Lepore  * the memory map.  When we get support for graphics it might make sense to
231034e9ed6SIan Lepore  * static map some of that area.  Be careful with other things in that area such
2321413a3abSSvatopluk Kraus  * as OCRAM that probably shouldn't be mapped as VM_MEMATTR_DEVICE memory.
233034e9ed6SIan Lepore  */
234ef7eac43SAndrew Turner static int
imx6_devmap_init(platform_t plat)235ef7eac43SAndrew Turner imx6_devmap_init(platform_t plat)
236034e9ed6SIan Lepore {
237034e9ed6SIan Lepore 	const uint32_t IMX6_ARMMP_PHYS = 0x00a00000;
238034e9ed6SIan Lepore 	const uint32_t IMX6_ARMMP_SIZE = 0x00100000;
239034e9ed6SIan Lepore 	const uint32_t IMX6_AIPS1_PHYS = 0x02000000;
240034e9ed6SIan Lepore 	const uint32_t IMX6_AIPS1_SIZE = 0x00100000;
241034e9ed6SIan Lepore 	const uint32_t IMX6_AIPS2_PHYS = 0x02100000;
242034e9ed6SIan Lepore 	const uint32_t IMX6_AIPS2_SIZE = 0x00100000;
243034e9ed6SIan Lepore 
24430b72b68SRuslan Bukin 	devmap_add_entry(IMX6_ARMMP_PHYS, IMX6_ARMMP_SIZE);
24530b72b68SRuslan Bukin 	devmap_add_entry(IMX6_AIPS1_PHYS, IMX6_AIPS1_SIZE);
24630b72b68SRuslan Bukin 	devmap_add_entry(IMX6_AIPS2_PHYS, IMX6_AIPS2_SIZE);
24781acdf3fSIan Lepore 
24881acdf3fSIan Lepore 	return (0);
249034e9ed6SIan Lepore }
250034e9ed6SIan Lepore 
2510dbb8873SAndrew Turner static void
imx6_cpu_reset(platform_t plat)2520dbb8873SAndrew Turner imx6_cpu_reset(platform_t plat)
253034e9ed6SIan Lepore {
254034e9ed6SIan Lepore 	const uint32_t IMX6_WDOG_CR_PHYS = 0x020bc000;
255034e9ed6SIan Lepore 
256034e9ed6SIan Lepore 	imx_wdog_cpu_reset(IMX6_WDOG_CR_PHYS);
257034e9ed6SIan Lepore }
258034e9ed6SIan Lepore 
259034e9ed6SIan Lepore /*
260034e9ed6SIan Lepore  * Determine what flavor of imx6 we're running on.
261034e9ed6SIan Lepore  *
262034e9ed6SIan Lepore  * This code is based on the way u-boot does it.  Information found on the web
263034e9ed6SIan Lepore  * indicates that Freescale themselves were the original source of this logic,
264034e9ed6SIan Lepore  * including the strange check for number of CPUs in the SCU configuration
265034e9ed6SIan Lepore  * register, which is apparently needed on some revisions of the SOLO.
266034e9ed6SIan Lepore  *
267034e9ed6SIan Lepore  * According to the documentation, there is such a thing as an i.MX6 Dual
268034e9ed6SIan Lepore  * (non-lite flavor).  However, Freescale doesn't seem to have assigned it a
269034e9ed6SIan Lepore  * number or provided any logic to handle it in their detection code.
270034e9ed6SIan Lepore  *
271034e9ed6SIan Lepore  * Note that the ANALOG_DIGPROG and SCU configuration registers are not
272034e9ed6SIan Lepore  * documented in the chip reference manual.  (SCU configuration is mentioned,
273034e9ed6SIan Lepore  * but not mapped out in detail.)  I think the bottom two bits of the scu config
274034e9ed6SIan Lepore  * register may be ncpu-1.
275034e9ed6SIan Lepore  *
276034e9ed6SIan Lepore  * This hasn't been tested yet on a dual[-lite].
277034e9ed6SIan Lepore  *
278034e9ed6SIan Lepore  * On a solo:
279034e9ed6SIan Lepore  *      digprog    = 0x00610001
280034e9ed6SIan Lepore  *      hwsoc      = 0x00000062
281034e9ed6SIan Lepore  *      scu config = 0x00000500
282034e9ed6SIan Lepore  * On a quad:
283034e9ed6SIan Lepore  *      digprog    = 0x00630002
284034e9ed6SIan Lepore  *      hwsoc      = 0x00000063
285034e9ed6SIan Lepore  *      scu config = 0x00005503
286034e9ed6SIan Lepore  */
287ba9f40caSAndrew Turner u_int
imx_soc_type(void)288ba9f40caSAndrew Turner imx_soc_type(void)
289034e9ed6SIan Lepore {
290034e9ed6SIan Lepore 	uint32_t digprog, hwsoc;
291034e9ed6SIan Lepore 	uint32_t *pcr;
2925fdc7f7eSIan Lepore 	static u_int soctype;
293034e9ed6SIan Lepore 	const vm_offset_t SCU_CONFIG_PHYSADDR = 0x00a00004;
294272faa5fSIan Lepore #define	HWSOC_MX6SL	0x60
295272faa5fSIan Lepore #define	HWSOC_MX6DL	0x61
296272faa5fSIan Lepore #define	HWSOC_MX6SOLO	0x62
297272faa5fSIan Lepore #define	HWSOC_MX6Q	0x63
298c1411a76SIan Lepore #define	HWSOC_MX6UL	0x64
299034e9ed6SIan Lepore 
3005fdc7f7eSIan Lepore 	if (soctype != 0)
3015fdc7f7eSIan Lepore 		return (soctype);
3025fdc7f7eSIan Lepore 
303034e9ed6SIan Lepore 	digprog = imx6_anatop_read_4(IMX6_ANALOG_DIGPROG_SL);
304034e9ed6SIan Lepore 	hwsoc = (digprog >> IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT) &
305034e9ed6SIan Lepore 	    IMX6_ANALOG_DIGPROG_SOCTYPE_MASK;
306034e9ed6SIan Lepore 
307034e9ed6SIan Lepore 	if (hwsoc != HWSOC_MX6SL) {
308034e9ed6SIan Lepore 		digprog = imx6_anatop_read_4(IMX6_ANALOG_DIGPROG);
309034e9ed6SIan Lepore 		hwsoc = (digprog & IMX6_ANALOG_DIGPROG_SOCTYPE_MASK) >>
310034e9ed6SIan Lepore 		    IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT;
311034e9ed6SIan Lepore 		/*printf("digprog = 0x%08x\n", digprog);*/
312034e9ed6SIan Lepore 		if (hwsoc == HWSOC_MX6DL) {
31330b72b68SRuslan Bukin 			pcr = devmap_ptov(SCU_CONFIG_PHYSADDR, 4);
31413a98c85SIan Lepore 			if (pcr != NULL) {
315034e9ed6SIan Lepore 				/*printf("scu config = 0x%08x\n", *pcr);*/
316034e9ed6SIan Lepore 				if ((*pcr & 0x03) == 0) {
317034e9ed6SIan Lepore 					hwsoc = HWSOC_MX6SOLO;
318034e9ed6SIan Lepore 				}
319034e9ed6SIan Lepore 			}
320034e9ed6SIan Lepore 		}
321034e9ed6SIan Lepore 	}
322034e9ed6SIan Lepore 	/* printf("hwsoc 0x%08x\n", hwsoc); */
323034e9ed6SIan Lepore 
324034e9ed6SIan Lepore 	switch (hwsoc) {
325034e9ed6SIan Lepore 	case HWSOC_MX6SL:
3265fdc7f7eSIan Lepore 		soctype = IMXSOC_6SL;
3275fdc7f7eSIan Lepore 		break;
328034e9ed6SIan Lepore 	case HWSOC_MX6SOLO:
3295fdc7f7eSIan Lepore 		soctype = IMXSOC_6S;
3305fdc7f7eSIan Lepore 		break;
331034e9ed6SIan Lepore 	case HWSOC_MX6DL:
3325fdc7f7eSIan Lepore 		soctype = IMXSOC_6DL;
3335fdc7f7eSIan Lepore 		break;
334034e9ed6SIan Lepore 	case HWSOC_MX6Q :
3355fdc7f7eSIan Lepore 		soctype = IMXSOC_6Q;
3365fdc7f7eSIan Lepore 		break;
337c1411a76SIan Lepore 	case HWSOC_MX6UL:
338c1411a76SIan Lepore 		soctype = IMXSOC_6UL;
339c1411a76SIan Lepore 		break;
340034e9ed6SIan Lepore 	default:
341034e9ed6SIan Lepore 		printf("imx_soc_type: Don't understand hwsoc 0x%02x, "
342034e9ed6SIan Lepore 		    "digprog 0x%08x; assuming IMXSOC_6Q\n", hwsoc, digprog);
3435fdc7f7eSIan Lepore 		soctype = IMXSOC_6Q;
344034e9ed6SIan Lepore 		break;
345034e9ed6SIan Lepore 	}
346034e9ed6SIan Lepore 
3475fdc7f7eSIan Lepore 	return (soctype);
348034e9ed6SIan Lepore }
349034e9ed6SIan Lepore 
3508df34dd2SIan Lepore /*
3518df34dd2SIan Lepore  * Early putc routine for EARLY_PRINTF support.  To use, add to kernel config:
3528df34dd2SIan Lepore  *   option SOCDEV_PA=0x02000000
3538df34dd2SIan Lepore  *   option SOCDEV_VA=0x02000000
3548df34dd2SIan Lepore  *   option EARLY_PRINTF
3558df34dd2SIan Lepore  * Resist the temptation to change the #if 0 to #ifdef EARLY_PRINTF here. It
3568df34dd2SIan Lepore  * makes sense now, but if multiple SOCs do that it will make early_putc another
3578df34dd2SIan Lepore  * duplicate symbol to be eliminated on the path to a generic kernel.
3588df34dd2SIan Lepore  */
3598df34dd2SIan Lepore #if 0
3608df34dd2SIan Lepore static void
3618df34dd2SIan Lepore imx6_early_putc(int c)
3628df34dd2SIan Lepore {
3638df34dd2SIan Lepore 	volatile uint32_t * UART_STAT_REG = (uint32_t *)0x02020098;
3648df34dd2SIan Lepore 	volatile uint32_t * UART_TX_REG   = (uint32_t *)0x02020040;
3658df34dd2SIan Lepore 	const uint32_t      UART_TXRDY    = (1 << 3);
3668df34dd2SIan Lepore 
3678df34dd2SIan Lepore 	while ((*UART_STAT_REG & UART_TXRDY) == 0)
3688df34dd2SIan Lepore 		continue;
3698df34dd2SIan Lepore 	*UART_TX_REG = c;
3708df34dd2SIan Lepore }
3718df34dd2SIan Lepore early_putc_t *early_putc = imx6_early_putc;
3728df34dd2SIan Lepore #endif
3738df34dd2SIan Lepore 
374ef7eac43SAndrew Turner static platform_method_t imx6_methods[] = {
375ef7eac43SAndrew Turner 	PLATFORMMETHOD(platform_attach,		imx6_attach),
376ef7eac43SAndrew Turner 	PLATFORMMETHOD(platform_devmap_init,	imx6_devmap_init),
377ef7eac43SAndrew Turner 	PLATFORMMETHOD(platform_late_init,	imx6_late_init),
3780dbb8873SAndrew Turner 	PLATFORMMETHOD(platform_cpu_reset,	imx6_cpu_reset),
379ef7eac43SAndrew Turner 
3800960989fSAndrew Turner #ifdef SMP
3810960989fSAndrew Turner 	PLATFORMMETHOD(platform_mp_start_ap,	imx6_mp_start_ap),
3820960989fSAndrew Turner 	PLATFORMMETHOD(platform_mp_setmaxid,	imx6_mp_setmaxid),
3830960989fSAndrew Turner #endif
3840960989fSAndrew Turner 
38575f48c23SAndrew Turner 	PLATFORMMETHOD(platform_pl310_init,	imx6_pl310_init),
38675f48c23SAndrew Turner 
387ef7eac43SAndrew Turner 	PLATFORMMETHOD_END,
388ef7eac43SAndrew Turner };
389ef7eac43SAndrew Turner 
3904bd9887cSAndrew Turner FDT_PLATFORM_DEF2(imx6, imx6s, "i.MX6 Solo", 0, "fsl,imx6s", 80);
3914bd9887cSAndrew Turner FDT_PLATFORM_DEF2(imx6, imx6d, "i.MX6 Dual", 0, "fsl,imx6dl", 80);
3924bd9887cSAndrew Turner FDT_PLATFORM_DEF2(imx6, imx6q, "i.MX6 Quad", 0, "fsl,imx6q", 80);
3934bd9887cSAndrew Turner FDT_PLATFORM_DEF2(imx6, imx6ul, "i.MX6 UltraLite", 0, "fsl,imx6ul", 67);
394