Broadcom's PMB (Power Management Bus) support
cover Broadcom's PMB (Power Management Bus) support
From: Rafał Miłecki <[email protected]>
PMB is a hardware block used for powering SoC devices like PCIe, USB, SATA. Initially I planned to treat it as a reset controller and Philipp pointed out in review that PMB driver should use a power subsystem.
This is my refactored support.
***
Please note one difference when compared to the initial reset attempt.
As I store info about SoC devices in the driver now, I had to put support for multiple buses there. That's required to avoid things like:
compatible = "brcm,bcm4908-pmb-no-1";
compatible = "brcm,bcm4908-pmb-no-2";
So now a single "reg" covers bigger buses (e.g. 0x40) in size, see:
reg = <0x802800e0 0x40>;
Other SoCs my use something like:
reg = <0x802800e0 0x20>;
reg = <0x802800e0 0x60>;
***
AFAIU this should go through Florian's tree. I based in on top of the soc-arm64/next.
Rafał Miłecki (2):
dt-bindings: power: document Broadcom's PMB binding
soc: bcm: add PM driver for Broadcom's PMB
.../bindings/power/brcm,bcm-pmb.yaml | 50 +++ drivers/soc/bcm/Kconfig | 8 + drivers/soc/bcm/Makefile | 1 + drivers/soc/bcm/bcm-pmb.c | 335 ++++++++++++++++++ include/dt-bindings/soc/bcm-pmb.h | 11 + 5 files changed, 405 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/brcm,bcm-pmb.yaml create mode 100644 drivers/soc/bcm/bcm-pmb.c create mode 100644 include/dt-bindings/soc/bcm-pmb.h
Signature · 1 line
2.26.2
PATCH 1/2 dt-bindings: power: document Broadcom's PMB binding
From: Rafał Miłecki <[email protected]>
Broadcom's PMB is power controller used for disabling and enabling SoC devices.
--- .../bindings/power/brcm,bcm-pmb.yaml | 50 +++++++++++++++++++ include/dt-bindings/soc/bcm-pmb.h | 11 ++++ 2 files changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/brcm,bcm-pmb.yaml create mode 100644 include/dt-bindings/soc/bcm-pmb.h
Documentation/devicetree/bindings/power/brcm,bcm-pmb.yaml new file +50 -0
@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/brcm,bcm-pmb.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom PMB (Power Management Bus) controller + +description: This document describes Broadcom's PMB controller. It supports + powering various types of connected devices (e.g. PCIe, USB, SATA). + +maintainers: + - Rafał Miłecki <[email protected]> + +properties: + compatible: + enum: + - brcm,bcm4908-pmb + + reg: + description: register space of one or more buses + maxItems: 1 + + big-endian: + $ref: /schemas/types.yaml#/definitions/flag + description: Flag to use for block working in big endian mode. + + "#power-domain-cells": + description: cell specifies device ID (see bcm-pmb.h) + const: 1 + +required: + - reg + - "#power-domain-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/soc/bcm-pmb.h> + + pmb: power-controller@802800e0 { + compatible = "brcm,bcm4908-pmb"; + reg = <0x802800e0 0x40>; + #power-domain-cells = <1>; + }; + + foo { + power-domains = <&pmb BCM_PMB_PCIE0>; + };
include/dt-bindings/soc/bcm-pmb.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later OR MIT */ + +#ifndef __DT_BINDINGS_SOC_BCM_PMB_H +#define __DT_BINDINGS_SOC_BCM_PMB_H + +#define BCM_PMB_PCIE0 0x01 +#define BCM_PMB_PCIE1 0x02 +#define BCM_PMB_PCIE2 0x03 +#define BCM_PMB_HOST_USB 0x04 + +#endif
Signature · 1 line
2.26.2
PATCH 2/2 soc: bcm: add PM driver for Broadcom's PMB
In reply to Rafał MiłeckiFrom: Rafał Miłecki <[email protected]>
PMB can be found on BCM4908 and many other chipsets (e.g. BCM63138). It's needed to power on and off SoC blocks like PCIe, SATA, USB.
--- drivers/soc/bcm/Kconfig | 8 + drivers/soc/bcm/Makefile | 1 + drivers/soc/bcm/bcm-pmb.c | 335 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 344 insertions(+) create mode 100644 drivers/soc/bcm/bcm-pmb.c
drivers/soc/bcm/Kconfig +8 -0
@@ -13,6 +13,14 @@ config BCM2835_POWER firmware means that Linux usage of the same power domain must be accessed using the RASPBERRYPI_POWER driver +config BCM_PMB + bool "Broadcom PMB (Power Management Bus) driver" + depends on ARCH_BCM4908 || (COMPILE_TEST && OF) + default ARCH_BCM4908 + select PM_GENERIC_DOMAINS if PM + help + Foo + config RASPBERRYPI_POWER bool "Raspberry Pi power domain driver" depends on ARCH_BCM2835 || (COMPILE_TEST && OF)
drivers/soc/bcm/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_BCM2835_POWER) += bcm2835-power.o +obj-$(CONFIG_BCM_PMB) += bcm-pmb.o obj-$(CONFIG_RASPBERRYPI_POWER) += raspberrypi-power.o obj-$(CONFIG_SOC_BCM63XX) += bcm63xx/ obj-$(CONFIG_SOC_BRCMSTB) += brcmstb/
drivers/soc/bcm/bcm-pmb.c new file +335 -0
335 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [PATCH 2/2] soc: bcm: add PM driver for Broadcom's PMB
Quoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
PMB can be found on BCM4908 and many other chipsets (e.g. BCM63138). It's needed to power on and off SoC blocks like PCIe, SATA, USB.
Signed-off-by Rafał Miłecki <[email protected]>
I will do a more thorough review tonight, however do you mind moving the driver under drives/soc/bcm/bcm63xx? The first SoC that had PMB was 63138 and that one is DSL.
And we would probably need a MAINTAINERS file update for this driver?
Thanks!
Signature · 1 line
Florian
Re: [PATCH 2/2] soc: bcm: add PM driver for Broadcom's PMB
Quoted 6 lines · Florian Fainelli
Quoted 5 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
PMB can be found on BCM4908 and many other chipsets (e.g. BCM63138). It's needed to power on and off SoC blocks like PCIe, SATA, USB.
Quoted 7 lines
Quoted 1 line
Signed-off-by Rafał Miłecki <[email protected]>I will do a more thorough review tonight, however do you mind moving the driver under drives/soc/bcm/bcm63xx? The first SoC that had PMB was 63138 and that one is DSL.
And we would probably need a
MAINTAINERSfile update for this driver?
Sounds good!
Signature · 1 line
Rafał
Rafał Miłecki
maintainerRe: [PATCH 2/2] soc: bcm: add PM driver for Broadcom's PMB
In reply to Florian FainelliQuoted 11 lines · Florian Fainelli
Quoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
PMB can be found on BCM4908 and many other chipsets (e.g. BCM63138). It's needed to power on and off SoC blocks like PCIe, SATA, USB.
Signed-off-by Rafał Miłecki <[email protected]>I will do a more thorough review tonight, however do you mind moving the driver under drives/soc/bcm/bcm63xx? The first SoC that had PMB was 63138 and that one is DSL.
I now realized that bcm63xx's:
* Kconfig is wrapper in: if SOC_BCM63XX
* Makefile is conditional: obj-$(CONFIG_SOC_BCM63XX)
So it means I've to either:
1. Refactor bcm63xx structure
2. Make SOC_BCM63XX selectable on ARCH_BCM4908 and select it
I'm not sure if any of above is a really good idea. Any further thought, ideas?
Re: [PATCH 2/2] soc: bcm: add PM driver for Broadcom's PMB
Quoted 17 lines · Rafał Miłecki
Quoted 11 lines · Florian Fainelli
Quoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
PMB can be found on BCM4908 and many other chipsets (e.g. BCM63138). It's needed to power on and off SoC blocks like PCIe, SATA, USB.
Signed-off-by Rafał Miłecki <[email protected]>I will do a more thorough review tonight, however do you mind moving the driver under drives/soc/bcm/bcm63xx? The first SoC that had PMB was 63138 and that one is DSL.
I now realized that bcm63xx's:
*Kconfigis wrapper in: ifSOC_BCM63XX
*Makefileis conditional: obj-$(CONFIG_SOC_BCM63XX)
Quoted 6 lines
So it means I've to either:
1. Refactor bcm63xx structure
2. MakeSOC_BCM63XXselectable onARCH_BCM4908and select itI'm not sure if any of above is a really good idea. Any further thought, ideas?
Well, I was thinking about thing along those lines below, it's really about putting drivers that belong to the same SoC family in the same basket for easier maintenance while submitting patches/pull requests from my side.
drivers/soc/bcm/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_BCM2835_POWER) += bcm2835-power.o obj-$(CONFIG_RASPBERRYPI_POWER) += raspberrypi-power.o -obj-$(CONFIG_SOC_BCM63XX) += bcm63xx/ +obj-y += bcm63xx/ obj-$(CONFIG_SOC_BRCMSTB) += brcmstb/
(quoted diff) +0 -0
b/drivers/soc/bcm/bcm63xx/Kconfig
index 16f648a6c70a..76fb61e7377e 100644
drivers/soc/bcm/bcm63xx/Kconfig +5 -0
@@ -10,3 +10,8 @@ config BCM63XX_POWER BCM6318, BCM6328, BCM6362 and BCM63268 SoCs. endif # SOC_BCM63XX + +config BCM_PMB_POWER + tristate "Broadcom PMB bus power domain driver" + depends on BMIPS_GENERIC || ARCH_BCM4908 || COMPILE_TEST + default ARCH_BCM4908
Signature · 1 line
Florian
Rafał Miłecki
maintainerRe: [PATCH 2/2] soc: bcm: add PM driver for Broadcom's PMB
Quoted 47 lines · Florian Fainelli
Quoted 17 lines · Rafał Miłecki
Quoted 11 lines · Florian Fainelli
Quoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
PMB can be found on BCM4908 and many other chipsets (e.g. BCM63138). It's needed to power on and off SoC blocks like PCIe, SATA, USB.
Signed-off-by Rafał Miłecki <[email protected]>I will do a more thorough review tonight, however do you mind moving the driver under drives/soc/bcm/bcm63xx? The first SoC that had PMB was 63138 and that one is DSL.
I now realized that bcm63xx's:
*Kconfigis wrapper in: ifSOC_BCM63XX
*Makefileis conditional: obj-$(CONFIG_SOC_BCM63XX)Quoted 6 lines
So it means I've to either:
1. Refactor bcm63xx structure
2. MakeSOC_BCM63XXselectable onARCH_BCM4908and select itI'm not sure if any of above is a really good idea. Any further thought, ideas?
Well, I was thinking about thing along those lines below, it's really about putting drivers that belong to the same SoC family in the same basket for easier maintenance while submitting patches/pull requests from my side.
drivers/soc/bcm/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_BCM2835_POWER) += bcm2835-power.o obj-$(CONFIG_RASPBERRYPI_POWER) += raspberrypi-power.o -obj-$(CONFIG_SOC_BCM63XX) += bcm63xx/ +obj-y += bcm63xx/ obj-$(CONFIG_SOC_BRCMSTB) += brcmstb/drivers/soc/bcm/bcm63xx/Kconfig +0
-0
drivers/soc/bcm/bcm63xx/Kconfig config BCM63XX_POWER · line 17
Quoted 8 lines
drivers/soc/bcm/bcm63xx/Kconfig +5
-0@@ -10,3 +10,8 @@ config BCM63XX_POWER BCM6318, BCM6328, BCM6362 and BCM63268 SoCs. endif # SOC_BCM63XX + +config BCM_PMB_POWER + tristate "Broadcom PMB bus power domain driver" + depends on BMIPS_GENERIC || ARCH_BCM4908 || COMPILE_TEST + default ARCH_BCM4908
Sounds OK to me, thanks for clarifying what approach you're OK with!
Rafał Miłecki
maintainerRe: [PATCH 2/2] soc: bcm: add PM driver for Broadcom's PMB
In reply to Rafał Miłeckidrivers/soc/bcm/Kconfig config BCM2835_POWER · line 22
Quoted 11 lines · Rafał Miłecki
drivers/soc/bcm/Kconfig +7
-0@@ -13,6 +13,14 @@ config BCM2835_POWER firmware means that Linux usage of the same power domain must be accessed using the RASPBERRYPI_POWER driver +config BCM_PMB + bool "Broadcom PMB (Power Management Bus) driver" + depends on ARCH_BCM4908 || (COMPILE_TEST && OF) + default ARCH_BCM4908 + select PM_GENERIC_DOMAINS if PM + help + Foo
I'll improve description a bit in V2 ;)
Re: [PATCH 2/2] soc: bcm: add PM driver for Broadcom's PMB
In reply to Rafał MiłeckiQuoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
PMB can be found on BCM4908 and many other chipsets (e.g. BCM63138). It's needed to power on and off SoC blocks like PCIe, SATA, USB.
Signed-off-by Rafał Miłecki <[email protected]>
This looks good to me, just a few nipicks below.
[snip]
drivers/soc/bcm/bcm-pmb.c line 260
Quoted 11 lines
drivers/soc/bcm/bcm-pmb.c new file +11
-0+static int bcm_pmb_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +const struct bcm_pmb_pd_data *table; +const struct bcm_pmb_pd_data *e; +struct resource *res; +struct bcm_pmb *pmb; +int max_id; +int err; + +dev_info (dev,"START\n" );
Stray debugging.
[snip]
drivers/soc/bcm/bcm-pmb.c line 318
Quoted 6 lines
drivers/soc/bcm/bcm-pmb.c new file +6
-0+ +static const struct bcm_pmb_pd_data bcm_pmb_bcm4908_data[] = { + { .name ="pcie2" , .id =BCM_PMB_PCIE2 , .bus =0 , .device =2 , }, + { .name ="pcie0" , .id =BCM_PMB_PCIE0 , .bus =1 , .device =14 , }, + { .name ="pcie1" , .id =BCM_PMB_PCIE1 , .bus =1 , .device =15 , }, + { .name ="usb" , .id =BCM_PMB_HOST_USB , .bus =1 , .device =17 , },
Do you have to be more specific and spell out whether this is the host controller (xhci) or device (bdc)? If not, then this looks good to me.
Signature · 1 line
Florian
Rafał Miłecki
maintainerRe: [PATCH 2/2] soc: bcm: add PM driver for Broadcom's PMB
Quoted 9 lines · Florian Fainelli
drivers/soc/bcm/bcm-pmb.c line 318
Quoted 6 lines
drivers/soc/bcm/bcm-pmb.c new file +6
-0+ +static const struct bcm_pmb_pd_data bcm_pmb_bcm4908_data[] = { + { .name ="pcie2" , .id =BCM_PMB_PCIE2 , .bus =0 , .device =2 , }, + { .name ="pcie0" , .id =BCM_PMB_PCIE0 , .bus =1 , .device =14 , }, + { .name ="pcie1" , .id =BCM_PMB_PCIE1 , .bus =1 , .device =15 , }, + { .name ="usb" , .id =BCM_PMB_HOST_USB , .bus =1 , .device =17 , },Do you have to be more specific and spell out whether this is the host controller (xhci) or device (bdc)? If not, then this looks good to me.
I believe I have to and I believe I already do. I used BCM_PMB_HOST_USB which clearly (I believe) points to the HOST controller.
In 6838 part of pmc_drv.h from Broadcom's SDK I found:
enum {
USB30_2X_Zone_Common,
USB30_2X_Zone_USB_Host,
USB30_2X_Zone_USB_Device,
};and that's what makes me believe we need to specify HOST explicitly.