Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/arm/mach-omap2/am33xx-restart.c
29269 views
1
// SPDX-License-Identifier: GPL-2.0-only
2
/*
3
* am33xx-restart.c - Code common to all AM33xx machines.
4
*/
5
#include <dt-bindings/pinctrl/am33xx.h>
6
#include <linux/delay.h>
7
#include <linux/kernel.h>
8
#include <linux/reboot.h>
9
10
#include "common.h"
11
#include "control.h"
12
#include "prm.h"
13
14
/*
15
* Advisory 1.0.36 EMU0 and EMU1: Terminals Must be Pulled High Before
16
* ICEPick Samples
17
*
18
* If EMU0/EMU1 pins have been used as GPIO outputs and actively driving low
19
* level, the device might not reboot in normal mode. We are in a bad position
20
* to override GPIO state here, so just switch the pins into EMU input mode
21
* (that's what reset will do anyway) and wait a bit, because the state will be
22
* latched 190 ns after reset.
23
*/
24
static void am33xx_advisory_1_0_36(void)
25
{
26
u32 emu0 = omap_ctrl_readl(AM335X_PIN_EMU0);
27
u32 emu1 = omap_ctrl_readl(AM335X_PIN_EMU1);
28
29
/* If both pins are in EMU mode, nothing to do */
30
if (!(emu0 & 7) && !(emu1 & 7))
31
return;
32
33
/* Switch GPIO3_7/GPIO3_8 into EMU0/EMU1 modes respectively */
34
omap_ctrl_writel(emu0 & ~7, AM335X_PIN_EMU0);
35
omap_ctrl_writel(emu1 & ~7, AM335X_PIN_EMU1);
36
37
/*
38
* Give pull-ups time to load the pin/PCB trace capacity.
39
* 5 ms shall be enough to load 1 uF (would be huge capacity for these
40
* pins) with TI-recommended 4k7 external pull-ups.
41
*/
42
mdelay(5);
43
}
44
45
/**
46
* am33xx_restart - trigger a software restart of the SoC
47
* @mode: the "reboot mode", see arch/arm/kernel/{setup,process}.c
48
* @cmd: passed from the userspace program rebooting the system (if provided)
49
*
50
* Resets the SoC. For @cmd, see the 'reboot' syscall in
51
* kernel/sys.c. No return value.
52
*/
53
void am33xx_restart(enum reboot_mode mode, const char *cmd)
54
{
55
am33xx_advisory_1_0_36();
56
57
/* TODO: Handle cmd if necessary */
58
prm_reboot_mode = mode;
59
60
omap_prm_reset_system();
61
}
62
63