i2c: i2c-qcom-geni: Provide support for ACPI
Subsystems (10)
PATCH v2 1/8 i2c: i2c-qcom-geni: Provide support for ACPI
Add a match table to allow automatic probing of ACPI device QCOM0220. Ignore clock attainment errors. Set default clock frequency value.
--- drivers/i2c/busses/i2c-qcom-geni.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-qcom-geni.c +17 -2
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. +#include <linux/acpi.h> #include <linux/clk.h> #include <linux/dma-mapping.h> #include <linux/err.h>
@@ -483,6 +484,12 @@ static const struct i2c_algorithm geni_i2c_algo = { .functionality = geni_i2c_func, }; +static const struct acpi_device_id geni_i2c_acpi_match[] = { + {"QCOM0220" }, + { }, +}; +MODULE_DEVICE_TABLE (acpi, geni_i2c_acpi_match); +static int geni_i2c_probe (struct platform_device *pdev) {struct geni_i2c_dev *gi2c;
@@ -502,7 +509,7 @@ static int geni_i2c_probe(struct platform_device *pdev)return PTR_ERR (gi2c->se.base); gi2c->se.clk =devm_clk_get (&pdev->dev,"se" ); -if (IS_ERR (gi2c->se.clk)) { +if (IS_ERR (gi2c->se.clk) && !ACPI_HANDLE (&pdev->dev)) { ret =PTR_ERR (gi2c->se.clk);dev_err (&pdev->dev,"Err getting SE Core clk %d\n" , ret);return ret;
@@ -510,12 +517,19 @@ static int geni_i2c_probe(struct platform_device *pdev) ret =device_property_read_u32 (&pdev->dev,"clock-frequency" , &gi2c->clk_freq_out); -if (ret) { +if (ret && !ACPI_HANDLE (&pdev->dev)) {dev_info (&pdev->dev,"Bus frequency not specified, default to 100kHz.\n" ); gi2c->clk_freq_out =KHZ (100 ); } +if (ACPI_HANDLE (&pdev->dev)) { +ACPI_COMPANION_SET (&gi2c->adap.dev,ACPI_COMPANION (&pdev->dev)); + +/* Using default, same as the !ACPI case above */ + gi2c->clk_freq_out =KHZ (100 ); + } + gi2c->irq =platform_get_irq (pdev,0 );if (gi2c->irq <0 ) {dev_err (&pdev->dev,"IRQ error for i2c-geni\n" );
@@ -660,6 +674,7 @@ static struct platform_driver geni_i2c_driver = { .name = "geni_i2c", .pm = &geni_i2c_pm_ops, .of_match_table = geni_i2c_dt_match, + .acpi_match_table = ACPI_PTR(geni_i2c_acpi_match), }, };
Signature · 1 line
2.17.1
PATCH v2 2/8 i2c: i2c-qcom-geni: Signify successful driver probe
The Qualcomm Geni I2C driver currently probes silently which can be confusing when debugging potential issues. Add a low level (INFO) print when each I2C controller is successfully initially set-up.
--- drivers/i2c/busses/i2c-qcom-geni.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-qcom-geni.c +2 -0
@@ -598,6 +598,8 @@ static int geni_i2c_probe(struct platform_device *pdev)return ret; } +dev_dbg (&pdev->dev,"Geni-I2C adaptor successfully added\n" ); +return 0 ; }
Signature · 1 line
2.17.1
PATCH v2 3/8 pinctrl: msm: Add ability for drivers to supply a reserved GPIO list
In reply to Lee JonesWhen booting MSM based platforms with Device Tree or some ACPI implementations, it is possible to provide a list of reserved pins via the 'gpio-reserved-ranges' and 'gpios' properties respectively. However some ACPI tables are not populated with this information, thus it has to come from a knowledgable device driver instead.
Here we provide the MSM common driver with additional support to parse this informtion and correctly populate the widely used 'valid_mask'.
--- drivers/pinctrl/qcom/pinctrl-msm.c | 18 ++++++++++++++++++ drivers/pinctrl/qcom/pinctrl-msm.h | 1 + 2 files changed, 19 insertions(+)
drivers/pinctrl/qcom/pinctrl-msm.c +18 -0
@@ -607,8 +607,23 @@ static int msm_gpio_init_valid_mask(struct gpio_chip *chip)int ret;unsigned int len, i;unsigned int max_gpios = pctrl->soc->ngpios; +const int *reserved = pctrl->soc->reserved_gpios;u16 *tmp; +/* Driver provided reserved list overrides DT and ACPI */ +if (reserved) { +bitmap_fill (chip->valid_mask, max_gpios); +for (i =0 ; reserved[i] >=0 ; i++) { +if (i >= max_gpios || reserved[i] >= max_gpios) { +dev_err (pctrl->dev,"invalid list of reserved GPIOs\n" ); +return -EINVAL ; + } +clear_bit (reserved[i], chip->valid_mask); + } + +return 0 ; + } +/* The number of GPIOs in the ACPI tables */ len = ret =device_property_read_u16_array (pctrl->dev,"gpios" ,NULL ,0 );
@@ -964,6 +979,9 @@ static void msm_gpio_irq_handler(struct irq_desc *desc)static bool msm_gpio_needs_valid_mask (struct msm_pinctrl *pctrl) { +if (pctrl->soc->reserved_gpios) +return true; +return device_property_read_u16_array (pctrl->dev,"gpios" ,NULL ,0 ) >0 ; }
drivers/pinctrl/qcom/pinctrl-msm.h +1 -0
@@ -121,6 +121,7 @@ struct msm_pinctrl_soc_data {bool pull_no_keeper;const char *const *tiles;unsigned int ntiles; +const int *reserved_gpios; };extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;
Signature · 1 line
2.17.1
PATCH v2 4/8 pinctrl: qcom: sdm845: Provide ACPI support
In reply to Lee JonesThis patch provides basic support for booting with ACPI instead of the currently supported Device Tree. When doing so there are a couple of differences which we need to taken into consideration.
Firstly, the SDM850 ACPI tables omit information pertaining to the 4 reserved GPIOs on the platform. If Linux attempts to touch/ initialise any of these lines, the firmware will restart the platform.
Secondly, when booting with ACPI, it is expected that the firmware will set-up things like; Regulators, Clocks, Pin Functions, etc in their ideal configuration. Thus, the possible Pin Functions available to this platform are not advertised when providing the higher GPIOD/Pinctrl APIs with pin information.
--- drivers/pinctrl/qcom/Kconfig | 2 +- drivers/pinctrl/qcom/pinctrl-sdm845.c | 35 ++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-)
drivers/pinctrl/qcom/Kconfig +1 -1
@@ -168,7 +168,7 @@ config PINCTRL_SDM660 config PINCTRL_SDM845 tristate "Qualcomm Technologies Inc SDM845 pin controller driver" - depends on GPIOLIB && OF + depends on GPIOLIB && (OF || ACPI) select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for the
drivers/pinctrl/qcom/pinctrl-sdm845.c +34 -1
@@ -3,6 +3,7 @@* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */ +#include <linux/acpi.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h>
@@ -1277,6 +1278,10 @@ static const struct msm_pingroup sdm845_groups[] = { UFS_RESET(ufs_reset, 0x99f000), }; +static const int sdm845_acpi_reserved_gpios[] = { +0 ,1 ,2 ,3 ,81 ,82 ,83 ,84 ,-1 +}; +static const struct msm_pinctrl_soc_data sdm845_pinctrl = { .pins = sdm845_pins, .npins =ARRAY_SIZE (sdm845_pins),
@@ -1284,14 +1289,41 @@ static const struct msm_pinctrl_soc_data sdm845_pinctrl = { .nfunctions = ARRAY_SIZE(sdm845_functions), .groups = sdm845_groups, .ngroups = ARRAY_SIZE(sdm845_groups), + .reserved_gpios = sdm845_acpi_reserved_gpios, + .ngpios = 150, +}; + +static const struct msm_pinctrl_soc_data sdm845_acpi_pinctrl = { + .pins = sdm845_pins, + .npins =ARRAY_SIZE (sdm845_pins), + .groups = sdm845_groups, + .ngroups =ARRAY_SIZE (sdm845_groups), + .reserved_gpios = sdm845_acpi_reserved_gpios, .ngpios =150 , };static int sdm845_pinctrl_probe (struct platform_device *pdev) { -return msm_pinctrl_probe (pdev, &sdm845_pinctrl); +int ret; + +if (pdev->dev.of_node) { + ret =msm_pinctrl_probe (pdev, &sdm845_pinctrl); + }else if (ACPI_HANDLE (&pdev->dev)) { + ret =msm_pinctrl_probe (pdev, &sdm845_acpi_pinctrl); + }else { +dev_err (&pdev->dev,"DT and ACPI disabled\n" ); +return -EINVAL ; + } + +return ret; } +static const struct acpi_device_id sdm845_pinctrl_acpi_match[] = { + {"QCOM0217" }, + { }, +}; +MODULE_DEVICE_TABLE (acpi, sdm845_pinctrl_acpi_match); +static const struct of_device_id sdm845_pinctrl_of_match[] = { { .compatible ="qcom,sdm845-pinctrl" , }, { },
@@ -1302,6 +1334,7 @@ static struct platform_driver sdm845_pinctrl_driver = { .name = "sdm845-pinctrl", .pm = &msm_pinctrl_dev_pm_ops, .of_match_table = sdm845_pinctrl_of_match, + .acpi_match_table = ACPI_PTR(sdm845_pinctrl_acpi_match), }, .probe = sdm845_pinctrl_probe, .remove = msm_pinctrl_remove,
Signature · 1 line
2.17.1
PATCH v2 5/8 soc: qcom: geni: Add support for ACPI
In reply to Lee JonesWhen booting with ACPI as the active set of configuration tables, all; clocks, regulators, pin functions ect are expected to be at their ideal values/levels/rates, thus the associated frameworks are unavailable. Ensure calls to these APIs are shielded when ACPI is enabled.
--- drivers/soc/qcom/qcom-geni-se.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/soc/qcom/qcom-geni-se.c +15 -6
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. +#include <linux/acpi.h> #include <linux/clk.h> #include <linux/slab.h> #include <linux/dma-mapping.h>
@@ -450,6 +451,9 @@ int geni_se_resources_off(struct geni_se *se) {int ret; +if (ACPI_HANDLE (se->dev)) +return 0 ; + ret =pinctrl_pm_select_sleep_state (se->dev);if (ret)return ret;
@@ -487,6 +491,9 @@ int geni_se_resources_on(struct geni_se *se) {int ret; +if (ACPI_HANDLE (se->dev)) +return 0 ; + ret =geni_se_clks_on (se);if (ret)return ret;
@@ -724,12 +731,14 @@ static int geni_se_probe(struct platform_device *pdev)if (IS_ERR (wrapper->base))return PTR_ERR (wrapper->base); - wrapper->ahb_clks[0 ].id ="m-ahb" ; - wrapper->ahb_clks[1 ].id ="s-ahb" ; - ret =devm_clk_bulk_get (dev,NUM_AHB_CLKS , wrapper->ahb_clks); -if (ret) { -dev_err (dev,"Err getting AHB clks %d\n" , ret); -return ret; +if (!ACPI_HANDLE (&pdev->dev)) { + wrapper->ahb_clks[0 ].id ="m-ahb" ; + wrapper->ahb_clks[1 ].id ="s-ahb" ; + ret =devm_clk_bulk_get (dev,NUM_AHB_CLKS , wrapper->ahb_clks); +if (ret) { +dev_err (dev,"Err getting AHB clks %d\n" , ret); +return ret; + } }dev_set_drvdata (dev, wrapper);
Signature · 1 line
2.17.1
PATCH v2 6/8 usb: dwc3: qcom: Add support for booting with ACPI
In reply to Lee JonesIn Linux, the DWC3 core exists as its own independent platform device. Thus when describing relationships in Device Tree, the current default boot configuration table option, the DWC3 core often resides as a child of the platform specific node. Both of which are given their own address space descriptions and the drivers can be mostly agnostic to each other.
However, other Operating Systems have taken a more monolithic approach, which is evident in the configuration ACPI tables for the Qualcomm Snapdragon SDM850, where all DWC3 (core and platform) components are described under a single IO memory region.
To ensure successful booting using the supplied ACPI tables, we need to devise a way to chop up the address regions provided and subsequently register the DWC3 core with the resultant information, which is precisely what this patch aims to achieve.
--- drivers/usb/dwc3/Kconfig | 2 +- drivers/usb/dwc3/dwc3-qcom.c | 206 ++++++++++++++++++++++++++++++----- 2 files changed, 179 insertions(+), 29 deletions(-)
drivers/usb/dwc3/Kconfig +1 -1
@@ -116,7 +116,7 @@ config USB_DWC3_ST config USB_DWC3_QCOM tristate "Qualcomm Platform" depends on EXTCON && (ARCH_QCOM || COMPILE_TEST) - depends on OF + depends on (OF || ACPI) default USB_DWC3 help Some Qualcomm SoCs use DesignWare Core IP for USB2/3
drivers/usb/dwc3/dwc3-qcom.c +178 -28
313 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 7/8 usb: dwc3: qcom: Start USB in 'host mode' on the SDM845
In reply to Lee JonesWhen booting with Device Tree, the current default boot configuration table option, the request to boot via 'host mode' comes from the 'dr_mode' property. A property of the same name can be used inside ACPI tables too. However it is missing from the SDM845's ACPI tables so we have to supply this information using Platform Device Properties instead.
This does not change the behaviour of any currently supported devices. The property is only set on ACPI enabled platforms, thus for H/W booting DT, unless a 'dr_mode' property is present, the default is still OTG (On-The-Go) as per [0]. Any new ACPI devices added will also be able to over-ride this implementation by providing a 'dr_mode' property in their ACPI tables. In cases where 'dr_mode' is omitted from the tables AND 'host mode' should not be the default (very unlikely), then we will have to add some way of choosing between them at run time - most likely by ACPI HID.
[0] Documentation/devicetree/bindings/usb/generic.txt
--- drivers/usb/dwc3/dwc3-qcom.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/usb/dwc3/dwc3-qcom.c +12 -0
@@ -444,6 +444,11 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)return 0 ; } +static const struct property_entry dwc3_qcom_acpi_properties[] = { +PROPERTY_ENTRY_STRING ("dr_mode" ,"host" ), + {} +}; +static int dwc3_qcom_acpi_register_core (struct platform_device *pdev) {struct dwc3_qcom *qcom =platform_get_drvdata (pdev);
@@ -488,6 +493,13 @@ static int dwc3_qcom_acpi_register_core(struct platform_device *pdev) goto out; } + ret =platform_device_add_properties (qcom->dwc3, + dwc3_qcom_acpi_properties); +if (ret <0 ) { +dev_err (&pdev->dev,"failed to add properties\n" ); + goto out; + } + ret =platform_device_add (qcom->dwc3);if (ret)dev_err (&pdev->dev,"failed to add device\n" );
Signature · 1 line
2.17.1
PATCH v2 8/8 usb: dwc3: qcom: Improve error handling
In reply to Lee Jonesdwc3_qcom_clk_init() is called with of_count_phandle_with_args() as an argument. If of_count_phandle_with_args() returns an error, the number of clocks will be a negative value and will lead to undefined behaviour.
Ensure we check for an error before attempting to blindly use the value.
--- drivers/usb/dwc3/dwc3-qcom.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/dwc3/dwc3-qcom.c +3 -0
@@ -409,6 +409,9 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)if (!np || !count)return 0 ; +if (count <0 ) +return count; + qcom->num_clocks = count; qcom->clks = devm_kcalloc(dev, qcom->num_clocks,
Signature · 1 line
2.17.1
Quoted 23 lines · Lee Jones
Add a match table to allow automatic probing of ACPI device QCOM0220. Ignore clock attainment errors. Set default clock frequency value.
Signed-off-by Lee Jones <[email protected]>--- drivers/i2c/busses/i2c-qcom-geni.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-qcom-geni.c +1
-0@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. +#include <linux/acpi.h> #include <linux/clk.h> #include <linux/dma-mapping.h> #include <linux/err.h>
drivers/i2c/busses/i2c-qcom-geni.c static const struct i2c_algorithm geni_i2c_algo = { · line 492
Quoted 9 lines
drivers/i2c/busses/i2c-qcom-geni.c +6
-0@@ -483,6 +484,12 @@ static const struct i2c_algorithm geni_i2c_algo = { .functionality = geni_i2c_func, }; +static const struct acpi_device_id geni_i2c_acpi_match[] = { + {"QCOM0220" }, + { }, +}; +MODULE_DEVICE_TABLE (acpi, geni_i2c_acpi_match); +
We usually put #ifdef CONFIG_ACPI/#endif around these, otherwise you end up with acpi:XXXX modaliases even though ACPI is not compiled in.
drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 511
Quoted 7 lines
drivers/i2c/busses/i2c-qcom-geni.c +0
-0static int geni_i2c_probe (struct platform_device *pdev) {struct geni_i2c_dev *gi2c;@@ -502,7 +509,7 @@ static int geni_i2c_probe(struct platform_device *pdev)return PTR_ERR (gi2c->se.base); gi2c->se.clk =devm_clk_get (&pdev->dev,"se" );
Can we avoid this call altogether in ACPI mode? Also, please use 'has_acpi_companion()' to test whether we are probing via ACPI.
Quoted 15 lines
drivers/i2c/busses/i2c-qcom-geni.c +1
-1-if (IS_ERR (gi2c->se.clk)) { +if (IS_ERR (gi2c->se.clk) && !ACPI_HANDLE (&pdev->dev)) { ret =PTR_ERR (gi2c->se.clk);dev_err(&pdev->dev, "Err getting SE Core clk %d\n", ret); return ret;drivers/i2c/busses/i2c-qcom-geni.c +1
-1@@ -510,12 +517,19 @@ static int geni_i2c_probe(struct platform_device *pdev) ret =device_property_read_u32 (&pdev->dev,"clock-frequency" , &gi2c->clk_freq_out); -if (ret) { +if (ret && !ACPI_HANDLE (&pdev->dev)) {dev_info (&pdev->dev,"Bus frequency not specified, default to 100kHz.\n" );
drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 532
Quoted 10 lines
drivers/i2c/busses/i2c-qcom-geni.c +7
-0gi2c->clk_freq_out =KHZ (100 ); } +if (ACPI_HANDLE (&pdev->dev)) { +ACPI_COMPANION_SET (&gi2c->adap.dev,ACPI_COMPANION (&pdev->dev)); + +/* Using default, same as the !ACPI case above */ + gi2c->clk_freq_out =KHZ (100 ); + } +
You are overriding the speed to 100 kHz even if the ACPI device has a "clock-frequency" property.
Quoted 19 lines
drivers/i2c/busses/i2c-qcom-geni.c +1
-1gi2c->irq =platform_get_irq (pdev,0 );if (gi2c->irq <0 ) {dev_err (&pdev->dev,"IRQ error for i2c-geni\n" );@@ -660,6 +674,7 @@ static struct platform_driver geni_i2c_driver = { .name = "geni_i2c", .pm = &geni_i2c_pm_ops, .of_match_table = geni_i2c_dt_match, + .acpi_match_table = ACPI_PTR(geni_i2c_acpi_match), }, }; --2.17.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 2/8] i2c: i2c-qcom-geni: Signify successful driver probe
In reply to Lee JonesQuoted 15 lines · Lee Jones
The Qualcomm Geni I2C driver currently probes silently which can be confusing when debugging potential issues. Add a low level (INFO) print when each I2C controller is successfully initially set-up.
Signed-off-by Lee Jones <[email protected]>--- drivers/i2c/busses/i2c-qcom-geni.c | 2 ++ 1 file changed, 2 insertions(+)drivers/i2c/busses/i2c-qcom-geni.c +0
-0
drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 605
Quoted 8 lines
drivers/i2c/busses/i2c-qcom-geni.c +2
-0@@ -598,6 +598,8 @@ static int geni_i2c_probe(struct platform_device *pdev)return ret; } +dev_dbg (&pdev->dev,"Geni-I2C adaptor successfully added\n" ); +return 0 ; }
Re: [PATCH v2 3/8] pinctrl: msm: Add ability for drivers to supply a reserved GPIO list
In reply to Lee JonesQuoted 7 lines · Lee Jones
When booting MSM based platforms with Device Tree or some ACPI implementations, it is possible to provide a list of reserved pins via the 'gpio-reserved-ranges' and 'gpios' properties respectively. However some ACPI tables are not populated with this information, thus it has to come from a knowledgable device driver instead.
Quoted 5 lines
Here we provide the MSM common driver with additional support to parse this informtion and correctly populate the widely used '
valid_mask'.Signed-off-by Lee Jones <[email protected]>
I'm not sure if this is the correct approach. Presumably, on ACPI systems, all the pinctl stuff is already set up by the firmware, and so we shouldn't touch *any* pins unless they have been requested explicitly. Is there any way we can support this in the current framework?
Quoted 63 lines
--- drivers/pinctrl/qcom/pinctrl-msm.c | 18 ++++++++++++++++++ drivers/pinctrl/qcom/pinctrl-msm.h | 1 + 2 files changed, 19 insertions(+)drivers/pinctrl/qcom/pinctrl-msm.c +18
-0@@ -607,8 +607,23 @@ static int msm_gpio_init_valid_mask(struct gpio_chip *chip)int ret;unsigned int len, i;unsigned int max_gpios = pctrl->soc->ngpios; +const int *reserved = pctrl->soc->reserved_gpios;u16 *tmp; +/* Driver provided reserved list overrides DT and ACPI */ +if (reserved) { +bitmap_fill (chip->valid_mask, max_gpios); +for (i =0 ; reserved[i] >=0 ; i++) { +if (i >= max_gpios || reserved[i] >= max_gpios) { +dev_err (pctrl->dev,"invalid list of reserved GPIOs\n" ); +return -EINVAL ; + } +clear_bit (reserved[i], chip->valid_mask); + } + +return 0 ; + } +/* The number of GPIOs in the ACPI tables */ len = ret =device_property_read_u16_array (pctrl->dev,"gpios" ,NULL ,0 );@@ -964,6 +979,9 @@ static void msm_gpio_irq_handler(struct irq_desc *desc)static bool msm_gpio_needs_valid_mask (struct msm_pinctrl *pctrl) { +if (pctrl->soc->reserved_gpios) +return true; +return device_property_read_u16_array (pctrl->dev,"gpios" ,NULL ,0 ) >0 ; }drivers/pinctrl/qcom/pinctrl-msm.h +1
-1@@ -121,6 +121,7 @@ struct msm_pinctrl_soc_data {bool pull_no_keeper;const char *const *tiles;unsigned int ntiles; +const int *reserved_gpios; };extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops; --2.17.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 4/8] pinctrl: qcom: sdm845: Provide ACPI support
In reply to Lee JonesQuoted 73 lines · Lee Jones
This patch provides basic support for booting with ACPI instead of the currently supported Device Tree. When doing so there are a couple of differences which we need to taken into consideration.
Firstly, the SDM850 ACPI tables omit information pertaining to the 4 reserved GPIOs on the platform. If Linux attempts to touch/ initialise any of these lines, the firmware will restart the platform.
Secondly, when booting with ACPI, it is expected that the firmware will set-up things like; Regulators, Clocks, Pin Functions, etc in their ideal configuration. Thus, the possible Pin Functions available to this platform are not advertised when providing the higher GPIOD/Pinctrl APIs with pin information.
Signed-off-by Lee Jones <[email protected]>--- drivers/pinctrl/qcom/Kconfig | 2 +- drivers/pinctrl/qcom/pinctrl-sdm845.c | 35 ++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-)drivers/pinctrl/qcom/Kconfig +1
-1@@ -168,7 +168,7 @@ config PINCTRL_SDM660 config PINCTRL_SDM845 tristate "Qualcomm Technologies Inc SDM845 pin controller driver" - depends on GPIOLIB && OF + depends on GPIOLIB && (OF || ACPI) select PINCTRL_MSM help This is the pinctrl, pinmux, pinconf and gpiolib driver for thedrivers/pinctrl/qcom/pinctrl-sdm845.c +15
-0@@ -3,6 +3,7 @@* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */ +#include <linux/acpi.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> @@ -1277,6 +1278,10 @@ static const struct msm_pingroup sdm845_groups[] = { UFS_RESET(ufs_reset, 0x99f000), }; +static const int sdm845_acpi_reserved_gpios[] = { +0 ,1 ,2 ,3 ,81 ,82 ,83 ,84 ,-1 +}; +static const struct msm_pinctrl_soc_data sdm845_pinctrl = { .pins = sdm845_pins, .npins =ARRAY_SIZE (sdm845_pins),@@ -1284,14 +1289,41 @@ static const struct msm_pinctrl_soc_data sdm845_pinctrl = { .nfunctions = ARRAY_SIZE(sdm845_functions), .groups = sdm845_groups, .ngroups = ARRAY_SIZE(sdm845_groups), + .reserved_gpios = sdm845_acpi_reserved_gpios, + .ngpios = 150, +}; + +static const struct msm_pinctrl_soc_data sdm845_acpi_pinctrl = { + .pins = sdm845_pins, + .npins =ARRAY_SIZE (sdm845_pins), + .groups = sdm845_groups, + .ngroups =ARRAY_SIZE (sdm845_groups), + .reserved_gpios = sdm845_acpi_reserved_gpios, .ngpios =150 ,
drivers/pinctrl/qcom/pinctrl-sdm845.c static const struct msm_pinctrl_soc_data sdm845_pinctrl = { · line 1311
Quoted 10 lines
drivers/pinctrl/qcom/pinctrl-sdm845.c +5
-1};static int sdm845_pinctrl_probe (struct platform_device *pdev) { -return msm_pinctrl_probe (pdev, &sdm845_pinctrl); +int ret; + +if (pdev->dev.of_node) { + ret =msm_pinctrl_probe (pdev, &sdm845_pinctrl); + }else if (ACPI_HANDLE (&pdev->dev)) {
Please use has_acpi_companion() here
Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-sdm845.c +5
-0+ ret =msm_pinctrl_probe (pdev, &sdm845_acpi_pinctrl); + }else { +dev_err (&pdev->dev,"DT and ACPI disabled\n" ); +return -EINVAL ; + }
drivers/pinctrl/qcom/pinctrl-sdm845.c static const struct msm_pinctrl_soc_data sdm845_pinctrl = { · line 1326
Quoted 10 lines
drivers/pinctrl/qcom/pinctrl-sdm845.c +8
-0+ +return ret; } +static const struct acpi_device_id sdm845_pinctrl_acpi_match[] = { + {"QCOM0217" }, + { }, +}; +MODULE_DEVICE_TABLE (acpi, sdm845_pinctrl_acpi_match); +
Put this in a #ifdef CONFIG_ACPI please
Quoted 19 lines
drivers/pinctrl/qcom/pinctrl-sdm845.c +1
-1static const struct of_device_id sdm845_pinctrl_of_match[] = { { .compatible ="qcom,sdm845-pinctrl" , }, { },@@ -1302,6 +1334,7 @@ static struct platform_driver sdm845_pinctrl_driver = { .name = "sdm845-pinctrl", .pm = &msm_pinctrl_dev_pm_ops, .of_match_table = sdm845_pinctrl_of_match, + .acpi_match_table = ACPI_PTR(sdm845_pinctrl_acpi_match), }, .probe = sdm845_pinctrl_probe, .remove = msm_pinctrl_remove, --2.17.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 5/8] soc: qcom: geni: Add support for ACPI
In reply to Lee JonesQuoted 25 lines · Lee Jones
When booting with ACPI as the active set of configuration tables, all; clocks, regulators, pin functions ect are expected to be at their ideal values/levels/rates, thus the associated frameworks are unavailable. Ensure calls to these APIs are shielded when ACPI is enabled.
Signed-off-by Lee Jones <[email protected]>--- drivers/soc/qcom/qcom-geni-se.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)drivers/soc/qcom/qcom-geni-se.c +1
-0@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. +#include <linux/acpi.h> #include <linux/clk.h> #include <linux/slab.h> #include <linux/dma-mapping.h>
drivers/soc/qcom/qcom-geni-se.c int geni_se_resources_off(struct geni_se *se) · line 454
Quoted 4 lines
drivers/soc/qcom/qcom-geni-se.c +1
-0@@ -450,6 +451,9 @@ int geni_se_resources_off(struct geni_se *se) {int ret; +if (ACPI_HANDLE (se->dev))
Please use has_acpi_companion() here
drivers/soc/qcom/qcom-geni-se.c int geni_se_resources_on(struct geni_se *se) · line 496
Quoted 12 lines
drivers/soc/qcom/qcom-geni-se.c +5
-0+return 0 ; + ret =pinctrl_pm_select_sleep_state (se->dev);if (ret)return ret;@@ -487,6 +491,9 @@ int geni_se_resources_on(struct geni_se *se) {int ret; +if (ACPI_HANDLE (se->dev)) +return 0 ; +
Same
Quoted 4 lines
drivers/soc/qcom/qcom-geni-se.c +0
-0ret =geni_se_clks_on (se);if (ret)return ret;
drivers/soc/qcom/qcom-geni-se.c static int geni_se_probe(struct platform_device *pdev) · line 734
Quoted 10 lines
drivers/soc/qcom/qcom-geni-se.c +1
-6@@ -724,12 +731,14 @@ static int geni_se_probe(struct platform_device *pdev)if (IS_ERR (wrapper->base))return PTR_ERR (wrapper->base); - wrapper->ahb_clks[0 ].id ="m-ahb" ; - wrapper->ahb_clks[1 ].id ="s-ahb" ; - ret =devm_clk_bulk_get (dev,NUM_AHB_CLKS , wrapper->ahb_clks); -if (ret) { -dev_err (dev,"Err getting AHB clks %d\n" , ret); -return ret; +if (!ACPI_HANDLE (&pdev->dev)) {
Same
Quoted 18 lines
drivers/soc/qcom/qcom-geni-se.c +7
-1+ wrapper->ahb_clks[0 ].id ="m-ahb" ; + wrapper->ahb_clks[1 ].id ="s-ahb" ; + ret =devm_clk_bulk_get (dev,NUM_AHB_CLKS , wrapper->ahb_clks); +if (ret) { +dev_err (dev,"Err getting AHB clks %d\n" , ret); +return ret; + } }dev_set_drvdata (dev, wrapper); --2.17.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 3/8] pinctrl: msm: Add ability for drivers to supply a reserved GPIO list
In reply to Ard BiesheuvelQuoted 12 lines · Ard Biesheuvel
Quoted 11 lines · Lee Jones
When booting MSM based platforms with Device Tree or some ACPI implementations, it is possible to provide a list of reserved pins via the 'gpio-reserved-ranges' and 'gpios' properties respectively. However some ACPI tables are not populated with this information, thus it has to come from a knowledgable device driver instead.
Here we provide the MSM common driver with additional support to parse this informtion and correctly populate the widely used '
valid_mask'.
Quoted 8 lines
Quoted 1 line
Signed-off-by Lee Jones <[email protected]>I'm not sure if this is the correct approach. Presumably, on ACPI systems, all the pinctl stuff is already set up by the firmware, and so we shouldn't touch *any* pins unless they have been requested explicitly. Is there any way we can support this in the current framework?
The only reason why we do this (at least the initial reason) is because gpiolib will read the current state of all GPIOs during initialization.
But due to the sensitive nature of the application using these pins Linux is prohibited from touching the associated GPIO/pinmux/pinconf registers - resulting in a security violation if we allow gpiolib to touch them.
When it comes to pinmux/pinconf those are only poked explicitly and those seems to be described in PEP nodes, such as:
Package (0x02)
{
"TLMMGPIO",
Package (0x06)
{
0x2C,
One,
Zero,
One,
Zero,
Zero
}
},So the pinctrl-sdm845/msm drivers gives us GPIOs, but for pinconf and pinmux there's a need for something very different from what we're used to.
Regards,
Bjorn
Quoted 63 lines
Quoted 63 lines
--- drivers/pinctrl/qcom/pinctrl-msm.c | 18 ++++++++++++++++++ drivers/pinctrl/qcom/pinctrl-msm.h | 1 + 2 files changed, 19 insertions(+)drivers/pinctrl/qcom/pinctrl-msm.c +18
-0@@ -607,8 +607,23 @@ static int msm_gpio_init_valid_mask(struct gpio_chip *chip)int ret;unsigned int len, i;unsigned int max_gpios = pctrl->soc->ngpios; +const int *reserved = pctrl->soc->reserved_gpios;u16 *tmp; +/* Driver provided reserved list overrides DT and ACPI */ +if (reserved) { +bitmap_fill (chip->valid_mask, max_gpios); +for (i =0 ; reserved[i] >=0 ; i++) { +if (i >= max_gpios || reserved[i] >= max_gpios) { +dev_err (pctrl->dev,"invalid list of reserved GPIOs\n" ); +return -EINVAL ; + } +clear_bit (reserved[i], chip->valid_mask); + } + +return 0 ; + } +/* The number of GPIOs in the ACPI tables */ len = ret =device_property_read_u16_array (pctrl->dev,"gpios" ,NULL ,0 );@@ -964,6 +979,9 @@ static void msm_gpio_irq_handler(struct irq_desc *desc)static bool msm_gpio_needs_valid_mask (struct msm_pinctrl *pctrl) { +if (pctrl->soc->reserved_gpios) +return true; +return device_property_read_u16_array (pctrl->dev,"gpios" ,NULL ,0 ) >0 ; }drivers/pinctrl/qcom/pinctrl-msm.h +1
-1@@ -121,6 +121,7 @@ struct msm_pinctrl_soc_data {bool pull_no_keeper;const char *const *tiles;unsigned int ntiles; +const int *reserved_gpios; };extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops; --2.17.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 3/8] pinctrl: msm: Add ability for drivers to supply a reserved GPIO list
In reply to Ard BiesheuvelQuoted 12 lines · Ard Biesheuvel
Quoted 11 lines · Lee Jones
When booting MSM based platforms with Device Tree or some ACPI implementations, it is possible to provide a list of reserved pins via the 'gpio-reserved-ranges' and 'gpios' properties respectively. However some ACPI tables are not populated with this information, thus it has to come from a knowledgable device driver instead.
Here we provide the MSM common driver with additional support to parse this informtion and correctly populate the widely used '
valid_mask'.
Quoted 7 lines
Quoted 1 line
Signed-off-by Lee Jones <[email protected]>I'm not sure if this is the correct approach. Presumably, on ACPI systems, all the pinctl stuff is already set up by the firmware, and so we shouldn't touch *any* pins unless they have been requested explicitly. Is there any way we can support this in the current framework?
I don't suppose anything but the GPIO portions of the pinctrl driver is ever used under ACPI. I guess in an ideal ACPI world noone (like userspace) would ever use a GPIO because ACPI would have all GPIOs assigned a particular purpose, so accessing any of them would lead to a crash.
But in practice it seems a lot of GPIOs are available and used for example by userspace hacks, so just blacklisting the ones that cannot be accessed by the GPIO subsystem seems like a viable compromise.
Then we have the ACPI paradigm of pin control being controlled by ACPI: this is also great in theory, but it seems like the ACPI firmware has in cases forgot or omitted to implement some of it and people need to access it anyways. The people writing the default firmware cannot think out or test all usecases, so some will be left open-ended to non-firmware authoring users. This is why drivers/pinctrl/intel/* exists despite being for exclusively ACPI platforms. Being able to control pins also from the kernel has become a viable compromise.
Yours,
Linus Walleij
Quoted 27 lines · Ard Biesheuvel
Quoted 26 lines · Lee Jones
Add a match table to allow automatic probing of ACPI device QCOM0220. Ignore clock attainment errors. Set default clock frequency value.
Signed-off-by Lee Jones <[email protected]>--- drivers/i2c/busses/i2c-qcom-geni.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-qcom-geni.c +1
-0@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. +#include <linux/acpi.h> #include <linux/clk.h> #include <linux/dma-mapping.h> #include <linux/err.h> @@ -483,6 +484,12 @@ static const struct i2c_algorithm geni_i2c_algo = { .functionality = geni_i2c_func, };
Quoted 9 lines
drivers/i2c/busses/i2c-qcom-geni.c static const struct i2c_algorithm geni_i2c_algo = { · line 492
Quoted 6 lines
drivers/i2c/busses/i2c-qcom-geni.c +6
-0+static const struct acpi_device_id geni_i2c_acpi_match[] = { + {"QCOM0220" }, + { }, +}; +MODULE_DEVICE_TABLE (acpi, geni_i2c_acpi_match); +We usually put #ifdef CONFIG_ACPI/#endif around these, otherwise you end up with acpi:XXXX modaliases even though ACPI is not compiled in.
No problem.
Quoted 9 lines
drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 511
Quoted 7 lines
drivers/i2c/busses/i2c-qcom-geni.c +0
-0static int geni_i2c_probe (struct platform_device *pdev) {struct geni_i2c_dev *gi2c;@@ -502,7 +509,7 @@ static int geni_i2c_probe(struct platform_device *pdev)return PTR_ERR (gi2c->se.base); gi2c->se.clk =devm_clk_get (&pdev->dev,"se" );Can we avoid this call altogether in ACPI mode? Also, please use
I'm trying not to place all non-ACPI specific callers into if () statements. The tabbing becomes ridiculous in some places. A great deal of these calls are requesting optional resources too, so it's better to simply ignore the returning error in the cases where non-optional resources (such as this one) are requested, since it has the least impact on the existing code.
Quoted 1 line
'
has_acpi_companion()' to test whether we are probing via ACPI.
Sure.
Quoted 18 lines
Quoted 18 lines
drivers/i2c/busses/i2c-qcom-geni.c +1
-1-if (IS_ERR (gi2c->se.clk)) { +if (IS_ERR (gi2c->se.clk) && !ACPI_HANDLE (&pdev->dev)) { ret =PTR_ERR (gi2c->se.clk);dev_err(&pdev->dev, "Err getting SE Core clk %d\n", ret); return ret;drivers/i2c/busses/i2c-qcom-geni.c +1
-1@@ -510,12 +517,19 @@ static int geni_i2c_probe(struct platform_device *pdev) ret =device_property_read_u32 (&pdev->dev,"clock-frequency" , &gi2c->clk_freq_out); -if (ret) { +if (ret && !ACPI_HANDLE (&pdev->dev)) {dev_info (&pdev->dev,"Bus frequency not specified, default to 100kHz.\n" ); gi2c->clk_freq_out =KHZ (100 ); }
Quoted 10 lines
drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 532
Quoted 7 lines
drivers/i2c/busses/i2c-qcom-geni.c +7
-0+if (ACPI_HANDLE (&pdev->dev)) { +ACPI_COMPANION_SET (&gi2c->adap.dev,ACPI_COMPANION (&pdev->dev)); + +/* Using default, same as the !ACPI case above */ + gi2c->clk_freq_out =KHZ (100 ); + } +You are overriding the speed to 100 kHz even if the ACPI device has a "clock-frequency" property.
Will look at this.
Thanks Ard.
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog