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

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>

authored by

Jiaxun Yang and committed by
Thomas Bogendoerfer
0cfd2440 a746f50d

+46 -23
+1 -1
arch/mips/loongson64/Makefile
··· 2 2 # 3 3 # Makefile for Loongson-3 family machines 4 4 # 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 \ 6 6 setup.o init.o env.o time.o reset.o \ 7 7 8 8 obj-$(CONFIG_SMP) += smp.o
+38 -20
arch/mips/loongson64/acpi_init.c drivers/platform/mips/rs780e-acpi.c
··· 3 3 #include <linux/init.h> 4 4 #include <linux/ioport.h> 5 5 #include <linux/export.h> 6 + #include <linux/of.h> 7 + #include <linux/platform_device.h> 6 8 7 - #define SBX00_ACPI_IO_BASE 0x800 8 - #define SBX00_ACPI_IO_SIZE 0x100 9 + static unsigned long acpi_iobase; 9 10 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) 16 17 17 18 #define PM_INDEX 0xCD6 18 19 #define PM_DATA 0xCD7 19 20 #define PM2_INDEX 0xCD0 20 21 #define PM2_DATA 0xCD1 21 - 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 22 32 23 static void pmio_write_index(u16 index, u8 reg, u8 value) 33 24 { ··· 132 141 pm2_iowrite(0xf8, value); 133 142 } 134 143 135 - int __init sbx00_acpi_init(void) 144 + static int rs780e_acpi_probe(struct platform_device *pdev) 136 145 { 137 - register_acpi_resource(); 146 + struct resource *res; 147 + 148 + res = platform_get_resource(pdev, IORESOURCE_IO, 0); 149 + if (!res) 150 + return -ENODEV; 151 + 152 + /* SCI interrupt need acpi space, allocate here */ 153 + if (!request_region(res->start, resource_size(res), "acpi")) { 154 + pr_err("RS780E-ACPI: Failed to request IO Region\n"); 155 + return -EBUSY; 156 + } 157 + 158 + acpi_iobase = res->start; 159 + 138 160 acpi_registers_setup(); 139 161 acpi_hw_clear_status(); 140 162 141 163 return 0; 142 164 } 165 + 166 + static const struct of_device_id rs780e_acpi_match[] = { 167 + { .compatible = "loongson,rs780e-acpi" }, 168 + {}, 169 + }; 170 + 171 + static struct platform_driver rs780e_acpi_driver = { 172 + .probe = rs780e_acpi_probe, 173 + .driver = { 174 + .name = "RS780E-ACPI", 175 + .of_match_table = rs780e_acpi_match, 176 + }, 177 + }; 178 + builtin_platform_driver(rs780e_acpi_driver);
-2
arch/mips/loongson64/pci.c
··· 43 43 44 44 register_pci_controller(&loongson_pci_controller); 45 45 46 - sbx00_acpi_init(); 47 - 48 46 return 0; 49 47 } 50 48
+6
drivers/platform/mips/Kconfig
··· 24 24 help 25 25 Loongson-3A/3B CPU Hwmon (temperature sensor) driver. 26 26 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 + 27 33 endif # MIPS_PLATFORM_DEVICES
+1
drivers/platform/mips/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 obj-$(CONFIG_CPU_HWMON) += cpu_hwmon.o 3 + obj-$(CONFIG_RS780E_ACPI) += rs780e-acpi.o