* [PATCH v2 00/14] Partial MIPS Malta DT conversion @ 2016-09-19 21:21 Paul Burton 2016-09-19 21:21 ` [PATCH v2 13/14] power: reset: Add Intel PIIX4 poweroff driver Paul Burton 0 siblings, 1 reply; 5+ messages in thread From: Paul Burton @ 2016-09-19 21:21 UTC (permalink / raw) To: linux-mips-6z/3iImG2C8G8FEW9MqTrA, Ralf Baechle Cc: Paul Burton, Bartlomiej Zolnierkiewicz, Jacek Anaszewski, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Alexander Sverdlin, Sebastian Reichel, Andy Yan, Thomas Gleixner, Alexandre Belloni, Krzysztof Kozlowski, John Stultz, Frank Rowand, Andrew Morton, Chris Brand, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-pm-u79uwXL29TY76Z2rM5mHXA, Matthias Brugger, Marc Zyngier This series begins converting the MIPS Malta board to use device tree to probe its various devices & peripherals, with the eventual goal of including Malta support in generic kernels. In terms of use the only change should be that kernels will automatically make use of more than 256MB DDR when built for 64 bit, or 32 bit with highmem enabled. The series leaves Malta with a significant amount less platform code and thus closer to being ready for inclusion in a generic MIPS kernel. Applies atop v4.8-rc7. Paul Burton (14): irqchip: i8259: Add domain before mapping parent irq irqchip: i8259: Allow platforms to override poll function irqchip: i8259: Remove unused i8259A_irq_pending MIPS: Malta: Allow PCI devices DMA to lower 2GB physical MIPS: Malta: Use all available DDR by default MIPS: Malta: Probe interrupt controllers via DT of/platform: Probe "isa" busses by default MIPS: Malta: Remove custom DT match table MIPS: Malta: Probe RTC via DT MIPS: Malta: Probe pflash via DT MIPS: Malta: Use syscon-reboot driver to reboot MIPS: Malta: Remove custom halt implementation power: reset: Add Intel PIIX4 poweroff driver MIPS: Malta: Use PIIX4 poweroff driver to power down arch/mips/Kconfig | 7 +- arch/mips/boot/dts/mti/malta.dts | 99 +++++++++++++++ arch/mips/configs/malta_defconfig | 5 +- arch/mips/configs/malta_kvm_defconfig | 5 +- arch/mips/configs/malta_kvm_guest_defconfig | 5 +- arch/mips/configs/malta_qemu_32r6_defconfig | 3 + arch/mips/configs/maltaaprp_defconfig | 3 + arch/mips/configs/maltasmvp_defconfig | 3 + arch/mips/configs/maltasmvp_eva_defconfig | 3 + arch/mips/configs/maltaup_defconfig | 3 + arch/mips/configs/maltaup_xpa_defconfig | 5 +- arch/mips/include/asm/i8259.h | 12 +- arch/mips/mti-malta/Makefile | 2 - arch/mips/mti-malta/malta-dt.c | 15 --- arch/mips/mti-malta/malta-dtshim.c | 187 +++++++++++++++++++++++++++- arch/mips/mti-malta/malta-init.c | 17 ++- arch/mips/mti-malta/malta-int.c | 96 +------------- arch/mips/mti-malta/malta-platform.c | 65 ---------- arch/mips/mti-malta/malta-pm.c | 96 -------------- arch/mips/mti-malta/malta-reset.c | 47 ------- drivers/irqchip/irq-i8259.c | 30 ++--- drivers/of/platform.c | 1 + drivers/power/reset/Kconfig | 10 ++ drivers/power/reset/Makefile | 1 + drivers/power/reset/piix4-poweroff.c | 104 ++++++++++++++++ 25 files changed, 461 insertions(+), 363 deletions(-) delete mode 100644 arch/mips/mti-malta/malta-pm.c delete mode 100644 arch/mips/mti-malta/malta-reset.c create mode 100644 drivers/power/reset/piix4-poweroff.c -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 13/14] power: reset: Add Intel PIIX4 poweroff driver 2016-09-19 21:21 [PATCH v2 00/14] Partial MIPS Malta DT conversion Paul Burton @ 2016-09-19 21:21 ` Paul Burton 2016-09-19 23:42 ` Sebastian Reichel 0 siblings, 1 reply; 5+ messages in thread From: Paul Burton @ 2016-09-19 21:21 UTC (permalink / raw) To: linux-mips, Ralf Baechle Cc: Paul Burton, Chris Brand, Alexandre Belloni, linux-kernel, linux-pm, Nicolas Ferre, Dmitry Eremin-Solenikov, Matthias Brugger, Sebastian Reichel, Andy Yan, Krzysztof Kozlowski, David Woodhouse, John Stultz Add a driver which allows powering off the system via an Intel PIIX4 southbridge, by entering the PIIX4 SOff state. This is useful on the MIPS Malta development board, where it will power down the FPGA based board until its ON/NMI button is pressed, or the QEMU implementation of the MIPS Malta board where it will cause QEMU to exit. Signed-off-by: Paul Burton <paul.burton@imgtec.com> --- Changes in v2: - Add MODULE_LICENSE - Allow non-MIPS builds with COMPILE_TEST drivers/power/reset/Kconfig | 10 ++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/piix4-poweroff.c | 104 +++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 drivers/power/reset/piix4-poweroff.c diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index c74c3f6..abeb772 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -104,6 +104,16 @@ config POWER_RESET_MSM help Power off and restart support for Qualcomm boards. +config POWER_RESET_PIIX4_POWEROFF + tristate "Intel PIIX4 power-off driver" + depends on PCI + depends on MIPS || COMPILE_TEST + help + This driver supports powering off a system using the Intel PIIX4 + southbridge, for example the MIPS Malta development board. The + southbridge SOff state is entered in response to a request to + power off the system. + config POWER_RESET_LTC2952 bool "LTC2952 PowerPath power-off driver" depends on OF_GPIO diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index 1be307c..11dae3b 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o obj-$(CONFIG_POWER_RESET_IMX) += imx-snvs-poweroff.o obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o +obj-$(CONFIG_POWER_RESET_PIIX4_POWEROFF) += piix4-poweroff.o obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o diff --git a/drivers/power/reset/piix4-poweroff.c b/drivers/power/reset/piix4-poweroff.c new file mode 100644 index 0000000..11f0999 --- /dev/null +++ b/drivers/power/reset/piix4-poweroff.c @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2016 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/io.h> +#include <linux/module.h> +#include <linux/pci.h> +#include <linux/pm.h> + +static struct pci_dev *pm_dev; +static resource_size_t io_offset; + +enum piix4_pm_io_reg { + PIIX4_FUNC3IO_PMSTS = 0x00, +#define PIIX4_FUNC3IO_PMSTS_PWRBTN_STS BIT(8) + PIIX4_FUNC3IO_PMCNTRL = 0x04, +#define PIIX4_FUNC3IO_PMCNTRL_SUS_EN BIT(13) +#define PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF (0x0 << 10) +}; + +#define PIIX4_SUSPEND_MAGIC 0x00120002 + +static void piix4_poweroff(void) +{ + int spec_devid; + u16 sts; + + /* Ensure the power button status is clear */ + while (1) { + sts = inw(io_offset + PIIX4_FUNC3IO_PMSTS); + if (!(sts & PIIX4_FUNC3IO_PMSTS_PWRBTN_STS)) + break; + outw(sts, io_offset + PIIX4_FUNC3IO_PMSTS); + } + + /* Enable entry to suspend */ + outw(PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF | PIIX4_FUNC3IO_PMCNTRL_SUS_EN, + 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_dev->bus, spec_devid, 0, + PIIX4_SUSPEND_MAGIC); + + /* Give the system some time to power down, then error */ + mdelay(1000); + pr_emerg("Unable to poweroff system\n"); +} + +static int piix4_poweroff_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + int res, io_region = PCI_BRIDGE_RESOURCES; + + /* Request access to the PIIX4 PM IO registers */ + res = pci_request_region(dev, io_region, "PIIX4 PM IO registers"); + if (res) { + dev_err(&dev->dev, "failed to request PM IO registers: %d\n", + res); + return res; + } + + pm_dev = dev; + io_offset = pci_resource_start(dev, io_region); + pm_power_off = piix4_poweroff; + + return 0; +} + +static void piix4_poweroff_remove(struct pci_dev *dev) +{ + if (pm_power_off == piix4_poweroff) + pm_power_off = NULL; +} + +static const struct pci_device_id piix4_poweroff_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3) }, + { 0 }, +}; + +static struct pci_driver piix4_poweroff_driver = { + .name = "piix4-poweroff", + .id_table = piix4_poweroff_ids, + .probe = piix4_poweroff_probe, + .remove = piix4_poweroff_remove, +}; + +module_pci_driver(piix4_poweroff_driver); +MODULE_AUTHOR("Paul Burton <paul.burton@imgtec.com>"); +MODULE_LICENSE("GPL"); -- 2.9.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 13/14] power: reset: Add Intel PIIX4 poweroff driver 2016-09-19 21:21 ` [PATCH v2 13/14] power: reset: Add Intel PIIX4 poweroff driver Paul Burton @ 2016-09-19 23:42 ` Sebastian Reichel 2016-09-28 15:30 ` [PATCH v3 " Paul Burton 0 siblings, 1 reply; 5+ messages in thread From: Sebastian Reichel @ 2016-09-19 23:42 UTC (permalink / raw) To: Paul Burton Cc: linux-mips, Ralf Baechle, Chris Brand, Alexandre Belloni, linux-kernel, linux-pm, Nicolas Ferre, Dmitry Eremin-Solenikov, Matthias Brugger, Andy Yan, Krzysztof Kozlowski, David Woodhouse, John Stultz [-- Attachment #1: Type: text/plain, Size: 5826 bytes --] Hi, On Mon, Sep 19, 2016 at 10:21:30PM +0100, Paul Burton wrote: > Add a driver which allows powering off the system via an Intel PIIX4 > southbridge, by entering the PIIX4 SOff state. This is useful on the > MIPS Malta development board, where it will power down the FPGA based > board until its ON/NMI button is pressed, or the QEMU implementation of > the MIPS Malta board where it will cause QEMU to exit. > > Signed-off-by: Paul Burton <paul.burton@imgtec.com> > > --- > > Changes in v2: > - Add MODULE_LICENSE > - Allow non-MIPS builds with COMPILE_TEST > > drivers/power/reset/Kconfig | 10 ++++ > drivers/power/reset/Makefile | 1 + > drivers/power/reset/piix4-poweroff.c | 104 +++++++++++++++++++++++++++++++++++ > 3 files changed, 115 insertions(+) > create mode 100644 drivers/power/reset/piix4-poweroff.c > > diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig > index c74c3f6..abeb772 100644 > --- a/drivers/power/reset/Kconfig > +++ b/drivers/power/reset/Kconfig > @@ -104,6 +104,16 @@ config POWER_RESET_MSM > help > Power off and restart support for Qualcomm boards. > > +config POWER_RESET_PIIX4_POWEROFF > + tristate "Intel PIIX4 power-off driver" > + depends on PCI > + depends on MIPS || COMPILE_TEST > + help > + This driver supports powering off a system using the Intel PIIX4 > + southbridge, for example the MIPS Malta development board. The > + southbridge SOff state is entered in response to a request to > + power off the system. > + > config POWER_RESET_LTC2952 > bool "LTC2952 PowerPath power-off driver" > depends on OF_GPIO > diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile > index 1be307c..11dae3b 100644 > --- a/drivers/power/reset/Makefile > +++ b/drivers/power/reset/Makefile > @@ -10,6 +10,7 @@ obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o > obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o > obj-$(CONFIG_POWER_RESET_IMX) += imx-snvs-poweroff.o > obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o > +obj-$(CONFIG_POWER_RESET_PIIX4_POWEROFF) += piix4-poweroff.o > obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o > obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o > obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o > diff --git a/drivers/power/reset/piix4-poweroff.c b/drivers/power/reset/piix4-poweroff.c > new file mode 100644 > index 0000000..11f0999 > --- /dev/null > +++ b/drivers/power/reset/piix4-poweroff.c > @@ -0,0 +1,104 @@ > +/* > + * Copyright (C) 2016 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/io.h> > +#include <linux/module.h> > +#include <linux/pci.h> > +#include <linux/pm.h> > + > +static struct pci_dev *pm_dev; > +static resource_size_t io_offset; > + > +enum piix4_pm_io_reg { > + PIIX4_FUNC3IO_PMSTS = 0x00, > +#define PIIX4_FUNC3IO_PMSTS_PWRBTN_STS BIT(8) > + PIIX4_FUNC3IO_PMCNTRL = 0x04, > +#define PIIX4_FUNC3IO_PMCNTRL_SUS_EN BIT(13) > +#define PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF (0x0 << 10) > +}; > + > +#define PIIX4_SUSPEND_MAGIC 0x00120002 > + > +static void piix4_poweroff(void) > +{ > + int spec_devid; > + u16 sts; > + > + /* Ensure the power button status is clear */ > + while (1) { > + sts = inw(io_offset + PIIX4_FUNC3IO_PMSTS); > + if (!(sts & PIIX4_FUNC3IO_PMSTS_PWRBTN_STS)) > + break; > + outw(sts, io_offset + PIIX4_FUNC3IO_PMSTS); > + } > + > + /* Enable entry to suspend */ > + outw(PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF | PIIX4_FUNC3IO_PMCNTRL_SUS_EN, > + 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_dev->bus, spec_devid, 0, > + PIIX4_SUSPEND_MAGIC); > + > + /* Give the system some time to power down, then error */ > + mdelay(1000); > + pr_emerg("Unable to poweroff system\n"); > +} > + > +static int piix4_poweroff_probe(struct pci_dev *dev, > + const struct pci_device_id *id) > +{ > + int res, io_region = PCI_BRIDGE_RESOURCES; if (pm_dev) return -EINVAL; > + /* Request access to the PIIX4 PM IO registers */ > + res = pci_request_region(dev, io_region, "PIIX4 PM IO registers"); > + if (res) { > + dev_err(&dev->dev, "failed to request PM IO registers: %d\n", > + res); > + return res; > + } > + > + pm_dev = dev; > + io_offset = pci_resource_start(dev, io_region); > + pm_power_off = piix4_poweroff; > + > + return 0; > +} > + > +static void piix4_poweroff_remove(struct pci_dev *dev) > +{ > + if (pm_power_off == piix4_poweroff) > + pm_power_off = NULL; pci_release_region() > +} > + > +static const struct pci_device_id piix4_poweroff_ids[] = { > + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3) }, > + { 0 }, > +}; > + > +static struct pci_driver piix4_poweroff_driver = { > + .name = "piix4-poweroff", > + .id_table = piix4_poweroff_ids, > + .probe = piix4_poweroff_probe, > + .remove = piix4_poweroff_remove, > +}; > + > +module_pci_driver(piix4_poweroff_driver); > +MODULE_AUTHOR("Paul Burton <paul.burton@imgtec.com>"); > +MODULE_LICENSE("GPL"); -- Sebastian [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 13/14] power: reset: Add Intel PIIX4 poweroff driver 2016-09-19 23:42 ` Sebastian Reichel @ 2016-09-28 15:30 ` Paul Burton 2016-10-19 2:52 ` Sebastian Reichel 0 siblings, 1 reply; 5+ messages in thread From: Paul Burton @ 2016-09-28 15:30 UTC (permalink / raw) To: linux-mips Cc: Ralf Baechle, Paul Burton, Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse, linux-pm Add a driver which allows powering off the system via an Intel PIIX4 southbridge, by entering the PIIX4 SOff state. This is useful on the MIPS Malta development board, where it will power down the FPGA based board until its ON/NMI button is pressed, or the QEMU implementation of the MIPS Malta board where it will cause QEMU to exit. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Cc: Sebastian Reichel <sre@kernel.org> Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: linux-pm@vger.kernel.org --- Changes in v3: - Fail probe with -EINVAL if pm_dev is already set - Release PCI I/O region in remove callback Changes in v2: - Add MODULE_LICENSE - Allow non-MIPS builds with COMPILE_TEST drivers/power/reset/Kconfig | 10 ++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/piix4-poweroff.c | 113 +++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 drivers/power/reset/piix4-poweroff.c diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index c74c3f6..abeb772 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -104,6 +104,16 @@ config POWER_RESET_MSM help Power off and restart support for Qualcomm boards. +config POWER_RESET_PIIX4_POWEROFF + tristate "Intel PIIX4 power-off driver" + depends on PCI + depends on MIPS || COMPILE_TEST + help + This driver supports powering off a system using the Intel PIIX4 + southbridge, for example the MIPS Malta development board. The + southbridge SOff state is entered in response to a request to + power off the system. + config POWER_RESET_LTC2952 bool "LTC2952 PowerPath power-off driver" depends on OF_GPIO diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index 1be307c..11dae3b 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o obj-$(CONFIG_POWER_RESET_IMX) += imx-snvs-poweroff.o obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o +obj-$(CONFIG_POWER_RESET_PIIX4_POWEROFF) += piix4-poweroff.o obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o diff --git a/drivers/power/reset/piix4-poweroff.c b/drivers/power/reset/piix4-poweroff.c new file mode 100644 index 0000000..bacfc95 --- /dev/null +++ b/drivers/power/reset/piix4-poweroff.c @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2016 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/io.h> +#include <linux/module.h> +#include <linux/pci.h> +#include <linux/pm.h> + +static struct pci_dev *pm_dev; +static resource_size_t io_offset; + +enum piix4_pm_io_reg { + PIIX4_FUNC3IO_PMSTS = 0x00, +#define PIIX4_FUNC3IO_PMSTS_PWRBTN_STS BIT(8) + PIIX4_FUNC3IO_PMCNTRL = 0x04, +#define PIIX4_FUNC3IO_PMCNTRL_SUS_EN BIT(13) +#define PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF (0x0 << 10) +}; + +#define PIIX4_SUSPEND_MAGIC 0x00120002 + +static const int piix4_pm_io_region = PCI_BRIDGE_RESOURCES; + +static void piix4_poweroff(void) +{ + int spec_devid; + u16 sts; + + /* Ensure the power button status is clear */ + while (1) { + sts = inw(io_offset + PIIX4_FUNC3IO_PMSTS); + if (!(sts & PIIX4_FUNC3IO_PMSTS_PWRBTN_STS)) + break; + outw(sts, io_offset + PIIX4_FUNC3IO_PMSTS); + } + + /* Enable entry to suspend */ + outw(PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF | PIIX4_FUNC3IO_PMCNTRL_SUS_EN, + 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_dev->bus, spec_devid, 0, + PIIX4_SUSPEND_MAGIC); + + /* Give the system some time to power down, then error */ + mdelay(1000); + pr_emerg("Unable to poweroff system\n"); +} + +static int piix4_poweroff_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + int res; + + if (pm_dev) + return -EINVAL; + + /* Request access to the PIIX4 PM IO registers */ + res = pci_request_region(dev, piix4_pm_io_region, + "PIIX4 PM IO registers"); + if (res) { + dev_err(&dev->dev, "failed to request PM IO registers: %d\n", + res); + return res; + } + + pm_dev = dev; + io_offset = pci_resource_start(dev, piix4_pm_io_region); + pm_power_off = piix4_poweroff; + + return 0; +} + +static void piix4_poweroff_remove(struct pci_dev *dev) +{ + if (pm_power_off == piix4_poweroff) + pm_power_off = NULL; + + pci_release_region(dev, piix4_pm_io_region); + pm_dev = NULL; +} + +static const struct pci_device_id piix4_poweroff_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3) }, + { 0 }, +}; + +static struct pci_driver piix4_poweroff_driver = { + .name = "piix4-poweroff", + .id_table = piix4_poweroff_ids, + .probe = piix4_poweroff_probe, + .remove = piix4_poweroff_remove, +}; + +module_pci_driver(piix4_poweroff_driver); +MODULE_AUTHOR("Paul Burton <paul.burton@imgtec.com>"); +MODULE_LICENSE("GPL"); -- 2.10.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 13/14] power: reset: Add Intel PIIX4 poweroff driver 2016-09-28 15:30 ` [PATCH v3 " Paul Burton @ 2016-10-19 2:52 ` Sebastian Reichel 0 siblings, 0 replies; 5+ messages in thread From: Sebastian Reichel @ 2016-10-19 2:52 UTC (permalink / raw) To: Paul Burton Cc: linux-mips, Ralf Baechle, Dmitry Eremin-Solenikov, David Woodhouse, linux-pm [-- Attachment #1: Type: text/plain, Size: 686 bytes --] Hi, On Wed, Sep 28, 2016 at 04:30:56PM +0100, Paul Burton wrote: > Add a driver which allows powering off the system via an Intel PIIX4 > southbridge, by entering the PIIX4 SOff state. This is useful on the > MIPS Malta development board, where it will power down the FPGA based > board until its ON/NMI button is pressed, or the QEMU implementation of > the MIPS Malta board where it will cause QEMU to exit. > > Signed-off-by: Paul Burton <paul.burton@imgtec.com> > Cc: Sebastian Reichel <sre@kernel.org> > Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> > Cc: David Woodhouse <dwmw2@infradead.org> > Cc: linux-pm@vger.kernel.org Thanks, queued. -- Sebastian [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 801 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-10-19 2:52 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-09-19 21:21 [PATCH v2 00/14] Partial MIPS Malta DT conversion Paul Burton 2016-09-19 21:21 ` [PATCH v2 13/14] power: reset: Add Intel PIIX4 poweroff driver Paul Burton 2016-09-19 23:42 ` Sebastian Reichel 2016-09-28 15:30 ` [PATCH v3 " Paul Burton 2016-10-19 2:52 ` Sebastian Reichel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox