Skip to contentSkip to conversation

i2c: i2c-qcom-geni: Provide support for ACPI

PATCH In review Lee Jones 6 participants 34 messages Jun 4, 2019 – Jun 12, 2019

Subsystems (10)
lore
Share & tools
lore

Lee Jones

author
#0 lore raw

PATCH 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
index db075bc0d952..0fa93b448e8d 100644
@@ -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
author
#1 lore raw

PATCH 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
index 0fa93b448e8d..e27466d77767 100644
@@ -598,6 +598,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	dev_info(&pdev->dev, "Geni-I2C adaptor successfully added\n");
+
 	return 0;
 }
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

Quoted 14 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.

---
 drivers/i2c/busses/i2c-qcom-geni.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-qcom-geni.c +0 -0
index 0fa93b448e8d..e27466d77767 100644

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 602

Quoted 5 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_info(&pdev->dev, "Geni-I2C adaptor successfully added\n");
+

I would prefer that we do not add such prints, as it would be to accept the downstream behaviour of spamming the log to the point where no one will ever look through it.

Regards,
Bjorn

Quoted 6 lines
drivers/i2c/busses/i2c-qcom-geni.c +0 -0
 	return 0;
 }
 
Signature · 1 line
2.17.1
author
#3 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

Quoted 19 lines · Bjorn Andersson
Quoted 17 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.

---
 drivers/i2c/busses/i2c-qcom-geni.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-qcom-geni.c +0 -0
index 0fa93b448e8d..e27466d77767 100644
@@ -598,6 +598,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
 		return ret;
 	}
 
Quoted 6 lines

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 602

Quoted 2 lines
drivers/i2c/busses/i2c-qcom-geni.c +2 -0
+	dev_info(&pdev->dev, "Geni-I2C adaptor successfully added\n");
+

I would prefer that we do not add such prints, as it would be to accept the downstream behaviour of spamming the log to the point where no one will ever look through it.

We should be able to find a middle ground. Spamming the log with all sorts of device specific information/debug is obviously not constructive, but a single liner to advertise that an important device/controller has been successfully initialised is more helpful than it is hinderous.

This print was added due to the silent initialisation costing me several hours of debugging ACPI device/driver code (albeit learning a lot about ACPI as I go) just to find out that it was already doing the right thing - just very quietly.

Signature · 9 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

Quoted 35 lines · Lee Jones
Quoted 19 lines · Bjorn Andersson
Quoted 17 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.

---
 drivers/i2c/busses/i2c-qcom-geni.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-qcom-geni.c +0 -0
index 0fa93b448e8d..e27466d77767 100644
@@ -598,6 +598,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
            return ret;
    }
 
Quoted 6 lines

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 602

Quoted 2 lines
drivers/i2c/busses/i2c-qcom-geni.c +2 -0
+   dev_info(&pdev->dev, "Geni-I2C adaptor successfully added\n");
+

I would prefer that we do not add such prints, as it would be to accept the downstream behaviour of spamming the log to the point where no one will ever look through it.

We should be able to find a middle ground. Spamming the log with all sorts of device specific information/debug is obviously not constructive, but a single liner to advertise that an important device/controller has been successfully initialised is more helpful than it is hinderous.

Quoted 5 lines

This print was added due to the silent initialisation costing me several hours of debugging ACPI device/driver code (albeit learning a lot about ACPI as I go) just to find out that it was already doing the right thing - just very quietly.

I agree.

There are numerous EHCI drivers IIRC which, if compiled in, unconditionally print some blurb, whether you have the hardware or not, which is pretty annoying.

In this case, however, having a single line per successfully probed device (containing the dev_name and perhaps the MMIO base address or some other identifying feature) is pretty useful, and shouldn't be regarded as log spamming imo. dev_info() honours the 'quiet' kernel command line parameter, and so you will only see the message if you actually look at the log.

author
#5 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

Quoted 48 lines · Ard Biesheuvel
Quoted 35 lines · Lee Jones
Quoted 19 lines · Bjorn Andersson
Quoted 17 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.

---
 drivers/i2c/busses/i2c-qcom-geni.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-qcom-geni.c +0 -0
index 0fa93b448e8d..e27466d77767 100644
@@ -598,6 +598,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
            return ret;
    }
 
Quoted 6 lines

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 602

Quoted 2 lines
drivers/i2c/busses/i2c-qcom-geni.c +2 -0
+   dev_info(&pdev->dev, "Geni-I2C adaptor successfully added\n");
+

I would prefer that we do not add such prints, as it would be to accept the downstream behaviour of spamming the log to the point where no one will ever look through it.

We should be able to find a middle ground. Spamming the log with all sorts of device specific information/debug is obviously not constructive, but a single liner to advertise that an important device/controller has been successfully initialised is more helpful than it is hinderous.

Quoted 5 lines

This print was added due to the silent initialisation costing me several hours of debugging ACPI device/driver code (albeit learning a lot about ACPI as I go) just to find out that it was already doing the right thing - just very quietly.

I agree.

There are numerous EHCI drivers IIRC which, if compiled in, unconditionally print some blurb, whether you have the hardware or not, which is pretty annoying.

Quoted 6 lines

In this case, however, having a single line per successfully probed device (containing the dev_name and perhaps the MMIO base address or some other identifying feature) is pretty useful, and shouldn't be regarded as log spamming imo. dev_info() honours the 'quiet' kernel command line parameter, and so you will only see the message if you actually look at the log.

+999

This is exactly as I see it.

If people want a quiet log/fast boot-up times, they can request it. Otherwise, it's far more useful to trade a second or two for important information such as which devices are present/enabled on a platform.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#6 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

In reply to Lee Jones
Quoted 34 lines · Lee Jones
Quoted 19 lines · Bjorn Andersson
Quoted 17 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.

---
 drivers/i2c/busses/i2c-qcom-geni.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-qcom-geni.c +0 -0
index 0fa93b448e8d..e27466d77767 100644
@@ -598,6 +598,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
 		return ret;
 	}
 
Quoted 6 lines

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 602

Quoted 2 lines
drivers/i2c/busses/i2c-qcom-geni.c +2 -0
+	dev_info(&pdev->dev, "Geni-I2C adaptor successfully added\n");
+

I would prefer that we do not add such prints, as it would be to accept the downstream behaviour of spamming the log to the point where no one will ever look through it.

We should be able to find a middle ground. Spamming the log with all sorts of device specific information/debug is obviously not constructive, but a single liner to advertise that an important device/controller has been successfully initialised is more helpful than it is hinderous.

Quoted 4 lines

This print was added due to the silent initialisation costing me several hours of debugging ACPI device/driver code (albeit learning a lot about ACPI as I go) just to find out that it was already doing the right thing - just very quietly.

No, we don't add noise like this to the logs just because it may be useful while debugging. Even one-liners add up.

There are plenty of options for debugging already ranging from adding a temporary dev_info() to the probe function in question to using dynamic debugging to have driver core log every successful probe.

And in this case you say the driver was in fact already bound; that can easily be verified through sysfs too in case things aren't behaving the way you expect.

Johan

author
#7 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

Quoted 35 lines · Johan Hovold
Quoted 34 lines · Lee Jones
Quoted 19 lines · Bjorn Andersson
Quoted 17 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.

---
 drivers/i2c/busses/i2c-qcom-geni.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-qcom-geni.c +0 -0
index 0fa93b448e8d..e27466d77767 100644
@@ -598,6 +598,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
 		return ret;
 	}
 
Quoted 6 lines

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 602

Quoted 2 lines
drivers/i2c/busses/i2c-qcom-geni.c +2 -0
+	dev_info(&pdev->dev, "Geni-I2C adaptor successfully added\n");
+

I would prefer that we do not add such prints, as it would be to accept the downstream behaviour of spamming the log to the point where no one will ever look through it.

We should be able to find a middle ground. Spamming the log with all sorts of device specific information/debug is obviously not constructive, but a single liner to advertise that an important device/controller has been successfully initialised is more helpful than it is hinderous.

Quoted 7 lines
Quoted 4 lines

This print was added due to the silent initialisation costing me several hours of debugging ACPI device/driver code (albeit learning a lot about ACPI as I go) just to find out that it was already doing the right thing - just very quietly.

No, we don't add noise like this to the logs just because it may be useful while debugging. Even one-liners add up.

One line per device is should not cause an issue.

Problems occur when developers try to print all kinds of device specifics to the boot log. A simple, single line for such an important device/controller has more benefits than drawbacks.

Quoted 3 lines

There are plenty of options for debugging already ranging from adding a temporary dev_info() to the probe function in question to using dynamic debugging to have driver core log every successful probe.

This is what I ended up doing. It was time consuming to parse though a log of that size when you have no paging or keyboard.

Quoted 3 lines

And in this case you say the driver was in fact already bound; that can easily be verified through sysfs too in case things aren't behaving the way you expect.

Not in a non-booting system with no keyboard you can't. ;)

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#8 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

Quoted 10 lines · Lee Jones
Quoted 2 lines · Johan Hovold

No, we don't add noise like this to the logs just because it may be useful while debugging. Even one-liners add up.

One line per device is should not cause an issue.

Problems occur when developers try to print all kinds of device specifics to the boot log. A simple, single line for such an important device/controller has more benefits than drawbacks.

What about the thousands of probe functions which do not currently spam the logs? If you want to see all successful probes reliably, you tell driver core to print it.

Quoted 6 lines
Quoted 3 lines

There are plenty of options for debugging already ranging from adding a temporary dev_info() to the probe function in question to using dynamic debugging to have driver core log every successful probe.

This is what I ended up doing. It was time consuming to parse though a log of that size when you have no paging or keyboard.

With the right command-line option to enable dynamic debugging you get one line per successful probe, just like you wanted. Or are you now saying that one-line per device is too much after all? ;)

Quoted 5 lines
Quoted 3 lines

And in this case you say the driver was in fact already bound; that can easily be verified through sysfs too in case things aren't behaving the way you expect.

Not in a non-booting system with no keyboard you can't. ;)

Fair enough, but the above would still work.

Johan

author
#9 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

Quoted 20 lines · Johan Hovold
Quoted 10 lines · Lee Jones
Quoted 2 lines · Johan Hovold

No, we don't add noise like this to the logs just because it may be useful while debugging. Even one-liners add up.

One line per device is should not cause an issue.

Problems occur when developers try to print all kinds of device specifics to the boot log. A simple, single line for such an important device/controller has more benefits than drawbacks.

What about the thousands of probe functions which do not currently spam the logs? If you want to see all successful probes reliably, you tell driver core to print it.

Quoted 4 lines
Quoted 3 lines

There are plenty of options for debugging already ranging from adding a temporary dev_info() to the probe function in question to using dynamic debugging to have driver core log every successful probe.

Quoted 6 lines
Quoted 2 lines

This is what I ended up doing. It was time consuming to parse though a log of that size when you have no paging or keyboard.

With the right command-line option to enable dynamic debugging you get one line per successful probe, just like you wanted. Or are you now saying that one-line per device is too much after all? ;)

Which command line option are you pertaining to?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

And in this case you say the driver was in fact already bound; that can easily be verified through sysfs too in case things aren't behaving the way you expect.

Not in a non-booting system with no keyboard you can't. ;)

Fair enough, but the above would still work.

Signature · 9 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#10 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

Quoted 9 lines · Lee Jones
Quoted 7 lines · Johan Hovold
Quoted 6 lines · Lee Jones
Quoted 3 lines · Johan Hovold

There are plenty of options for debugging already ranging from adding a temporary dev_info() to the probe function in question to using dynamic debugging to have driver core log every successful probe.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

This is what I ended up doing. It was time consuming to parse though a log of that size when you have no paging or keyboard.

With the right command-line option to enable dynamic debugging you get one line per successful probe, just like you wanted. Or are you now saying that one-line per device is too much after all? ;)

Which command line option are you pertaining to?

To enable dynamic debugging in driver core you could use something like

CONFIG_CMDLINE="dyndbg=\"func really_probe =p\""

That gives you two printouts per successful probe, for example:

bus: 'usb-serial': really_probe: probing driver edgeport_ti_1 with device ttyUSB0
bus: 'usb-serial': really_probe: bound device ttyUSB0 to driver edgeport_ti_1

Or you can of course just change the corresponding pr_debug to pr_info while debugging.

Johan

#11 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

Quoted 9 lines

To enable dynamic debugging in driver core you could use something like

CONFIG_CMDLINE="dyndbg=\"func really_probe =p\""

That gives you two printouts per successful probe, for example:

bus: 'usb-serial': really_probe: probing driver edgeport_ti_1 with device ttyUSB0
bus: 'usb-serial': really_probe: bound device ttyUSB0 to driver edgeport_ti_1

I agree that this scales much better than adding strings to every driver. Also, the driver core will report failed probes other than -ENODEV, or?

Regarding this patch, however, I don't care much. I'll let the driver maintainers decide.

author
#12 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

Quoted 10 lines · Wolfram Sang
Quoted 9 lines

To enable dynamic debugging in driver core you could use something like

CONFIG_CMDLINE="dyndbg=\"func really_probe =p\""

That gives you two printouts per successful probe, for example:

bus: 'usb-serial': really_probe: probing driver edgeport_ti_1 with device ttyUSB0
bus: 'usb-serial': really_probe: bound device ttyUSB0 to driver edgeport_ti_1

Quoted 6 lines

I agree that this scales much better than adding strings to every driver. Also, the driver core will report failed probes other than -ENODEV, or?

Regarding this patch, however, I don't care much. I'll let the driver maintainers decide.

I've downgraded this to dev_dbg() in v2.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#13 lore raw

Re: [PATCH 2/8] i2c: i2c-qcom-geni: Signify successful driver probe

In reply to Wolfram Sang
Quoted 5 lines · Wolfram Sang
Quoted 5 lines

To enable dynamic debugging in driver core you could use something like

CONFIG_CMDLINE="dyndbg=\"func really_probe =p\""

Quoted 8 lines
Quoted 4 lines

That gives you two printouts per successful probe, for example:

bus: 'usb-serial': really_probe: probing driver edgeport_ti_1 with device ttyUSB0
bus: 'usb-serial': really_probe: bound device ttyUSB0 to driver edgeport_ti_1

I agree that this scales much better than adding strings to every driver. Also, the driver core will report failed probes other than -ENODEV, or?

Right, errors other than -EPROBE_DEFER, -ENODEV and -ENXIO are always logged, and the previous three would also be logged with debugging enabled.

Johan

author
#14 lore raw

PATCH 3/8 pinctrl: msm: Add ability for drivers to supply a reserved GPIO list

In reply to 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'.

---
 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
index ee8119879c4c..b77f22348907 100644
@@ -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; i < max_gpios && 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
index c12048e54a6f..23b93ae92269 100644
@@ -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
author
#15 lore raw

PATCH 4/8 pinctrl: qcom: sdm845: Provide ACPI support

In reply to 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.

---
 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
index 2e66ab72c10b..aafbe932424f 100644
@@ -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
index c97f20fca5fd..7188bee3cf3e 100644
@@ -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
#16 lore raw

Re: [PATCH 4/8] pinctrl: qcom: sdm845: Provide ACPI support

Quoted 58 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.

---
 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
index 2e66ab72c10b..aafbe932424f 100644
@@ -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 +5 -0
index c97f20fca5fd..7188bee3cf3e 100644
@@ -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),

drivers/pinctrl/qcom/pinctrl-sdm845.c static const struct msm_pinctrl_soc_data sdm845_pinctrl = { · line 1292

Quoted 4 lines
drivers/pinctrl/qcom/pinctrl-sdm845.c +1 -0
@@ -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,

The reason why put these in DT is because the list is board/firmware dependent. E.g. the firmware on db845c does not support the peripherals that sits on these 8 pins and as such these are not reserved.

But given that the two structs looks identical now, did you perhaps not intend to add.reserved_gpios for the non-ACPI case?

Regards,
Bjorn

Quoted 49 lines
drivers/pinctrl/qcom/pinctrl-sdm845.c +28 -1
+	.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
author
#17 lore raw

Re: [PATCH 4/8] pinctrl: qcom: sdm845: Provide ACPI support

Quoted 52 lines · Bjorn Andersson
Quoted 50 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.

---
 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
index 2e66ab72c10b..aafbe932424f 100644
@@ -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 +1 -0
index c97f20fca5fd..7188bee3cf3e 100644
@@ -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),
 };
 
Quoted 16 lines

drivers/pinctrl/qcom/pinctrl-sdm845.c static const struct msm_pinctrl_soc_data sdm845_pinctrl = { · line 1292

Quoted 12 lines
drivers/pinctrl/qcom/pinctrl-sdm845.c +5 -0
+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,

The reason why put these in DT is because the list is board/firmware dependent. E.g. the firmware on db845c does not support the peripherals that sits on these 8 pins and as such these are not reserved.

If we need to be more particular about which platform(s) this affects, we could add matching based on their differences (some ACPI HID or F/W version/descriptor, etc) as and when we enable them for booting with ACPI.

Quoted 2 lines

But given that the two structs looks identical now, did you perhaps not intend to add.reserved_gpios for the non-ACPI case?

Given your example above, I think it's best that we let the configuration tables advertise these in the first instance. I only add them here because it is not possible to obtain them from elsewhere.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#18 lore raw

Re: [PATCH 4/8] pinctrl: qcom: sdm845: Provide ACPI support

Quoted 71 lines · Lee Jones
Quoted 52 lines · Bjorn Andersson
Quoted 50 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.

---
 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
index 2e66ab72c10b..aafbe932424f 100644
@@ -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 +1 -0
index c97f20fca5fd..7188bee3cf3e 100644
@@ -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),
 };
 
Quoted 16 lines

drivers/pinctrl/qcom/pinctrl-sdm845.c static const struct msm_pinctrl_soc_data sdm845_pinctrl = { · line 1292

Quoted 12 lines
drivers/pinctrl/qcom/pinctrl-sdm845.c +5 -0
+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,

The reason why put these in DT is because the list is board/firmware dependent. E.g. the firmware on db845c does not support the peripherals that sits on these 8 pins and as such these are not reserved.

Quoted 5 lines

If we need to be more particular about which platform(s) this affects, we could add matching based on their differences (some ACPI HID or F/W version/descriptor, etc) as and when we enable them for booting with ACPI.

You're making an assumption that all SDM845 (the platform) devices using ACPI will have this list of GPIOs reserved for secure firmware to use, this is questionable but I don't have any better suggestion.

But you do this by adding a new struct msm_pinctrl_soc_data sdm845_acpi_pinctrl, specifically for the ACPI case. And then, on the line I object to here, you add this list as the list of reserved GPIOs for the DT case as well.

Quoted 8 lines
Quoted 2 lines

But given that the two structs looks identical now, did you perhaps not intend to add.reserved_gpios for the non-ACPI case?

Given your example above, I think it's best that we let the configuration tables advertise these in the first instance. I only add them here because it is not possible to obtain them from elsewhere.

Then add it for ACPI only - which I still presume you intended to do by adding sdm845_acpi_pinctrl (which is now identical to sdm845_pinctrl).

Regards,
Bjorn

author
#19 lore raw

Re: [PATCH 4/8] pinctrl: qcom: sdm845: Provide ACPI support

Quoted 79 lines · Bjorn Andersson
Quoted 71 lines · Lee Jones
Quoted 52 lines · Bjorn Andersson
Quoted 50 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.

---
 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
index 2e66ab72c10b..aafbe932424f 100644
@@ -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 +1 -0
index c97f20fca5fd..7188bee3cf3e 100644
@@ -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),
 };
 
Quoted 16 lines

drivers/pinctrl/qcom/pinctrl-sdm845.c static const struct msm_pinctrl_soc_data sdm845_pinctrl = { · line 1292

Quoted 12 lines
drivers/pinctrl/qcom/pinctrl-sdm845.c +5 -0
+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,

The reason why put these in DT is because the list is board/firmware dependent. E.g. the firmware on db845c does not support the peripherals that sits on these 8 pins and as such these are not reserved.

Quoted 5 lines

If we need to be more particular about which platform(s) this affects, we could add matching based on their differences (some ACPI HID or F/W version/descriptor, etc) as and when we enable them for booting with ACPI.

Quoted 3 lines

You're making an assumption that all SDM845 (the platform) devices using ACPI will have this list of GPIOs reserved for secure firmware to use, this is questionable but I don't have any better suggestion.

Yes, I am, since this is the first and currently only device which ticks those boxes. If/when there are others AND if they require a different configuration, we can look at the differences and conduct some suitable matching on them at the time.

Quoted 4 lines

But you do this by adding a new struct msm_pinctrl_soc_data sdm845_acpi_pinctrl, specifically for the ACPI case. And then, on the line I object to here, you add this list as the list of reserved GPIOs for the DT case as well.

Ohhhh, now I see what you're getting at. Yes, that's a mistake left over from testing. That needs removing -- good spot.

Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

But given that the two structs looks identical now, did you perhaps not intend to add.reserved_gpios for the non-ACPI case?

Given your example above, I think it's best that we let the configuration tables advertise these in the first instance. I only add them here because it is not possible to obtain them from elsewhere.

Then add it for ACPI only - which I still presume you intended to do by adding sdm845_acpi_pinctrl (which is now identical to sdm845_pinctrl).

We're arguing about the same thing - sorry for the confusion.

I will fix this.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#20 lore raw

PATCH 5/8 soc: qcom: geni: Add support for ACPI

In reply to 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.

---
 drivers/soc/qcom/qcom-geni-se.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/soc/qcom/qcom-geni-se.c +15 -6
index 6b8ef01472e9..cff0a413e59a 100644
@@ -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
author
#21 lore raw

PATCH 6/8 usb: dwc3: qcom: Add support for booting with ACPI

In reply to Lee Jones

In 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 | 194 ++++++++++++++++++++++++++++++-----
 2 files changed, 170 insertions(+), 26 deletions(-)
drivers/usb/dwc3/Kconfig +1 -1
index 2b1494460d0c..6dab3fd1e233 100644
@@ -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 +169 -25

295 lines not on this page · raw message

Signature · 1 line
2.17.1
#22 lore raw

Re: [PATCH 6/8] usb: dwc3: qcom: Add support for booting with ACPI

Quoted 1 line · Lee Jones
drivers/usb/dwc3/dwc3-qcom.c +0 -0

[..]

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) · line 420

Quoted 7 lines
drivers/usb/dwc3/dwc3-qcom.c +1 -1
@@ -373,7 +416,7 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)
 
 	qcom->num_clocks = count;
 
-	if (!count)
+	if (!count || ACPI_HANDLE(dev))
 		return 0;

Afaict you call this with count = of_count_phandle_with_args(), which should be 0. But why not skip calling this at all?

Quoted 11 lines
drivers/usb/dwc3/dwc3-qcom.c +5 -0
 	qcom->clks = devm_kcalloc(dev, qcom->num_clocks,
@@ -409,12 +452,28 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)
 	return 0;
 }
 
+static const struct dwc3_acpi_pdata sdm845_acpi_pdata = {
+	.qscratch_base_offset = SDM845_QSCRATCH_BASE_OFFSET,
+	.qscratch_base_size = SDM845_QSCRATCH_SIZE,
+	.dwc3_core_base_size = SDM845_DWC3_CORE_SIZE,
+	.hs_phy_irq_index = 1,

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) · line 469

Quoted 10 lines
drivers/usb/dwc3/dwc3-qcom.c +10 -0
+	.dp_hs_phy_irq_index = 4,
+	.dm_hs_phy_irq_index = 3,
+	.ss_phy_irq_index = 2
+};
+
+static const struct acpi_device_id dwc3_qcom_acpi_match[] = {
+	{ "QCOM2430", (unsigned long)&sdm845_acpi_pdata },
+	{ },
+};
+MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);

Analog to of_device_get_match_data() there seems to be a acpi_device_get_match_data(), if you use this you should be able to have you acpi_device_id array next to the of_device_id.

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) · line 471

Quoted 2 lines
drivers/usb/dwc3/dwc3-qcom.c +1 -0
+
 static int dwc3_qcom_probe(struct platform_device *pdev)

It seems that all that's left unconditional on ACPI_HANDLE() in this function are the optional pieces and the tail. Wouldn't it be cleaner to split it out in different functions?

Regards,
Bjorn

author
#23 lore raw

Re: [PATCH 6/8] usb: dwc3: qcom: Add support for booting with ACPI

Quoted 5 lines · Bjorn Andersson
Quoted 1 line · Lee Jones
drivers/usb/dwc3/dwc3-qcom.c +0 -0

[..]

Quoted 2 lines
drivers/usb/dwc3/dwc3-qcom.c +0 -0
@@ -373,7 +416,7 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)
 
Quoted 8 lines

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) · line 420

Quoted 5 lines
drivers/usb/dwc3/dwc3-qcom.c +1 -1
 	qcom->num_clocks = count;
 
-	if (!count)
+	if (!count || ACPI_HANDLE(dev))
 		return 0;

Afaict you call this with count = of_count_phandle_with_args(), which should be 0. But why not skip calling this at all?

Actually count can be <0, which is why I must have needed it at the beginning. There is another patch in this set which checks for errors, thus the ACPI_HANDLE() call should now be superfluous. I will test and remove it.

Quoted 16 lines
Quoted 16 lines
drivers/usb/dwc3/dwc3-qcom.c +11 -0
 	qcom->clks = devm_kcalloc(dev, qcom->num_clocks,
@@ -409,12 +452,28 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)
 	return 0;
 }
 
+static const struct dwc3_acpi_pdata sdm845_acpi_pdata = {
+	.qscratch_base_offset = SDM845_QSCRATCH_BASE_OFFSET,
+	.qscratch_base_size = SDM845_QSCRATCH_SIZE,
+	.dwc3_core_base_size = SDM845_DWC3_CORE_SIZE,
+	.hs_phy_irq_index = 1,
+	.dp_hs_phy_irq_index = 4,
+	.dm_hs_phy_irq_index = 3,
+	.ss_phy_irq_index = 2
+};
+
+static const struct acpi_device_id dwc3_qcom_acpi_match[] = {
Quoted 8 lines

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) · line 469

Quoted 4 lines
drivers/usb/dwc3/dwc3-qcom.c +4 -0
+	{ "QCOM2430", (unsigned long)&sdm845_acpi_pdata },
+	{ },
+};
+MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);

Analog to of_device_get_match_data() there seems to be a acpi_device_get_match_data(), if you use this you should be able to have you acpi_device_id array next to the of_device_id.

Do you mean "Analogous"?

I will try to group them, thanks.

Quoted 6 lines

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) · line 471

Quoted 2 lines
drivers/usb/dwc3/dwc3-qcom.c +1 -0
+
 static int dwc3_qcom_probe(struct platform_device *pdev)

It seems that all that's left unconditional on ACPI_HANDLE() in this function are the optional pieces and the tail. Wouldn't it be cleaner to split it out in different functions?

There are ~50 lines of shared code in dwc3_qcom_probe(), most of it is interspersed between the configuration table (DT, ACPI) pieces, which is why it's formatted in the current way.

I can split a few things out into separate functions if you think it'll help.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#24 lore raw

Re: [PATCH 6/8] usb: dwc3: qcom: Add support for booting with ACPI

Quoted 16 lines · Lee Jones
Quoted 5 lines · Bjorn Andersson
Quoted 1 line · Lee Jones
drivers/usb/dwc3/dwc3-qcom.c +0 -0

[..]

Quoted 2 lines
drivers/usb/dwc3/dwc3-qcom.c +0 -0
@@ -373,7 +416,7 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)
 
Quoted 8 lines

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) · line 420

Quoted 5 lines
drivers/usb/dwc3/dwc3-qcom.c +1 -1
 	qcom->num_clocks = count;
 
-	if (!count)
+	if (!count || ACPI_HANDLE(dev))
 		return 0;

Afaict you call this with count = of_count_phandle_with_args(), which should be 0. But why not skip calling this at all?

Quoted 4 lines

Actually count can be <0, which is why I must have needed it at the beginning. There is another patch in this set which checks for errors, thus the ACPI_HANDLE() call should now be superfluous. I will test and remove it.

Just looked into this - it is still required.

of_count_phandle_with_args() returns an error not to be heeded in the ACPI case. So the logic goes:

[This patch]
* It's fine to boot DT with no clocks to initialise (return 0)
* There are no clocks to enable when booting ACPI (return 0)

[Another patch]
* It's not fine to boot DT and for 'count < 0' (return count)

Quoted 43 lines
Quoted 16 lines
Quoted 16 lines
drivers/usb/dwc3/dwc3-qcom.c +11 -0
 	qcom->clks = devm_kcalloc(dev, qcom->num_clocks,
@@ -409,12 +452,28 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)
 	return 0;
 }
 
+static const struct dwc3_acpi_pdata sdm845_acpi_pdata = {
+	.qscratch_base_offset = SDM845_QSCRATCH_BASE_OFFSET,
+	.qscratch_base_size = SDM845_QSCRATCH_SIZE,
+	.dwc3_core_base_size = SDM845_DWC3_CORE_SIZE,
+	.hs_phy_irq_index = 1,
+	.dp_hs_phy_irq_index = 4,
+	.dm_hs_phy_irq_index = 3,
+	.ss_phy_irq_index = 2
+};
+
+static const struct acpi_device_id dwc3_qcom_acpi_match[] = {
Quoted 8 lines

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) · line 469

Quoted 4 lines
drivers/usb/dwc3/dwc3-qcom.c +4 -0
+	{ "QCOM2430", (unsigned long)&sdm845_acpi_pdata },
+	{ },
+};
+MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);

Analog to of_device_get_match_data() there seems to be a acpi_device_get_match_data(), if you use this you should be able to have you acpi_device_id array next to the of_device_id.

Do you mean "Analogous"?

I will try to group them, thanks.

Quoted 6 lines

drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count) · line 471

Quoted 2 lines
drivers/usb/dwc3/dwc3-qcom.c +1 -0
+
 static int dwc3_qcom_probe(struct platform_device *pdev)

It seems that all that's left unconditional on ACPI_HANDLE() in this function are the optional pieces and the tail. Wouldn't it be cleaner to split it out in different functions?

There are ~50 lines of shared code in dwc3_qcom_probe(), most of it is interspersed between the configuration table (DT, ACPI) pieces, which is why it's formatted in the current way.

I can split a few things out into separate functions if you think it'll help.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#25 lore raw

PATCH 7/8 usb: dwc3: qcom: Start USB in 'host mode' on the SDM845

In reply to Lee Jones

When 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 Properites instead.

---
 drivers/usb/dwc3/dwc3-qcom.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/usb/dwc3/dwc3-qcom.c +12 -0
index 349bf549ee44..f21fdd6cdd1a 100644
@@ -468,6 +468,11 @@ static const struct acpi_device_id dwc3_qcom_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);
 
+static const struct property_entry dwc3_qcom_acpi_properties[] = {
+	PROPERTY_ENTRY_STRING("dr_mode", "host"),
+	{}
+};
+
 static int dwc3_qcom_probe(struct platform_device *pdev)
 {
 	struct device_node	*np = pdev->dev.of_node, *dwc3_np;
@@ -603,6 +608,13 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 			goto platform_unalloc;
 		}
 
+		ret = platform_device_add_properties(qcom->dwc3,
+						     dwc3_qcom_acpi_properties);
+		if (ret < 0) {
+			dev_err(&pdev->dev, "failed to add properties\n");
+			goto platform_unalloc;
+		}
+
 		ret = platform_device_add(qcom->dwc3);
 		if (ret) {
 			dev_err(&pdev->dev, "failed to add device\n");
Signature · 1 line
2.17.1
#26 lore raw

Re: [PATCH 7/8] usb: dwc3: qcom: Start USB in 'host mode' on the SDM845

Quoted 3 lines · Lee Jones

When booting with Device Tree, the current default boot configuration table option, the request to boot via 'host mode' comes from the "dr_mode" property.

This has been the default on the MTP, but this is changing as this is causing issues when connected downstream from a hub (the typical development case for the primary USB port of a phone like device) and more importantly we don't have support for the PMIC blocks that control VBUS.

Once these issues are resolved the dr_mode would be "otg".

Quoted 5 lines

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 Properites instead.

Afaict this would install a fall-back property, so in the case that we have specified dr_mode in DT (or ACPI) that would take precedence. So the commit message should reflect that this redefines the default choice to be "host", rather than "otg".

Which is in conflict with what's described for dr_mode in Documentation/devicetree/bindings/usb/generic.txt

And this driver is used on a range of different Qualcomm platforms, so I don't think this is SDM845 specific.

Regards,
Bjorn

Quoted 38 lines
---
 drivers/usb/dwc3/dwc3-qcom.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/usb/dwc3/dwc3-qcom.c +12 -0
index 349bf549ee44..f21fdd6cdd1a 100644
@@ -468,6 +468,11 @@ static const struct acpi_device_id dwc3_qcom_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);
 
+static const struct property_entry dwc3_qcom_acpi_properties[] = {
+	PROPERTY_ENTRY_STRING("dr_mode", "host"),
+	{}
+};
+
 static int dwc3_qcom_probe(struct platform_device *pdev)
 {
 	struct device_node	*np = pdev->dev.of_node, *dwc3_np;
@@ -603,6 +608,13 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 			goto platform_unalloc;
 		}
 
+		ret = platform_device_add_properties(qcom->dwc3,
+						     dwc3_qcom_acpi_properties);
+		if (ret < 0) {
+			dev_err(&pdev->dev, "failed to add properties\n");
+			goto platform_unalloc;
+		}
+
 		ret = platform_device_add(qcom->dwc3);
 		if (ret) {
 			dev_err(&pdev->dev, "failed to add device\n");
Signature · 1 line
2.17.1
author
#27 lore raw

Re: [PATCH 7/8] usb: dwc3: qcom: Start USB in 'host mode' on the SDM845

Quoted 11 lines · Bjorn Andersson
Quoted 3 lines · Lee Jones

When booting with Device Tree, the current default boot configuration table option, the request to boot via 'host mode' comes from the "dr_mode" property.

This has been the default on the MTP, but this is changing as this is causing issues when connected downstream from a hub (the typical development case for the primary USB port of a phone like device) and more importantly we don't have support for the PMIC blocks that control VBUS.

My point is not about which mode is currently chosen. It's more about the capability of choosing which mode is appropriate for a given system via DT.

Quoted 1 line

Once these issues are resolved the dr_mode would be "otg".

OTG doesn't work on this H/W, so we need to specify "host" mode.

Quoted 8 lines
Quoted 5 lines

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 Properites instead.

Afaict this would install a fall-back property, so in the case that we have specified dr_mode in DT (or ACPI) that would take precedence. So

That's correct.

Quoted 2 lines

the commit message should reflect that this redefines the default choice to be "host", rather than "otg".

No problem.

Quoted 2 lines

Which is in conflict with what's described for dr_mode in Documentation/devicetree/bindings/usb/generic.txt

This implementation only affects ACPI based platforms. When booting with DT, the description in that DT related document is still accurate.

Quoted 2 lines

And this driver is used on a range of different Qualcomm platforms, so I don't think this is SDM845 specific.

ACPI based platforms?

All the ones I've seen use the XHCI USB driver directly ("PNP0D10").

Quoted 35 lines
Quoted 35 lines
---
 drivers/usb/dwc3/dwc3-qcom.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/usb/dwc3/dwc3-qcom.c +12 -0
index 349bf549ee44..f21fdd6cdd1a 100644
@@ -468,6 +468,11 @@ static const struct acpi_device_id dwc3_qcom_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);
 
