xref: /linux/arch/x86/platform/intel-mid/intel-mid.c (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1b886d83cSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
205454c26SKuppuswamy Sathyanarayanan /*
3c9c26882SAndy Shevchenko  * Intel MID platform setup code
405454c26SKuppuswamy Sathyanarayanan  *
5c9c26882SAndy Shevchenko  * (C) Copyright 2008, 2012, 2021 Intel Corporation
605454c26SKuppuswamy Sathyanarayanan  * Author: Jacob Pan (jacob.jun.pan@intel.com)
705454c26SKuppuswamy Sathyanarayanan  * Author: Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>
805454c26SKuppuswamy Sathyanarayanan  */
905454c26SKuppuswamy Sathyanarayanan 
10712b6aa8SKuppuswamy Sathyanarayanan #define pr_fmt(fmt) "intel_mid: " fmt
1105454c26SKuppuswamy Sathyanarayanan 
1205454c26SKuppuswamy Sathyanarayanan #include <linux/init.h>
1305454c26SKuppuswamy Sathyanarayanan #include <linux/kernel.h>
1405454c26SKuppuswamy Sathyanarayanan #include <linux/interrupt.h>
15a11836faSAndy Shevchenko #include <linux/regulator/machine.h>
1605454c26SKuppuswamy Sathyanarayanan #include <linux/scatterlist.h>
1705454c26SKuppuswamy Sathyanarayanan #include <linux/irq.h>
18cc3ae7b0SPaul Gortmaker #include <linux/export.h>
1905454c26SKuppuswamy Sathyanarayanan #include <linux/notifier.h>
2005454c26SKuppuswamy Sathyanarayanan 
2105454c26SKuppuswamy Sathyanarayanan #include <asm/setup.h>
2205454c26SKuppuswamy Sathyanarayanan #include <asm/mpspec_def.h>
2305454c26SKuppuswamy Sathyanarayanan #include <asm/hw_irq.h>
2405454c26SKuppuswamy Sathyanarayanan #include <asm/apic.h>
252cf615a4STony Luck #include <asm/cpu_device_id.h>
2605454c26SKuppuswamy Sathyanarayanan #include <asm/io_apic.h>
2705454c26SKuppuswamy Sathyanarayanan #include <asm/intel-mid.h>
2805454c26SKuppuswamy Sathyanarayanan #include <asm/io.h>
2905454c26SKuppuswamy Sathyanarayanan #include <asm/i8259.h>
3005454c26SKuppuswamy Sathyanarayanan #include <asm/reboot.h>
3105454c26SKuppuswamy Sathyanarayanan 
32*c912ac66SMika Westerberg #include <linux/platform_data/x86/intel_scu_ipc.h>
33*c912ac66SMika Westerberg 
346517da7aSAndy Shevchenko #define IPCMSG_COLD_OFF		0x80	/* Only for Tangier */
356517da7aSAndy Shevchenko #define IPCMSG_COLD_RESET	0xF1
366517da7aSAndy Shevchenko 
intel_mid_power_off(void)3785611e3fSKuppuswamy Sathyanarayanan static void intel_mid_power_off(void)
3885611e3fSKuppuswamy Sathyanarayanan {
39bda7b072SAndy Shevchenko 	/* Shut down South Complex via PWRMU */
40bda7b072SAndy Shevchenko 	intel_mid_pwr_power_off();
41bda7b072SAndy Shevchenko 
42bda7b072SAndy Shevchenko 	/* Only for Tangier, the rest will ignore this command */
436517da7aSAndy Shevchenko 	intel_scu_ipc_dev_simple_command(NULL, IPCMSG_COLD_OFF, 1);
4485611e3fSKuppuswamy Sathyanarayanan };
4585611e3fSKuppuswamy Sathyanarayanan 
intel_mid_reboot(void)46712b6aa8SKuppuswamy Sathyanarayanan static void intel_mid_reboot(void)
4705454c26SKuppuswamy Sathyanarayanan {
486517da7aSAndy Shevchenko 	intel_scu_ipc_dev_simple_command(NULL, IPCMSG_COLD_RESET, 0);
4905454c26SKuppuswamy Sathyanarayanan }
5005454c26SKuppuswamy Sathyanarayanan 
intel_mid_time_init(void)51712b6aa8SKuppuswamy Sathyanarayanan static void __init intel_mid_time_init(void)
5205454c26SKuppuswamy Sathyanarayanan {
536648d1b4SThomas Gleixner 	/* Lapic only, no apbt */
5405454c26SKuppuswamy Sathyanarayanan 	x86_init.timers.setup_percpu_clockev = setup_boot_APIC_clock;
5505454c26SKuppuswamy Sathyanarayanan 	x86_cpuinit.setup_percpu_clockev = setup_secondary_APIC_clock;
5605454c26SKuppuswamy Sathyanarayanan }
5705454c26SKuppuswamy Sathyanarayanan 
intel_mid_arch_setup(void)58aeeca404SPaul Gortmaker static void intel_mid_arch_setup(void)
5905454c26SKuppuswamy Sathyanarayanan {
602cf615a4STony Luck 	switch (boot_cpu_data.x86_vfm) {
612cf615a4STony Luck 	case INTEL_ATOM_SILVERMONT_MID:
6241afb1dfSAndy Shevchenko 		x86_platform.legacy.rtc = 1;
63bc20aa48SDavid Cohen 		break;
6485611e3fSKuppuswamy Sathyanarayanan 	default:
6585611e3fSKuppuswamy Sathyanarayanan 		break;
6685611e3fSKuppuswamy Sathyanarayanan 	}
6785611e3fSKuppuswamy Sathyanarayanan 
68a11836faSAndy Shevchenko 	/*
69a11836faSAndy Shevchenko 	 * Intel MID platforms are using explicitly defined regulators.
70a11836faSAndy Shevchenko 	 *
71a11836faSAndy Shevchenko 	 * Let the regulator core know that we do not have any additional
72a11836faSAndy Shevchenko 	 * regulators left. This lets it substitute unprovided regulators with
73a11836faSAndy Shevchenko 	 * dummy ones:
74a11836faSAndy Shevchenko 	 */
75a11836faSAndy Shevchenko 	regulator_has_full_constraints();
7605454c26SKuppuswamy Sathyanarayanan }
7705454c26SKuppuswamy Sathyanarayanan 
7805454c26SKuppuswamy Sathyanarayanan /*
7905454c26SKuppuswamy Sathyanarayanan  * Moorestown does not have external NMI source nor port 0x61 to report
8005454c26SKuppuswamy Sathyanarayanan  * NMI status. The possible NMI sources are from pmu as a result of NMI
8105454c26SKuppuswamy Sathyanarayanan  * watchdog or lock debug. Reading io port 0x61 results in 0xff which
8205454c26SKuppuswamy Sathyanarayanan  * misled NMI handler.
8305454c26SKuppuswamy Sathyanarayanan  */
intel_mid_get_nmi_reason(void)84712b6aa8SKuppuswamy Sathyanarayanan static unsigned char intel_mid_get_nmi_reason(void)
8505454c26SKuppuswamy Sathyanarayanan {
8605454c26SKuppuswamy Sathyanarayanan 	return 0;
8705454c26SKuppuswamy Sathyanarayanan }
8805454c26SKuppuswamy Sathyanarayanan 
8905454c26SKuppuswamy Sathyanarayanan /*
9005454c26SKuppuswamy Sathyanarayanan  * Moorestown specific x86_init function overrides and early setup
9105454c26SKuppuswamy Sathyanarayanan  * calls.
9205454c26SKuppuswamy Sathyanarayanan  */
x86_intel_mid_early_setup(void)93712b6aa8SKuppuswamy Sathyanarayanan void __init x86_intel_mid_early_setup(void)
9405454c26SKuppuswamy Sathyanarayanan {
9505454c26SKuppuswamy Sathyanarayanan 	x86_init.resources.probe_roms = x86_init_noop;
9605454c26SKuppuswamy Sathyanarayanan 	x86_init.resources.reserve_resources = x86_init_noop;
9705454c26SKuppuswamy Sathyanarayanan 
98712b6aa8SKuppuswamy Sathyanarayanan 	x86_init.timers.timer_init = intel_mid_time_init;
9905454c26SKuppuswamy Sathyanarayanan 	x86_init.timers.setup_percpu_clockev = x86_init_noop;
10005454c26SKuppuswamy Sathyanarayanan 
10105454c26SKuppuswamy Sathyanarayanan 	x86_init.irqs.pre_vector_init = x86_init_noop;
10205454c26SKuppuswamy Sathyanarayanan 
103712b6aa8SKuppuswamy Sathyanarayanan 	x86_init.oem.arch_setup = intel_mid_arch_setup;
10405454c26SKuppuswamy Sathyanarayanan 
105712b6aa8SKuppuswamy Sathyanarayanan 	x86_platform.get_nmi_reason = intel_mid_get_nmi_reason;
10605454c26SKuppuswamy Sathyanarayanan 
107a912a758SAndy Shevchenko 	x86_init.pci.arch_init = intel_mid_pci_init;
10805454c26SKuppuswamy Sathyanarayanan 	x86_init.pci.fixup_irqs = x86_init_noop;
10905454c26SKuppuswamy Sathyanarayanan 
11005454c26SKuppuswamy Sathyanarayanan 	legacy_pic = &null_legacy_pic;
11105454c26SKuppuswamy Sathyanarayanan 
11202428742SAndy Shevchenko 	/*
11302428742SAndy Shevchenko 	 * Do nothing for now as everything needed done in
11402428742SAndy Shevchenko 	 * x86_intel_mid_early_setup() below.
11502428742SAndy Shevchenko 	 */
11602428742SAndy Shevchenko 	x86_init.acpi.reduced_hw_early_init = x86_init_noop;
11702428742SAndy Shevchenko 
118712b6aa8SKuppuswamy Sathyanarayanan 	pm_power_off = intel_mid_power_off;
119712b6aa8SKuppuswamy Sathyanarayanan 	machine_ops.emergency_restart  = intel_mid_reboot;
12005454c26SKuppuswamy Sathyanarayanan 
12105454c26SKuppuswamy Sathyanarayanan 	/* Avoid searching for BIOS MP tables */
122e061c7aeSThomas Gleixner 	x86_init.mpparse.find_mptable		= x86_init_noop;
123a626ded4SThomas Gleixner 	x86_init.mpparse.early_parse_smp_cfg	= x86_init_noop;
124a626ded4SThomas Gleixner 	x86_init.mpparse.parse_smp_cfg		= x86_init_noop;
12505454c26SKuppuswamy Sathyanarayanan 	set_bit(MP_BUS_ISA, mp_bus_not_pci);
12605454c26SKuppuswamy Sathyanarayanan }
127