1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/kernel.h>
3 #include <linux/module.h>
4 #include <linux/delay.h>
5 #include <linux/gpio.h>
7 #include <asm/proc-fns.h>
8 #include <asm/system_misc.h>
14 static void do_hw_reset(void);
16 static int reset_gpio = -1;
18 int init_gpio_reset(int gpio, int output, int level)
22 rc = gpio_request(gpio, "reset generator");
24 printk(KERN_ERR "Can't request reset_gpio\n");
29 rc = gpio_direction_output(gpio, level);
31 rc = gpio_direction_input(gpio);
33 printk(KERN_ERR "Can't configure reset_gpio\n");
47 * This covers various types of logic connecting gpio pin
48 * to RESET pins (nRESET or GPIO_RESET):
50 static void do_gpio_reset(void)
52 BUG_ON(reset_gpio == -1);
55 gpio_direction_output(reset_gpio, 0);
57 /* rising edge or drive high */
58 gpio_set_value(reset_gpio, 1);
61 gpio_set_value(reset_gpio, 0);
63 /* give it some time */
71 static void do_hw_reset(void)
73 /* Initialize the watchdog and let it fire */
74 writel_relaxed(OWER_WME, OWER);
75 writel_relaxed(OSSR_M3, OSSR);
77 writel_relaxed(readl_relaxed(OSCR) + 368640, OSMR3);
79 * SDRAM hangs on watchdog reset on Marvell PXA270 (erratum 71)
80 * we put SDRAM into self-refresh to prevent that
83 writel_relaxed(MDREFR_SLFRSH, MDREFR);
86 void pxa_restart(enum reboot_mode mode, const char *cmd)
91 clear_reset_status(RESET_STATUS_ALL);
95 /* Jump into ROM at address 0 */