Skip to contentSkip to conversation

mfd: intel_quark_i2c_gpio: Refactor and support for IOT2000

PATCH Superseded Jan Kiszka 4 participants 18 messages May 22, 2017 – May 30, 2017 Multifunction devices (MFD)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

v2 cover mfd: intel_quark_i2c_gpio: Refactor and support for IOT2000

Changes in v2:
- refactor DMI matching first

Jan

Jan Kiszka (2):
mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving
frequency
mfd: intel_quark_i2c_gpio: Add support for SIMATIC IOT2000 platform

 drivers/mfd/intel_quark_i2c_gpio.c | 49 ++++++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 20 deletions(-)
Signature · 1 line
2.12.0
author
#1 lore raw

PATCH v2 1/2 mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Avoids reimplementation of DMI matching in intel_quark_i2c_setup.

---
 drivers/mfd/intel_quark_i2c_gpio.c | 33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)
drivers/mfd/intel_quark_i2c_gpio.c +13 -20
index 7946d6e38b87..050061320377 100644
@@ -58,19 +58,18 @@ struct intel_quark_mfd {
 	struct clk_lookup	*i2c_clk_lookup;
 };
 
-struct i2c_mode_info {
-	const char *name;
-	unsigned int i2c_scl_freq;
-};
-
-static const struct i2c_mode_info platform_i2c_mode_info[] = {
+static const struct dmi_system_id dmi_platform_info[] = {
 	{
-		.name = "Galileo",
-		.i2c_scl_freq = 100000,
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Galileo"),
+		},
+		.driver_data = (void *)100000,
 	},
 	{
-		.name = "GalileoGen2",
-		.i2c_scl_freq = 400000,
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "GalileoGen2"),
+		},
+		.driver_data = (void *)400000,
 	},
 	{}
 };
