// SPDX-License-Identifier: GPL-2.0-only1/*2* am33xx-restart.c - Code common to all AM33xx machines.3*/4#include <dt-bindings/pinctrl/am33xx.h>5#include <linux/delay.h>6#include <linux/kernel.h>7#include <linux/reboot.h>89#include "common.h"10#include "control.h"11#include "prm.h"1213/*14* Advisory 1.0.36 EMU0 and EMU1: Terminals Must be Pulled High Before15* ICEPick Samples16*17* If EMU0/EMU1 pins have been used as GPIO outputs and actively driving low18* level, the device might not reboot in normal mode. We are in a bad position19* to override GPIO state here, so just switch the pins into EMU input mode20* (that's what reset will do anyway) and wait a bit, because the state will be21* latched 190 ns after reset.22*/23static void am33xx_advisory_1_0_36(void)24{25u32 emu0 = omap_ctrl_readl(AM335X_PIN_EMU0);26u32 emu1 = omap_ctrl_readl(AM335X_PIN_EMU1);2728/* If both pins are in EMU mode, nothing to do */29if (!(emu0 & 7) && !(emu1 & 7))30return;3132/* Switch GPIO3_7/GPIO3_8 into EMU0/EMU1 modes respectively */33omap_ctrl_writel(emu0 & ~7, AM335X_PIN_EMU0);34omap_ctrl_writel(emu1 & ~7, AM335X_PIN_EMU1);3536/*37* Give pull-ups time to load the pin/PCB trace capacity.38* 5 ms shall be enough to load 1 uF (would be huge capacity for these39* pins) with TI-recommended 4k7 external pull-ups.40*/41mdelay(5);42}4344/**45* am33xx_restart - trigger a software restart of the SoC46* @mode: the "reboot mode", see arch/arm/kernel/{setup,process}.c47* @cmd: passed from the userspace program rebooting the system (if provided)48*49* Resets the SoC. For @cmd, see the 'reboot' syscall in50* kernel/sys.c. No return value.51*/52void am33xx_restart(enum reboot_mode mode, const char *cmd)53{54am33xx_advisory_1_0_36();5556/* TODO: Handle cmd if necessary */57prm_reboot_mode = mode;5859omap_prm_reset_system();60}616263