+static const struct property_entry dwc3_qcom_acpi_properties[] = {
+	PROPERTY_ENTRY_STRING("dr_mode", "host"),
+	{}
+};
+
 static int dwc3_qcom_probe(struct platform_device *pdev)
 {
 	struct device_node	*np = pdev->dev.of_node, *dwc3_np;
@@ -603,6 +608,13 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 			goto platform_unalloc;
 		}
 
+		ret = platform_device_add_properties(qcom->dwc3,
+						     dwc3_qcom_acpi_properties);
+		if (ret < 0) {
+			dev_err(&pdev->dev, "failed to add properties\n");
+			goto platform_unalloc;
+		}
+
 		ret = platform_device_add(qcom->dwc3);
 		if (ret) {
 			dev_err(&pdev->dev, "failed to add device\n");
Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#28 lore raw

Re: [PATCH 7/8] usb: dwc3: qcom: Start USB in 'host mode' on the SDM845

Quoted 14 lines · Lee Jones
Quoted 11 lines · Bjorn Andersson
Quoted 3 lines · Lee Jones

When booting with Device Tree, the current default boot configuration table option, the request to boot via 'host mode' comes from the "dr_mode" property.

This has been the default on the MTP, but this is changing as this is causing issues when connected downstream from a hub (the typical development case for the primary USB port of a phone like device) and more importantly we don't have support for the PMIC blocks that control VBUS.

Quoted 7 lines

My point is not about which mode is currently chosen. It's more about the capability of choosing which mode is appropriate for a given system via DT.

Quoted 1 line

Once these issues are resolved the dr_mode would be "otg".

OTG doesn't work on this H/W, so we need to specify "host" mode.

How have you made that determination?

Quoted 66 lines
Quoted 9 lines
Quoted 6 lines

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 Properites instead.

Afaict this would install a fall-back property, so in the case that we have specified dr_mode in DT (or ACPI) that would take precedence. So

That's correct.

Quoted 2 lines

the commit message should reflect that this redefines the default choice to be "host", rather than "otg".

No problem. >

Quoted 2 lines

Which is in conflict with what's described for dr_mode in Documentation/devicetree/bindings/usb/generic.txt

This implementation only affects ACPI based platforms. When booting with DT, the description in that DT related document is still accurate.

Quoted 2 lines

And this driver is used on a range of different Qualcomm platforms, so I don't think this is SDM845 specific.

ACPI based platforms?

All the ones I've seen use the XHCI USB driver directly ("PNP0D10").

Quoted 35 lines
Quoted 35 lines
---
  drivers/usb/dwc3/dwc3-qcom.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
drivers/usb/dwc3/dwc3-qcom.c +12 -0
index 349bf549ee44..f21fdd6cdd1a 100644
@@ -468,6 +468,11 @@ static const struct acpi_device_id dwc3_qcom_acpi_match[] = {
  };
  MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);
 
+static const struct property_entry dwc3_qcom_acpi_properties[] = {
+	PROPERTY_ENTRY_STRING("dr_mode", "host"),
+	{}
+};
+
  static int dwc3_qcom_probe(struct platform_device *pdev)
  {
  	struct device_node	*np = pdev->dev.of_node, *dwc3_np;
@@ -603,6 +608,13 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
  			goto platform_unalloc;
  		}
 
+		ret = platform_device_add_properties(qcom->dwc3,
+						     dwc3_qcom_acpi_properties);
+		if (ret < 0) {
+			dev_err(&pdev->dev, "failed to add properties\n");
+			goto platform_unalloc;
+		}
+
  		ret = platform_device_add(qcom->dwc3);
  		if (ret) {
  			dev_err(&pdev->dev, "failed to add device\n");
Signature · 4 lines
Jeffrey Hugo
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
author
#29 lore raw

Re: [PATCH 7/8] usb: dwc3: qcom: Start USB in 'host mode' on the SDM845

Quoted 19 lines · Jeffrey Hugo
Quoted 18 lines · Lee Jones
Quoted 11 lines · Bjorn Andersson
Quoted 3 lines · Lee Jones

When booting with Device Tree, the current default boot configuration table option, the request to boot via 'host mode' comes from the "dr_mode" property.

This has been the default on the MTP, but this is changing as this is causing issues when connected downstream from a hub (the typical development case for the primary USB port of a phone like device) and more importantly we don't have support for the PMIC blocks that control VBUS.

My point is not about which mode is currently chosen. It's more about the capability of choosing which mode is appropriate for a given system via DT.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Once these issues are resolved the dr_mode would be "otg".

OTG doesn't work on this H/W, so we need to specify "host" mode.

How have you made that determination?

I enabled OTG and plugged in all of the things.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#30 lore raw

Re: [PATCH 7/8] usb: dwc3: qcom: Start USB in 'host mode' on the SDM845

In reply to Lee Jones
Quoted 14 lines · Lee Jones
Quoted 11 lines · Bjorn Andersson
Quoted 3 lines · Lee Jones

When booting with Device Tree, the current default boot configuration table option, the request to boot via 'host mode' comes from the "dr_mode" property.

This has been the default on the MTP, but this is changing as this is causing issues when connected downstream from a hub (the typical development case for the primary USB port of a phone like device) and more importantly we don't have support for the PMIC blocks that control VBUS.

Quoted 8 lines

My point is not about which mode is currently chosen. It's more about the capability of choosing which mode is appropriate for a given system via DT.

Quoted 1 line

Once these issues are resolved the dr_mode would be "otg".

OTG doesn't work on this H/W, so we need to specify "host" mode.

My objection is that when you say "this H/W" you mean a particular product, but you're making this decision for all SDM845 based products using ACPI.

I don't know if there is a Windows phone based on SDM845, but if there is then I don't think forcing it to host would be correct.

Quoted 14 lines
Quoted 8 lines
Quoted 5 lines

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 Properites instead.

Afaict this would install a fall-back property, so in the case that we have specified dr_mode in DT (or ACPI) that would take precedence. So

That's correct.

Quoted 2 lines

the commit message should reflect that this redefines the default choice to be "host", rather than "otg".

Quoted 9 lines

No problem.

Quoted 2 lines

Which is in conflict with what's described for dr_mode in Documentation/devicetree/bindings/usb/generic.txt

This implementation only affects ACPI based platforms. When booting with DT, the description in that DT related document is still accurate.

You're right, I got lost between the patches and the sprinkled if (ACPI_HANDLE()) in the probe. This is only added for ACPI.

Quoted 7 lines
Quoted 2 lines

And this driver is used on a range of different Qualcomm platforms, so I don't think this is SDM845 specific.

ACPI based platforms?

All the ones I've seen use the XHCI USB driver directly ("PNP0D10").

MSM8998 (835) has the same controller, so this should affect those laptops as well.

Regards,
Bjorn

Quoted 41 lines
Quoted 35 lines
Quoted 35 lines
---
 drivers/usb/dwc3/dwc3-qcom.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/usb/dwc3/dwc3-qcom.c +12 -0
index 349bf549ee44..f21fdd6cdd1a 100644
@@ -468,6 +468,11 @@ static const struct acpi_device_id dwc3_qcom_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);
 
+static const struct property_entry dwc3_qcom_acpi_properties[] = {
+	PROPERTY_ENTRY_STRING("dr_mode", "host"),
+	{}
+};
+
 static int dwc3_qcom_probe(struct platform_device *pdev)
 {
 	struct device_node	*np = pdev->dev.of_node, *dwc3_np;
@@ -603,6 +608,13 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 			goto platform_unalloc;
 		}
 
+		ret = platform_device_add_properties(qcom->dwc3,
+						     dwc3_qcom_acpi_properties);
+		if (ret < 0) {
+			dev_err(&pdev->dev, "failed to add properties\n");
+			goto platform_unalloc;
+		}
+
 		ret = platform_device_add(qcom->dwc3);
 		if (ret) {
 			dev_err(&pdev->dev, "failed to add device\n");
Signature · 4 lines
Lee Jones [?????????]
Linaro Services Technical Lead
Linaro.org ??? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#31 lore raw

Re: [PATCH 7/8] usb: dwc3: qcom: Start USB in 'host mode' on the SDM845

Quoted 22 lines · Bjorn Andersson
Quoted 20 lines · Lee Jones
Quoted 11 lines · Bjorn Andersson
Quoted 3 lines · Lee Jones

When booting with Device Tree, the current default boot configuration table option, the request to boot via 'host mode' comes from the "dr_mode" property.

This has been the default on the MTP, but this is changing as this is causing issues when connected downstream from a hub (the typical development case for the primary USB port of a phone like device) and more importantly we don't have support for the PMIC blocks that control VBUS.

My point is not about which mode is currently chosen. It's more about the capability of choosing which mode is appropriate for a given system via DT.

Quoted 1 line

Once these issues are resolved the dr_mode would be "otg".

Quoted 8 lines
Quoted 1 line

OTG doesn't work on this H/W, so we need to specify "host" mode.

My objection is that when you say "this H/W" you mean a particular product, but you're making this decision for all SDM845 based products using ACPI.

I don't know if there is a Windows phone based on SDM845, but if there is then I don't think forcing it to host would be correct.

You mean if someone wanted to boot Linux on a Windows phone? Not sure how likely that is, but even if a) there is an SDM845 based Windows phone and b) someone is crazy enough to run Linux on it, it should be trivial for them to conduct some device matching and choose a different property based on the result.

[...]

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

And this driver is used on a range of different Qualcomm platforms, so I don't think this is SDM845 specific.

ACPI based platforms?

All the ones I've seen use the XHCI USB driver directly ("PNP0D10").

MSM8998 (835) has the same controller, so this should affect those laptops as well.

This would also be the correct configuration for them too. OTG doesn't make much sense for a laptop form factor.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#32 lore raw

PATCH 8/8 usb: dwc3: qcom: Improve error handling

In reply to Lee Jones

dwc3_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
index f21fdd6cdd1a..633482926497 100644
@@ -419,6 +419,9 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)
 	if (!count || ACPI_HANDLE(dev))
 		return 0;
 
+	if (count < 0)
+		return count;
+
 	qcom->clks = devm_kcalloc(dev, qcom->num_clocks,
 				  sizeof(struct clk *), GFP_KERNEL);
 	if (!qcom->clks)
Signature · 1 line
2.17.1
Reviewed-by on v1 8/8
#33 lore raw

Re: [PATCH 8/8] usb: dwc3: qcom: Improve error handling

Quoted 7 lines · Lee Jones

dwc3_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.

Quoted 21 lines
---
 drivers/usb/dwc3/dwc3-qcom.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/dwc3/dwc3-qcom.c +3 -0
index f21fdd6cdd1a..633482926497 100644
@@ -419,6 +419,9 @@ static int dwc3_qcom_clk_init(struct dwc3_qcom *qcom, int count)
 	if (!count || ACPI_HANDLE(dev))
 		return 0;
 
+	if (count < 0)
+		return count;
+
 	qcom->clks = devm_kcalloc(dev, qcom->num_clocks,
 				  sizeof(struct clk *), GFP_KERNEL);
 	if (!qcom->clks)
Signature · 1 line
2.17.1