@@ -160,8 +159,7 @@ static void intel_quark_unregister_i2c_clk(struct device *dev)
 
 static int intel_quark_i2c_setup(struct pci_dev *pdev, struct mfd_cell *cell)
 {
-	const char *board_name = dmi_get_system_info(DMI_BOARD_NAME);
-	const struct i2c_mode_info *info;
+	const struct dmi_system_id *dmi_id;
 	struct dw_i2c_platform_data *pdata;
 	struct resource *res = (struct resource *)cell->resources;
 	struct device *dev = &pdev->dev;
@@ -181,14 +179,9 @@ static int intel_quark_i2c_setup(struct pci_dev *pdev, struct mfd_cell *cell)
 	/* Normal mode by default */
 	pdata->i2c_scl_freq = 100000;
 
-	if (board_name) {
-		for (info = platform_i2c_mode_info; info->name; info++) {
-			if (!strcmp(board_name, info->name)) {
-				pdata->i2c_scl_freq = info->i2c_scl_freq;
-				break;
-			}
-		}
-	}
+	dmi_id = dmi_first_match(dmi_platform_info);
+	if (dmi_id)
+		pdata->i2c_scl_freq = (uintptr_t)dmi_id->driver_data;
 
 	cell->platform_data = pdata;
 	cell->pdata_size = sizeof(*pdata);
Signature · 1 line
2.12.0
#2 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 1 line · Jan Kiszka

Avoids reimplementation of DMI matching in intel_quark_i2c_setup.

What's wrong with current approach? I suppose this will make sense when we will have an issue / impediment. Right now it looks like over-engineering.

(Yes, I know what I said to you about this earlier, OTOH see above)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#3 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 9 lines · Andy Shevchenko
Quoted 1 line · Jan Kiszka

Avoids reimplementation of DMI matching in intel_quark_i2c_setup.

What's wrong with current approach? I suppose this will make sense when we will have an issue / impediment. Right now it looks like over-engineering.

(Yes, I know what I said to you about this earlier, OTOH see above)

It allows matching on additional DMI tags without additional code - patch 2 depends on it.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
#4 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Andy Shevchenko
Quoted 1 line · Jan Kiszka

Avoids reimplementation of DMI matching in intel_quark_i2c_setup.

What's wrong with current approach? I suppose this will make sense when we will have an issue / impediment. Right now it looks like over-engineering.

Quoted 5 lines
Quoted 2 lines

(Yes, I know what I said to you about this earlier, OTOH see above)

It allows matching on additional DMI tags without additional code - patch 2 depends on it.

And since there is no difference to the frequency the name is enough. So, I wouldn't go with this series as is. See above.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#5 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Andy Shevchenko
Quoted 1 line · Jan Kiszka

Avoids reimplementation of DMI matching in intel_quark_i2c_setup.

What's wrong with current approach? I suppose this will make sense when we will have an issue / impediment. Right now it looks like over-engineering.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

(Yes, I know what I said to you about this earlier, OTOH see above)

It allows matching on additional DMI tags without additional code - patch 2 depends on it.

And since there is no difference to the frequency the name is enough. So, I wouldn't go with this series as is. See above.

Nope: Just like for the stmmac, we need to include the asset tags to avoid matching variations of the devices which may carry the same board name. While I will try to avoid that this happens, we are better safe than sorry here.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
#6 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 16 lines · Jan Kiszka
Quoted 15 lines · Andy Shevchenko
Quoted 13 lines · Jan Kiszka
Quoted 9 lines · Andy Shevchenko
Quoted 1 line · Jan Kiszka

Avoids reimplementation of DMI matching in intel_quark_i2c_setup.

What's wrong with current approach? I suppose this will make sense when we will have an issue / impediment. Right now it looks like over-engineering.

(Yes, I know what I said to you about this earlier, OTOH see above)

It allows matching on additional DMI tags without additional code - patch 2 depends on it.

Quoted 7 lines
Quoted 2 lines

And since there is no difference to the frequency the name is enough. So, I wouldn't go with this series as is. See above.

Nope: Just like for the stmmac, we need to include the asset tags to avoid matching variations of the devices which may carry the same board name. While I will try to avoid that this happens, we are better safe than sorry here.

Do we have an issue right now?
Yes / No

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#7 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 20 lines · Andy Shevchenko
Quoted 19 lines · Jan Kiszka
Quoted 17 lines · Andy Shevchenko
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Andy Shevchenko
Quoted 1 line · Jan Kiszka

Avoids reimplementation of DMI matching in intel_quark_i2c_setup.

What's wrong with current approach? I suppose this will make sense when we will have an issue / impediment. Right now it looks like over-engineering.

Quoted 5 lines
Quoted 2 lines

(Yes, I know what I said to you about this earlier, OTOH see above)

It allows matching on additional DMI tags without additional code - patch 2 depends on it.

And since there is no difference to the frequency the name is enough. So, I wouldn't go with this series as is. See above.

Quoted 7 lines
Quoted 4 lines

Nope: Just like for the stmmac, we need to include the asset tags to avoid matching variations of the devices which may carry the same board name. While I will try to avoid that this happens, we are better safe than sorry here.

Do we have an issue right now?
Yes / No

Andy, we are trying to design a robust upstream driver here, no ad-hoc BSP that will not survive the hardware anyway.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
#8 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 15 lines · Jan Kiszka
Quoted 14 lines · Andy Shevchenko
Quoted 12 lines · Jan Kiszka
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Jan Kiszka
Quoted 1 line · Andy Shevchenko

On Mon, May 22, 2017 at 1:53 PM, Jan Kiszka <[email protected]> wrote:

And since there is no difference to the frequency the name is enough. So, I wouldn't go with this series as is. See above.

Nope: Just like for the stmmac, we need to include the asset tags to avoid matching variations of the devices which may carry the same board name. While I will try to avoid that this happens, we are better safe than sorry here.

Quoted 5 lines
Quoted 2 lines

Do we have an issue right now?
Yes / No

Andy, we are trying to design a robust upstream driver here, no ad-hoc BSP that will not survive the hardware anyway.

You didn't answer my question...

I do not see a good point to solve the issue that might happen in the future.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#9 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 19 lines · Andy Shevchenko
Quoted 18 lines · Jan Kiszka
Quoted 16 lines · Andy Shevchenko
Quoted 5 lines · Jan Kiszka
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Jan Kiszka
Quoted 1 line · Andy Shevchenko

On Mon, May 22, 2017 at 1:53 PM, Jan Kiszka <[email protected]> wrote:

Quoted 7 lines
Quoted 2 lines

And since there is no difference to the frequency the name is enough. So, I wouldn't go with this series as is. See above.

Nope: Just like for the stmmac, we need to include the asset tags to avoid matching variations of the devices which may carry the same board name. While I will try to avoid that this happens, we are better safe than sorry here.

Do we have an issue right now?
Yes / No

Quoted 7 lines
Quoted 2 lines

Andy, we are trying to design a robust upstream driver here, no ad-hoc BSP that will not survive the hardware anyway.

You didn't answer my question...

I do not see a good point to solve the issue that might happen in the future.

While I do - that's why your question is misleading.

Then let's leave the decision up to the maintainer.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
#10 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 23 lines · Jan Kiszka
Quoted 22 lines · Andy Shevchenko
Quoted 20 lines · Jan Kiszka
Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Jan Kiszka
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Jan Kiszka
Quoted 1 line · Andy Shevchenko

On Mon, May 22, 2017 at 1:53 PM, Jan Kiszka <[email protected]> wrote:

And since there is no difference to the frequency the name is enough. So, I wouldn't go with this series as is. See above.

Quoted 7 lines
Quoted 4 lines

Nope: Just like for the stmmac, we need to include the asset tags to avoid matching variations of the devices which may carry the same board name. While I will try to avoid that this happens, we are better safe than sorry here.

Do we have an issue right now?
Yes / No

Andy, we are trying to design a robust upstream driver here, no ad-hoc BSP that will not survive the hardware anyway.

Quoted 8 lines
Quoted 4 lines

You didn't answer my question...

I do not see a good point to solve the issue that might happen in the future.

While I do - that's why your question is misleading.

Then let's leave the decision up to the maintainer.

Lee, just for your convenience I'm repeating myself here:

I do not like this series at all since it tries to solve non-existing issue in over-engineering way.

If you on opposite side I will be happy to help reviewing it.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 31 lines · Andy Shevchenko
Quoted 30 lines · Jan Kiszka
Quoted 19 lines · Andy Shevchenko
Quoted 18 lines · Jan Kiszka
Quoted 16 lines · Andy Shevchenko
Quoted 5 lines · Jan Kiszka
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Jan Kiszka
Quoted 1 line · Andy Shevchenko

On Mon, May 22, 2017 at 1:53 PM, Jan Kiszka <[email protected]> wrote:

Quoted 7 lines
Quoted 2 lines

And since there is no difference to the frequency the name is enough. So, I wouldn't go with this series as is. See above.

Nope: Just like for the stmmac, we need to include the asset tags to avoid matching variations of the devices which may carry the same board name. While I will try to avoid that this happens, we are better safe than sorry here.

Do we have an issue right now?
Yes / No

Quoted 7 lines
Quoted 2 lines

Andy, we are trying to design a robust upstream driver here, no ad-hoc BSP that will not survive the hardware anyway.

You didn't answer my question...

I do not see a good point to solve the issue that might happen in the future.

While I do - that's why your question is misleading.

Quoted 8 lines
Quoted 1 line

Then let's leave the decision up to the maintainer.

Lee, just for your convenience I'm repeating myself here:

I do not like this series at all since it tries to solve non-existing issue in over-engineering way.

If you on opposite side I will be happy to help reviewing it.

New code looks cleaner and appears to use an already defined API.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#12 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 6 lines · Lee Jones
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Jan Kiszka

On 2017-05-22 19:36, Andy Shevchenko wrote:

Then let's leave the decision up to the maintainer.

Quoted 8 lines
Quoted 6 lines

Lee, just for your convenience I'm repeating myself here:

I do not like this series at all since it tries to solve non-existing issue in over-engineering way.

If you on opposite side I will be happy to help reviewing it.

New code looks cleaner and appears to use an already defined API.

Got your point.
Jan, care to resend (an updated?) version?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#13 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 12 lines · Andy Shevchenko
Quoted 11 lines · Lee Jones
Quoted 10 lines · Andy Shevchenko
Quoted 3 lines · Jan Kiszka

On 2017-05-22 19:36, Andy Shevchenko wrote:

Then let's leave the decision up to the maintainer.

Lee, just for your convenience I'm repeating myself here:

I do not like this series at all since it tries to solve non-existing issue in over-engineering way.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

If you on opposite side I will be happy to help reviewing it.

New code looks cleaner and appears to use an already defined API.

Got your point.
Jan, care to resend (an updated?) version?

Updated in which regard? The one for stmmac is broken, this one should be fine.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
#14 lore raw

Re: [PATCH v2 1/2] mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency

Quoted 10 lines · Jan Kiszka
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Lee Jones
Quoted 1 line · Andy Shevchenko

On Mon, May 22, 2017 at 8:38 PM, Jan Kiszka <[email protected]> wrote:

Got your point.
Jan, care to resend (an updated?) version?

Updated in which regard? The one for stmmac is broken, this one should be fine.

Can you just resend then, please? I have been out a while and now I have a pile of mails, it would be slightly easy for me to go through a fresh series.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#15 lore raw

PATCH v2 2/2 mfd: intel_quark_i2c_gpio: Add support for SIMATIC IOT2000 platform

In reply to Jan Kiszka

The SIMATIC IOT2020 and IOT2040 are derived from the Galileo Gen2 board and share its I2C frequency.

---
 drivers/mfd/intel_quark_i2c_gpio.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/mfd/intel_quark_i2c_gpio.c +16 -0
index 050061320377..90e35dec8648 100644
@@ -71,6 +71,22 @@ static const struct dmi_system_id dmi_platform_info[] = {
 		},
 		.driver_data = (void *)400000,
 	},
+	{
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
+			DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG,
+					"6ES7647-0AA00-0YA2"),
+		},
+		.driver_data = (void *)400000,
+	},
+	{
+		.matches = {
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
+			DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG,
+					"6ES7647-0AA00-1YA2"),
+		},
+		.driver_data = (void *)400000,
+	},
 	{}
 };
 
Signature · 1 line
2.12.0
Reviewed-by on the v2 series
#16 lore raw
In reply to Jan Kiszka
Quoted 2 lines · Jan Kiszka

Changes in v2:
 - refactor DMI matching first

Okay, we would do amendments later if something new comes up. For now, FWIW:

P.S. After all it looks not bad.

Quoted 12 lines

Jan

Jan Kiszka (2):
  mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving frequency
  mfd: intel_quark_i2c_gpio: Add support for SIMATIC IOT2000 platform

 drivers/mfd/intel_quark_i2c_gpio.c | 49 ++++++++++++++++++++++-------
---------

 1 file changed, 29 insertions(+), 20 deletions(-)
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#17 lore raw
In reply to Jan Kiszka
Quoted 5 lines · Jan Kiszka

Changes in v2:
- refactor DMI matching first

Jan

Quoted 7 lines

Jan Kiszka (2):
mfd: intel_quark_i2c_gpio: Use dmi_system_id table for retrieving
frequency
mfd: intel_quark_i2c_gpio: Add support for SIMATIC IOT2000 platform

 drivers/mfd/intel_quark_i2c_gpio.c | 49 ++++++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 20 deletions(-)

Jan, to make this easy, will you resend with Andy's Acks please?

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog