Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Malta: Use PIIX4 poweroff driver to power down

Remove the platform code used to power down the system, instead relying
upon the new PIIX4 poweroff driver. This reduces the amount of platform
code required for the Malta board in preparation for allowing it to be
part of a more generic kernel.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Patchwork: https://patchwork.linux-mips.org/patch/14282/

+9 -134
-6
arch/mips/Kconfig
··· 1974 1974 config SYS_HAS_CPU_XLP 1975 1975 bool 1976 1976 1977 - config MIPS_MALTA_PM 1978 - depends on MIPS_MALTA 1979 - depends on PCI 1980 - bool 1981 - default y 1982 - 1983 1977 # 1984 1978 # CPU may reorder R->R, R->W, W->R, W->W 1985 1979 # Reordering beyond LL and SC is handled in WEAK_REORDERING_BEYOND_LLSC
+1
arch/mips/configs/malta_defconfig
··· 317 317 CONFIG_SERIAL_8250=y 318 318 CONFIG_SERIAL_8250_CONSOLE=y 319 319 CONFIG_POWER_RESET=y 320 + CONFIG_POWER_RESET_PIIX4_POWEROFF=y 320 321 CONFIG_POWER_RESET_SYSCON=y 321 322 # CONFIG_HWMON is not set 322 323 CONFIG_FB=y
+1
arch/mips/configs/malta_kvm_defconfig
··· 328 328 CONFIG_SERIAL_8250=y 329 329 CONFIG_SERIAL_8250_CONSOLE=y 330 330 CONFIG_POWER_RESET=y 331 + CONFIG_POWER_RESET_PIIX4_POWEROFF=y 331 332 CONFIG_POWER_RESET_SYSCON=y 332 333 # CONFIG_HWMON is not set 333 334 CONFIG_FB=y
+1
arch/mips/configs/malta_kvm_guest_defconfig
··· 330 330 CONFIG_SERIAL_8250=y 331 331 CONFIG_SERIAL_8250_CONSOLE=y 332 332 CONFIG_POWER_RESET=y 333 + CONFIG_POWER_RESET_PIIX4_POWEROFF=y 333 334 CONFIG_POWER_RESET_SYSCON=y 334 335 # CONFIG_HWMON is not set 335 336 CONFIG_FB=y
+1
arch/mips/configs/malta_qemu_32r6_defconfig
··· 133 133 CONFIG_SERIAL_8250_CONSOLE=y 134 134 CONFIG_HW_RANDOM=y 135 135 CONFIG_POWER_RESET=y 136 + CONFIG_POWER_RESET_PIIX4_POWEROFF=y 136 137 CONFIG_POWER_RESET_SYSCON=y 137 138 # CONFIG_HWMON is not set 138 139 CONFIG_FB=y
+1
arch/mips/configs/maltaaprp_defconfig
··· 133 133 CONFIG_SERIAL_8250_CONSOLE=y 134 134 CONFIG_HW_RANDOM=y 135 135 CONFIG_POWER_RESET=y 136 + CONFIG_POWER_RESET_PIIX4_POWEROFF=y 136 137 CONFIG_POWER_RESET_SYSCON=y 137 138 # CONFIG_HWMON is not set 138 139 CONFIG_FB=y
+1
arch/mips/configs/maltasmvp_defconfig
··· 134 134 CONFIG_SERIAL_8250_CONSOLE=y 135 135 CONFIG_HW_RANDOM=y 136 136 CONFIG_POWER_RESET=y 137 + CONFIG_POWER_RESET_PIIX4_POWEROFF=y 137 138 CONFIG_POWER_RESET_SYSCON=y 138 139 # CONFIG_HWMON is not set 139 140 CONFIG_FB=y
+1
arch/mips/configs/maltasmvp_eva_defconfig
··· 137 137 CONFIG_SERIAL_8250_CONSOLE=y 138 138 CONFIG_HW_RANDOM=y 139 139 CONFIG_POWER_RESET=y 140 + CONFIG_POWER_RESET_PIIX4_POWEROFF=y 140 141 CONFIG_POWER_RESET_SYSCON=y 141 142 # CONFIG_HWMON is not set 142 143 CONFIG_FB=y
+1
arch/mips/configs/maltaup_defconfig
··· 132 132 CONFIG_SERIAL_8250_CONSOLE=y 133 133 CONFIG_HW_RANDOM=y 134 134 CONFIG_POWER_RESET=y 135 + CONFIG_POWER_RESET_PIIX4_POWEROFF=y 135 136 CONFIG_POWER_RESET_SYSCON=y 136 137 # CONFIG_HWMON is not set 137 138 CONFIG_FB=y
+1
arch/mips/configs/maltaup_xpa_defconfig
··· 326 326 CONFIG_SERIAL_8250=y 327 327 CONFIG_SERIAL_8250_CONSOLE=y 328 328 CONFIG_POWER_RESET=y 329 + CONFIG_POWER_RESET_PIIX4_POWEROFF=y 329 330 CONFIG_POWER_RESET_SYSCON=y 330 331 # CONFIG_HWMON is not set 331 332 CONFIG_FB=y
-2
arch/mips/mti-malta/Makefile
··· 13 13 obj-y += malta-int.o 14 14 obj-y += malta-memory.o 15 15 obj-y += malta-platform.o 16 - obj-y += malta-reset.o 17 16 obj-y += malta-setup.o 18 17 obj-y += malta-time.o 19 18 20 19 obj-$(CONFIG_MIPS_CMP) += malta-amon.o 21 - obj-$(CONFIG_MIPS_MALTA_PM) += malta-pm.o 22 20 23 21 CFLAGS_malta-dtshim.o = -I$(src)/../../../scripts/dtc/libfdt
-96
arch/mips/mti-malta/malta-pm.c
··· 1 - /* 2 - * Copyright (C) 2014 Imagination Technologies 3 - * Author: Paul Burton <paul.burton@mips.com> 4 - * 5 - * This program is free software; you can redistribute it and/or modify it 6 - * under the terms of the GNU General Public License as published by the 7 - * Free Software Foundation; either version 2 of the License, or (at your 8 - * option) any later version. 9 - */ 10 - 11 - #include <linux/delay.h> 12 - #include <linux/init.h> 13 - #include <linux/io.h> 14 - #include <linux/pci.h> 15 - 16 - #include <asm/mach-malta/malta-pm.h> 17 - 18 - static struct pci_bus *pm_pci_bus; 19 - static resource_size_t pm_io_offset; 20 - 21 - int mips_pm_suspend(unsigned state) 22 - { 23 - int spec_devid; 24 - u16 sts; 25 - 26 - if (!pm_pci_bus || !pm_io_offset) 27 - return -ENODEV; 28 - 29 - /* Ensure the power button status is clear */ 30 - while (1) { 31 - sts = inw(pm_io_offset + PIIX4_FUNC3IO_PMSTS); 32 - if (!(sts & PIIX4_FUNC3IO_PMSTS_PWRBTN_STS)) 33 - break; 34 - outw(sts, pm_io_offset + PIIX4_FUNC3IO_PMSTS); 35 - } 36 - 37 - /* Enable entry to suspend */ 38 - outw(state | PIIX4_FUNC3IO_PMCNTRL_SUS_EN, 39 - pm_io_offset + PIIX4_FUNC3IO_PMCNTRL); 40 - 41 - /* If the special cycle occurs too soon this doesn't work... */ 42 - mdelay(10); 43 - 44 - /* 45 - * The PIIX4 will enter the suspend state only after seeing a special 46 - * cycle with the correct magic data on the PCI bus. Generate that 47 - * cycle now. 48 - */ 49 - spec_devid = PCI_DEVID(0, PCI_DEVFN(0x1f, 0x7)); 50 - pci_bus_write_config_dword(pm_pci_bus, spec_devid, 0, 51 - PIIX4_SUSPEND_MAGIC); 52 - 53 - /* Give the system some time to power down */ 54 - mdelay(1000); 55 - 56 - return 0; 57 - } 58 - 59 - static int __init malta_pm_setup(void) 60 - { 61 - struct pci_dev *dev; 62 - int res, io_region = PCI_BRIDGE_RESOURCES; 63 - 64 - /* Find a reference to the PCI bus */ 65 - pm_pci_bus = pci_find_next_bus(NULL); 66 - if (!pm_pci_bus) { 67 - pr_warn("malta-pm: failed to find reference to PCI bus\n"); 68 - return -ENODEV; 69 - } 70 - 71 - /* Find the PIIX4 PM device */ 72 - dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 73 - PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, 74 - PCI_ANY_ID, NULL); 75 - if (!dev) { 76 - pr_warn("malta-pm: failed to find PIIX4 PM\n"); 77 - return -ENODEV; 78 - } 79 - 80 - /* Request access to the PIIX4 PM IO registers */ 81 - res = pci_request_region(dev, io_region, "PIIX4 PM IO registers"); 82 - if (res) { 83 - pr_warn("malta-pm: failed to request PM IO registers (%d)\n", 84 - res); 85 - pci_dev_put(dev); 86 - return -ENODEV; 87 - } 88 - 89 - /* Find the offset to the PIIX4 PM IO registers */ 90 - pm_io_offset = pci_resource_start(dev, io_region); 91 - 92 - pci_dev_put(dev); 93 - return 0; 94 - } 95 - 96 - late_initcall(malta_pm_setup);
-30
arch/mips/mti-malta/malta-reset.c
··· 1 - /* 2 - * This file is subject to the terms and conditions of the GNU General Public 3 - * License. See the file "COPYING" in the main directory of this archive 4 - * for more details. 5 - * 6 - * Carsten Langgaard, carstenl@mips.com 7 - * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. 8 - */ 9 - #include <linux/io.h> 10 - #include <linux/pm.h> 11 - #include <linux/reboot.h> 12 - 13 - #include <asm/reboot.h> 14 - #include <asm/mach-malta/malta-pm.h> 15 - 16 - static void mips_machine_power_off(void) 17 - { 18 - mips_pm_suspend(PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF); 19 - 20 - pr_info("Failed to power down, resetting\n"); 21 - machine_restart(NULL); 22 - } 23 - 24 - static int __init mips_reboot_setup(void) 25 - { 26 - pm_power_off = mips_machine_power_off; 27 - 28 - return 0; 29 - } 30 - arch_initcall(mips_reboot_setup);