BCM2835 PM driver (MFD version)
Subsystems (7)
v2 cover BCM2835 PM driver (MFD version)
Guenter Roeck and Stefan Wahren both wanted a MFD-style driver to cover the PM node that lets WDT and soc/bcm2835-power both attach to it. I think this is an ugly solution because it bloats this feature addition by 25% more lines for all the boilerplate, but here it is. Tested with V3D powering on, haven't double-checked the reset controller.
Eric Anholt (5):
dt-bindings: soc: Add a new binding for the BCM2835 PM node.
bcm2835-pm: Move bcm2835-watchdog's DT probe to an MFD.
soc: bcm: bcm2835-pm: Add support for power domains under a new
binding.
ARM: bcm283x: Extend the WDT DT node out to cover the whole PM block.
ARM: bcm283x: Switch V3D over to using the PM driver instead of
firmware.
.../bindings/soc/bcm/brcm,bcm2835-pm.txt | 42 ++ arch/arm/boot/dts/bcm2835-rpi.dtsi | 4 - arch/arm/boot/dts/bcm283x.dtsi | 16 +- arch/arm/mach-bcm/Kconfig | 1 + drivers/mfd/Makefile | 1 + drivers/mfd/bcm2835-pm.c | 98 +++ drivers/soc/bcm/Kconfig | 11 + drivers/soc/bcm/Makefile | 1 + drivers/soc/bcm/bcm2835-power.c | 661 ++++++++++++++++++ drivers/watchdog/bcm2835_wdt.c | 30 +- include/dt-bindings/soc/bcm2835-pm.h | 28 + include/linux/mfd/bcm2835-pm.h | 14 + 12 files changed, 882 insertions(+), 25 deletions(-) create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt create mode 100644 drivers/mfd/bcm2835-pm.c create mode 100644 drivers/soc/bcm/bcm2835-power.c create mode 100644 include/dt-bindings/soc/bcm2835-pm.h create mode 100644 include/linux/mfd/bcm2835-pm.h
Signature · 1 line
2.19.1
PATCH v2 1/5 dt-bindings: soc: Add a new binding for the BCM2835 PM node.
This binding supersedes the bcm2835-pm-wdt binding which only covered enough to provide a watchdog, but the HW block is actually mostly about power domains.
--- .../bindings/soc/bcm/brcm,bcm2835-pm.txt | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt
Documentation/devicetree/bindings/soc/bcm/brcm,bcm2835-pm.txt new file +42 -0
@@ -0,0 +1,42 @@ +BCM2835 PM (Power domains, watchdog) + +The PM block controls power domains and some reset lines, and includes +a watchdog timer. This binding supersedes the brcm,bcm2835-pm-wdt +binding which covered some of PM's register range and functionality. + +Required properties: + +- compatible: Should be "brcm,bcm2835-pm" +- reg: Specifies base physical address and size of the two + register ranges ("PM" and "ASYNC_BRIDGE" in that + order) +- clocks: a) v3d: The V3D clock from CPRMAN + b) peri_image: The PERI_IMAGE clock from CPRMAN + c) h264: The H264 clock from CPRMAN + d) isp: The ISP clock from CPRMAN +- #reset-cells: Should be 1. This property follows the reset controller + bindings[1]. +- #power-domain-cells: Should be 1. This property follows the power domain + bindings[2]. + +Optional properties: + +- timeout-sec: Contains the watchdog timeout in seconds + +[1] Documentation/devicetree/bindings/reset/reset.txt +[2] Documentation/devicetree/bindings/power/power_domain.txt + +Example: + +pm { + compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt"; + #power-domain-cells = <1>; + #reset-cells = <1>; + reg = <0x7e100000 0x114>, + <0x7e00a000 0x24>; + clocks = <&clocks BCM2835_CLOCK_V3D>, + <&clocks BCM2835_CLOCK_PERI_IMAGE>, + <&clocks BCM2835_CLOCK_H264>, + <&clocks BCM2835_CLOCK_ISP>; + clock-names = "v3d", "peri_image", "h264", "isp"; +};
Signature · 1 line
2.19.1
PATCH v2 2/5 bcm2835-pm: Move bcm2835-watchdog's DT probe to an MFD.
In reply to Eric AnholtThe PM block that the wdt driver was binding to actually has multiple features we want to expose (power domains, reset, watchdog). Move the DT attachment to a MFD driver and make WDT probe against MFD.
--- arch/arm/mach-bcm/Kconfig | 1 + drivers/mfd/Makefile | 1 + drivers/mfd/bcm2835-pm.c | 70 ++++++++++++++++++++++++++++++++++ drivers/watchdog/bcm2835_wdt.c | 30 ++++++--------- include/linux/mfd/bcm2835-pm.h | 13 +++++++ 5 files changed, 97 insertions(+), 18 deletions(-) create mode 100644 drivers/mfd/bcm2835-pm.c create mode 100644 include/linux/mfd/bcm2835-pm.h
arch/arm/mach-bcm/Kconfig +1 -0
@@ -167,6 +167,7 @@ config ARCH_BCM2835 select BCM2835_TIMER select PINCTRL select PINCTRL_BCM2835 + select MFD_CORE help This enables support for the Broadcom BCM2835 and BCM2836 SoCs. This SoC is used in the Raspberry Pi and Roku 2 devices.
drivers/mfd/Makefile +1 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_MFD_88PM805) += 88pm805.o 88pm80x.o obj-$(CONFIG_MFD_ACT8945A) += act8945a.o obj-$(CONFIG_MFD_SM501) += sm501.o obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o +obj-$(CONFIG_ARCH_BCM2835) += bcm2835-pm.o obj-$(CONFIG_MFD_BCM590XX) += bcm590xx.o obj-$(CONFIG_MFD_BD9571MWV) += bd9571mwv.o cros_ec_core-objs := cros_ec.o
drivers/mfd/bcm2835-pm.c new file +70 -0
70 lines not on this page · raw message
drivers/watchdog/bcm2835_wdt.c +12 -18
@@ -12,6 +12,7 @@#include <linux/delay.h> #include <linux/types.h> +#include <linux/mfd/bcm2835-pm.h> #include <linux/module.h> #include <linux/io.h> #include <linux/watchdog.h>
@@ -47,6 +48,8 @@ struct bcm2835_wdt {spinlock_t lock; }; +struct bcm2835_wdt *bcm2835_power_off_wdt; +static unsigned int heartbeat;static bool nowayout =WATCHDOG_NOWAYOUT ;
@@ -148,10 +151,7 @@ static struct watchdog_device bcm2835_wdt_wdd = {*/ static void bcm2835_power_off (void ) { -struct device_node *np = -of_find_compatible_node (NULL ,NULL ,"brcm,bcm2835-pm-wdt" ); -struct platform_device *pdev =of_find_device_by_node (np); -struct bcm2835_wdt *wdt =platform_get_drvdata (pdev); +struct bcm2835_wdt *wdt = bcm2835_power_off_wdt;u32 val;/*
@@ -169,7 +169,7 @@ static void bcm2835_power_off(void)static int bcm2835_wdt_probe (struct platform_device *pdev) { -struct resource *res; +struct bcm2835_pm *pm =dev_get_drvdata (pdev->dev.parent);struct device *dev = &pdev->dev;struct bcm2835_wdt *wdt;int err;
@@ -181,10 +181,7 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)spin_lock_init (&wdt->lock); - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - wdt->base =devm_ioremap_resource (dev, res); -if (IS_ERR (wdt->base)) -return PTR_ERR (wdt->base); + wdt->base = pm->base;watchdog_set_drvdata (&bcm2835_wdt_wdd, wdt);watchdog_init_timeout (&bcm2835_wdt_wdd, heartbeat, dev);
@@ -211,8 +208,10 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)return err; } -if (pm_power_off ==NULL ) +if (pm_power_off ==NULL ) { pm_power_off = bcm2835_power_off; + bcm2835_power_off_wdt = wdt; + }dev_info (dev,"Broadcom BCM2835 watchdog timer" );return 0 ;
@@ -220,24 +219,19 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)static int bcm2835_wdt_remove (struct platform_device *pdev) { -if (pm_power_off == bcm2835_power_off) +if (pm_power_off == bcm2835_power_off) { pm_power_off =NULL ; + bcm2835_power_off_wdt =NULL ; + }return 0 ; } -static const struct of_device_id bcm2835_wdt_of_match[] = { - { .compatible ="brcm,bcm2835-pm-wdt" , }, - {}, -}; -MODULE_DEVICE_TABLE (of, bcm2835_wdt_of_match); -static struct platform_driver bcm2835_wdt_driver = { .probe = bcm2835_wdt_probe, .remove = bcm2835_wdt_remove, .driver = { .name ="bcm2835-wdt" , - .of_match_table = bcm2835_wdt_of_match, }, };module_platform_driver (bcm2835_wdt_driver);
include/linux/mfd/bcm2835-pm.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef BCM2835_MFD_PM_H +#define BCM2835_MFD_PM_H + +#include <linux/regmap.h> + +struct bcm2835_pm { +struct device *dev; +void __iomem *base; +}; + +#endif /* BCM2835_MFD_PM_H */
Signature · 1 line
2.19.1
PATCH v2 3/5 soc: bcm: bcm2835-pm: Add support for power domains under a new binding.
In reply to Eric AnholtThis provides a free software alternative to raspberrypi-power.c's firmware calls to manage power domains. It also exposes a reset line, where previously the vc4 driver had to try to force power off the domain in order to trigger a reset.
--- drivers/mfd/bcm2835-pm.c | 36 +- drivers/soc/bcm/Kconfig | 11 + drivers/soc/bcm/Makefile | 1 + drivers/soc/bcm/bcm2835-power.c | 661 +++++++++++++++++++++++++++ include/dt-bindings/soc/bcm2835-pm.h | 28 ++ include/linux/mfd/bcm2835-pm.h | 1 + 6 files changed, 734 insertions(+), 4 deletions(-) create mode 100644 drivers/soc/bcm/bcm2835-power.c create mode 100644 include/dt-bindings/soc/bcm2835-pm.h
drivers/mfd/bcm2835-pm.c +32 -4
@@ -3,7 +3,7 @@* PM MFD driver for Broadcom BCM2835 * * This driver binds to the PM block and creates the MFD device for -* the WDT driver. +* the WDT and power drivers. */ #include <linux/delay.h>
@@ -21,11 +21,16 @@ static const struct mfd_cell bcm2835_pm_devs[] = { { .name = "bcm2835-wdt" }, }; +static const struct mfd_cell bcm2835_power_devs[] = { + { .name ="bcm2835-power" }, +}; +static int bcm2835_pm_probe (struct platform_device *pdev) {struct resource *res;struct device *dev = &pdev->dev;struct bcm2835_pm *pm; +int ret; pm =devm_kzalloc (dev,sizeof (*pm),GFP_KERNEL );if (!pm)
@@ -39,9 +44,31 @@ static int bcm2835_pm_probe(struct platform_device *pdev)if (IS_ERR (pm->base))return PTR_ERR (pm->base); -return devm_mfd_add_devices (dev,-1 , - bcm2835_pm_devs,ARRAY_SIZE (bcm2835_pm_devs), -NULL ,0 ,NULL ); + ret =devm_mfd_add_devices (dev,-1 , + bcm2835_pm_devs,ARRAY_SIZE (bcm2835_pm_devs), +NULL ,0 ,NULL ); +if (ret) +return ret; + +/* We'll use the presence of the AXI ASB regs in the +* bcm2835-pm binding as the key for whether we can reference +* the full PM register range and support power domains. +*/ + res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); +if (res) { + pm->asb =devm_ioremap_resource (dev, res); +if (IS_ERR (pm->asb)) +return PTR_ERR (pm->asb); + + ret =devm_mfd_add_devices (dev,-1 , + bcm2835_power_devs, +ARRAY_SIZE (bcm2835_power_devs), +NULL ,0 ,NULL ); +if (ret) +return ret; + } + +return 0 ; }static int bcm2835_pm_remove (struct platform_device *pdev)
@@ -51,6 +78,7 @@ static int bcm2835_pm_remove(struct platform_device *pdev)static const struct of_device_id bcm2835_pm_of_match[] = { { .compatible ="brcm,bcm2835-pm-wdt" , }, + { .compatible ="brcm,bcm2835-pm" , }, {}, };MODULE_DEVICE_TABLE (of, bcm2835_pm_of_match);
drivers/soc/bcm/Kconfig +11 -0
@@ -1,5 +1,16 @@ menu "Broadcom SoC drivers" +config BCM2835_POWER + bool "BCM2835 power domain driver" + depends on ARCH_BCM2835 || (COMPILE_TEST && OF) + select PM_GENERIC_DOMAINS if PM + select RESET_CONTROLLER + help + This enables support for the BCM2835 power domains and reset + controller. Any usage of power domains by the Raspberry Pi + firmware means that Linux usage of the same power domain + must be accessed using the RASPBERRYPI_POWER driver + config RASPBERRYPI_POWER bool "Raspberry Pi power domain driver" depends on ARCH_BCM2835 || (COMPILE_TEST && OF)
drivers/soc/bcm/Makefile +1 -0
@@ -1,2 +1,3 @@ +obj-$(CONFIG_BCM2835_POWER) += bcm2835-power.o obj-$(CONFIG_RASPBERRYPI_POWER) += raspberrypi-power.o obj-$(CONFIG_SOC_BRCMSTB) += brcmstb/
drivers/soc/bcm/bcm2835-power.c new file +661 -0
661 lines not on this page · raw message
include/dt-bindings/soc/bcm2835-pm.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */ + +#ifndef _DT_BINDINGS_ARM_BCM2835_PM_H +#define _DT_BINDINGS_ARM_BCM2835_PM_H + +#define BCM2835_POWER_DOMAIN_GRAFX 0 +#define BCM2835_POWER_DOMAIN_GRAFX_V3D 1 +#define BCM2835_POWER_DOMAIN_IMAGE 2 +#define BCM2835_POWER_DOMAIN_IMAGE_PERI 3 +#define BCM2835_POWER_DOMAIN_IMAGE_ISP 4 +#define BCM2835_POWER_DOMAIN_IMAGE_H264 5 +#define BCM2835_POWER_DOMAIN_USB 6 +#define BCM2835_POWER_DOMAIN_DSI0 7 +#define BCM2835_POWER_DOMAIN_DSI1 8 +#define BCM2835_POWER_DOMAIN_CAM0 9 +#define BCM2835_POWER_DOMAIN_CAM1 10 +#define BCM2835_POWER_DOMAIN_CCP2TX 11 +#define BCM2835_POWER_DOMAIN_HDMI 12 + +#define BCM2835_POWER_DOMAIN_COUNT 13 + +#define BCM2835_RESET_V3D 0 +#define BCM2835_RESET_ISP 1 +#define BCM2835_RESET_H264 2 + +#define BCM2835_RESET_COUNT 3 + +#endif /* _DT_BINDINGS_ARM_BCM2835_PM_H */
include/linux/mfd/bcm2835-pm.h +1 -0
@@ -8,6 +8,7 @@struct bcm2835_pm {struct device *dev;void __iomem *base; +void __iomem *asb; };#endif /* BCM2835_MFD_PM_H */
Signature · 1 line
2.19.1
PATCH v2 4/5 ARM: bcm283x: Extend the WDT DT node out to cover the whole PM block.
In reply to Eric AnholtIt was covering part of the PM block's range, up to the WDT regs. To support the rest of the PM block's functionality, we need the full register range plus the AXI Async Bridge regs for PM sequencing.
This doesn't convert any of the consumers over to the new binding yet, since we will need to be careful in coordinating our usage of firmware services that might power domains on and off versus the bcm2835-pm driver's access of those same domains.
--- arch/arm/boot/dts/bcm283x.dtsi | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
arch/arm/boot/dts/bcm283x.dtsi +10 -2
@@ -121,8 +121,16 @@ }; watchdog at 7e100000 { - compatible = "brcm,bcm2835-pm-wdt"; - reg = <0x7e100000 0x28>; + compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt"; + #power-domain-cells = <1>; + #reset-cells = <1>; + reg = <0x7e100000 0x114>, + <0x7e00a000 0x24>; + clocks = <&clocks BCM2835_CLOCK_V3D>, + <&clocks BCM2835_CLOCK_PERI_IMAGE>, + <&clocks BCM2835_CLOCK_H264>, + <&clocks BCM2835_CLOCK_ISP>; + clock-names = "v3d", "peri_image", "h264", "isp"; }; clocks: cprman at 7e101000 {
Signature · 1 line
2.19.1
PATCH v2 5/5 ARM: bcm283x: Switch V3D over to using the PM driver instead of firmware.
In reply to Eric AnholtThe GRAFX domain only contains V3D, and this driver should be the only accessor of V3D (firmware usage gets disabled when V3D is in the DT), so we can safely make Linux control the GRAFX and GRAFX_V3D power domains.
--- arch/arm/boot/dts/bcm2835-rpi.dtsi | 4 ---- arch/arm/boot/dts/bcm283x.dtsi | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-)
arch/arm/boot/dts/bcm2835-rpi.dtsi +0 -4
@@ -87,10 +87,6 @@ power-domains = <&power RPI_POWER_DOMAIN_USB>; }; -&v3d { - power-domains = <&power RPI_POWER_DOMAIN_V3D>; -}; - &hdmi { power-domains = <&power RPI_POWER_DOMAIN_HDMI>; status = "okay";
arch/arm/boot/dts/bcm283x.dtsi +3 -1
@@ -3,6 +3,7 @@ #include <dt-bindings/clock/bcm2835-aux.h> #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/soc/bcm2835-pm.h> /* firmware-provided startup stubs live here, where the secondary CPUs are * spinning.
@@ -120,7 +121,7 @@ #interrupt-cells = <2>; }; - watchdog at 7e100000 { + pm: watchdog at 7e100000 { compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt"; #power-domain-cells = <1>; #reset-cells = <1>;
@@ -637,6 +638,7 @@ compatible = "brcm,bcm2835-v3d"; reg = <0x7ec00000 0x1000>; interrupts = <1 10>; + power-domains = <&pm BCM2835_POWER_DOMAIN_GRAFX_V3D>; }; vc4: gpu {
Signature · 1 line
2.19.1
Guenter Roeck
maintainerRe: [PATCH v2 2/5] bcm2835-pm: Move bcm2835-watchdog's DT probe to an MFD.
In reply to Eric AnholtQuoted 53 lines · Eric Anholt
The PM block that the wdt driver was binding to actually has multiple features we want to expose (power domains, reset, watchdog). Move the DT attachment to a MFD driver and make WDT probe against MFD.
Signed-off-by Eric Anholt <[email protected]>--- arch/arm/mach-bcm/Kconfig | 1 + drivers/mfd/Makefile | 1 + drivers/mfd/bcm2835-pm.c | 70 ++++++++++++++++++++++++++++++++++ drivers/watchdog/bcm2835_wdt.c | 30 ++++++--------- include/linux/mfd/bcm2835-pm.h | 13 +++++++ 5 files changed, 97 insertions(+), 18 deletions(-)create mode 100644
drivers/mfd/bcm2835-pm.ccreate mode 100644include/linux/mfd/bcm2835-pm.harch/arm/mach-bcm/Kconfig +1
-0@@ -167,6 +167,7 @@ config ARCH_BCM2835 select BCM2835_TIMER select PINCTRL select PINCTRL_BCM2835 + select MFD_CORE help This enables support for the Broadcom BCM2835 and BCM2836 SoCs. This SoC is used in the Raspberry Pi and Roku 2 devices.drivers/mfd/Makefile +1
-0@@ -10,6 +10,7 @@ obj-$(CONFIG_MFD_88PM805) += 88pm805.o 88pm80x.o obj-$(CONFIG_MFD_ACT8945A) += act8945a.o obj-$(CONFIG_MFD_SM501) += sm501.o obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o +obj-$(CONFIG_ARCH_BCM2835) += bcm2835-pm.o obj-$(CONFIG_MFD_BCM590XX) += bcm590xx.o obj-$(CONFIG_MFD_BD9571MWV) += bd9571mwv.o cros_ec_core-objs := cros_ec.odrivers/mfd/bcm2835-pm.c new file +8
-0@@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* PM MFD driver for Broadcom BCM2835 +* +* This driver binds to the PM block and creates the MFD device for +* the WDT driver. +*/ +
drivers/mfd/bcm2835-pm.c line 18
Quoted 10 lines
drivers/mfd/bcm2835-pm.c new file +10
-0+#include <linux/delay.h> +#include <linux/types.h> +#include <linux/mfd/core.h> +#include <linux/mfd/bcm2835-pm.h> +#include <linux/module.h> +#include <linux/io.h> +#include <linux/watchdog.h> +#include <linux/platform_device.h> +#include <linux/of_address.h> +#include <linux/of_platform.h>
Alphabetic order would be a bit nicer.
Quoted 22 lines
drivers/mfd/bcm2835-pm.c new file +22
-0+ +static const struct mfd_cell bcm2835_pm_devs[] = { + { .name ="bcm2835-wdt" }, +}; + +static int bcm2835_pm_probe (struct platform_device *pdev) +{ +struct resource *res; +struct device *dev = &pdev->dev; +struct bcm2835_pm *pm; + + pm =devm_kzalloc (dev,sizeof (*pm),GFP_KERNEL ); +if (!pm) +return -ENOMEM ; +platform_set_drvdata (pdev, pm); + + pm->dev = dev; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + pm->base =devm_ioremap_resource (dev, res); +if (IS_ERR (pm->base)) +return PTR_ERR (pm->base);
drivers/mfd/bcm2835-pm.c line 50
Quoted 10 lines
drivers/mfd/bcm2835-pm.c new file +10
-0+ +return devm_mfd_add_devices (dev,-1 , + bcm2835_pm_devs,ARRAY_SIZE (bcm2835_pm_devs), +NULL ,0 ,NULL ); +} + +static int bcm2835_pm_remove (struct platform_device *pdev) +{ +return 0 ; +}
I don't think that is needed.
Quoted 33 lines
drivers/mfd/bcm2835-pm.c new file +20
-0+ +static const struct of_device_id bcm2835_pm_of_match[] = { + { .compatible ="brcm,bcm2835-pm-wdt" , }, + {}, +}; +MODULE_DEVICE_TABLE (of, bcm2835_pm_of_match); + +static struct platform_driver bcm2835_pm_driver = { + .probe = bcm2835_pm_probe, + .remove = bcm2835_pm_remove, + .driver = { + .name ="bcm2835-pm" , + .of_match_table = bcm2835_pm_of_match, + }, +}; +module_platform_driver (bcm2835_pm_driver); + +MODULE_AUTHOR ("Eric Anholt <[email protected]>" ); +MODULE_DESCRIPTION ("Driver for Broadcom BCM2835 PM MFD" ); +MODULE_LICENSE ("GPL" );drivers/watchdog/bcm2835_wdt.c +1
-0@@ -12,6 +12,7 @@#include <linux/delay.h> #include <linux/types.h> +#include <linux/mfd/bcm2835-pm.h> #include <linux/module.h> #include <linux/io.h> #include <linux/watchdog.h>
drivers/watchdog/bcm2835_wdt.c struct bcm2835_wdt { · line 51
Quoted 4 lines
drivers/watchdog/bcm2835_wdt.c +1
-0@@ -47,6 +48,8 @@ struct bcm2835_wdt {spinlock_t lock; }; +struct bcm2835_wdt *bcm2835_power_off_wdt;
static
Quoted 50 lines
drivers/watchdog/bcm2835_wdt.c +7
-10+static unsigned int heartbeat;static bool nowayout =WATCHDOG_NOWAYOUT ;@@ -148,10 +151,7 @@ static struct watchdog_device bcm2835_wdt_wdd = {*/ static void bcm2835_power_off (void ) { -struct device_node *np = -of_find_compatible_node (NULL ,NULL ,"brcm,bcm2835-pm-wdt" ); -struct platform_device *pdev =of_find_device_by_node (np); -struct bcm2835_wdt *wdt =platform_get_drvdata (pdev); +struct bcm2835_wdt *wdt = bcm2835_power_off_wdt;u32 val;/* @@ -169,7 +169,7 @@ static void bcm2835_power_off(void)static int bcm2835_wdt_probe (struct platform_device *pdev) { -struct resource *res; +struct bcm2835_pm *pm =dev_get_drvdata (pdev->dev.parent);struct device *dev = &pdev->dev;struct bcm2835_wdt *wdt;int err;@@ -181,10 +181,7 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)spin_lock_init (&wdt->lock); - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - wdt->base =devm_ioremap_resource (dev, res); -if (IS_ERR (wdt->base)) -return PTR_ERR (wdt->base); + wdt->base = pm->base;watchdog_set_drvdata (&bcm2835_wdt_wdd, wdt);watchdog_init_timeout (&bcm2835_wdt_wdd, heartbeat, dev);@@ -211,8 +208,10 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)return err; } -if (pm_power_off ==NULL ) +if (pm_power_off ==NULL ) { pm_power_off = bcm2835_power_off; + bcm2835_power_off_wdt = wdt; + }dev_info (dev,"Broadcom BCM2835 watchdog timer" );return 0 ;
drivers/watchdog/bcm2835_wdt.c static int bcm2835_wdt_probe(struct platform_device *pdev) · line 224
Quoted 7 lines
drivers/watchdog/bcm2835_wdt.c +2
-1@@ -220,24 +219,19 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)static int bcm2835_wdt_remove (struct platform_device *pdev) { -if (pm_power_off == bcm2835_power_off) +if (pm_power_off == bcm2835_power_off) { pm_power_off =NULL ; + bcm2835_power_off_wdt =NULL ;
I don't think this is needed.
Quoted 40 lines
drivers/watchdog/bcm2835_wdt.c +1
-7+ }return 0 ; } -static const struct of_device_id bcm2835_wdt_of_match[] = { - { .compatible ="brcm,bcm2835-pm-wdt" , }, - {}, -}; -MODULE_DEVICE_TABLE (of, bcm2835_wdt_of_match); -static struct platform_driver bcm2835_wdt_driver = { .probe = bcm2835_wdt_probe, .remove = bcm2835_wdt_remove, .driver = { .name ="bcm2835-wdt" , - .of_match_table = bcm2835_wdt_of_match, }, };module_platform_driver (bcm2835_wdt_driver);include/linux/mfd/bcm2835-pm.h new file +13
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef BCM2835_MFD_PM_H +#define BCM2835_MFD_PM_H + +#include <linux/regmap.h> + +struct bcm2835_pm { +struct device *dev; +void __iomem *base; +}; + +#endif /* BCM2835_MFD_PM_H */