diff mbox series

[v2,3/4] powerpc/pseries: register pseries-wdt device with platform bus

Message ID 20220602175353.68942-4-cheloha@linux.ibm.com
State Superseded
Headers show
Series pseries-wdt: initial support for H_WATCHDOG-based watchdog timers | expand

Commit Message

Scott Cheloha June 2, 2022, 5:53 p.m. UTC
PAPR v2.12 defines a new hypercall, H_WATCHDOG.  The hypercall permits
guest control of one or more virtual watchdog timers.

These timers do not conform to PowerPC device conventions.  They are
not affixed to any extant bus, nor do they have full representation in
the device tree.

As a workaround we represent them as platform devices.

This patch registers a single platform device, "pseries-wdt", with the
platform bus if the FW_FEATURE_WATCHDOG flag is set.

A driver for this device, "pseries-wdt", will be introduced in a
subsequent patch.

Signed-off-by: Scott Cheloha <cheloha@linux.ibm.com>
---
 arch/powerpc/platforms/pseries/setup.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Nathan Lynch June 21, 2022, 3:30 p.m. UTC | #1
Scott Cheloha <cheloha@linux.ibm.com> writes:
> PAPR v2.12 defines a new hypercall, H_WATCHDOG.  The hypercall permits
> guest control of one or more virtual watchdog timers.
>
> These timers do not conform to PowerPC device conventions.  They are
> not affixed to any extant bus, nor do they have full representation in
> the device tree.
>
> As a workaround we represent them as platform devices.
>
> This patch registers a single platform device, "pseries-wdt", with the
> platform bus if the FW_FEATURE_WATCHDOG flag is set.
>
> A driver for this device, "pseries-wdt", will be introduced in a
> subsequent patch.
>
> Signed-off-by: Scott Cheloha <cheloha@linux.ibm.com>
> ---
>  arch/powerpc/platforms/pseries/setup.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
> index afb074269b42..233c64f59815 100644
> --- a/arch/powerpc/platforms/pseries/setup.c
> +++ b/arch/powerpc/platforms/pseries/setup.c
> @@ -14,6 +14,7 @@
>  
>  #include <linux/cpu.h>
>  #include <linux/errno.h>
> +#include <linux/platform_device.h>
>  #include <linux/sched.h>
>  #include <linux/kernel.h>
>  #include <linux/mm.h>
> @@ -169,6 +170,22 @@ static void __init fwnmi_init(void)
>  #endif
>  }
>  
> +/*
> + * Affix a device for the first timer to the platform bus if
> + * we have firmware support for the H_WATCHDOG hypercall.
> + */
> +static struct platform_device *pseries_wdt_pdev;
> +
> +static __init int pseries_wdt_init(void)
> +{
> +	if (!firmware_has_feature(FW_FEATURE_WATCHDOG))
> +		return 0;
> +	pseries_wdt_pdev = platform_device_register_simple("pseries-wdt",
> +							   0, NULL, 0);
> +	return 0;
> +}
> +machine_subsys_initcall(pseries, pseries_wdt_init);
> +

Seems like we don't need pseries_wdt_pdev as it's unused elsewhere? But
that's quite minor.

Reviewed-by: Nathan Lynch <nathanl@linux.ibm.com>
Michael Ellerman June 24, 2022, 1:27 p.m. UTC | #2
Nathan Lynch <nathanl@linux.ibm.com> writes:
> Scott Cheloha <cheloha@linux.ibm.com> writes:
>> PAPR v2.12 defines a new hypercall, H_WATCHDOG.  The hypercall permits
>> guest control of one or more virtual watchdog timers.
...
>
> Seems like we don't need pseries_wdt_pdev as it's unused elsewhere? But
> that's quite minor.

It's minor but please drop it in the next version.

cheers
Scott Cheloha July 7, 2022, 3:53 p.m. UTC | #3
On Fri, Jun 24, 2022 at 11:27:36PM +1000, Michael Ellerman wrote:
> Nathan Lynch <nathanl@linux.ibm.com> writes:
> > Scott Cheloha <cheloha@linux.ibm.com> writes:
> >> PAPR v2.12 defines a new hypercall, H_WATCHDOG.  The hypercall permits
> >> guest control of one or more virtual watchdog timers.
> ...
> >
> > Seems like we don't need pseries_wdt_pdev as it's unused elsewhere? But
> > that's quite minor.
> 
> It's minor but please drop it in the next version.

Dropped.
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index afb074269b42..233c64f59815 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -14,6 +14,7 @@ 
 
 #include <linux/cpu.h>
 #include <linux/errno.h>
+#include <linux/platform_device.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
@@ -169,6 +170,22 @@  static void __init fwnmi_init(void)
 #endif
 }
 
+/*
+ * Affix a device for the first timer to the platform bus if
+ * we have firmware support for the H_WATCHDOG hypercall.
+ */
+static struct platform_device *pseries_wdt_pdev;
+
+static __init int pseries_wdt_init(void)
+{
+	if (!firmware_has_feature(FW_FEATURE_WATCHDOG))
+		return 0;
+	pseries_wdt_pdev = platform_device_register_simple("pseries-wdt",
+							   0, NULL, 0);
+	return 0;
+}
+machine_subsys_initcall(pseries, pseries_wdt_init);
+
 static void pseries_8259_cascade(struct irq_desc *desc)
 {
 	struct irq_chip *chip = irq_desc_get_chip(desc);