* [PATCH 0/5] MIPS Malta halt & power off
@ 2014-05-07 11:20 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:20 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
This series improves the behaviour of the MIPS Malta board in response
to a halt or power off command. The previous behaviour was that both of
these would trigger a reset of the board. The new behaviour with this
series applied is that halt will execute an infinite loop and power off
will power off the board via the PIIX4.
Paul Burton (5):
MIPS: define some more PIIX4 registers & values
MIPS: Malta: add suspend state entry code
MIPS: Malta: let PIIX4 respond to PCI special cycles
MIPS: Malta: hang on halt
MIPS: Malta: support powering down
arch/mips/Kconfig | 6 ++
arch/mips/include/asm/mach-malta/malta-pm.h | 37 +++++++++++
arch/mips/include/asm/mips-boards/piix4.h | 12 ++++
arch/mips/mti-malta/Makefile | 2 +
arch/mips/mti-malta/malta-pm.c | 96 +++++++++++++++++++++++++++++
arch/mips/mti-malta/malta-reset.c | 15 +++--
arch/mips/pci/fixup-malta.c | 6 ++
7 files changed, 170 insertions(+), 4 deletions(-)
create mode 100644 arch/mips/include/asm/mach-malta/malta-pm.h
create mode 100644 arch/mips/mti-malta/malta-pm.c
--
1.8.5.3
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 0/5] MIPS Malta halt & power off
@ 2014-05-07 11:20 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:20 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
This series improves the behaviour of the MIPS Malta board in response
to a halt or power off command. The previous behaviour was that both of
these would trigger a reset of the board. The new behaviour with this
series applied is that halt will execute an infinite loop and power off
will power off the board via the PIIX4.
Paul Burton (5):
MIPS: define some more PIIX4 registers & values
MIPS: Malta: add suspend state entry code
MIPS: Malta: let PIIX4 respond to PCI special cycles
MIPS: Malta: hang on halt
MIPS: Malta: support powering down
arch/mips/Kconfig | 6 ++
arch/mips/include/asm/mach-malta/malta-pm.h | 37 +++++++++++
arch/mips/include/asm/mips-boards/piix4.h | 12 ++++
arch/mips/mti-malta/Makefile | 2 +
arch/mips/mti-malta/malta-pm.c | 96 +++++++++++++++++++++++++++++
arch/mips/mti-malta/malta-reset.c | 15 +++--
arch/mips/pci/fixup-malta.c | 6 ++
7 files changed, 170 insertions(+), 4 deletions(-)
create mode 100644 arch/mips/include/asm/mach-malta/malta-pm.h
create mode 100644 arch/mips/mti-malta/malta-pm.c
--
1.8.5.3
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/5] MIPS: define some more PIIX4 registers & values
@ 2014-05-07 11:20 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:20 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
This patch simply adds definitions for some I/O registers in the PIIX4
PM device, and the magic data for a special cycle which must occur on
the PCI bus in order for the PIIX4 to enter a suspend state.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
arch/mips/include/asm/mips-boards/piix4.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/mips/include/asm/mips-boards/piix4.h b/arch/mips/include/asm/mips-boards/piix4.h
index 9cf5404..9e340be 100644
--- a/arch/mips/include/asm/mips-boards/piix4.h
+++ b/arch/mips/include/asm/mips-boards/piix4.h
@@ -55,4 +55,16 @@
#define PIIX4_FUNC3_PMREGMISC 0x80
#define PIIX4_FUNC3_PMREGMISC_EN (1 << 0)
+/* Power Management IO Space */
+#define PIIX4_FUNC3IO_PMSTS 0x00
+#define PIIX4_FUNC3IO_PMSTS_PWRBTN_STS (1 << 8)
+#define PIIX4_FUNC3IO_PMCNTRL 0x04
+#define PIIX4_FUNC3IO_PMCNTRL_SUS_EN (1 << 13)
+#define PIIX4_FUNC3IO_PMCNTRL_SUS_TYP (0x7 << 10)
+#define PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF (0x0 << 10)
+#define PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_STR (0x1 << 10)
+
+/* Data for magic special PCI cycle */
+#define PIIX4_SUSPEND_MAGIC 0x00120002
+
#endif /* __ASM_MIPS_BOARDS_PIIX4_H */
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 1/5] MIPS: define some more PIIX4 registers & values
@ 2014-05-07 11:20 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:20 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
This patch simply adds definitions for some I/O registers in the PIIX4
PM device, and the magic data for a special cycle which must occur on
the PCI bus in order for the PIIX4 to enter a suspend state.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
arch/mips/include/asm/mips-boards/piix4.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/mips/include/asm/mips-boards/piix4.h b/arch/mips/include/asm/mips-boards/piix4.h
index 9cf5404..9e340be 100644
--- a/arch/mips/include/asm/mips-boards/piix4.h
+++ b/arch/mips/include/asm/mips-boards/piix4.h
@@ -55,4 +55,16 @@
#define PIIX4_FUNC3_PMREGMISC 0x80
#define PIIX4_FUNC3_PMREGMISC_EN (1 << 0)
+/* Power Management IO Space */
+#define PIIX4_FUNC3IO_PMSTS 0x00
+#define PIIX4_FUNC3IO_PMSTS_PWRBTN_STS (1 << 8)
+#define PIIX4_FUNC3IO_PMCNTRL 0x04
+#define PIIX4_FUNC3IO_PMCNTRL_SUS_EN (1 << 13)
+#define PIIX4_FUNC3IO_PMCNTRL_SUS_TYP (0x7 << 10)
+#define PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF (0x0 << 10)
+#define PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_STR (0x1 << 10)
+
+/* Data for magic special PCI cycle */
+#define PIIX4_SUSPEND_MAGIC 0x00120002
+
#endif /* __ASM_MIPS_BOARDS_PIIX4_H */
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/5] MIPS: Malta: add suspend state entry code
@ 2014-05-07 11:20 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:20 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
This patch introduces code which will enter a suspend state via the
PIIX4. This can only be done when PCI support is enabled since it
requires access to PCI I/O space and the generation of a special cycle
on the PCI bus. In cases where PCI is disabled the mips_pm_suspend
function will simply always return an error.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
arch/mips/Kconfig | 6 ++
arch/mips/include/asm/mach-malta/malta-pm.h | 37 +++++++++++
arch/mips/mti-malta/Makefile | 2 +
arch/mips/mti-malta/malta-pm.c | 96 +++++++++++++++++++++++++++++
4 files changed, 141 insertions(+)
create mode 100644 arch/mips/include/asm/mach-malta/malta-pm.h
create mode 100644 arch/mips/mti-malta/malta-pm.c
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 5cd695f..7d742ce 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1659,6 +1659,12 @@ config SYS_HAS_CPU_XLR
config SYS_HAS_CPU_XLP
bool
+config MIPS_MALTA_PM
+ depends on MIPS_MALTA
+ depends on PCI
+ bool
+ default y
+
#
# CPU may reorder R->R, R->W, W->R, W->W
# Reordering beyond LL and SC is handled in WEAK_REORDERING_BEYOND_LLSC
diff --git a/arch/mips/include/asm/mach-malta/malta-pm.h b/arch/mips/include/asm/mach-malta/malta-pm.h
new file mode 100644
index 0000000..21d131f
--- /dev/null
+++ b/arch/mips/include/asm/mach-malta/malta-pm.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 Imagination Technologies
+ * Author: Paul Burton <paul.burton@imgtec.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#ifndef __ASM_MIPS_MACH_MALTA_PM_H__
+#define __ASM_MIPS_MACH_MALTA_PM_H__
+
+#include <asm/mips-boards/piix4.h>
+
+#ifdef CONFIG_MIPS_MALTA_PM
+
+/**
+ * mips_pm_suspend - enter a suspend state
+ * @state: the state to enter, one of PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_*
+ *
+ * Enters a suspend state via the Malta's PIIX4. If the state to be entered
+ * is one which loses context (eg. SOFF) then this function will never
+ * return.
+ */
+extern int mips_pm_suspend(unsigned state);
+
+#else /* !CONFIG_MIPS_MALTA_PM */
+
+static inline int mips_pm_suspend(unsigned state)
+{
+ return -EINVAL;
+}
+
+#endif /* !CONFIG_MIPS_MALTA_PM */
+
+#endif /* __ASM_MIPS_MACH_MALTA_PM_H__ */
diff --git a/arch/mips/mti-malta/Makefile b/arch/mips/mti-malta/Makefile
index eae0ba3..5c372c6 100644
--- a/arch/mips/mti-malta/Makefile
+++ b/arch/mips/mti-malta/Makefile
@@ -11,3 +11,5 @@ obj-y := malta-amon.o malta-display.o malta-init.o \
# FIXME FIXME FIXME
obj-$(CONFIG_MIPS_MT_SMTC) += malta-smtc.o
+
+obj-$(CONFIG_MIPS_MALTA_PM) += malta-pm.o
diff --git a/arch/mips/mti-malta/malta-pm.c b/arch/mips/mti-malta/malta-pm.c
new file mode 100644
index 0000000..c1e456c
--- /dev/null
+++ b/arch/mips/mti-malta/malta-pm.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2014 Imagination Technologies
+ * Author: Paul Burton <paul.burton@imgtec.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/pci.h>
+
+#include <asm/mach-malta/malta-pm.h>
+
+static struct pci_bus *pm_pci_bus;
+static resource_size_t pm_io_offset;
+
+int mips_pm_suspend(unsigned state)
+{
+ int spec_devid;
+ u16 sts;
+
+ if (!pm_pci_bus || !pm_io_offset)
+ return -ENODEV;
+
+ /* Ensure the power button status is clear */
+ while (1) {
+ sts = inw(pm_io_offset + PIIX4_FUNC3IO_PMSTS);
+ if (!(sts & PIIX4_FUNC3IO_PMSTS_PWRBTN_STS))
+ break;
+ outw(sts, pm_io_offset + PIIX4_FUNC3IO_PMSTS);
+ }
+
+ /* Enable entry to suspend */
+ outw(state | PIIX4_FUNC3IO_PMCNTRL_SUS_EN,
+ pm_io_offset + PIIX4_FUNC3IO_PMCNTRL);
+
+ /* If the special cycle occurs too soon this doesn't work... */
+ mdelay(10);
+
+ /*
+ * The PIIX4 will enter the suspend state only after seeing a special
+ * cycle with the correct magic data on the PCI bus. Generate that
+ * cycle now.
+ */
+ spec_devid = PCI_DEVID(0, PCI_DEVFN(0x1f, 0x7));
+ pci_bus_write_config_dword(pm_pci_bus, spec_devid, 0,
+ PIIX4_SUSPEND_MAGIC);
+
+ /* Give the system some time to power down */
+ mdelay(1000);
+
+ return 0;
+}
+
+static int __init malta_pm_setup(void)
+{
+ struct pci_dev *dev;
+ int res, io_region = PCI_BRIDGE_RESOURCES;
+
+ /* Find a reference to the PCI bus */
+ pm_pci_bus = pci_find_next_bus(NULL);
+ if (!pm_pci_bus) {
+ pr_warn("malta-pm: failed to find reference to PCI bus\n");
+ return -ENODEV;
+ }
+
+ /* Find the PIIX4 PM device */
+ dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
+ PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID,
+ PCI_ANY_ID, NULL);
+ if (!dev) {
+ pr_warn("malta-pm: failed to find PIIX4 PM\n");
+ return -ENODEV;
+ }
+
+ /* Request access to the PIIX4 PM IO registers */
+ res = pci_request_region(dev, io_region, "PIIX4 PM IO registers");
+ if (res) {
+ pr_warn("malta-pm: failed to request PM IO registers (%d)\n",
+ res);
+ pci_dev_put(dev);
+ return -ENODEV;
+ }
+
+ /* Find the offset to the PIIX4 PM IO registers */
+ pm_io_offset = pci_resource_start(dev, io_region);
+
+ pci_dev_put(dev);
+ return 0;
+}
+
+late_initcall(malta_pm_setup);
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/5] MIPS: Malta: add suspend state entry code
@ 2014-05-07 11:20 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:20 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
This patch introduces code which will enter a suspend state via the
PIIX4. This can only be done when PCI support is enabled since it
requires access to PCI I/O space and the generation of a special cycle
on the PCI bus. In cases where PCI is disabled the mips_pm_suspend
function will simply always return an error.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
arch/mips/Kconfig | 6 ++
arch/mips/include/asm/mach-malta/malta-pm.h | 37 +++++++++++
arch/mips/mti-malta/Makefile | 2 +
arch/mips/mti-malta/malta-pm.c | 96 +++++++++++++++++++++++++++++
4 files changed, 141 insertions(+)
create mode 100644 arch/mips/include/asm/mach-malta/malta-pm.h
create mode 100644 arch/mips/mti-malta/malta-pm.c
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 5cd695f..7d742ce 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1659,6 +1659,12 @@ config SYS_HAS_CPU_XLR
config SYS_HAS_CPU_XLP
bool
+config MIPS_MALTA_PM
+ depends on MIPS_MALTA
+ depends on PCI
+ bool
+ default y
+
#
# CPU may reorder R->R, R->W, W->R, W->W
# Reordering beyond LL and SC is handled in WEAK_REORDERING_BEYOND_LLSC
diff --git a/arch/mips/include/asm/mach-malta/malta-pm.h b/arch/mips/include/asm/mach-malta/malta-pm.h
new file mode 100644
index 0000000..21d131f
--- /dev/null
+++ b/arch/mips/include/asm/mach-malta/malta-pm.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 Imagination Technologies
+ * Author: Paul Burton <paul.burton@imgtec.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#ifndef __ASM_MIPS_MACH_MALTA_PM_H__
+#define __ASM_MIPS_MACH_MALTA_PM_H__
+
+#include <asm/mips-boards/piix4.h>
+
+#ifdef CONFIG_MIPS_MALTA_PM
+
+/**
+ * mips_pm_suspend - enter a suspend state
+ * @state: the state to enter, one of PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_*
+ *
+ * Enters a suspend state via the Malta's PIIX4. If the state to be entered
+ * is one which loses context (eg. SOFF) then this function will never
+ * return.
+ */
+extern int mips_pm_suspend(unsigned state);
+
+#else /* !CONFIG_MIPS_MALTA_PM */
+
+static inline int mips_pm_suspend(unsigned state)
+{
+ return -EINVAL;
+}
+
+#endif /* !CONFIG_MIPS_MALTA_PM */
+
+#endif /* __ASM_MIPS_MACH_MALTA_PM_H__ */
diff --git a/arch/mips/mti-malta/Makefile b/arch/mips/mti-malta/Makefile
index eae0ba3..5c372c6 100644
--- a/arch/mips/mti-malta/Makefile
+++ b/arch/mips/mti-malta/Makefile
@@ -11,3 +11,5 @@ obj-y := malta-amon.o malta-display.o malta-init.o \
# FIXME FIXME FIXME
obj-$(CONFIG_MIPS_MT_SMTC) += malta-smtc.o
+
+obj-$(CONFIG_MIPS_MALTA_PM) += malta-pm.o
diff --git a/arch/mips/mti-malta/malta-pm.c b/arch/mips/mti-malta/malta-pm.c
new file mode 100644
index 0000000..c1e456c
--- /dev/null
+++ b/arch/mips/mti-malta/malta-pm.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2014 Imagination Technologies
+ * Author: Paul Burton <paul.burton@imgtec.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/pci.h>
+
+#include <asm/mach-malta/malta-pm.h>
+
+static struct pci_bus *pm_pci_bus;
+static resource_size_t pm_io_offset;
+
+int mips_pm_suspend(unsigned state)
+{
+ int spec_devid;
+ u16 sts;
+
+ if (!pm_pci_bus || !pm_io_offset)
+ return -ENODEV;
+
+ /* Ensure the power button status is clear */
+ while (1) {
+ sts = inw(pm_io_offset + PIIX4_FUNC3IO_PMSTS);
+ if (!(sts & PIIX4_FUNC3IO_PMSTS_PWRBTN_STS))
+ break;
+ outw(sts, pm_io_offset + PIIX4_FUNC3IO_PMSTS);
+ }
+
+ /* Enable entry to suspend */
+ outw(state | PIIX4_FUNC3IO_PMCNTRL_SUS_EN,
+ pm_io_offset + PIIX4_FUNC3IO_PMCNTRL);
+
+ /* If the special cycle occurs too soon this doesn't work... */
+ mdelay(10);
+
+ /*
+ * The PIIX4 will enter the suspend state only after seeing a special
+ * cycle with the correct magic data on the PCI bus. Generate that
+ * cycle now.
+ */
+ spec_devid = PCI_DEVID(0, PCI_DEVFN(0x1f, 0x7));
+ pci_bus_write_config_dword(pm_pci_bus, spec_devid, 0,
+ PIIX4_SUSPEND_MAGIC);
+
+ /* Give the system some time to power down */
+ mdelay(1000);
+
+ return 0;
+}
+
+static int __init malta_pm_setup(void)
+{
+ struct pci_dev *dev;
+ int res, io_region = PCI_BRIDGE_RESOURCES;
+
+ /* Find a reference to the PCI bus */
+ pm_pci_bus = pci_find_next_bus(NULL);
+ if (!pm_pci_bus) {
+ pr_warn("malta-pm: failed to find reference to PCI bus\n");
+ return -ENODEV;
+ }
+
+ /* Find the PIIX4 PM device */
+ dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
+ PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID,
+ PCI_ANY_ID, NULL);
+ if (!dev) {
+ pr_warn("malta-pm: failed to find PIIX4 PM\n");
+ return -ENODEV;
+ }
+
+ /* Request access to the PIIX4 PM IO registers */
+ res = pci_request_region(dev, io_region, "PIIX4 PM IO registers");
+ if (res) {
+ pr_warn("malta-pm: failed to request PM IO registers (%d)\n",
+ res);
+ pci_dev_put(dev);
+ return -ENODEV;
+ }
+
+ /* Find the offset to the PIIX4 PM IO registers */
+ pm_io_offset = pci_resource_start(dev, io_region);
+
+ pci_dev_put(dev);
+ return 0;
+}
+
+late_initcall(malta_pm_setup);
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/5] MIPS: Malta: let PIIX4 respond to PCI special cycles
@ 2014-05-07 11:20 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:20 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
This patch enables the PIIX4 to respond to special cycles on the PCI
bus. One such special cycle must be used in order to enter a suspend
state, and if response to it is not enabled then the suspend state will
never be entered.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
arch/mips/pci/fixup-malta.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/mips/pci/fixup-malta.c b/arch/mips/pci/fixup-malta.c
index 2f9e52a..40e920c 100644
--- a/arch/mips/pci/fixup-malta.c
+++ b/arch/mips/pci/fixup-malta.c
@@ -68,6 +68,7 @@ static void malta_piix_func0_fixup(struct pci_dev *pdev)
{
unsigned char reg_val;
u32 reg_val32;
+ u16 reg_val16;
/* PIIX PIRQC[A:D] irq mappings */
static int piixirqmap[PIIX4_FUNC0_PIRQRC_IRQ_ROUTING_MAX] = {
0, 0, 0, 3,
@@ -107,6 +108,11 @@ static void malta_piix_func0_fixup(struct pci_dev *pdev)
pci_read_config_byte(pdev, PIIX4_FUNC0_SERIRQC, ®_val);
reg_val |= PIIX4_FUNC0_SERIRQC_EN | PIIX4_FUNC0_SERIRQC_CONT;
pci_write_config_byte(pdev, PIIX4_FUNC0_SERIRQC, reg_val);
+
+ /* Enable response to special cycles */
+ pci_read_config_word(pdev, PCI_COMMAND, ®_val16);
+ pci_write_config_word(pdev, PCI_COMMAND,
+ reg_val16 | PCI_COMMAND_SPECIAL);
}
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0,
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/5] MIPS: Malta: let PIIX4 respond to PCI special cycles
@ 2014-05-07 11:20 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:20 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
This patch enables the PIIX4 to respond to special cycles on the PCI
bus. One such special cycle must be used in order to enter a suspend
state, and if response to it is not enabled then the suspend state will
never be entered.
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
arch/mips/pci/fixup-malta.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/mips/pci/fixup-malta.c b/arch/mips/pci/fixup-malta.c
index 2f9e52a..40e920c 100644
--- a/arch/mips/pci/fixup-malta.c
+++ b/arch/mips/pci/fixup-malta.c
@@ -68,6 +68,7 @@ static void malta_piix_func0_fixup(struct pci_dev *pdev)
{
unsigned char reg_val;
u32 reg_val32;
+ u16 reg_val16;
/* PIIX PIRQC[A:D] irq mappings */
static int piixirqmap[PIIX4_FUNC0_PIRQRC_IRQ_ROUTING_MAX] = {
0, 0, 0, 3,
@@ -107,6 +108,11 @@ static void malta_piix_func0_fixup(struct pci_dev *pdev)
pci_read_config_byte(pdev, PIIX4_FUNC0_SERIRQC, ®_val);
reg_val |= PIIX4_FUNC0_SERIRQC_EN | PIIX4_FUNC0_SERIRQC_CONT;
pci_write_config_byte(pdev, PIIX4_FUNC0_SERIRQC, reg_val);
+
+ /* Enable response to special cycles */
+ pci_read_config_word(pdev, PCI_COMMAND, ®_val16);
+ pci_write_config_word(pdev, PCI_COMMAND,
+ reg_val16 | PCI_COMMAND_SPECIAL);
}
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0,
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/5] MIPS: Malta: hang on halt
@ 2014-05-07 11:20 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:20 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
When the system is halted it makes little sense to reset it. Instead,
hang by executing an infinite loop.
Suggested-by: Maciej W. Rozycki <macro@linux-mips.org>
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
arch/mips/mti-malta/malta-reset.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/arch/mips/mti-malta/malta-reset.c b/arch/mips/mti-malta/malta-reset.c
index d627d4b..4471dea 100644
--- a/arch/mips/mti-malta/malta-reset.c
+++ b/arch/mips/mti-malta/malta-reset.c
@@ -24,17 +24,20 @@ static void mips_machine_restart(char *command)
static void mips_machine_halt(void)
{
- unsigned int __iomem *softres_reg =
- ioremap(SOFTRES_REG, sizeof(unsigned int));
+ pr_info("Halting\n");
+ while (true);
+}
- __raw_writel(GORESET, softres_reg);
+static void mips_machine_power_off(void)
+{
+ mips_machine_restart(NULL);
}
static int __init mips_reboot_setup(void)
{
_machine_restart = mips_machine_restart;
_machine_halt = mips_machine_halt;
- pm_power_off = mips_machine_halt;
+ pm_power_off = mips_machine_power_off;
return 0;
}
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/5] MIPS: Malta: hang on halt
@ 2014-05-07 11:20 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:20 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
When the system is halted it makes little sense to reset it. Instead,
hang by executing an infinite loop.
Suggested-by: Maciej W. Rozycki <macro@linux-mips.org>
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
arch/mips/mti-malta/malta-reset.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/arch/mips/mti-malta/malta-reset.c b/arch/mips/mti-malta/malta-reset.c
index d627d4b..4471dea 100644
--- a/arch/mips/mti-malta/malta-reset.c
+++ b/arch/mips/mti-malta/malta-reset.c
@@ -24,17 +24,20 @@ static void mips_machine_restart(char *command)
static void mips_machine_halt(void)
{
- unsigned int __iomem *softres_reg =
- ioremap(SOFTRES_REG, sizeof(unsigned int));
+ pr_info("Halting\n");
+ while (true);
+}
- __raw_writel(GORESET, softres_reg);
+static void mips_machine_power_off(void)
+{
+ mips_machine_restart(NULL);
}
static int __init mips_reboot_setup(void)
{
_machine_restart = mips_machine_restart;
_machine_halt = mips_machine_halt;
- pm_power_off = mips_machine_halt;
+ pm_power_off = mips_machine_power_off;
return 0;
}
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 5/5] MIPS: Malta: support powering down
@ 2014-05-07 11:22 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:22 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
This patch powers down the Malta in response to a power off command (eg.
poweroff or shutdown -P). It may then be powered back up by pressing the
"ON/NMI" button (S4) on the board. In cases where the power off state
cannot be entered (eg. because the required PCI support is disabled) the
current reset behaviour will be used as a fallback.
Tested-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
Changes in v2:
- Rebase atop previous patches in this series which abstract the
PIIX4 suspend functionality, making this patch trivial and avoiding
build issues when CONFIG_PCI is disabled.
---
arch/mips/mti-malta/malta-reset.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/mips/mti-malta/malta-reset.c b/arch/mips/mti-malta/malta-reset.c
index 4471dea..773aca9 100644
--- a/arch/mips/mti-malta/malta-reset.c
+++ b/arch/mips/mti-malta/malta-reset.c
@@ -10,6 +10,7 @@
#include <linux/pm.h>
#include <asm/reboot.h>
+#include <asm/mach-malta/malta-pm.h>
#define SOFTRES_REG 0x1f000500
#define GORESET 0x42
@@ -30,6 +31,9 @@ static void mips_machine_halt(void)
static void mips_machine_power_off(void)
{
+ mips_pm_suspend(PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF);
+
+ pr_info("Failed to power down, resetting\n");
mips_machine_restart(NULL);
}
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 5/5] MIPS: Malta: support powering down
@ 2014-05-07 11:22 ` Paul Burton
0 siblings, 0 replies; 13+ messages in thread
From: Paul Burton @ 2014-05-07 11:22 UTC (permalink / raw)
To: linux-mips; +Cc: Paul Burton
This patch powers down the Malta in response to a power off command (eg.
poweroff or shutdown -P). It may then be powered back up by pressing the
"ON/NMI" button (S4) on the board. In cases where the power off state
cannot be entered (eg. because the required PCI support is disabled) the
current reset behaviour will be used as a fallback.
Tested-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---
Changes in v2:
- Rebase atop previous patches in this series which abstract the
PIIX4 suspend functionality, making this patch trivial and avoiding
build issues when CONFIG_PCI is disabled.
---
arch/mips/mti-malta/malta-reset.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/mips/mti-malta/malta-reset.c b/arch/mips/mti-malta/malta-reset.c
index 4471dea..773aca9 100644
--- a/arch/mips/mti-malta/malta-reset.c
+++ b/arch/mips/mti-malta/malta-reset.c
@@ -10,6 +10,7 @@
#include <linux/pm.h>
#include <asm/reboot.h>
+#include <asm/mach-malta/malta-pm.h>
#define SOFTRES_REG 0x1f000500
#define GORESET 0x42
@@ -30,6 +31,9 @@ static void mips_machine_halt(void)
static void mips_machine_power_off(void)
{
+ mips_pm_suspend(PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF);
+
+ pr_info("Failed to power down, resetting\n");
mips_machine_restart(NULL);
}
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 4/5] MIPS: Malta: hang on halt
2014-05-07 11:20 ` Paul Burton
(?)
@ 2014-05-30 16:50 ` Ralf Baechle
-1 siblings, 0 replies; 13+ messages in thread
From: Ralf Baechle @ 2014-05-30 16:50 UTC (permalink / raw)
To: Paul Burton; +Cc: linux-mips
On Wed, May 07, 2014 at 12:20:59PM +0100, Paul Burton wrote:
> When the system is halted it makes little sense to reset it. Instead,
> hang by executing an infinite loop.
>
> Suggested-by: Maciej W. Rozycki <macro@linux-mips.org>
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> ---
> arch/mips/mti-malta/malta-reset.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/arch/mips/mti-malta/malta-reset.c b/arch/mips/mti-malta/malta-reset.c
> index d627d4b..4471dea 100644
> --- a/arch/mips/mti-malta/malta-reset.c
> +++ b/arch/mips/mti-malta/malta-reset.c
> @@ -24,17 +24,20 @@ static void mips_machine_restart(char *command)
>
> static void mips_machine_halt(void)
> {
> - unsigned int __iomem *softres_reg =
> - ioremap(SOFTRES_REG, sizeof(unsigned int));
> + pr_info("Halting\n");
> + while (true);
> +}
I don't think this should print anything - communication with the user
is up to userland.
while (true) is going to burn lots of power - undesirable on a virtualized
system in particular. How about something like while (cpu_wait()); instead?
The invocation of cpu_wait() is a little tricky however in this case I think
it's ok if the CPU goes terminally goes to sleep which simplifies things
over the idle loop :-)
Ralf
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-05-30 16:50 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-07 11:20 [PATCH 0/5] MIPS Malta halt & power off Paul Burton
2014-05-07 11:20 ` Paul Burton
2014-05-07 11:20 ` [PATCH 1/5] MIPS: define some more PIIX4 registers & values Paul Burton
2014-05-07 11:20 ` Paul Burton
2014-05-07 11:20 ` [PATCH 2/5] MIPS: Malta: add suspend state entry code Paul Burton
2014-05-07 11:20 ` Paul Burton
2014-05-07 11:20 ` [PATCH 3/5] MIPS: Malta: let PIIX4 respond to PCI special cycles Paul Burton
2014-05-07 11:20 ` Paul Burton
2014-05-07 11:20 ` [PATCH 4/5] MIPS: Malta: hang on halt Paul Burton
2014-05-07 11:20 ` Paul Burton
2014-05-30 16:50 ` Ralf Baechle
2014-05-07 11:22 ` [PATCH v2 5/5] MIPS: Malta: support powering down Paul Burton
2014-05-07 11:22 ` Paul Burton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.