Commit 119581e5 authored by Jing Li's avatar Jing Li Committed by guzitao
Browse files

sw64: pci: remove function fix_jm585_reset()

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IB73UR



--------------------------------

Remove function fix_jm585_reset() and add a PCI quirk to fix the issue
of JMicron 585 SATA card when reboot.

Signed-off-by: default avatarJing Li <jingli@wxiat.com>
Reviewed-by: default avatarHe Sheng <hesheng@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent 5923165a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ extern void (*pm_restart)(void);
extern void (*pm_halt)(void);
extern int i2c_set_adapter(void);
extern void cpld_write(uint8_t slave_addr, uint8_t reg, uint8_t data);
extern void fix_jm585_reset(void);
extern void early_parse_fdt_property(const void *fdt, const char *path,
		const char *prop_name, u64 *property, int size);

+3 −23
Original line number Diff line number Diff line
@@ -8,32 +8,13 @@
#include <linux/efi.h>
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/pm.h>
#include <linux/reboot.h>
#include <linux/types.h>

#include <acpi/reboot.h>
#include <asm/idle.h>
#include <asm/sw64io.h>

void fix_jm585_reset(void)
{
	struct pci_dev *pdev;
	struct pci_controller *hose;
	int val;

	pdev = pci_get_device(PCI_VENDOR_ID_JMICRON,
				0x0585, NULL);
	if (pdev) {
		hose = pci_bus_to_pci_controller(pdev->bus);
		val = readl(hose->rc_config_space_base + RC_PORT_LINK_CTL);
		writel((val | 0x8), (hose->rc_config_space_base + RC_PORT_LINK_CTL));
		writel(val, (hose->rc_config_space_base + RC_PORT_LINK_CTL));

	}

}
static void default_halt(void)
{
	local_irq_disable();
@@ -57,10 +38,6 @@ static void default_poweroff(void)

static void default_restart(void)
{
	/* No point in taking interrupts anymore. */
	local_irq_disable();

	fix_jm585_reset();
#ifdef CONFIG_EFI
	if (efi_capsule_pending(NULL))
		efi_reboot(REBOOT_WARM, NULL);
@@ -103,6 +80,9 @@ void machine_restart(char *command)
	preempt_disable();
	smp_send_stop();
#endif
	/* No point in taking interrupts anymore. */
	local_irq_disable();

	do_kernel_restart(command);
	pm_restart();
}
+30 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
#include <linux/pci.h>
#include <linux/pci-ecam.h>
#include <linux/acpi.h>
#include <linux/reboot.h>

#include <asm/pci.h>
#include <asm/sw64_init.h>
@@ -265,6 +266,35 @@ static void enable_sw_dca(struct pci_dev *dev)
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, enable_sw_dca);
#endif

static int jm585_restart_notify(struct notifier_block *nb, unsigned long action,
		void *data)
{
	struct pci_dev *pdev;
	struct pci_controller *hose;
	int val;

	pdev = pci_get_device(PCI_VENDOR_ID_JMICRON, 0x0585, NULL);
	if (pdev) {
		hose = pci_bus_to_pci_controller(pdev->bus);
		val = readl(hose->rc_config_space_base + RC_PORT_LINK_CTL);
		writel((val | 0x8), (hose->rc_config_space_base + RC_PORT_LINK_CTL));
		writel(val, (hose->rc_config_space_base + RC_PORT_LINK_CTL));
	}

	return NOTIFY_DONE;
}

static void quirk_jm585_restart(struct pci_dev *dev)
{
	static struct notifier_block jm585_restart_nb = {
		.notifier_call = jm585_restart_notify,
		.priority = 128,
	};

	register_restart_handler(&jm585_restart_nb);
}
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_JMICRON, 0x0585, quirk_jm585_restart);

/**
 * There are some special aspects to the Root Complex of Sunway:
 * 1. Root Complex config space base addr is different
+2 −3
Original line number Diff line number Diff line
@@ -41,10 +41,9 @@ void sw64_poweroff(void)

void sw64_restart(void)
{
	if (is_in_host()) {
		fix_jm585_reset();
	if (is_in_host())
		cpld_write(0x64, 0x00, 0xc3);
	} else
	else
		vt_mode_kill_arch(LINUX_REBOOT_CMD_RESTART);
}

+2 −3
Original line number Diff line number Diff line
@@ -42,10 +42,9 @@ void sw64_poweroff(void)

void sw64_restart(void)
{
	if (is_in_host()) {
		fix_jm585_reset();
	if (is_in_host())
		cpld_write(0x64, 0x00, 0xc3);
	} else
	else
		vt_mode_kill_arch(LINUX_REBOOT_CMD_RESTART);
}