Skip to contentSkip to conversation

serial: dw8250: ACPI tuning

PATCH In review Heikki Krogerus 4 participants 7 messages Aug 23, 2016 – Sep 12, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover serial: dw8250: ACPI tuning

Hi,

Since we now have the build-in properties available, using those when ever possible to get the details the driver expects and when they are not being provided by the fw. Right now there is only one exception ACPI enumerated board where we have no means to provide the properties with build-in ones, so simply handling that as an exception in dw8250_quirks().

Changes since v1:
- Fix a compiler error in acpi_apd.c found by kbuild test robot
- ACK from Mika

Heikki Krogerus (3):
ACPI / APD: Provide build-in properties of the UART ACPI / LPSS: Provide build-in properties of the UART
serial: 8250_dw: Add quirk for APM X-Gene SoC

 drivers/acpi/acpi_apd.c           | 15 +++++++++++++++
 drivers/acpi/acpi_lpss.c          | 17 +++++++++++++++++
 drivers/tty/serial/8250/8250_dw.c | 15 ++++++++++-----
 3 files changed, 42 insertions(+), 5 deletions(-)
Signature · 1 line
2.8.1
#1 lore raw

PATCH v2 1/3 ACPI / APD: Provide build-in properties of the UART

The UART driver, dw8250.c, needs some details regarding the Designware UART. For ACPI enumerated devices the values are hard-coded, but since the driver also reads the values from device properties, providing them with build-in properties. This allows us to later remove the hard-coded values from the driver.

---
 drivers/acpi/acpi_apd.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/acpi/acpi_apd.c +15 -0
index c80c8f8..1f30fff 100644
@@ -42,6 +42,7 @@ struct apd_private_data;
 struct apd_device_desc {
 	unsigned int flags;
 	unsigned int fixed_clk_rate;
+	struct property_entry *properties;
 	int (*setup)(struct apd_private_data *pdata);
 };
 
@@ -76,9 +77,17 @@ static struct apd_device_desc cz_i2c_desc = {
 	.fixed_clk_rate = 133000000,
 };
 
+static struct property_entry uart_properties[] = {
+	PROPERTY_ENTRY_U32("reg-io-width", 4),
+	PROPERTY_ENTRY_U32("reg-shift", 2),
+	PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
+	{ },
+};
+
 static struct apd_device_desc cz_uart_desc = {
 	.setup = acpi_apd_setup,
 	.fixed_clk_rate = 48000000,
+	.properties = uart_properties,
 };
 #endif
 
@@ -130,6 +139,12 @@ static int acpi_apd_create_device(struct acpi_device *adev,
 			goto err_out;
 	}
 
+	if (dev_desc->properties) {
+		ret = device_add_properties(&adev->dev, dev_desc->properties);
+		if (ret)
+			goto err_out;
+	}
+
 	adev->driver_data = pdata;
 	pdev = acpi_create_platform_device(adev);
 	if (!IS_ERR_OR_NULL(pdev))
Signature · 1 line
2.8.1
#2 lore raw

PATCH v2 2/3 ACPI / LPSS: Provide build-in properties of the UART

In reply to Heikki Krogerus

The UART driver, dw8250.c, needs some details regarding the Designware UART. For ACPI enumerated devices the values are hard-coded, but since the driver also reads the values from device properties, providing them with build-in properties. This allows us to later remove the hard-coded values from the driver.

---
 drivers/acpi/acpi_lpss.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/acpi/acpi_lpss.c +17 -0
index 357a0b8..5520102 100644
@@ -75,6 +75,7 @@ struct lpss_device_desc {
 	const char *clk_con_id;
 	unsigned int prv_offset;
 	size_t prv_size_override;
+	struct property_entry *properties;
 	void (*setup)(struct lpss_private_data *pdata);
 };
 
@@ -163,11 +164,19 @@ static const struct lpss_device_desc lpt_i2c_dev_desc = {
 	.prv_offset = 0x800,
 };
 
