|
2 | 2 | /* |
3 | 3 | * am33xx-restart.c - Code common to all AM33xx machines. |
4 | 4 | */ |
| 5 | +#include <dt-bindings/pinctrl/am33xx.h> |
| 6 | +#include <linux/delay.h> |
5 | 7 | #include <linux/kernel.h> |
6 | 8 | #include <linux/reboot.h> |
7 | 9 |
|
8 | 10 | #include "common.h" |
| 11 | +#include "control.h" |
9 | 12 | #include "prm.h" |
10 | 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 | + |
11 | 45 | /** |
12 | 46 | * am33xx_restart - trigger a software restart of the SoC |
13 | 47 | * @mode: the "reboot mode", see arch/arm/kernel/{setup,process}.c |
|
18 | 52 | */ |
19 | 53 | void am33xx_restart(enum reboot_mode mode, const char *cmd) |
20 | 54 | { |
| 55 | + am33xx_advisory_1_0_36(); |
| 56 | + |
21 | 57 | /* TODO: Handle cmd if necessary */ |
22 | 58 | prm_reboot_mode = mode; |
23 | 59 |
|
|
0 commit comments