|
2 | 2 | * Synopsys DesignWare 8250 driver.
|
3 | 3 | *
|
4 | 4 | * Copyright 2011 Picochip, Jamie Iles.
|
| 5 | + * Copyright 2013 Intel Corporation |
5 | 6 | *
|
6 | 7 | * This program is free software; you can redistribute it and/or modify
|
7 | 8 | * it under the terms of the GNU General Public License as published by
|
|
24 | 25 | #include <linux/of_platform.h>
|
25 | 26 | #include <linux/platform_device.h>
|
26 | 27 | #include <linux/slab.h>
|
| 28 | +#include <linux/acpi.h> |
27 | 29 |
|
28 | 30 | /* Offsets for the DesignWare specific registers */
|
29 | 31 | #define DW_UART_USR 0x1f /* UART Status Register */
|
30 | 32 | #define DW_UART_CPR 0xf4 /* Component Parameter Register */
|
31 | 33 | #define DW_UART_UCV 0xf8 /* UART Component Version */
|
32 | 34 |
|
| 35 | +/* Intel Low Power Subsystem specific */ |
| 36 | +#define LPSS_PRV_CLOCK_PARAMS 0x800 |
| 37 | + |
33 | 38 | /* Component Parameter Register bits */
|
34 | 39 | #define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0)
|
35 | 40 | #define DW_UART_CPR_AFCE_MODE (1 << 4)
|
@@ -138,6 +143,30 @@ static int dw8250_probe_of(struct uart_port *p)
|
138 | 143 | return 0;
|
139 | 144 | }
|
140 | 145 |
|
| 146 | +static int dw8250_probe_acpi(struct uart_port *p) |
| 147 | +{ |
| 148 | + const struct acpi_device_id *id; |
| 149 | + u32 reg; |
| 150 | + |
| 151 | + id = acpi_match_device(p->dev->driver->acpi_match_table, p->dev); |
| 152 | + if (!id) |
| 153 | + return -ENODEV; |
| 154 | + |
| 155 | + p->iotype = UPIO_MEM32; |
| 156 | + p->serial_in = dw8250_serial_in32; |
| 157 | + p->serial_out = dw8250_serial_out32; |
| 158 | + p->regshift = 2; |
| 159 | + p->uartclk = (unsigned int)id->driver_data; |
| 160 | + |
| 161 | + /* Fix Haswell issue where the clocks do not get enabled */ |
| 162 | + if (!strcmp(id->id, "INT33C4") || !strcmp(id->id, "INT33C5")) { |
| 163 | + reg = readl(p->membase + LPSS_PRV_CLOCK_PARAMS); |
| 164 | + writel(reg | 1, p->membase + LPSS_PRV_CLOCK_PARAMS); |
| 165 | + } |
| 166 | + |
| 167 | + return 0; |
| 168 | +} |
| 169 | + |
141 | 170 | static void dw8250_setup_port(struct uart_8250_port *up)
|
142 | 171 | {
|
143 | 172 | struct uart_port *p = &up->port;
|
@@ -199,6 +228,10 @@ static int dw8250_probe(struct platform_device *pdev)
|
199 | 228 | err = dw8250_probe_of(&uart.port);
|
200 | 229 | if (err)
|
201 | 230 | return err;
|
| 231 | + } else if (ACPI_HANDLE(&pdev->dev)) { |
| 232 | + err = dw8250_probe_acpi(&uart.port); |
| 233 | + if (err) |
| 234 | + return err; |
202 | 235 | } else {
|
203 | 236 | return -ENODEV;
|
204 | 237 | }
|
@@ -258,11 +291,19 @@ static const struct of_device_id dw8250_of_match[] = {
|
258 | 291 | };
|
259 | 292 | MODULE_DEVICE_TABLE(of, dw8250_of_match);
|
260 | 293 |
|
| 294 | +static const struct acpi_device_id dw8250_acpi_match[] = { |
| 295 | + { "INT33C4", 100000000 }, |
| 296 | + { "INT33C5", 100000000 }, |
| 297 | + { }, |
| 298 | +}; |
| 299 | +MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match); |
| 300 | + |
261 | 301 | static struct platform_driver dw8250_platform_driver = {
|
262 | 302 | .driver = {
|
263 | 303 | .name = "dw-apb-uart",
|
264 | 304 | .owner = THIS_MODULE,
|
265 | 305 | .of_match_table = dw8250_of_match,
|
| 306 | + .acpi_match_table = ACPI_PTR(dw8250_acpi_match), |
266 | 307 | },
|
267 | 308 | .probe = dw8250_probe,
|
268 | 309 | .remove = dw8250_remove,
|
|
0 commit comments