]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/arm/mach-pxa/reset.c
Merge tag 'topic/drm-fixes-2015-11-11' of git://anongit.freedesktop.org/drm-intel...
[mirror_ubuntu-artful-kernel.git] / arch / arm / mach-pxa / reset.c
CommitLineData
75f10b46
DES
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
5 */
6#include <linux/kernel.h>
7#include <linux/module.h>
8#include <linux/delay.h>
9#include <linux/gpio.h>
fced80c7 10#include <linux/io.h>
75f10b46 11#include <asm/proc-fns.h>
9f97da78 12#include <asm/system_misc.h>
75f10b46 13
5bf3df3f 14#include <mach/regs-ost.h>
afd2fc02 15#include <mach/reset.h>
ff88b472 16#include <mach/smemc.h>
75f10b46 17
04fef228
EM
18unsigned int reset_status;
19EXPORT_SYMBOL(reset_status);
75f10b46
DES
20
21static void do_hw_reset(void);
22
23static int reset_gpio = -1;
24
216e3b7a 25int init_gpio_reset(int gpio, int output, int level)
75f10b46
DES
26{
27 int rc;
28
29 rc = gpio_request(gpio, "reset generator");
30 if (rc) {
31 printk(KERN_ERR "Can't request reset_gpio\n");
32 goto out;
33 }
34
69fc7eed 35 if (output)
216e3b7a 36 rc = gpio_direction_output(gpio, level);
69fc7eed
DES
37 else
38 rc = gpio_direction_input(gpio);
75f10b46 39 if (rc) {
69fc7eed 40 printk(KERN_ERR "Can't configure reset_gpio\n");
75f10b46
DES
41 gpio_free(gpio);
42 goto out;
43 }
44
45out:
46 if (!rc)
47 reset_gpio = gpio;
48
49 return rc;
50}
51
52/*
53 * Trigger GPIO reset.
54 * This covers various types of logic connecting gpio pin
55 * to RESET pins (nRESET or GPIO_RESET):
56 */
57static void do_gpio_reset(void)
58{
59 BUG_ON(reset_gpio == -1);
60
61 /* drive it low */
62 gpio_direction_output(reset_gpio, 0);
63 mdelay(2);
64 /* rising edge or drive high */
65 gpio_set_value(reset_gpio, 1);
66 mdelay(2);
67 /* falling edge */
68 gpio_set_value(reset_gpio, 0);
69
70 /* give it some time */
71 mdelay(10);
72
73 WARN_ON(1);
74 /* fallback */
75 do_hw_reset();
76}
77
78static void do_hw_reset(void)
79{
80 /* Initialize the watchdog and let it fire */
3169663a
RK
81 writel_relaxed(OWER_WME, OWER);
82 writel_relaxed(OSSR_M3, OSSR);
83 /* ... in 100 ms */
84 writel_relaxed(readl_relaxed(OSCR) + 368640, OSMR3);
ff88b472
SI
85 /*
86 * SDRAM hangs on watchdog reset on Marvell PXA270 (erratum 71)
87 * we put SDRAM into self-refresh to prevent that
88 */
89 while (1)
90 writel_relaxed(MDREFR_SLFRSH, MDREFR);
75f10b46
DES
91}
92
7b6d864b 93void pxa_restart(enum reboot_mode mode, const char *cmd)
75f10b46 94{
271a74fc
RK
95 local_irq_disable();
96 local_fiq_disable();
97
04fef228 98 clear_reset_status(RESET_STATUS_ALL);
75f10b46
DES
99
100 switch (mode) {
7b6d864b 101 case REBOOT_SOFT:
75f10b46 102 /* Jump into ROM at address 0 */
e879c862 103 soft_restart(0);
75f10b46 104 break;
7b6d864b 105 case REBOOT_GPIO:
75f10b46
DES
106 do_gpio_reset();
107 break;
7b6d864b 108 case REBOOT_HARD:
28105fda
JK
109 default:
110 do_hw_reset();
111 break;
75f10b46
DES
112 }
113}