Commit 0cfd2440 authored by Jiaxun Yang's avatar Jiaxun Yang Committed by Thomas Bogendoerfer

MIPS: Loongson64: Make RS780E ACPI as a platform driver

Make RS780E ACPI as a platform driver so we can enable it
by DeviceTree selectively.
Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
parent a746f50d
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# Makefile for Loongson-3 family machines # Makefile for Loongson-3 family machines
# #
obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o platform.o acpi_init.o dma.o \ obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o platform.o dma.o \
setup.o init.o env.o time.o reset.o \ setup.o init.o env.o time.o reset.o \
obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SMP) += smp.o
......
...@@ -43,8 +43,6 @@ static int __init pcibios_init(void) ...@@ -43,8 +43,6 @@ static int __init pcibios_init(void)
register_pci_controller(&loongson_pci_controller); register_pci_controller(&loongson_pci_controller);
sbx00_acpi_init();
return 0; return 0;
} }
......
...@@ -24,4 +24,10 @@ config CPU_HWMON ...@@ -24,4 +24,10 @@ config CPU_HWMON
help help
Loongson-3A/3B CPU Hwmon (temperature sensor) driver. Loongson-3A/3B CPU Hwmon (temperature sensor) driver.
config RS780E_ACPI
bool "Loongson RS780E ACPI Controller"
depends on MACH_LOONGSON64 || COMPILE_TEST
help
Loongson RS780E PCH ACPI Controller driver.
endif # MIPS_PLATFORM_DEVICES endif # MIPS_PLATFORM_DEVICES
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_CPU_HWMON) += cpu_hwmon.o obj-$(CONFIG_CPU_HWMON) += cpu_hwmon.o
obj-$(CONFIG_RS780E_ACPI) += rs780e-acpi.o
...@@ -3,32 +3,23 @@ ...@@ -3,32 +3,23 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#define SBX00_ACPI_IO_BASE 0x800 static unsigned long acpi_iobase;
#define SBX00_ACPI_IO_SIZE 0x100
#define ACPI_PM_EVT_BLK (SBX00_ACPI_IO_BASE + 0x00) /* 4 bytes */ #define ACPI_PM_EVT_BLK (acpi_iobase + 0x00) /* 4 bytes */
#define ACPI_PM_CNT_BLK (SBX00_ACPI_IO_BASE + 0x04) /* 2 bytes */ #define ACPI_PM_CNT_BLK (acpi_iobase + 0x04) /* 2 bytes */
#define ACPI_PMA_CNT_BLK (SBX00_ACPI_IO_BASE + 0x0F) /* 1 byte */ #define ACPI_PMA_CNT_BLK (acpi_iobase + 0x0F) /* 1 byte */
#define ACPI_PM_TMR_BLK (SBX00_ACPI_IO_BASE + 0x18) /* 4 bytes */ #define ACPI_PM_TMR_BLK (acpi_iobase + 0x18) /* 4 bytes */
#define ACPI_GPE0_BLK (SBX00_ACPI_IO_BASE + 0x10) /* 8 bytes */ #define ACPI_GPE0_BLK (acpi_iobase + 0x10) /* 8 bytes */
#define ACPI_END (SBX00_ACPI_IO_BASE + 0x80) #define ACPI_END (acpi_iobase + 0x80)
#define PM_INDEX 0xCD6 #define PM_INDEX 0xCD6
#define PM_DATA 0xCD7 #define PM_DATA 0xCD7
#define PM2_INDEX 0xCD0 #define PM2_INDEX 0xCD0
#define PM2_DATA 0xCD1 #define PM2_DATA 0xCD1
/*
* SCI interrupt need acpi space, allocate here
*/
static int __init register_acpi_resource(void)
{
request_region(SBX00_ACPI_IO_BASE, SBX00_ACPI_IO_SIZE, "acpi");
return 0;
}
static void pmio_write_index(u16 index, u8 reg, u8 value) static void pmio_write_index(u16 index, u8 reg, u8 value)
{ {
outb(reg, index); outb(reg, index);
...@@ -141,11 +132,38 @@ void acpi_registers_setup(void) ...@@ -141,11 +132,38 @@ void acpi_registers_setup(void)
pm2_iowrite(0xf8, value); pm2_iowrite(0xf8, value);
} }
int __init sbx00_acpi_init(void) static int rs780e_acpi_probe(struct platform_device *pdev)
{ {
register_acpi_resource(); struct resource *res;
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
if (!res)
return -ENODEV;
/* SCI interrupt need acpi space, allocate here */
if (!request_region(res->start, resource_size(res), "acpi")) {
pr_err("RS780E-ACPI: Failed to request IO Region\n");
return -EBUSY;
}
acpi_iobase = res->start;
acpi_registers_setup(); acpi_registers_setup();
acpi_hw_clear_status(); acpi_hw_clear_status();
return 0; return 0;
} }
static const struct of_device_id rs780e_acpi_match[] = {
{ .compatible = "loongson,rs780e-acpi" },
{},
};
static struct platform_driver rs780e_acpi_driver = {
.probe = rs780e_acpi_probe,
.driver = {
.name = "RS780E-ACPI",
.of_match_table = rs780e_acpi_match,
},
};
builtin_platform_driver(rs780e_acpi_driver);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment