xref: /freebsd/sys/arm/freescale/imx/imx6_machdep.c (revision c76b8bda0b5fc8cceece3b627ebfc5fcb64f5dad)
1034e9ed6SIan Lepore /*-
2af3dc4a7SPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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/cdefs.h>
32034e9ed6SIan Lepore __FBSDID("$FreeBSD$");
33034e9ed6SIan Lepore 
34034e9ed6SIan Lepore #include <sys/param.h>
35034e9ed6SIan Lepore #include <sys/systm.h>
36034e9ed6SIan Lepore #include <sys/bus.h>
37034e9ed6SIan Lepore #include <sys/reboot.h>
3830b72b68SRuslan Bukin #include <sys/devmap.h>
39034e9ed6SIan Lepore 
40034e9ed6SIan Lepore #include <vm/vm.h>
4113a98c85SIan Lepore 
4213a98c85SIan Lepore #include <machine/bus.h>
43952ded80SIan Lepore #include <machine/intr.h>
4481acdf3fSIan Lepore #include <machine/machdep.h>
45ef7eac43SAndrew Turner #include <machine/platformvar.h>
4613a98c85SIan Lepore 
47a3ff7ef6SIan Lepore #include <arm/arm/mpcore_timervar.h>
48034e9ed6SIan Lepore #include <arm/freescale/imx/imx6_anatopreg.h>
49034e9ed6SIan Lepore #include <arm/freescale/imx/imx6_anatopvar.h>
50034e9ed6SIan Lepore #include <arm/freescale/imx/imx_machdep.h>
51034e9ed6SIan Lepore 
52952ded80SIan Lepore #include <dev/fdt/fdt_common.h>
53952ded80SIan Lepore #include <dev/ofw/openfirm.h>
54952ded80SIan Lepore 
553185adf0SAndrew Turner #include <arm/freescale/imx/imx6_machdep.h>
560960989fSAndrew Turner 
57ef7eac43SAndrew Turner #include "platform_if.h"
5875f48c23SAndrew Turner #include "platform_pl310_if.h"
59ef7eac43SAndrew Turner 
60ba9f40caSAndrew Turner static platform_attach_t imx6_attach;
61ba9f40caSAndrew Turner static platform_devmap_init_t imx6_devmap_init;
62ba9f40caSAndrew Turner static platform_late_init_t imx6_late_init;
63ba9f40caSAndrew Turner static platform_cpu_reset_t imx6_cpu_reset;
64ba9f40caSAndrew Turner 
65e28fbecaSIan Lepore /*
66e28fbecaSIan Lepore  * Fix FDT data related to interrupts.
67e28fbecaSIan Lepore  *
68e28fbecaSIan Lepore  * Driven by the needs of linux and its drivers (as always), the published FDT
69e28fbecaSIan Lepore  * data for imx6 now sets the interrupt parent for most devices to the GPC
70e28fbecaSIan Lepore  * interrupt controller, which is for use when the chip is in deep-sleep mode.
71e28fbecaSIan Lepore  * We don't support deep sleep or have a GPC-PIC driver; we need all interrupts
72e28fbecaSIan Lepore  * to be handled by the GIC.
73e28fbecaSIan Lepore  *
74e28fbecaSIan Lepore  * Luckily, the change to the FDT data was to assign the GPC as the interrupt
75e28fbecaSIan Lepore  * parent for the soc node and letting that get inherited by all other devices
76e28fbecaSIan Lepore  * (except a few that directly name GIC as their interrupt parent).  So we can
77e28fbecaSIan Lepore  * set the world right by just changing the interrupt-parent property of the soc
78e28fbecaSIan Lepore  * node to refer to GIC instead of GPC.  This will get us by until we write our
79e28fbecaSIan Lepore  * own GPC driver (or until linux changes its mind and the FDT data again).
80e28fbecaSIan Lepore  *
81e28fbecaSIan Lepore  * We validate that we have data that looks like we expect before changing it:
82e28fbecaSIan Lepore  *  - SOC node exists and has GPC as its interrupt parent.
83e28fbecaSIan Lepore  *  - GPC node exists and has GIC as its interrupt parent.
8408efd2cdSIan Lepore  *  - GIC node exists and is its own interrupt parent or has no parent.
85e28fbecaSIan Lepore  *
86e28fbecaSIan Lepore  * This applies to all models of imx6.  Luckily all of them have the devices
87db4fcadfSConrad Meyer  * involved at the same addresses on the same buses, so we don't need any
88e28fbecaSIan Lepore  * per-soc logic.  We handle this at platform attach time rather than via the
89e28fbecaSIan Lepore  * fdt_fixup_table, because the latter requires matching on the FDT "model"
90e28fbecaSIan Lepore  * property, and this applies to all boards including those not yet invented.
9107fca7acSIan Lepore  *
9207fca7acSIan Lepore  * This just in:  as of the import of dts files from linux 4.15 on 2018-02-10,
9307fca7acSIan Lepore  * they appear to have applied a new style rule to the dts which forbids leading
9407fca7acSIan Lepore  * zeroes in the @address qualifiers on node names.  Since we have to find those
9507fca7acSIan Lepore  * nodes by string matching we now have to search for both flavors of each node
9607fca7acSIan Lepore  * name involved.
97e28fbecaSIan Lepore  */
98e28fbecaSIan Lepore static void
99e28fbecaSIan Lepore fix_fdt_interrupt_data(void)
100e28fbecaSIan Lepore {
101e28fbecaSIan Lepore 	phandle_t gicipar, gicnode, gicxref;
102e28fbecaSIan Lepore 	phandle_t gpcipar, gpcnode, gpcxref;
103e28fbecaSIan Lepore 	phandle_t socipar, socnode;
104e28fbecaSIan Lepore 	int result;
105e28fbecaSIan Lepore 
106e28fbecaSIan Lepore 	socnode = OF_finddevice("/soc");
107e28fbecaSIan Lepore 	if (socnode == -1)
108e28fbecaSIan Lepore 	    return;
109e28fbecaSIan Lepore 	result = OF_getencprop(socnode, "interrupt-parent", &socipar,
110e28fbecaSIan Lepore 	    sizeof(socipar));
111e28fbecaSIan Lepore 	if (result <= 0)
112e28fbecaSIan Lepore 		return;
113e28fbecaSIan Lepore 
11408efd2cdSIan Lepore 	/* GIC node may be child of soc node, or appear directly at root. */
115e28fbecaSIan Lepore 	gicnode = OF_finddevice("/soc/interrupt-controller@00a01000");
11607fca7acSIan Lepore 	if (gicnode == -1)
11707fca7acSIan Lepore 		gicnode = OF_finddevice("/soc/interrupt-controller@a01000");
11808efd2cdSIan Lepore 	if (gicnode == -1) {
11908efd2cdSIan Lepore 		gicnode = OF_finddevice("/interrupt-controller@00a01000");
120e28fbecaSIan Lepore 		if (gicnode == -1)
12107fca7acSIan Lepore 			gicnode = OF_finddevice("/interrupt-controller@a01000");
12207fca7acSIan Lepore 		if (gicnode == -1)
123e28fbecaSIan Lepore 			return;
12408efd2cdSIan Lepore 	}
12508efd2cdSIan Lepore 	gicxref = OF_xref_from_node(gicnode);
12608efd2cdSIan Lepore 
12708efd2cdSIan Lepore 	/* If gic node has no parent, pretend it is its own parent. */
128e28fbecaSIan Lepore 	result = OF_getencprop(gicnode, "interrupt-parent", &gicipar,
129e28fbecaSIan Lepore 	    sizeof(gicipar));
130e28fbecaSIan Lepore 	if (result <= 0)
13108efd2cdSIan Lepore 		gicipar = gicxref;
132e28fbecaSIan Lepore 
133e28fbecaSIan Lepore 	gpcnode = OF_finddevice("/soc/aips-bus@02000000/gpc@020dc000");
134e28fbecaSIan Lepore 	if (gpcnode == -1)
13507fca7acSIan Lepore 		gpcnode = OF_finddevice("/soc/aips-bus@2000000/gpc@20dc000");
13607fca7acSIan Lepore 	if (gpcnode == -1)
137*c76b8bdaSAndreas Tobler 		gpcnode = OF_finddevice("/soc/bus@2000000/gpc@20dc000");
138*c76b8bdaSAndreas Tobler 	if (gpcnode == -1)
139e28fbecaSIan Lepore 		return;
140e28fbecaSIan Lepore 	result = OF_getencprop(gpcnode, "interrupt-parent", &gpcipar,
141e28fbecaSIan Lepore 	    sizeof(gpcipar));
142e28fbecaSIan Lepore 	if (result <= 0)
143e28fbecaSIan Lepore 		return;
144e28fbecaSIan Lepore 	gpcxref = OF_xref_from_node(gpcnode);
145e28fbecaSIan Lepore 
146e28fbecaSIan Lepore 	if (socipar != gpcxref || gpcipar != gicxref || gicipar != gicxref)
147e28fbecaSIan Lepore 		return;
148e28fbecaSIan Lepore 
149e28fbecaSIan Lepore 	gicxref = cpu_to_fdt32(gicxref);
150e28fbecaSIan Lepore 	OF_setprop(socnode, "interrupt-parent", &gicxref, sizeof(gicxref));
151e28fbecaSIan Lepore }
152e28fbecaSIan Lepore 
1537887a5a1SIan Lepore static void
1547887a5a1SIan Lepore fix_fdt_iomuxc_data(void)
1557887a5a1SIan Lepore {
1567887a5a1SIan Lepore 	phandle_t node;
1577887a5a1SIan Lepore 
1587887a5a1SIan Lepore 	/*
1597887a5a1SIan Lepore 	 * The linux dts defines two nodes with the same mmio address range,
1607887a5a1SIan Lepore 	 * iomuxc-gpr and the regular iomuxc.  The -grp node is a simple_mfd and
1617887a5a1SIan Lepore 	 * a syscon, but it only has access to a small subset of the iomuxc
1627887a5a1SIan Lepore 	 * registers, so it can't serve as the accessor for the iomuxc driver's
1637887a5a1SIan Lepore 	 * register IO.  But right now, the simple_mfd driver attaches first,
1647887a5a1SIan Lepore 	 * preventing the real iomuxc driver from allocating its mmio register
1657887a5a1SIan Lepore 	 * range because it partially overlaps with the -gpr range.
1667887a5a1SIan Lepore 	 *
1677887a5a1SIan Lepore 	 * For now, by far the easiest thing to do to keep imx6 working is to
1687887a5a1SIan Lepore 	 * just disable the iomuxc-gpr node because we don't have a driver for
1697887a5a1SIan Lepore 	 * it anyway, we just need to prevent attachment of simple_mfd.
1707887a5a1SIan Lepore 	 *
1717887a5a1SIan Lepore 	 * If we ever write a -gpr driver, this code should probably switch to
1727887a5a1SIan Lepore 	 * modifying the reg property so that the range covers all the iomuxc
1737887a5a1SIan Lepore 	 * regs, then the -gpr driver can be a regular syscon driver that iomuxc
1747887a5a1SIan Lepore 	 * uses for register access.
1757887a5a1SIan Lepore 	 */
1767887a5a1SIan Lepore 	node = OF_finddevice("/soc/aips-bus@2000000/iomuxc-gpr@20e0000");
177*c76b8bdaSAndreas Tobler 	if (node == -1)
178*c76b8bdaSAndreas Tobler 	    node = OF_finddevice("/soc/bus@2000000/iomuxc-gpr@20e0000");
1797887a5a1SIan Lepore 	if (node != -1)
1807887a5a1SIan Lepore 		OF_setprop(node, "status", "disabled", sizeof("disabled"));
1817887a5a1SIan Lepore }
1827887a5a1SIan Lepore 
183ef7eac43SAndrew Turner static int
184ef7eac43SAndrew Turner imx6_attach(platform_t plat)
18581acdf3fSIan Lepore {
186e28fbecaSIan Lepore 
187e28fbecaSIan Lepore 	/* Fix soc interrupt-parent property. */
188e28fbecaSIan Lepore 	fix_fdt_interrupt_data();
189e28fbecaSIan Lepore 
1907887a5a1SIan Lepore 	/* Fix iomuxc-gpr and iomuxc nodes both using the same mmio range. */
1917887a5a1SIan Lepore 	fix_fdt_iomuxc_data();
1927887a5a1SIan Lepore 
193a3ff7ef6SIan Lepore 	/* Inform the MPCore timer driver that its clock is variable. */
194a3ff7ef6SIan Lepore 	arm_tmr_change_frequency(ARM_TMR_FREQUENCY_VARIES);
195ef7eac43SAndrew Turner 
196ef7eac43SAndrew Turner 	return (0);
19781acdf3fSIan Lepore }
19881acdf3fSIan Lepore 
199ef7eac43SAndrew Turner static void
200ef7eac43SAndrew Turner imx6_late_init(platform_t plat)
20181acdf3fSIan Lepore {
202bd6b2f9bSIan Lepore 	const uint32_t IMX6_WDOG_SR_PHYS = 0x020bc004;
203bd6b2f9bSIan Lepore 
204bd6b2f9bSIan Lepore 	imx_wdog_init_last_reset(IMX6_WDOG_SR_PHYS);
20581acdf3fSIan Lepore }
20681acdf3fSIan Lepore 
207034e9ed6SIan Lepore /*
20881acdf3fSIan Lepore  * Set up static device mappings.
209034e9ed6SIan Lepore  *
210034e9ed6SIan Lepore  * This attempts to cover the most-used devices with 1MB section mappings, which
211034e9ed6SIan Lepore  * is good for performance (uses fewer TLB entries for device access).
212034e9ed6SIan Lepore  *
213034e9ed6SIan Lepore  * ARMMP covers the interrupt controller, MPCore timers, global timer, and the
214034e9ed6SIan Lepore  * L2 cache controller.  Most of the 1MB range is unused reserved space.
215034e9ed6SIan Lepore  *
216034e9ed6SIan Lepore  * AIPS1/AIPS2 cover most of the on-chip devices such as uart, spi, i2c, etc.
217034e9ed6SIan Lepore  *
218034e9ed6SIan Lepore  * Notably not mapped right now are HDMI, GPU, and other devices below ARMMP in
219034e9ed6SIan Lepore  * the memory map.  When we get support for graphics it might make sense to
220034e9ed6SIan Lepore  * static map some of that area.  Be careful with other things in that area such
2211413a3abSSvatopluk Kraus  * as OCRAM that probably shouldn't be mapped as VM_MEMATTR_DEVICE memory.
222034e9ed6SIan Lepore  */
223ef7eac43SAndrew Turner static int
224ef7eac43SAndrew Turner imx6_devmap_init(platform_t plat)
225034e9ed6SIan Lepore {
226034e9ed6SIan Lepore 	const uint32_t IMX6_ARMMP_PHYS = 0x00a00000;
227034e9ed6SIan Lepore 	const uint32_t IMX6_ARMMP_SIZE = 0x00100000;
228034e9ed6SIan Lepore 	const uint32_t IMX6_AIPS1_PHYS = 0x02000000;
229034e9ed6SIan Lepore 	const uint32_t IMX6_AIPS1_SIZE = 0x00100000;
230034e9ed6SIan Lepore 	const uint32_t IMX6_AIPS2_PHYS = 0x02100000;
231034e9ed6SIan Lepore 	const uint32_t IMX6_AIPS2_SIZE = 0x00100000;
232034e9ed6SIan Lepore 
23330b72b68SRuslan Bukin 	devmap_add_entry(IMX6_ARMMP_PHYS, IMX6_ARMMP_SIZE);
23430b72b68SRuslan Bukin 	devmap_add_entry(IMX6_AIPS1_PHYS, IMX6_AIPS1_SIZE);
23530b72b68SRuslan Bukin 	devmap_add_entry(IMX6_AIPS2_PHYS, IMX6_AIPS2_SIZE);
23681acdf3fSIan Lepore 
23781acdf3fSIan Lepore 	return (0);
238034e9ed6SIan Lepore }
239034e9ed6SIan Lepore 
2400dbb8873SAndrew Turner static void
2410dbb8873SAndrew Turner imx6_cpu_reset(platform_t plat)
242034e9ed6SIan Lepore {
243034e9ed6SIan Lepore 	const uint32_t IMX6_WDOG_CR_PHYS = 0x020bc000;
244034e9ed6SIan Lepore 
245034e9ed6SIan Lepore 	imx_wdog_cpu_reset(IMX6_WDOG_CR_PHYS);
246034e9ed6SIan Lepore }
247034e9ed6SIan Lepore 
248034e9ed6SIan Lepore /*
249034e9ed6SIan Lepore  * Determine what flavor of imx6 we're running on.
250034e9ed6SIan Lepore  *
251034e9ed6SIan Lepore  * This code is based on the way u-boot does it.  Information found on the web
252034e9ed6SIan Lepore  * indicates that Freescale themselves were the original source of this logic,
253034e9ed6SIan Lepore  * including the strange check for number of CPUs in the SCU configuration
254034e9ed6SIan Lepore  * register, which is apparently needed on some revisions of the SOLO.
255034e9ed6SIan Lepore  *
256034e9ed6SIan Lepore  * According to the documentation, there is such a thing as an i.MX6 Dual
257034e9ed6SIan Lepore  * (non-lite flavor).  However, Freescale doesn't seem to have assigned it a
258034e9ed6SIan Lepore  * number or provided any logic to handle it in their detection code.
259034e9ed6SIan Lepore  *
260034e9ed6SIan Lepore  * Note that the ANALOG_DIGPROG and SCU configuration registers are not
261034e9ed6SIan Lepore  * documented in the chip reference manual.  (SCU configuration is mentioned,
262034e9ed6SIan Lepore  * but not mapped out in detail.)  I think the bottom two bits of the scu config
263034e9ed6SIan Lepore  * register may be ncpu-1.
264034e9ed6SIan Lepore  *
265034e9ed6SIan Lepore  * This hasn't been tested yet on a dual[-lite].
266034e9ed6SIan Lepore  *
267034e9ed6SIan Lepore  * On a solo:
268034e9ed6SIan Lepore  *      digprog    = 0x00610001
269034e9ed6SIan Lepore  *      hwsoc      = 0x00000062
270034e9ed6SIan Lepore  *      scu config = 0x00000500
271034e9ed6SIan Lepore  * On a quad:
272034e9ed6SIan Lepore  *      digprog    = 0x00630002
273034e9ed6SIan Lepore  *      hwsoc      = 0x00000063
274034e9ed6SIan Lepore  *      scu config = 0x00005503
275034e9ed6SIan Lepore  */
276ba9f40caSAndrew Turner u_int
277ba9f40caSAndrew Turner imx_soc_type(void)
278034e9ed6SIan Lepore {
279034e9ed6SIan Lepore 	uint32_t digprog, hwsoc;
280034e9ed6SIan Lepore 	uint32_t *pcr;
2815fdc7f7eSIan Lepore 	static u_int soctype;
282034e9ed6SIan Lepore 	const vm_offset_t SCU_CONFIG_PHYSADDR = 0x00a00004;
283272faa5fSIan Lepore #define	HWSOC_MX6SL	0x60
284272faa5fSIan Lepore #define	HWSOC_MX6DL	0x61
285272faa5fSIan Lepore #define	HWSOC_MX6SOLO	0x62
286272faa5fSIan Lepore #define	HWSOC_MX6Q	0x63
287c1411a76SIan Lepore #define	HWSOC_MX6UL	0x64
288034e9ed6SIan Lepore 
2895fdc7f7eSIan Lepore 	if (soctype != 0)
2905fdc7f7eSIan Lepore 		return (soctype);
2915fdc7f7eSIan Lepore 
292034e9ed6SIan Lepore 	digprog = imx6_anatop_read_4(IMX6_ANALOG_DIGPROG_SL);
293034e9ed6SIan Lepore 	hwsoc = (digprog >> IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT) &
294034e9ed6SIan Lepore 	    IMX6_ANALOG_DIGPROG_SOCTYPE_MASK;
295034e9ed6SIan Lepore 
296034e9ed6SIan Lepore 	if (hwsoc != HWSOC_MX6SL) {
297034e9ed6SIan Lepore 		digprog = imx6_anatop_read_4(IMX6_ANALOG_DIGPROG);
298034e9ed6SIan Lepore 		hwsoc = (digprog & IMX6_ANALOG_DIGPROG_SOCTYPE_MASK) >>
299034e9ed6SIan Lepore 		    IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT;
300034e9ed6SIan Lepore 		/*printf("digprog = 0x%08x\n", digprog);*/
301034e9ed6SIan Lepore 		if (hwsoc == HWSOC_MX6DL) {
30230b72b68SRuslan Bukin 			pcr = devmap_ptov(SCU_CONFIG_PHYSADDR, 4);
30313a98c85SIan Lepore 			if (pcr != NULL) {
304034e9ed6SIan Lepore 				/*printf("scu config = 0x%08x\n", *pcr);*/
305034e9ed6SIan Lepore 				if ((*pcr & 0x03) == 0) {
306034e9ed6SIan Lepore 					hwsoc = HWSOC_MX6SOLO;
307034e9ed6SIan Lepore 				}
308034e9ed6SIan Lepore 			}
309034e9ed6SIan Lepore 		}
310034e9ed6SIan Lepore 	}
311034e9ed6SIan Lepore 	/* printf("hwsoc 0x%08x\n", hwsoc); */
312034e9ed6SIan Lepore 
313034e9ed6SIan Lepore 	switch (hwsoc) {
314034e9ed6SIan Lepore 	case HWSOC_MX6SL:
3155fdc7f7eSIan Lepore 		soctype = IMXSOC_6SL;
3165fdc7f7eSIan Lepore 		break;
317034e9ed6SIan Lepore 	case HWSOC_MX6SOLO:
3185fdc7f7eSIan Lepore 		soctype = IMXSOC_6S;
3195fdc7f7eSIan Lepore 		break;
320034e9ed6SIan Lepore 	case HWSOC_MX6DL:
3215fdc7f7eSIan Lepore 		soctype = IMXSOC_6DL;
3225fdc7f7eSIan Lepore 		break;
323034e9ed6SIan Lepore 	case HWSOC_MX6Q :
3245fdc7f7eSIan Lepore 		soctype = IMXSOC_6Q;
3255fdc7f7eSIan Lepore 		break;
326c1411a76SIan Lepore 	case HWSOC_MX6UL:
327c1411a76SIan Lepore 		soctype = IMXSOC_6UL;
328c1411a76SIan Lepore 		break;
329034e9ed6SIan Lepore 	default:
330034e9ed6SIan Lepore 		printf("imx_soc_type: Don't understand hwsoc 0x%02x, "
331034e9ed6SIan Lepore 		    "digprog 0x%08x; assuming IMXSOC_6Q\n", hwsoc, digprog);
3325fdc7f7eSIan Lepore 		soctype = IMXSOC_6Q;
333034e9ed6SIan Lepore 		break;
334034e9ed6SIan Lepore 	}
335034e9ed6SIan Lepore 
3365fdc7f7eSIan Lepore 	return (soctype);
337034e9ed6SIan Lepore }
338034e9ed6SIan Lepore 
3398df34dd2SIan Lepore /*
3408df34dd2SIan Lepore  * Early putc routine for EARLY_PRINTF support.  To use, add to kernel config:
3418df34dd2SIan Lepore  *   option SOCDEV_PA=0x02000000
3428df34dd2SIan Lepore  *   option SOCDEV_VA=0x02000000
3438df34dd2SIan Lepore  *   option EARLY_PRINTF
3448df34dd2SIan Lepore  * Resist the temptation to change the #if 0 to #ifdef EARLY_PRINTF here. It
3458df34dd2SIan Lepore  * makes sense now, but if multiple SOCs do that it will make early_putc another
3468df34dd2SIan Lepore  * duplicate symbol to be eliminated on the path to a generic kernel.
3478df34dd2SIan Lepore  */
3488df34dd2SIan Lepore #if 0
3498df34dd2SIan Lepore static void
3508df34dd2SIan Lepore imx6_early_putc(int c)
3518df34dd2SIan Lepore {
3528df34dd2SIan Lepore 	volatile uint32_t * UART_STAT_REG = (uint32_t *)0x02020098;
3538df34dd2SIan Lepore 	volatile uint32_t * UART_TX_REG   = (uint32_t *)0x02020040;
3548df34dd2SIan Lepore 	const uint32_t      UART_TXRDY    = (1 << 3);
3558df34dd2SIan Lepore 
3568df34dd2SIan Lepore 	while ((*UART_STAT_REG & UART_TXRDY) == 0)
3578df34dd2SIan Lepore 		continue;
3588df34dd2SIan Lepore 	*UART_TX_REG = c;
3598df34dd2SIan Lepore }
3608df34dd2SIan Lepore early_putc_t *early_putc = imx6_early_putc;
3618df34dd2SIan Lepore #endif
3628df34dd2SIan Lepore 
363ef7eac43SAndrew Turner static platform_method_t imx6_methods[] = {
364ef7eac43SAndrew Turner 	PLATFORMMETHOD(platform_attach,		imx6_attach),
365ef7eac43SAndrew Turner 	PLATFORMMETHOD(platform_devmap_init,	imx6_devmap_init),
366ef7eac43SAndrew Turner 	PLATFORMMETHOD(platform_late_init,	imx6_late_init),
3670dbb8873SAndrew Turner 	PLATFORMMETHOD(platform_cpu_reset,	imx6_cpu_reset),
368ef7eac43SAndrew Turner 
3690960989fSAndrew Turner #ifdef SMP
3700960989fSAndrew Turner 	PLATFORMMETHOD(platform_mp_start_ap,	imx6_mp_start_ap),
3710960989fSAndrew Turner 	PLATFORMMETHOD(platform_mp_setmaxid,	imx6_mp_setmaxid),
3720960989fSAndrew Turner #endif
3730960989fSAndrew Turner 
37475f48c23SAndrew Turner 	PLATFORMMETHOD(platform_pl310_init,	imx6_pl310_init),
37575f48c23SAndrew Turner 
376ef7eac43SAndrew Turner 	PLATFORMMETHOD_END,
377ef7eac43SAndrew Turner };
378ef7eac43SAndrew Turner 
3794bd9887cSAndrew Turner FDT_PLATFORM_DEF2(imx6, imx6s, "i.MX6 Solo", 0, "fsl,imx6s", 80);
3804bd9887cSAndrew Turner FDT_PLATFORM_DEF2(imx6, imx6d, "i.MX6 Dual", 0, "fsl,imx6dl", 80);
3814bd9887cSAndrew Turner FDT_PLATFORM_DEF2(imx6, imx6q, "i.MX6 Quad", 0, "fsl,imx6q", 80);
3824bd9887cSAndrew Turner FDT_PLATFORM_DEF2(imx6, imx6ul, "i.MX6 UltraLite", 0, "fsl,imx6ul", 67);
383