1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 1999 ARM Limited
4 * Copyright (C) 2000 Deep Blue Solutions Ltd
5 * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
6 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
7 * Copyright 2009 Ilya Yanok, Emcraft Systems Ltd, yanok@emcraft.com
10 #include <linux/kernel.h>
11 #include <linux/clk.h>
13 #include <linux/err.h>
14 #include <linux/delay.h>
16 #include <linux/of_address.h>
18 #include <asm/system_misc.h>
19 #include <asm/proc-fns.h>
20 #include <asm/mach-types.h>
21 #include <asm/hardware/cache-l2x0.h>
26 static void __iomem
*wdog_base
;
27 static struct clk
*wdog_clk
;
28 static int wcr_enable
= (1 << 2);
31 * Reset the system. It is called by machine_restart().
33 void mxc_restart(enum reboot_mode mode
, const char *cmd
)
38 if (!IS_ERR(wdog_clk
))
41 /* Assert SRS signal */
42 imx_writew(wcr_enable
, wdog_base
);
44 * Due to imx6q errata ERR004346 (WDOG: WDOG SRS bit requires to be
45 * written twice), we add another two writes to ensure there must be at
46 * least two writes happen in the same one 32kHz clock period. We save
47 * the target check here, since the writes shouldn't be a huge burden
48 * for other platforms.
50 imx_writew(wcr_enable
, wdog_base
);
51 imx_writew(wcr_enable
, wdog_base
);
53 /* wait for reset to assert... */
56 pr_err("%s: Watchdog reset failed to assert reset\n", __func__
);
58 /* delay to allow the serial port to show the message */
62 /* we'll take a jump through zero as a poor second */
66 void __init
mxc_arch_reset_init(void __iomem
*base
)
70 wdog_clk
= clk_get_sys("imx2-wdt.0", NULL
);
72 pr_warn("%s: failed to get wdog clock\n", __func__
);
74 clk_prepare(wdog_clk
);
77 #ifdef CONFIG_SOC_IMX1
78 void __init
imx1_reset_init(void __iomem
*base
)
80 wcr_enable
= (1 << 0);
81 mxc_arch_reset_init(base
);
85 #ifdef CONFIG_CACHE_L2X0
86 void __init
imx_init_l2cache(void)
88 void __iomem
*l2x0_base
;
89 struct device_node
*np
;
92 np
= of_find_compatible_node(NULL
, NULL
, "arm,pl310-cache");
96 l2x0_base
= of_iomap(np
, 0);
100 if (!(readl_relaxed(l2x0_base
+ L2X0_CTRL
) & L2X0_CTRL_EN
)) {
101 /* Configure the L2 PREFETCH and POWER registers */
102 val
= readl_relaxed(l2x0_base
+ L310_PREFETCH_CTRL
);
103 val
|= L310_PREFETCH_CTRL_DBL_LINEFILL
|
104 L310_PREFETCH_CTRL_INSTR_PREFETCH
|
105 L310_PREFETCH_CTRL_DATA_PREFETCH
;
107 /* Set perfetch offset to improve performance */
108 val
&= ~L310_PREFETCH_CTRL_OFFSET_MASK
;
111 writel_relaxed(val
, l2x0_base
+ L310_PREFETCH_CTRL
);