serial: dw8250: ACPI tuning
Subsystems (4)
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().
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 | 12 ++++++++++++ drivers/acpi/acpi_lpss.c | 17 +++++++++++++++++ drivers/tty/serial/8250/8250_dw.c | 15 ++++++++++----- 3 files changed, 39 insertions(+), 5 deletions(-)
Signature · 1 line
2.8.1
PATCH 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/acpi/acpi_apd.c +12 -0
@@ -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); };
@@ -67,6 +68,9 @@ static int acpi_apd_setup(struct apd_private_data *pdata) pdata->clk = clk; } +if (pdata->properties) +return device_add_properties (&pdata->adev->dev, + pdata->properties);return 0 ; }
@@ -76,9 +80,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
Signature · 1 line
2.8.1
kbuild test robot
build botRe: [PATCH 1/3] ACPI / APD: Provide build-in properties of the UART
reproduce:
Hi Heikki,
[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.8-rc3 next-20160822]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]
url: https://github.com/0day-ci/linux/commits/Heikki-Krogerus/ACPI-APD-Provide-build-in-properties-of-the-UART/20160822-222543 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next config: x86_64-randconfig-x016-201634 (attached as .config) compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
All errors (new ones prefixed by >>):
drivers/acpi/acpi_apd.c: In function 'acpi_apd_setup':
>> drivers/acpi/acpi_apd.c:71:11: error: 'struct apd_private_data' has no member named 'properties'
if (pdata->properties)
^~
drivers/acpi/acpi_apd.c:73:16: error: 'struct apd_private_data' has no member named 'properties'
pdata->properties);
^~vim +71 drivers/acpi/acpi_apd.c
65 dev_name(&pdata->adev->dev),
66 NULL, 0, dev_desc->fixed_clk_rate);
67 clk_register_clkdev(clk, NULL, dev_name(&pdata->adev->dev));
68 pdata->clk = clk;
69 }
70
> 71 if (pdata->properties)
72 return device_add_properties(&pdata->adev->dev,
73 pdata->properties);
74 return 0;---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH 1/3] ACPI / APD: Provide build-in properties of the UART
Hi,
Quoted 26 lines · kbuild test robot
Hi Heikki,
[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.8-rc3 next-20160822]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]url: https://github.com/0day-ci/linux/commits/Heikki-Krogerus/ACPI-APD-Provide-build-in-properties-of-the-UART/20160822-222543 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next config: x86_64-randconfig-x016-201634 (attached as .config) compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce: # save the attached .config to linux build tree make ARCH=x86_64All errors (new ones prefixed by >>):
drivers/acpi/acpi_apd.c: In function 'acpi_apd_setup':Quoted 1 line
Quoted 1 line
drivers/acpi/acpi_apd.c:71:11: error: 'structapd_private_data' has no member named 'properties'if (pdata->properties) ^~ drivers/acpi/acpi_apd.c:73:16: error: 'struct apd_private_data' has no member named 'properties' pdata->properties); ^~
Quoted 9 lines
vim +71
drivers/acpi/acpi_apd.c65 dev_name(&pdata->adev->dev), 66 NULL, 0, dev_desc->fixed_clk_rate); 67 clk_register_clkdev(clk, NULL, dev_name(&pdata->adev->dev)); 68 pdata->clk = clk; 69 } 70Quoted 1 line
71 if (
pdata->properties)
Thanks, I'll fix it. I did not get compiler error from this? Weird.
Br,
Signature · 1 line
heikki
kbuild test robot
build botRe: [PATCH 1/3] ACPI / APD: Provide build-in properties of the UART
In reply to Heikki Krogerusreproduce:
Hi Heikki,
[auto build test WARNING on pm/linux-next]
[also build test WARNING on v4.8-rc3 next-20160822]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]
url: https://github.com/0day-ci/linux/commits/Heikki-Krogerus/ACPI-APD-Provide-build-in-properties-of-the-UART/20160822-222543 base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next config: i386-randconfig-s1-201634 (attached as .config) compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce: # save the attached .config to linux build tree make ARCH=i386
All warnings (new ones prefixed by >>):
In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/linux/io.h:21,
from include/linux/clk-provider.h:14,
from drivers/acpi/acpi_apd.c:13:
drivers/acpi/acpi_apd.c: In function 'acpi_apd_setup':
drivers/acpi/acpi_apd.c:71:11: error: 'struct apd_private_data' has no member named 'properties'
if (pdata->properties)
^
include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
^~~~
>> drivers/acpi/acpi_apd.c:71:2: note: in expansion of macro 'if'
if (pdata->properties)
^~
drivers/acpi/acpi_apd.c:71:11: error: 'struct apd_private_data' has no member named 'properties'
if (pdata->properties)
^
include/linux/compiler.h:149:42: note: in definition of macro '__trace_if'
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
^~~~
>> drivers/acpi/acpi_apd.c:71:2: note: in expansion of macro 'if'
if (pdata->properties)
^~
drivers/acpi/acpi_apd.c:71:11: error: 'struct apd_private_data' has no member named 'properties'
if (pdata->properties)
^
include/linux/compiler.h:160:16: note: in definition of macro '__trace_if'
______r = !!(cond); \
^~~~
>> drivers/acpi/acpi_apd.c:71:2: note: in expansion of macro 'if'
if (pdata->properties)
^~
drivers/acpi/acpi_apd.c:73:16: error: 'struct apd_private_data' has no member named 'properties'
pdata->properties);
^~vim +/if +71 drivers/acpi/acpi_apd.c
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
> 13 #include <linux/clk-provider.h>
14 #include <linux/platform_device.h>
15 #include <linux/pm_domain.h>
16 #include <linux/clkdev.h>
17 #include <linux/acpi.h>
18 #include <linux/err.h>
19 #include <linux/pm.h>
20
21 #include "internal.h"
22
23 ACPI_MODULE_NAME("acpi_apd");
24 struct apd_private_data;
25
26 /**
27 * ACPI_APD_SYSFS : add device attributes in sysfs
28 * ACPI_APD_PM : attach power domain to device
29 */
30 #define ACPI_APD_SYSFS BIT(0)
31 #define ACPI_APD_PM BIT(1)
32
33 /**
34 * struct apd_device_desc - a descriptor for apd device
35 * @flags: device flags like %ACPI_APD_SYSFS, %ACPI_APD_PM
36 * @fixed_clk_rate: fixed rate input clock source for acpi device;
37 * 0 means no fixed rate input clock source
38 * @setup: a hook routine to set device resource during create platform device
39 *
40 * Device description defined as acpi_device_id.driver_data
41 */
42 struct apd_device_desc {
43 unsigned int flags;
44 unsigned int fixed_clk_rate;
45 struct property_entry *properties;
46 int (*setup)(struct apd_private_data *pdata);
47 };
48
49 struct apd_private_data {
50 struct clk *clk;
51 struct acpi_device *adev;
52 const struct apd_device_desc *dev_desc;
53 };
54
55 #if defined(CONFIG_X86_AMD_PLATFORM_DEVICE) || defined(CONFIG_ARM64)
56 #define APD_ADDR(desc) ((unsigned long)&desc)
57
58 static int acpi_apd_setup(struct apd_private_data *pdata)
59 {
60 const struct apd_device_desc *dev_desc = pdata->dev_desc;
61 struct clk *clk = ERR_PTR(-ENODEV);
62
63 if (dev_desc->fixed_clk_rate) {
64 clk = clk_register_fixed_rate(&pdata->adev->dev,
65 dev_name(&pdata->adev->dev),
66 NULL, 0, dev_desc->fixed_clk_rate);
67 clk_register_clkdev(clk, NULL, dev_name(&pdata->adev->dev));
68 pdata->clk = clk;
69 }
70
> 71 if (pdata->properties)
72 return device_add_properties(&pdata->adev->dev,
73 pdata->properties);
74 return 0;---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH 2/3 ACPI / LPSS: Provide build-in properties of the UART
In reply to Heikki KrogerusThe 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
@@ -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
Re: [PATCH 2/3] ACPI / LPSS: Provide build-in properties of the UART
Quoted 9 lines · 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.Signed-off-by Heikki Krogerus <[email protected]>Cc Mika Westerberg <[email protected]>
Good idea.
PATCH 3/3 serial: 8250_dw: Add quirk for APM X-Gene SoC
In reply to Heikki KrogerusThe 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
@@ -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