Skip to content

Commit 6a7320c

Browse files
Heikki Krogerusgregkh
authored andcommitted
serial: 8250_dw: Add ACPI 5.0 support
This adds support for ACPI 5.0 enumerated Designware UARTs. ACPI does not deliver information about uart clk, so delivering it with the driver_data. Signed-off-by: Heikki Krogerus <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 30046df commit 6a7320c

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

drivers/tty/serial/8250/8250_dw.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Synopsys DesignWare 8250 driver.
33
*
44
* Copyright 2011 Picochip, Jamie Iles.
5+
* Copyright 2013 Intel Corporation
56
*
67
* This program is free software; you can redistribute it and/or modify
78
* it under the terms of the GNU General Public License as published by
@@ -24,12 +25,16 @@
2425
#include <linux/of_platform.h>
2526
#include <linux/platform_device.h>
2627
#include <linux/slab.h>
28+
#include <linux/acpi.h>
2729

2830
/* Offsets for the DesignWare specific registers */
2931
#define DW_UART_USR 0x1f /* UART Status Register */
3032
#define DW_UART_CPR 0xf4 /* Component Parameter Register */
3133
#define DW_UART_UCV 0xf8 /* UART Component Version */
3234

35+
/* Intel Low Power Subsystem specific */
36+
#define LPSS_PRV_CLOCK_PARAMS 0x800
37+
3338
/* Component Parameter Register bits */
3439
#define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0)
3540
#define DW_UART_CPR_AFCE_MODE (1 << 4)
@@ -138,6 +143,30 @@ static int dw8250_probe_of(struct uart_port *p)
138143
return 0;
139144
}
140145

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+
141170
static void dw8250_setup_port(struct uart_8250_port *up)
142171
{
143172
struct uart_port *p = &up->port;
@@ -199,6 +228,10 @@ static int dw8250_probe(struct platform_device *pdev)
199228
err = dw8250_probe_of(&uart.port);
200229
if (err)
201230
return err;
231+
} else if (ACPI_HANDLE(&pdev->dev)) {
232+
err = dw8250_probe_acpi(&uart.port);
233+
if (err)
234+
return err;
202235
} else {
203236
return -ENODEV;
204237
}
@@ -258,11 +291,19 @@ static const struct of_device_id dw8250_of_match[] = {
258291
};
259292
MODULE_DEVICE_TABLE(of, dw8250_of_match);
260293

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+
261301
static struct platform_driver dw8250_platform_driver = {
262302
.driver = {
263303
.name = "dw-apb-uart",
264304
.owner = THIS_MODULE,
265305
.of_match_table = dw8250_of_match,
306+
.acpi_match_table = ACPI_PTR(dw8250_acpi_match),
266307
},
267308
.probe = dw8250_probe,
268309
.remove = dw8250_remove,

drivers/tty/serial/8250/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ config SERIAL_8250_FSL
256256

257257
config SERIAL_8250_DW
258258
tristate "Support for Synopsys DesignWare 8250 quirks"
259-
depends on SERIAL_8250 && OF
259+
depends on SERIAL_8250
260260
help
261261
Selecting this option will enable handling of the extra features
262262
present in the Synopsys DesignWare APB UART.

0 commit comments

Comments
 (0)