tqmx86: TQMxE40M support
Subsystems (3)
cover tqmx86: TQMxE40M support
This fixes a bug in the IRQ setup of the tqmx86 MFD / GPIO drivers and adds support for our upcoming Elkhart Lake module TQMxE40M (as well as future SoMs).
As patch 2 depends on patch 1, it would make sense to push the whole series through the same tree.
Matthias Schiffer (3):
gpio: tqmx86: really make IRQ optional
mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set
mfd: tqmx86: add support for TQMxE40M
drivers/gpio/gpio-tqmx86.c | 6 +++--- drivers/mfd/tqmx86.c | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 gpio: tqmx86: really make IRQ optional
The tqmx86 MFD driver was passing IRQ 0 for "no IRQ" in the past. This causes warnings with newer kernels.
Prepare the gpio-tqmx86 driver for the fixed MFD driver by handling a missing IRQ properly.
--- drivers/gpio/gpio-tqmx86.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpio-tqmx86.c +3 -3
@@ -238,8 +238,8 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)struct resource *res;int ret, irq; - irq =platform_get_irq (pdev,0 ); -if (irq <0 ) + irq =platform_get_irq_optional (pdev,0 ); +if (irq <0 && irq != -ENXIO )return irq; res =platform_get_resource (pdev,IORESOURCE_IO ,0 );
@@ -278,7 +278,7 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)pm_runtime_enable (&pdev->dev); -if (irq) { +if (irq >0 ) {struct irq_chip *irq_chip = &gpio->irq_chip;u8 irq_status;
Signature · 1 line
2.17.1
Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
Quoted 6 lines · Matthias Schiffer
The tqmx86 MFD driver was passing IRQ 0 for "no IRQ" in the past. This causes warnings with newer kernels.
Prepare the gpio-tqmx86 driver for the fixed MFD driver by handling a missing IRQ properly.
...
drivers/gpio/gpio-tqmx86.c static int tqmx86_gpio_probe(struct platform_device *pdev)
Quoted 6 lines
drivers/gpio/gpio-tqmx86.c +2
-2- irq =platform_get_irq (pdev,0 ); -if (irq <0 ) + irq =platform_get_irq_optional (pdev,0 ); +if (irq <0 && irq != -ENXIO )return irq;
This is a dead code now. I suggest you to do the opposite, i.e. if (irq < 0)
irq = 0;
In such a case below change is not required.
...
Quoted 4 lines
drivers/gpio/gpio-tqmx86.c +1
-1-if (irq) { +if (irq >0 ) {struct irq_chip *irq_chip = &gpio->irq_chip;u8 irq_status;
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: (EXT) Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
Quoted 17 lines · Andy Shevchenko
Quoted 6 lines · Matthias Schiffer
The tqmx86 MFD driver was passing IRQ 0 for "no IRQ" in the past. This causes warnings with newer kernels.
Prepare the gpio-tqmx86 driver for the fixed MFD driver by handling a missing IRQ properly.
...
drivers/gpio/gpio-tqmx86.c static int tqmx86_gpio_probe(struct platform_device *pdev) · line 243
Quoted 5 lines
drivers/gpio/gpio-tqmx86.c +2
-2- irq =platform_get_irq (pdev,0 ); -if (irq <0 ) + irq =platform_get_irq_optional (pdev,0 ); +if (irq <0 && irq != -ENXIO )return irq;
Quoted 3 lines
This is a dead code now. I suggest you to do the opposite, i.e. if (irq < 0)
irq = 0;
I don't understand which part of the code is dead now. I assume the return irq case is still useful for unexpected errors, or things like EPROBE_DEFER? I'm not sure if EPROBE_DEFER is relevant for this driver, but just ignoring the error code completely doesn't seem right to me.
Quoted 11 lines
In such a case below change is not required.
...
Quoted 4 lines
drivers/gpio/gpio-tqmx86.c +1
-1-if (irq) { +if (irq >0 ) {struct irq_chip *irq_chip = &gpio->irq_chip;u8 irq_status;
Re: (EXT) Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
Quoted 3 lines · Matthias Schiffer
Quoted 2 lines · Andy Shevchenko
On Wed, Mar 31, 2021 at 2:37 PM Matthias Schiffer
<[email protected]> wrote:
...
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/gpio/gpio-tqmx86.c +2
-2- irq =platform_get_irq (pdev,0 ); -if (irq <0 ) + irq =platform_get_irq_optional (pdev,0 ); +if (irq <0 && irq != -ENXIO )return irq;
Quoted 8 lines
Quoted 3 lines
This is a dead code now. I suggest you to do the opposite, i.e. if (irq < 0)
irq = 0;I don't understand which part of the code is dead now. I assume the
return irqcase is still useful for unexpected errors, or things likeEPROBE_DEFER? I'm not sure ifEPROBE_DEFERis relevant for this driver, but just ignoring the error code completely doesn't seem right to me.
platform_get_irq() AFAIK won't ever return such a code. So, basically your conditional is always false.
I would like to see the code path which makes my comment wrong.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
Quoted 23 lines · Andy Shevchenko
Quoted 3 lines · Matthias Schiffer
Quoted 2 lines · Andy Shevchenko
On Wed, Mar 31, 2021 at 2:37 PM Matthias Schiffer
<[email protected]> wrote:...
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/gpio/gpio-tqmx86.c +2
-2- irq =platform_get_irq (pdev,0 ); -if (irq <0 ) + irq =platform_get_irq_optional (pdev,0 ); +if (irq <0 && irq != -ENXIO )return irq;Quoted 8 lines
Quoted 3 lines
This is a dead code now. I suggest you to do the opposite, i.e. if (irq < 0)
irq = 0;I don't understand which part of the code is dead now. I assume the
return irqcase is still useful for unexpected errors, or things likeEPROBE_DEFER? I'm not sure ifEPROBE_DEFERis relevant for this driver, but just ignoring the error code completely doesn't seem right to me.
Quoted 5 lines
platform_get_irq()AFAIK won't ever return such a code. So, basically your conditional is always false.I would like to see the code path which makes my comment wrong.
EPROBE_DEFER appears a few times in platform_get_irq_optional() (drivers/base/platform.c), but it's possible that this is only relevant for OF-based platforms and not x86.
Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
Quoted 5 lines · Matthias Schiffer
Quoted 3 lines · Andy Shevchenko
Quoted 1 line · Matthias Schiffer
On Wed, 2021-03-31 at 15:29 +0300, Andy Shevchenko wrote:
...
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
I don't understand which part of the code is dead now. I assume the
return irqcase is still useful for unexpected errors, or things likeEPROBE_DEFER? I'm not sure ifEPROBE_DEFERis relevant for this driver, but just ignoring the error code completely doesn't seem right to me.
platform_get_irq()AFAIK won't ever return such a code. So, basically your conditional is always false.
Quoted 6 lines
Quoted 2 lines
I would like to see the code path which makes my comment wrong.
EPROBE_DEFERappears a few times inplatform_get_irq_optional()(drivers/base/platform.c), but it's possible that this is only relevant for OF-based platforms and not x86.
Ah, okay, that's something I haven't paid attention to.
So the root cause of the your case is platform_get_irq_optional|() return code. I'm wondering why it can't return 0 instead of absent IRQ? Perhaps you need to fix it instead of lurking into each caller.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
Quoted 25 lines · Andy Shevchenko
Quoted 5 lines · Matthias Schiffer
Quoted 3 lines · Andy Shevchenko
Quoted 1 line · Matthias Schiffer
On Wed, 2021-03-31 at 15:29 +0300, Andy Shevchenko wrote:
...
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
I don't understand which part of the code is dead now. I assume the
return irqcase is still useful for unexpected errors, or things likeEPROBE_DEFER? I'm not sure ifEPROBE_DEFERis relevant for this driver, but just ignoring the error code completely doesn't seem right to me.
platform_get_irq()AFAIK won't ever return such a code. So, basically your conditional is always false.Quoted 6 lines
Quoted 2 lines
I would like to see the code path which makes my comment wrong.
EPROBE_DEFERappears a few times inplatform_get_irq_optional()(drivers/base/platform.c), but it's possible that this is only relevant for OF-based platforms and not x86.
Quoted 6 lines
Ah, okay, that's something I haven't paid attention to.
So the root cause of the your case is platform_get_irq_optional|() return code. I'm wondering why it can't return 0 instead of absent IRQ? Perhaps you need to fix it instead of lurking into each caller.
Hi Andy,
what's the plan here? "driver core: platform: Make platform_get_irq_optional() optional" had to be reverted because it broke existing users of platform_get_irq_optional(). I'm not convinced that a slightly more convenient API is worth going through the trouble of fixing them all - I know we don't care much about out-of-tree modules, but subtly changing the behaviour of such a function doesn't seem like a good idea to me even if we review all in-tree users.
Should I just rebase my patches with the existing ENXIO handing (and fix up the other issues that were noted), or do you intend to give the platform_get_irq_optional() revamp another try?
Kind regards,
Matthias
Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
Quoted 7 lines · Matthias Schiffer
Quoted 6 lines · Andy Shevchenko
Quoted 4 lines · Matthias Schiffer
Quoted 3 lines · Andy Shevchenko
Quoted 1 line · Matthias Schiffer
On Wed, 2021-03-31 at 15:29 +0300, Andy Shevchenko wrote:
...
Quoted 20 lines
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
I don't understand which part of the code is dead now. I assume the
return irqcase is still useful for unexpected errors, or things likeEPROBE_DEFER? I'm not sure ifEPROBE_DEFERis relevant for this driver, but just ignoring the error code completely doesn't seem right to me.Quoted 8 lines
Quoted 4 lines
platform_get_irq()AFAIK won't ever return such a code. So, basically your conditional is always false.I would like to see the code path which makes my comment wrong.
EPROBE_DEFERappears a few times inplatform_get_irq_optional()(drivers/base/platform.c), but it's possible that this is only relevant for OF-based platforms and not x86.Quoted 5 lines
Ah, okay, that's something I haven't paid attention to.
So the root cause of the your case is platform_get_irq_optional|() return code. I'm wondering why it can't return 0 instead of absent IRQ? Perhaps you need to fix it instead of lurking into each caller.
Quoted 7 lines
what's the plan here? "driver core: platform: Make
platform_get_irq_optional()optional" had to be reverted because it broke existing users ofplatform_get_irq_optional(). I'm not convinced that a slightly more convenient API is worth going through the trouble of fixing them all - I know we don't care much about out-of-tree modules, but subtly changing the behaviour of such a function doesn't seem like a good idea to me even if we review all in-tree users.
Why? The problem with this function is either naming or semantics. It should be fixed and that will require revisiting all current users anyway.
Quoted 3 lines
Should I just rebase my patches with the existing ENXIO handing (and fix up the other issues that were noted), or do you intend to give the
platform_get_irq_optional()revamp another try?
I do intend to give another try, but if you want to be independent of that, just make sure that in any new / revisited user of platform_get_irq_optional() the 0 is taken into consideration as an optional case.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 1/3] gpio: tqmx86: really make IRQ optional
In reply to Matthias SchifferQuoted 6 lines · Matthias Schiffer
The tqmx86 MFD driver was passing IRQ 0 for "no IRQ" in the past. This causes warnings with newer kernels.
Prepare the gpio-tqmx86 driver for the fixed MFD driver by handling a missing IRQ properly.
Also you missed a Fixes tag.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 2/3 mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set
In reply to Matthias SchifferThe driver was registering IRQ 0 when no IRQ was set. This leads to warnings with newer kernels.
Clear the resource flags, so no resource is registered at all in this case.
--- drivers/mfd/tqmx86.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/tqmx86.c +2 -0
@@ -209,6 +209,8 @@ static int tqmx86_probe(struct platform_device *pdev)/* Assumes the IRQ resource is first. */ tqmx_gpio_resources[0 ].start = gpio_irq; + }else { + tqmx_gpio_resources[0 ].flags =0 ; } ocores_platfom_data.clock_khz =tqmx86_board_id_to_clk_rate (board_id);
Signature · 1 line
2.17.1
Re: [PATCH 2/3] mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set
Quoted 6 lines · Matthias Schiffer
The driver was registering IRQ 0 when no IRQ was set. This leads to warnings with newer kernels.
Clear the resource flags, so no resource is registered at all in this case.
...
drivers/mfd/tqmx86.c static int tqmx86_probe(struct platform_device *pdev) · line 213
Quoted 4 lines
/* Assumes the IRQ resource is first. */ tqmx_gpio_resources[0].start = gpio_irq;drivers/mfd/tqmx86.c +2
-0+ }else { + tqmx_gpio_resources[0 ].flags =0 ;
Please set IORESOURCE_DISABLED flag in the initial structure instead.
Quoted 1 line
}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 2/3] mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Matthias Schiffer
The driver was registering IRQ 0 when no IRQ was set. This leads to warnings with newer kernels.
Clear the resource flags, so no resource is registered at all in this case.
Quoted 8 lines
...
drivers/mfd/tqmx86.c static int tqmx86_probe(struct platform_device *pdev) · line 213
Quoted 4 lines
/* Assumes the IRQ resource is first. */ tqmx_gpio_resources[0].start = gpio_irq;drivers/mfd/tqmx86.c +2
-0+ }else { + tqmx_gpio_resources[0 ].flags =0 ;Please set
IORESOURCE_DISABLEDflag in the initial structure instead.
Is there any documentation for the correct usage of this flag? I think I tried IORESOURCE_DISABLED originally, but it didn't have any effect (platform_get_irq() ignored the flag and returned the resource anyways). I might misremember though, I originally wrote the series some time ago.
Quoted 4 lines
Quoted 2 lines
}
Re: [PATCH 2/3] mfd: tqmx86: clear GPIO IRQ resource when no IRQ is set
Quoted 3 lines · Matthias Schiffer
Quoted 2 lines · Andy Shevchenko
On Wed, Mar 31, 2021 at 2:39 PM Matthias Schiffer
<[email protected]> wrote:
...
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
+ tqmx_gpio_resources[0].flags = 0;
Please set
IORESOURCE_DISABLEDflag in the initial structure instead.Is there any documentation for the correct usage of this flag? I think I tried
IORESOURCE_DISABLEDoriginally, but it didn't have any effect (platform_get_irq()ignored the flag and returned the resource anyways). I might misremember though, I originally wrote the series some time ago.
It seems this flag is used solely for ACPI / PNP resources... Hmm... I dunno how platorm_get_irq*() should respect this flag. You see, that in the ACPI branch it has been checked there.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 3/3 mfd: tqmx86: add support for TQMxE40M
In reply to Matthias SchifferAll future TQMx86 SoMs will use a 24MHz LPC clock, so we can use that as a default instead of listing each new module individually.
--- drivers/mfd/tqmx86.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/mfd/tqmx86.c +4 -7
@@ -36,6 +36,7 @@#define TQMX86_REG_BOARD_ID_70EB 8#define TQMX86_REG_BOARD_ID_80UC 9#define TQMX86_REG_BOARD_ID_90UC 10 +#define TQMX86_REG_BOARD_ID_E40M 12#define TQMX86_REG_BOARD_REV 0x21#define TQMX86_REG_IO_EXT_INT 0x26#define TQMX86_REG_IO_EXT_INT_NONE 0
@@ -130,6 +131,8 @@ static const char *tqmx86_board_id_to_name(u8 board_id)return "TQMx80UC" ;case TQMX86_REG_BOARD_ID_90UC :return "TQMx90UC" ; +case TQMX86_REG_BOARD_ID_E40M : +return "TQMxE40M" ;default :return "Unknown" ; }
@@ -138,12 +141,6 @@ static const char *tqmx86_board_id_to_name(u8 board_id)static int tqmx86_board_id_to_clk_rate (u8 board_id) {switch (board_id) { -case TQMX86_REG_BOARD_ID_50UC : -case TQMX86_REG_BOARD_ID_60EB : -case TQMX86_REG_BOARD_ID_70EB : -case TQMX86_REG_BOARD_ID_80UC : -case TQMX86_REG_BOARD_ID_90UC : -return 24000 ;case TQMX86_REG_BOARD_ID_E39M :case TQMX86_REG_BOARD_ID_E39C :case TQMX86_REG_BOARD_ID_E39x:
@@ -152,7 +149,7 @@ static int tqmx86_board_id_to_clk_rate(u8 board_id)case TQMX86_REG_BOARD_ID_E38C :return 33000 ;default : -return 0 ; +return 24000 ; } }
Signature · 1 line
2.17.1
Re: [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M
Quoted 3 lines · Matthias Schiffer
All future TQMx86 SoMs will use a 24MHz LPC clock, so we can use that as a default instead of listing each new module individually.
...
Quoted 21 lines
case TQMX86_REG_BOARD_ID_90UC: return "TQMx90UC";drivers/mfd/tqmx86.c +2
-6+case TQMX86_REG_BOARD_ID_E40M : +return "TQMxE40M" ;default :return "Unknown" ; }@@ -138,12 +141,6 @@ static const char *tqmx86_board_id_to_name(u8 board_id)static int tqmx86_board_id_to_clk_rate (u8 board_id) {switch (board_id) { -case TQMX86_REG_BOARD_ID_50UC : -case TQMX86_REG_BOARD_ID_60EB : -case TQMX86_REG_BOARD_ID_70EB : -case TQMX86_REG_BOARD_ID_80UC : -case TQMX86_REG_BOARD_ID_90UC : -return 24000 ;case TQMX86_REG_BOARD_ID_E39M :case TQMX86_REG_BOARD_ID_E39C :case TQMX86_REG_BOARD_ID_E39x:
drivers/mfd/tqmx86.c static int tqmx86_board_id_to_clk_rate(u8 board_id) · line 152
Quoted 5 lines
drivers/mfd/tqmx86.c +1
-1@@ -152,7 +149,7 @@ static int tqmx86_board_id_to_clk_rate(u8 board_id)case TQMX86_REG_BOARD_ID_E38C :return 33000 ;default : -return 0 ; +return 24000 ;
AFAICS it will return 24 MHz for "Unknown" board. Is it okay to be so brave?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M
Quoted 28 lines · Andy Shevchenko
Quoted 3 lines · Matthias Schiffer
All future TQMx86 SoMs will use a 24MHz LPC clock, so we can use that as a default instead of listing each new module individually.
...
Quoted 20 lines
case TQMX86_REG_BOARD_ID_90UC: return "TQMx90UC";drivers/mfd/tqmx86.c +2
-6+case TQMX86_REG_BOARD_ID_E40M : +return "TQMxE40M" ;default :return "Unknown" ; }@@ -138,12 +141,6 @@ static const char *tqmx86_board_id_to_name(u8 board_id)static int tqmx86_board_id_to_clk_rate (u8 board_id) {switch (board_id) { -case TQMX86_REG_BOARD_ID_50UC : -case TQMX86_REG_BOARD_ID_60EB : -case TQMX86_REG_BOARD_ID_70EB : -case TQMX86_REG_BOARD_ID_80UC : -case TQMX86_REG_BOARD_ID_90UC : -return 24000 ;case TQMX86_REG_BOARD_ID_E39M :case TQMX86_REG_BOARD_ID_E39C :case TQMX86_REG_BOARD_ID_E39x:
Quoted 8 lines
drivers/mfd/tqmx86.c static int tqmx86_board_id_to_clk_rate(u8 board_id) · line 152
Quoted 6 lines
drivers/mfd/tqmx86.c +1
-1@@ -152,7 +149,7 @@ static int tqmx86_board_id_to_clk_rate(u8 board_id)case TQMX86_REG_BOARD_ID_E38C :return 33000 ;default : -return 0 ; +return 24000 ;AFAICS it will return 24 MHz for "Unknown" board. Is it okay to be so brave?
As noted in the commit message, our hardware developers intend to use 24 MHz for all future x86 SoMs.
Re: [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M
Quoted 3 lines · Matthias Schiffer
Quoted 2 lines · Andy Shevchenko
On Wed, Mar 31, 2021 at 2:38 PM Matthias Schiffer
<[email protected]> wrote:
...
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+ return 24000;
AFAICS it will return 24 MHz for "Unknown" board. Is it okay to be so brave?
As noted in the commit message, our hardware developers intend to use 24 MHz for all future x86 SoMs.
What may go wrong in the future?.. (rhetorical question, obviously)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M
Quoted 8 lines · Andy Shevchenko
Quoted 3 lines · Matthias Schiffer
Quoted 2 lines · Andy Shevchenko
On Wed, Mar 31, 2021 at 2:38 PM Matthias Schiffer
<[email protected]> wrote:...
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+ return 24000;
AFAICS it will return 24 MHz for "Unknown" board. Is it okay to be so brave?
As noted in the commit message, our hardware developers intend to use 24 MHz for all future x86 SoMs.
What may go wrong in the future?.. (rhetorical question, obviously)
My preference would be to be explicit.
Rather than support boards implicitly i.e. by accident.
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH 3/3] mfd: tqmx86: add support for TQMxE40M
Quoted 14 lines · Lee Jones
Quoted 12 lines · Andy Shevchenko
Quoted 3 lines · Matthias Schiffer
Quoted 2 lines · Andy Shevchenko
On Wed, Mar 31, 2021 at 2:38 PM Matthias Schiffer
<[email protected]> wrote:...
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
+ return 24000;
AFAICS it will return 24 MHz for "Unknown" board. Is it okay to be so brave?
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
As noted in the commit message, our hardware developers intend to use 24 MHz for all future x86 SoMs.
What may go wrong in the future?.. (rhetorical question, obviously)
My preference would be to be explicit.
Rather than support boards implicitly i.e. by accident.
How about logging a warning for unknown boards, but still returning 24 MHz?