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>
15 static void do_hw_reset(void);
17 static int reset_gpio
= -1;
19 int init_gpio_reset(int gpio
, int output
, int level
)
23 rc
= gpio_request(gpio
, "reset generator");
25 printk(KERN_ERR
"Can't request reset_gpio\n");
30 rc
= gpio_direction_output(gpio
, level
);
32 rc
= gpio_direction_input(gpio
);
34 printk(KERN_ERR
"Can't configure reset_gpio\n");
48 * This covers various types of logic connecting gpio pin
49 * to RESET pins (nRESET or GPIO_RESET):
51 static void do_gpio_reset(void)
53 BUG_ON(reset_gpio
== -1);
56 gpio_direction_output(reset_gpio
, 0);
58 /* rising edge or drive high */
59 gpio_set_value(reset_gpio
, 1);
62 gpio_set_value(reset_gpio
, 0);
64 /* give it some time */
72 static void do_hw_reset(void)
74 /* Initialize the watchdog and let it fire */
75 writel_relaxed(OWER_WME
, OWER
);
76 writel_relaxed(OSSR_M3
, OSSR
);
78 writel_relaxed(readl_relaxed(OSCR
) + 368640, OSMR3
);
80 * SDRAM hangs on watchdog reset on Marvell PXA270 (erratum 71)
81 * we put SDRAM into self-refresh to prevent that
84 writel_relaxed(MDREFR_SLFRSH
, MDREFR
);
87 void pxa_restart(enum reboot_mode mode
, const char *cmd
)
92 clear_reset_status(RESET_STATUS_ALL
);
96 /* Jump into ROM at address 0 */