@@ -6,6 +6,7 @@
* the WDT and power drivers.
*/
+#include <linux/bits.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/mfd/bcm2835-pm.h>
@@ -17,6 +18,9 @@
#include <linux/types.h>
#include <linux/watchdog.h>
+#define BCM2835 BIT(1)
+#define BCM2711 BIT(2)
+
static const struct mfd_cell bcm2835_pm_devs[] = {
{ .name = "bcm2835-wdt" },
};
@@ -30,6 +34,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
struct resource *res;
struct device *dev = &pdev->dev;
struct bcm2835_pm *pm;
+ bool is_bcm2711;
int ret;
pm = devm_kzalloc(dev, sizeof(*pm), GFP_KERNEL);
@@ -38,6 +43,7 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, pm);
pm->dev = dev;
+ is_bcm2711 = (uintptr_t)device_get_match_data(&pdev->dev) & BCM2711;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
pm->base = devm_ioremap_resource(dev, res);
@@ -50,30 +56,53 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
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.
+ /* To support old firmware, check if a third resource was defined and
+ * use that as a hint that we're on bcm2711.
*/
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+ if (res) {
+ pm->arsan_asb = devm_ioremap_resource(dev, res);
+ if (IS_ERR(pm->arsan_asb)) {
+ dev_err(dev, "Failed to map Arsan ASB: %ld\n",
+ PTR_ERR(pm->arsan_asb));
+ return PTR_ERR(pm->arsan_asb);
+ }
+
+ if (!is_bcm2711) {
+ dev_warn(dev, "Using an outdated DT, please update it\n");
+ is_bcm2711 = true;
+ }
+ }
+
+ if (is_bcm2711 && !pm->arsan_asb) {
+ dev_err(dev, "Arsan ASB resource missing\n");
+ return -EINVAL;
+ }
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (res) {
pm->asb = devm_ioremap_resource(dev, res);
- if (IS_ERR(pm->asb))
+ if (IS_ERR(pm->asb)) {
+ dev_err(dev, "Failed to map ASB: %ld\n", PTR_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;
+ }
}
+ /* We'll use the presence of the ASB regs in the bcm2835-pm binding as
+ * the key for whether we can reference the full PM register range and
+ * support power domains.
+ */
+ if (pm->asb)
+ return devm_mfd_add_devices(dev, -1, bcm2835_power_devs,
+ ARRAY_SIZE(bcm2835_power_devs),
+ NULL, 0, NULL);
return 0;
}
static const struct of_device_id bcm2835_pm_of_match[] = {
- { .compatible = "brcm,bcm2835-pm-wdt", },
- { .compatible = "brcm,bcm2835-pm", },
+ { .compatible = "brcm,bcm2835-pm-wdt", .data = (void *)BCM2835},
+ { .compatible = "brcm,bcm2835-pm", .data = (void *)BCM2835},
+ { .compatible = "brcm,bcm2711-pm", .data = (void *)BCM2711},
{},
};
MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
@@ -9,6 +9,7 @@ struct bcm2835_pm {
struct device *dev;
void __iomem *base;
void __iomem *asb;
+ void __iomem *arsan_asb;
};
#endif /* BCM2835_MFD_PM_H */
In BCM2711 the new ARGON ASB took over V3D. The old ASB is still present with the ISP and H264 bits, and V3D is in the same place in the new ASB as the old one. As per the devicetree bindings, BCM2711 will provide both the old and new ASB registers, so get both of them and pass them into 'bcm2835-power,' which will take care of selecting which one to use accordingly. We're being extra careful when dealing with older firmware. We can't assume all V3D users will use the new "brcm,bcm2711-pm" compatible string, so use the fact that a 3rd resource is present in firmware as a hint we're running on BCM2711. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> --- drivers/mfd/bcm2835-pm.c | 55 ++++++++++++++++++++++++++-------- include/linux/mfd/bcm2835-pm.h | 1 + 2 files changed, 43 insertions(+), 13 deletions(-)