Skip to contentSkip to conversation

ARM: bcm2835: add support for rpi power domain driver

PATCH New Alexander Aring 3 participants 9 messages Nov 29, 2015 – Nov 30, 2015

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

v2 cover ARM: bcm2835: add support for rpi power domain driver

Hi,

this patch series contains at first a patch for the power domain subsystem which offers to exit generic power domains when init was called before.

The RPi Power-Domains need to be enabled/disabled by interacting with the RPi firmware which can fail. To cleanup the probing we need to undo the power domains again which was registered before.

- Alex

changes since PATCHv2:
- rename pm_genpd_uninit to pm_genpd_exit. I adapted here a review note from another patch. Usually kernel naming style is like "foobar_init" and "foobar_exit" but rarely "uninit". That's why I don't add the ack from Ulf Hansson here.
- split dtsi updates into a separate patch.
- remove testing steps from commit message.
- change to "depends on ARCH_BCM2835 || COMPILE_TEST".
- Add Rob Herring ack.
- Add Eric Anholt sob.

changes since PATCH (was RFCv2 before):
- add WARN_ON_ONCE if there are still references from generic power domain inside the power domain subsystem when running pm_genpd_uninit.
- add mutex_destroy when running pm_genpd_uninit.
- split devicetree binding for rpi power domain driver into a separate patch.
- rename config RASPBERRY_POWER to RASPBERRYPI_POWER
- order list of <linux/...> includes alphabetical.
- use rpi_ prefix than raspberrypi_ prefix.
- rename _DT_BINDINGS_ARM_BCM2835_MBOX_POWER_H to _DT_BINDINGS_ARM_BCM2835_RPI_POWER_H

changes since RFCv2:
- add pm_genpd_uninit to handle probing failure.
- move power domain drive to his own driver in arch/arm/mach-bcm/ Also add own devicetree node for this driver, "raspberrypi,bcm2835-power".
- Removing all power domains which might exists for the firmware API but we currently have no use-case for it. I tried to keep the same domain numbering in generic power domains subsystem like they are offered from the firmware API. This works, all power_domains which are NULL inside the array of genpd_onecell_data.domains[#] will be ignored.
- Adding Eric Anholt and me to the authors.
- Creating devicetree documentation for the power domain driver.
- fix error handling in raspberrypi_firmware_set_power.
- Remove comment about mapping between power domains array, this is not necessary anymore. I add a "enabled" attribute to raspberrypi_power_domain which indicates if a domain should be registered or not (zeroed values does not indicate such handling, but enabled is false then).
- remove "goto mbox" not necessary anymore because an own driver implementation.
- Update devicetrees for changes in v2.

Alexander Aring (4):
power: domain: add pm_genpd_exit
ARM: bcm2835: add rpi power domain driver
devicetree: add rpi power domain driver bindings
ARM: bcm2835: update rpi devicetree entries

 .../bindings/arm/bcm/raspberrypi,bcm2835-power.txt |  25 +++
 arch/arm/boot/dts/bcm2835-rpi.dtsi                 |  11 ++
 arch/arm/boot/dts/bcm2835.dtsi                     |   2 +-
 arch/arm/mach-bcm/Kconfig                          |  10 ++
 arch/arm/mach-bcm/Makefile                         |   1 +
 arch/arm/mach-bcm/raspberrypi-power.c              | 180 +++++++++++++++++++++
 drivers/base/power/domain.c                        |  22 +++
 include/dt-bindings/arm/raspberrypi-power.h        |  14 ++
 include/linux/pm_domain.h                          |   4 +
 9 files changed, 268 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-power.txt
 create mode 100644 arch/arm/mach-bcm/raspberrypi-power.c
 create mode 100644 include/dt-bindings/arm/raspberrypi-power.h
Signature · 1 line
2.6.1
#1 lore raw

PATCH v2 1/4 power: domain: add pm_genpd_exit

This patch adds function pm_genpd_exit for undo a pm_genpd_init. This is useful for multiple power domains while probing. If the probing fails after one pm_genpd_init was called we need to undo all previous registrations of generic pm domains inside the gpd_list list.

There is a check on IS_ERR_OR_NULL(genpd) which is useful to check again registered power domains and not registered domains, the driver can use this mechanism to have an array with registered and non-registered power domains, where non-registered power domains are NULL.

Cc Rafael J. Wysocki <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Len Brown <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/base/power/domain.c | 22 ++++++++++++++++++++++
 include/linux/pm_domain.h   |  4 ++++
 2 files changed, 26 insertions(+)
drivers/base/power/domain.c +22 -0
index e03b1ad..311cb0e 100644
@@ -1509,6 +1509,28 @@ void pm_genpd_init(struct generic_pm_domain *genpd,
 }
 EXPORT_SYMBOL_GPL(pm_genpd_init);
 
+/**
+ * pm_genpd_exit - Uninitialize a generic I/O PM domain object.
+ * @genpd: PM domain object to uninitialize.
+ */
+void pm_genpd_exit(struct generic_pm_domain *genpd)
+{
+	if (IS_ERR_OR_NULL(genpd))
+		return;
+
+	/* check if domain is still in registered inside the pm subsystem */
+	WARN_ON_ONCE(!list_empty(&genpd->master_links) ||
+		     !list_empty(&genpd->slave_links) ||
+		     !list_empty(&genpd->dev_list));
+
+	mutex_lock(&gpd_list_lock);
+	list_del(&genpd->gpd_list_node);
+	mutex_unlock(&gpd_list_lock);
+
+	mutex_destroy(&genpd->lock);
+}
+EXPORT_SYMBOL_GPL(pm_genpd_exit);
+
 #ifdef CONFIG_PM_GENERIC_DOMAINS_OF
 /*
  * Device Tree based PM domain providers.
include/linux/pm_domain.h +4 -0
index ba4ced3..5020b36 100644
@@ -123,6 +123,7 @@ extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
 				     struct generic_pm_domain *target);
 extern void pm_genpd_init(struct generic_pm_domain *genpd,
 			  struct dev_power_governor *gov, bool is_off);
+extern void pm_genpd_exit(struct generic_pm_domain *genpd);
 
 extern struct dev_power_governor simple_qos_governor;
 extern struct dev_power_governor pm_domain_always_on_gov;
@@ -161,6 +162,9 @@ static inline void pm_genpd_init(struct generic_pm_domain *genpd,
 				 struct dev_power_governor *gov, bool is_off)
 {
 }
+static inline void pm_genpd_exit(struct generic_pm_domain *genpd)
+{
+}
 #endif
 
 static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
Signature · 1 line
2.6.1
#2 lore raw

PATCH v2 1/4 power: domain: add pm_genpd_exit

Quoted 10 lines · Alexander Aring

This patch adds function pm_genpd_exit for undo a pm_genpd_init. This is useful for multiple power domains while probing. If the probing fails after one pm_genpd_init was called we need to undo all previous registrations of generic pm domains inside the gpd_list list.

There is a check on IS_ERR_OR_NULL(genpd) which is useful to check again registered power domains and not registered domains, the driver can use this mechanism to have an array with registered and non-registered power domains, where non-registered power domains are NULL.

Quoted 7 lines
Cc Rafael J. Wysocki <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Len Brown <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

Kind regards
Uffe

Quoted 63 lines
---
 drivers/base/power/domain.c | 22 ++++++++++++++++++++++
 include/linux/pm_domain.h   |  4 ++++
 2 files changed, 26 insertions(+)
drivers/base/power/domain.c +22 -0
index e03b1ad..311cb0e 100644
@@ -1509,6 +1509,28 @@ void pm_genpd_init(struct generic_pm_domain *genpd,
 }
 EXPORT_SYMBOL_GPL(pm_genpd_init);
 
+/**
+ * pm_genpd_exit - Uninitialize a generic I/O PM domain object.
+ * @genpd: PM domain object to uninitialize.
+ */
+void pm_genpd_exit(struct generic_pm_domain *genpd)
+{
+       if (IS_ERR_OR_NULL(genpd))
+               return;
+
+       /* check if domain is still in registered inside the pm subsystem */
+       WARN_ON_ONCE(!list_empty(&genpd->master_links) ||
+                    !list_empty(&genpd->slave_links) ||
+                    !list_empty(&genpd->dev_list));
+
+       mutex_lock(&gpd_list_lock);
+       list_del(&genpd->gpd_list_node);
+       mutex_unlock(&gpd_list_lock);
+
+       mutex_destroy(&genpd->lock);
+}
+EXPORT_SYMBOL_GPL(pm_genpd_exit);
+
 #ifdef CONFIG_PM_GENERIC_DOMAINS_OF
 /*
  * Device Tree based PM domain providers.
include/linux/pm_domain.h +4 -1
index ba4ced3..5020b36 100644
@@ -123,6 +123,7 @@ extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
                                     struct generic_pm_domain *target);
 extern void pm_genpd_init(struct generic_pm_domain *genpd,
                          struct dev_power_governor *gov, bool is_off);
+extern void pm_genpd_exit(struct generic_pm_domain *genpd);
 
 extern struct dev_power_governor simple_qos_governor;
 extern struct dev_power_governor pm_domain_always_on_gov;
@@ -161,6 +162,9 @@ static inline void pm_genpd_init(struct generic_pm_domain *genpd,
                                 struct dev_power_governor *gov, bool is_off)
 {
 }
+static inline void pm_genpd_exit(struct generic_pm_domain *genpd)
+{
+}
 #endif
 
 static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
--

2.6.1

#3 lore raw

PATCH v2 2/4 ARM: bcm2835: add rpi power domain driver

In reply to Alexander Aring

This patch adds support for RPi several Power Domains and enable support to enable the USB Power Domain when it's not enabled before.

This patch based on Eric Anholt's patch to support Power Domains. He had an issue about -EPROBE_DEFER inside the power domain subsystem, this issue was solved by commit <311fa6a> ("PM / Domains: Return -EPROBE_DEFER if we fail to init or turn-on domain").

---
 arch/arm/mach-bcm/Kconfig                   |  10 ++
 arch/arm/mach-bcm/Makefile                  |   1 +
 arch/arm/mach-bcm/raspberrypi-power.c       | 180 ++++++++++++++++++++++++++++
 include/dt-bindings/arm/raspberrypi-power.h |  14 +++
 4 files changed, 205 insertions(+)
 create mode 100644 arch/arm/mach-bcm/raspberrypi-power.c
 create mode 100644 include/dt-bindings/arm/raspberrypi-power.h
arch/arm/mach-bcm/Kconfig +10 -0
index 8c53c55..0f23bad 100644
@@ -134,6 +134,16 @@ config ARCH_BCM2835
 	  This enables support for the Broadcom BCM2835 SoC. This SoC is
 	  used in the Raspberry Pi and Roku 2 devices.
 
+config RASPBERRYPI_POWER
+	bool "Raspberry Pi power domain driver"
+	depends on ARCH_BCM2835 || COMPILE_TEST
+	depends on RASPBERRYPI_FIRMWARE
+	select PM_GENERIC_DOMAINS if PM
+	select PM_GENERIC_DOMAINS_OF if PM
+	help
+	  This enables support for the RPi power domains which can be enabled
+	  or disabled via the RPi firmware.
+
 config ARCH_BCM_63XX
 	bool "Broadcom BCM63xx DSL SoC" if ARCH_MULTI_V7
 	depends on MMU
arch/arm/mach-bcm/Makefile +1 -0
index 892261f..fec2d6b 100644
@@ -36,6 +36,7 @@ endif
 
 # BCM2835
 obj-$(CONFIG_ARCH_BCM2835)	+= board_bcm2835.o
+obj-$(CONFIG_RASPBERRYPI_POWER)	+= raspberrypi-power.o
 
 # BCM5301X
 obj-$(CONFIG_ARCH_BCM_5301X)	+= bcm_5301x.o
arch/arm/mach-bcm/raspberrypi-power.c new file +180 -0

180 lines not on this page · raw message

include/dt-bindings/arm/raspberrypi-power.h new file +14 -0
new file mode 100644
index 0000000..c2ffbebc
@@ -0,0 +1,14 @@
+/*
+ *  Copyright ? 2015 Broadcom
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _DT_BINDINGS_ARM_BCM2835_RPI_POWER_H
+#define _DT_BINDINGS_ARM_BCM2835_RPI_POWER_H
+
+#define RPI_POWER_DOMAIN_USB	3
+
+#endif /* _DT_BINDINGS_ARM_BCM2835_RPI_POWER_H */
Signature · 1 line
2.6.1
#4 lore raw

PATCH v2 2/4 ARM: bcm2835: add rpi power domain driver

Quoted 8 lines · Alexander Aring

This patch adds support for RPi several Power Domains and enable support to enable the USB Power Domain when it's not enabled before.

This patch based on Eric Anholt's patch to support Power Domains. He had an issue about -EPROBE_DEFER inside the power domain subsystem, this issue was solved by commit <311fa6a> ("PM / Domains: Return -EPROBE_DEFER if we fail to init or turn-on domain").

Quoted 5 lines

I'm still hoping Ulf will pull this patch along with the genpd change,
to reduce synchronization between trees. (That just leaves the DT
change's dependency on the header in this one).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151130/2311a782/attachment.sig>

#5 lore raw

PATCH v2 3/4 devicetree: add rpi power domain driver bindings

In reply to Alexander Aring

This patch adds devicetree tree bindings for the Raspberry Pi power domain driver.

---
 .../bindings/arm/bcm/raspberrypi,bcm2835-power.txt | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-power.txt
Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-power.txt new file +25 -0
new file mode 100644
index 0000000..c3abc24
@@ -0,0 +1,25 @@
+Raspberry Pi power domain driver
+
+Required properties:
+
+- compatible:		Should be "raspberrypi,bcm2835-power".
+- firmware:		Reference to the RPi firmware device node.
+- #power-domain-cells:	Should be <1>, we providing multiple power domains.
+
+The valid defines for power domain are:
+
+ RPI_POWER_DOMAIN_USB
+
+Example:
+
+power: power {
+	compatible = "raspberrypi,bcm2835-power";
+	firmware = <&firmware>;
+	#power-domain-cells = <1>;
+};
+
+Example for using power domain:
+
+&usb {
+       power-domains = <&power RPI_POWER_DOMAIN_USB>;
+};
Signature · 1 line
2.6.1
#6 lore raw

PATCH v2 3/4 devicetree: add rpi power domain driver bindings

Quoted 5 lines · Alexander Aring

This patch adds devicetree tree bindings for the Raspberry Pi power domain driver.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151130/d63914a9/attachment.sig>

#7 lore raw

PATCH v2 4/4 ARM: bcm2835: update rpi devicetree entries

In reply to Alexander Aring

This patch updates the Raspberry Pi devicetree bindings to support the power domain driver and enable the USB power domain.

---
 arch/arm/boot/dts/bcm2835-rpi.dtsi | 11 +++++++++++
 arch/arm/boot/dts/bcm2835.dtsi     |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
arch/arm/boot/dts/bcm2835-rpi.dtsi +11 -0
index 3572f03..f828202 100644
@@ -1,3 +1,4 @@
+#include <dt-bindings/arm/raspberrypi-power.h>
 #include "bcm2835.dtsi"
 
 / {
@@ -20,6 +21,12 @@
 			compatible = "raspberrypi,bcm2835-firmware";
 			mboxes = <&mailbox>;
 		};
+
+		power: power {
+			compatible = "raspberrypi,bcm2835-power";
+			firmware = <&firmware>;
+			#power-domain-cells = <1>;
+		};
 	};
 };
 
@@ -60,3 +67,7 @@
 	status = "okay";
 	bus-width = <4>;
 };
+
+&usb {
+	power-domains = <&power RPI_POWER_DOMAIN_USB>;
+};
arch/arm/boot/dts/bcm2835.dtsi +1 -1
index aef64de..6d62af0 100644
@@ -177,7 +177,7 @@
 			status = "disabled";
 		};
 
-		usb at 7e980000 {
+		usb: usb at 7e980000 {
 			compatible = "brcm,bcm2835-usb";
 			reg = <0x7e980000 0x10000>;
 			interrupts = <1 9>;
Signature · 1 line
2.6.1
#8 lore raw

PATCH v2 4/4 ARM: bcm2835: update rpi devicetree entries

Quoted 4 lines · Alexander Aring

This patch updates the Raspberry Pi devicetree bindings to support the power domain driver and enable the USB power domain.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151130/f2c1d5ba/attachment.sig>