Skip to content

Commit 0cfd244

Browse files
FlyGoattsbogend
authored andcommitted
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: Jiaxun Yang <jiaxun.yang@flygoat.com> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
1 parent a746f50 commit 0cfd244

5 files changed

Lines changed: 46 additions & 23 deletions

File tree

‎arch/mips/loongson64/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for Loongson-3 family machines
44
#
5-
obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o platform.o acpi_init.o dma.o \
5+
obj-$(CONFIG_MACH_LOONGSON64) += cop2-ex.o platform.o dma.o \
66
setup.o init.o env.o time.o reset.o \
77

88
obj-$(CONFIG_SMP) += smp.o

‎arch/mips/loongson64/pci.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ static int __init pcibios_init(void)
4343

4444
register_pci_controller(&loongson_pci_controller);
4545

46-
sbx00_acpi_init();
47-
4846
return 0;
4947
}
5048

‎drivers/platform/mips/Kconfig‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,10 @@ config CPU_HWMON
2424
help
2525
Loongson-3A/3B CPU Hwmon (temperature sensor) driver.
2626

27+
config RS780E_ACPI
28+
bool "Loongson RS780E ACPI Controller"
29+
depends on MACH_LOONGSON64 || COMPILE_TEST
30+
help
31+
Loongson RS780E PCH ACPI Controller driver.
32+
2733
endif # MIPS_PLATFORM_DEVICES

‎drivers/platform/mips/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
obj-$(CONFIG_CPU_HWMON) += cpu_hwmon.o
3+
obj-$(CONFIG_RS780E_ACPI) += rs780e-acpi.o
Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,23 @@
33
#include <linux/init.h>
44
#include <linux/ioport.h>
55
#include <linux/export.h>
6+
#include <linux/of.h>
7+
#include <linux/platform_device.h>
68

7-
#define SBX00_ACPI_IO_BASE 0x800
8-
#define SBX00_ACPI_IO_SIZE 0x100
9+
static unsigned long acpi_iobase;
910

10-
#define ACPI_PM_EVT_BLK (SBX00_ACPI_IO_BASE + 0x00) /* 4 bytes */
11-
#define ACPI_PM_CNT_BLK (SBX00_ACPI_IO_BASE + 0x04) /* 2 bytes */
12-
#define ACPI_PMA_CNT_BLK (SBX00_ACPI_IO_BASE + 0x0F) /* 1 byte */
13-
#define ACPI_PM_TMR_BLK (SBX00_ACPI_IO_BASE + 0x18) /* 4 bytes */
14-
#define ACPI_GPE0_BLK (SBX00_ACPI_IO_BASE + 0x10) /* 8 bytes */
15-
#define ACPI_END (SBX00_ACPI_IO_BASE + 0x80)
11+
#define ACPI_PM_EVT_BLK (acpi_iobase + 0x00) /* 4 bytes */
12+
#define ACPI_PM_CNT_BLK (acpi_iobase + 0x04) /* 2 bytes */
13+
#define ACPI_PMA_CNT_BLK (acpi_iobase + 0x0F) /* 1 byte */
14+
#define ACPI_PM_TMR_BLK (acpi_iobase + 0x18) /* 4 bytes */
15+
#define ACPI_GPE0_BLK (acpi_iobase + 0x10) /* 8 bytes */
16+
#define ACPI_END (acpi_iobase + 0x80)
1617

1718
#define PM_INDEX 0xCD6
1819
#define PM_DATA 0xCD7
1920
#define PM2_INDEX 0xCD0
2021
#define PM2_DATA 0xCD1
2122

22-
/*
23-
* SCI interrupt need acpi space, allocate here
24-
*/
25-
26-
static int __init register_acpi_resource(void)
27-
{
28-
request_region(SBX00_ACPI_IO_BASE, SBX00_ACPI_IO_SIZE, "acpi");
29-
return 0;
30-
}
31-
3223
static void pmio_write_index(u16 index, u8 reg, u8 value)
3324
{
3425
outb(reg, index);
@@ -141,11 +132,38 @@ void acpi_registers_setup(void)
141132
pm2_iowrite(0xf8, value);
142133
}
143134

144-
int __init sbx00_acpi_init(void)
135+
static int rs780e_acpi_probe(struct platform_device *pdev)
145136
{
146-
register_acpi_resource();
137+
struct resource *res;
138+
139+
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
140+
if (!res)
141+
return -ENODEV;
142+
143+
/* SCI interrupt need acpi space, allocate here */
144+
if (!request_region(res->start, resource_size(res), "acpi")) {
145+
pr_err("RS780E-ACPI: Failed to request IO Region\n");
146+
return -EBUSY;
147+
}
148+
149+
acpi_iobase = res->start;
150+
147151
acpi_registers_setup();
148152
acpi_hw_clear_status();
149153

150154
return 0;
151155
}
156+
157+
static const struct of_device_id rs780e_acpi_match[] = {
158+
{ .compatible = "loongson,rs780e-acpi" },
159+
{},
160+
};
161+
162+
static struct platform_driver rs780e_acpi_driver = {
163+
.probe = rs780e_acpi_probe,
164+
.driver = {
165+
.name = "RS780E-ACPI",
166+
.of_match_table = rs780e_acpi_match,
167+
},
168+
};
169+
builtin_platform_driver(rs780e_acpi_driver);

0 commit comments

Comments
 (0)