Merge git://git.infradead.org/users/willy/linux-nvme
[cascardo/linux.git] / arch / arm / mach-imx / mach-imx6q.c
index 8deb012..c257281 100644 (file)
  * http://www.gnu.org/copyleft/gpl.html
  */
 
+#include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/io.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
+#include <linux/phy.h>
+#include <linux/micrel_phy.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/hardware/gic.h>
 #include <asm/mach/arch.h>
 #include <mach/common.h>
 #include <mach/hardware.h>
 
+void imx6q_restart(char mode, const char *cmd)
+{
+       struct device_node *np;
+       void __iomem *wdog_base;
+
+       np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-wdt");
+       wdog_base = of_iomap(np, 0);
+       if (!wdog_base)
+               goto soft;
+
+       imx_src_prepare_restart();
+
+       /* enable wdog */
+       writew_relaxed(1 << 2, wdog_base);
+       /* write twice to ensure the request will not get ignored */
+       writew_relaxed(1 << 2, wdog_base);
+
+       /* wait for reset to assert ... */
+       mdelay(500);
+
+       pr_err("Watchdog reset failed to assert reset\n");
+
+       /* delay to allow the serial port to show the message */
+       mdelay(50);
+
+soft:
+       /* we'll take a jump through zero as a poor second */
+       soft_restart(0);
+}
+
+/* For imx6q sabrelite board: set KSZ9021RN RGMII pad skew */
+static int ksz9021rn_phy_fixup(struct phy_device *phydev)
+{
+       /* min rx data delay */
+       phy_write(phydev, 0x0b, 0x8105);
+       phy_write(phydev, 0x0c, 0x0000);
+
+       /* max rx/tx clock delay, min rx/tx control delay */
+       phy_write(phydev, 0x0b, 0x8104);
+       phy_write(phydev, 0x0c, 0xf0f0);
+       phy_write(phydev, 0x0b, 0x104);
+
+       return 0;
+}
+
 static void __init imx6q_init_machine(void)
 {
+       if (of_machine_is_compatible("fsl,imx6q-sabrelite"))
+               phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
+                                          ksz9021rn_phy_fixup);
+
        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
        imx6q_pm_init();
@@ -72,7 +126,8 @@ static struct sys_timer imx6q_timer = {
 };
 
 static const char *imx6q_dt_compat[] __initdata = {
-       "fsl,imx6q-sabreauto",
+       "fsl,imx6q-arm2",
+       "fsl,imx6q-sabrelite",
        NULL,
 };
 
@@ -83,4 +138,5 @@ DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad (Device Tree)")
        .timer          = &imx6q_timer,
        .init_machine   = imx6q_init_machine,
        .dt_compat      = imx6q_dt_compat,
+       .restart        = imx6q_restart,
 MACHINE_END