Skip to contentSkip to conversation

pinctrl: intel: retrieve pure platform driver data as well

PATCH In review Andy Shevchenko 2 participants 6 messages Sep 3

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

v2 cover pinctrl: intel: retrieve pure platform driver data as well

The reported platform can't be enumerated as it misses driver data associated with the firmware node. Instead we should use platform driver data. This mini-series to make it happen.

Changes v2:
- constified parameter in intel_pinctrl_get_soc_data() (Mika)
- added tag (Radek)

Cc Radek Válko <[email protected]>

Andy Shevchenko (3):
pinctrl: intel: Move intel_pinctrl_get_soc_data() upper in the code
pinctrl: intel: constify parameter in intel_pinctrl_get_soc_data()
pinctrl: intel: Try to retrieve driver data for pure platform drivers

 drivers/pinctrl/intel/pinctrl-intel.c | 51 ++++++++++++++++++---------
 drivers/pinctrl/intel/pinctrl-intel.h |  2 +-
 2 files changed, 36 insertions(+), 17 deletions(-)
Signature · 1 line
2.50.1
#1 lore raw

PATCH v2 1/3 pinctrl: intel: Move intel_pinctrl_get_soc_data() upper in the code

While it's exported function, move it upper in the code to be on top of the local user. This brings a consistency to the follow change that will introduce similar helper for the intel_pinctrl_probe_by_hid().

---
 drivers/pinctrl/intel/pinctrl-intel.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/pinctrl/intel/pinctrl-intel.c +12 -12
index 261ec2ee63ef..fd02409a2415 100644
@@ -1714,18 +1714,6 @@ int intel_pinctrl_probe_by_hid(struct platform_device *pdev)
 }
 EXPORT_SYMBOL_NS_GPL(intel_pinctrl_probe_by_hid, "PINCTRL_INTEL");
 
-int intel_pinctrl_probe_by_uid(struct platform_device *pdev)
-{
-	const struct intel_pinctrl_soc_data *data;
-
-	data = intel_pinctrl_get_soc_data(pdev);
-	if (IS_ERR(data))
-		return PTR_ERR(data);
-
-	return intel_pinctrl_probe(pdev, data);
-}
-EXPORT_SYMBOL_NS_GPL(intel_pinctrl_probe_by_uid, "PINCTRL_INTEL");
-
 const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_device *pdev)
 {
 	const struct intel_pinctrl_soc_data * const *table;
@@ -1757,6 +1745,18 @@ const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_
 }
 EXPORT_SYMBOL_NS_GPL(intel_pinctrl_get_soc_data, "PINCTRL_INTEL");
 
+int intel_pinctrl_probe_by_uid(struct platform_device *pdev)
+{
+	const struct intel_pinctrl_soc_data *data;
+
+	data = intel_pinctrl_get_soc_data(pdev);
+	if (IS_ERR(data))
+		return PTR_ERR(data);
+
+	return intel_pinctrl_probe(pdev, data);
+}
+EXPORT_SYMBOL_NS_GPL(intel_pinctrl_probe_by_uid, "PINCTRL_INTEL");
+
 static bool __intel_gpio_is_direct_irq(u32 value)
 {
 	return (value & PADCFG0_GPIROUTIOXAPIC) &&
Signature · 1 line
2.50.1
#2 lore raw

PATCH v2 2/3 pinctrl: intel: constify parameter in intel_pinctrl_get_soc_data()

In reply to Andy Shevchenko

The parameter of intel_pinctrl_get_soc_data() is not going to be modified. Mark it with const qualifier.

---
 drivers/pinctrl/intel/pinctrl-intel.c | 4 ++--
 drivers/pinctrl/intel/pinctrl-intel.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-intel.c +2 -2
index fd02409a2415..08790bff2951 100644
@@ -1714,11 +1714,11 @@ int intel_pinctrl_probe_by_hid(struct platform_device *pdev)
 }
 EXPORT_SYMBOL_NS_GPL(intel_pinctrl_probe_by_hid, "PINCTRL_INTEL");
 
-const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_device *pdev)
+const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(const struct platform_device *pdev)
 {
 	const struct intel_pinctrl_soc_data * const *table;
 	const struct intel_pinctrl_soc_data *data;
-	struct device *dev = &pdev->dev;
+	const struct device *dev = &pdev->dev;
 
 	table = device_get_match_data(dev);
 	if (table) {
drivers/pinctrl/intel/pinctrl-intel.h +1 -1
index b5476b9de0db..b7ee7fd0c5f2 100644
@@ -225,7 +225,7 @@ struct intel_pinctrl_soc_data {
 	size_t ncommunities;
 };
 
-const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_device *pdev);
+const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(const struct platform_device *pdev);
 
 struct intel_pad_context;
 struct intel_community_context;
Signature · 1 line
2.50.1
#3 lore raw

PATCH v2 3/3 pinctrl: intel: Try to retrieve driver data for pure platform drivers

In reply to Andy Shevchenko

The Denverton pinctrl device can be instantiated by the Intel LPC driver as an MFD platform device named "denverton-pinctrl".

On affected systems the platform device does not carry the INTC3000 ACPI match data itself. As a result, intel_pinctrl_probe_by_hid() fails to obtain the SoC data using device_get_match_data() and returns -ENODATA.

This might be also true for other platforms that can be enumerated by ACPI _HID. Fix the above by trying the pure platform driver data in case the firmware node is not set or doesn't carry the necessary information.

---
 drivers/pinctrl/intel/pinctrl-intel.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-intel.c +22 -3
index 08790bff2951..1363301098d5 100644
@@ -1702,13 +1702,32 @@ int intel_pinctrl_probe(struct platform_device *pdev,
 }
 EXPORT_SYMBOL_NS_GPL(intel_pinctrl_probe, "PINCTRL_INTEL");
 
+static const struct intel_pinctrl_soc_data *
+intel_pinctrl_get_soc_data_by_hid(const struct platform_device *pdev)
+{
+	const struct intel_pinctrl_soc_data *data;
+	const struct device *dev = &pdev->dev;
+	const struct platform_device_id *id;
+
+	data = device_get_match_data(dev);
+	if (data)
+		return data;
+
+	id = platform_get_device_id(pdev);
+	if (!id)
+		return ERR_PTR(-ENODEV);
+
+	data = (const struct intel_pinctrl_soc_data *)id->driver_data;
+	return data ?: ERR_PTR(-ENODATA);
+}
+
 int intel_pinctrl_probe_by_hid(struct platform_device *pdev)
 {
 	const struct intel_pinctrl_soc_data *data;
 
-	data = device_get_match_data(&pdev->dev);
-	if (!data)
-		return -ENODATA;
+	data = intel_pinctrl_get_soc_data_by_hid(pdev);
+	if (IS_ERR(data))
+		return PTR_ERR(data);
 
 	return intel_pinctrl_probe(pdev, data);
 }
Signature · 1 line
2.50.1
maintainer Acked-by on the v2 series
#4 lore raw
In reply to Andy Shevchenko
Quoted 8 lines · Andy Shevchenko

The reported platform can't be enumerated as it misses driver data associated with the firmware node. Instead we should use platform driver data. This mini-series to make it happen.

Changes v2:
- constified parameter in intel_pinctrl_get_soc_data() (Mika)
- added tag (Radek)

Quoted 7 lines
Cc Radek Válko <[email protected]>

Andy Shevchenko (3):
pinctrl: intel: Move intel_pinctrl_get_soc_data() upper in the code
pinctrl: intel: constify parameter in intel_pinctrl_get_soc_data()
pinctrl: intel: Try to retrieve driver data for pure platform drivers

#5 lore raw
Quoted 9 lines · Mika Westerberg
Quoted 8 lines · Andy Shevchenko

The reported platform can't be enumerated as it misses driver data associated with the firmware node. Instead we should use platform driver data. This mini-series to make it happen.

Changes v2:
- constified parameter in intel_pinctrl_get_soc_data() (Mika)
- added tag (Radek)

Quoted 8 lines
Quoted 6 lines
Cc Radek Válko <[email protected]>

Andy Shevchenko (3):
pinctrl: intel: Move intel_pinctrl_get_soc_data() upper in the code
pinctrl: intel: constify parameter in intel_pinctrl_get_soc_data()
pinctrl: intel: Try to retrieve driver data for pure platform drivers

Pushed to my review and testing queue, thanks!

Signature · 2 lines
With Best Regards,
Andy Shevchenko