|
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 |
|
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 | | - |
32 | 23 | static void pmio_write_index(u16 index, u8 reg, u8 value) |
33 | 24 | { |
34 | 25 | outb(reg, index); |
@@ -141,11 +132,38 @@ void acpi_registers_setup(void) |
141 | 132 | pm2_iowrite(0xf8, value); |
142 | 133 | } |
143 | 134 |
|
144 | | -int __init sbx00_acpi_init(void) |
| 135 | +static int rs780e_acpi_probe(struct platform_device *pdev) |
145 | 136 | { |
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 | + |
147 | 151 | acpi_registers_setup(); |
148 | 152 | acpi_hw_clear_status(); |
149 | 153 |
|
150 | 154 | return 0; |
151 | 155 | } |
| 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