+static struct property_entry uart_properties[] = {
+	PROPERTY_ENTRY_U32("reg-io-width", 4),
+	PROPERTY_ENTRY_U32("reg-shift", 2),
+	PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"),
+	{ },
+};
+
 static const struct lpss_device_desc lpt_uart_dev_desc = {
 	.flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR,
 	.clk_con_id = "baudclk",
 	.prv_offset = 0x800,
 	.setup = lpss_uart_setup,
+	.properties = uart_properties,
 };
 
 static const struct lpss_device_desc lpt_sdio_dev_desc = {
@@ -189,6 +198,7 @@ static const struct lpss_device_desc byt_uart_dev_desc = {
 	.clk_con_id = "baudclk",
 	.prv_offset = 0x800,
 	.setup = lpss_uart_setup,
+	.properties = uart_properties,
 };
 
 static const struct lpss_device_desc bsw_uart_dev_desc = {
@@ -197,6 +207,7 @@ static const struct lpss_device_desc bsw_uart_dev_desc = {
 	.clk_con_id = "baudclk",
 	.prv_offset = 0x800,
 	.setup = lpss_uart_setup,
+	.properties = uart_properties,
 };
 
 static const struct lpss_device_desc byt_spi_dev_desc = {
@@ -440,6 +451,12 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
 		goto err_out;
 	}
 
+	if (dev_desc->properties) {
+		ret = device_add_properties(&adev->dev, dev_desc->properties);
+		if (ret)
+			goto err_out;
+	}
+
 	adev->driver_data = pdata;
 	pdev = acpi_create_platform_device(adev);
 	if (!IS_ERR_OR_NULL(pdev)) {
Signature · 1 line
2.8.1
#3 lore raw

PATCH v2 3/3 serial: 8250_dw: Add quirk for APM X-Gene SoC

In reply to Heikki Krogerus

The APM X-Gene SoC UART is the only board that still needs the hard-coded values, so handle it separately in dw8250_quirks(). The other ACPI platforms are able to provide the values with device properties.

---
 drivers/tty/serial/8250/8250_dw.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/tty/serial/8250/8250_dw.c +10 -5
index e199696..5c0c123 100644
@@ -298,12 +298,17 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
 			p->serial_out = dw8250_serial_out32be;
 		}
 	} else if (has_acpi_companion(p->dev)) {
-		p->iotype = UPIO_MEM32;
-		p->regshift = 2;
-		p->serial_in = dw8250_serial_in32;
+		const struct acpi_device_id *id;
+
+		id = acpi_match_device(p->dev->driver->acpi_match_table,
+				       p->dev);
+		if (id && !strcmp(id->id, "APMC0D08")) {
+			p->iotype = UPIO_MEM32;
+			p->regshift = 2;
+			p->serial_in = dw8250_serial_in32;
+			data->uart_16550_compatible = true;
+		}
 		p->set_termios = dw8250_set_termios;
-		/* So far none of there implement the Busy Functionality */
-		data->uart_16550_compatible = true;
 	}
 
 	/* Platforms with iDMA */
Signature · 1 line
2.8.1
reviewer Reviewed-by on the v2 series
#5 lore raw
In reply to Heikki Krogerus
Quoted 8 lines · Heikki Krogerus

Hi,

Since we now have the build-in properties available, using those when ever possible to get the details the driver expects and when they are not being provided by the fw. Right now there is only one exception ACPI enumerated board where we have no means to provide the properties with build-in ones, so simply handling that as an exception in dw8250_quirks().

Looks good to me.

Quoted 16 lines

Changes since v1:
- Fix a compiler error in acpi_apd.c found by kbuild test robot
- ACK from Mika

Heikki Krogerus (3):
  ACPI / APD: Provide build-in properties of the UART ACPI / LPSS: Provide build-in properties of the UART
  serial: 8250_dw: Add quirk for APM X-Gene SoC

 drivers/acpi/acpi_apd.c           | 15 +++++++++++++++ drivers/acpi/acpi_lpss.c          | 17 +++++++++++++++++ drivers/tty/serial/8250/8250_dw.c | 15 ++++++++++-----

 3 files changed, 42 insertions(+), 5 deletions(-)
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
maintainer Acked-by on v2 3/3
#4 lore raw

Re: [PATCHv2 3/3] serial: 8250_dw: Add quirk for APM X-Gene SoC

In reply to Heikki Krogerus
Quoted 10 lines · Heikki Krogerus

The APM X-Gene SoC UART is the only board that still needs the hard-coded values, so handle it separately in dw8250_quirks(). The other ACPI platforms are able to provide the values with device properties.

---
 drivers/tty/serial/8250/8250_dw.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
#6 lore raw
In reply to Heikki Krogerus
Quoted 14 lines · Heikki Krogerus

Hi,

Since we now have the build-in properties available, using those when ever possible to get the details the driver expects and when they are not being provided by the fw. Right now there is only one exception ACPI enumerated board where we have no means to provide the properties with build-in ones, so simply handling that as an exception in dw8250_quirks().

Changes since v1:
- Fix a compiler error in acpi_apd.c found by kbuild test robot
- ACK from Mika

Quoted 4 lines

Heikki Krogerus (3):
ACPI / APD: Provide build-in properties of the UART ACPI / LPSS: Provide build-in properties of the UART
serial: 8250_dw: Add quirk for APM X-Gene SoC

Whole series applied.

Thanks,
Rafael