1 From 25b7b6863a8dd292fa88309f70c980265b076c4e Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Wed, 12 Dec 2018 15:51:48 -0800
4 Subject: [PATCH 557/725] soc: bcm: bcm2835-pm: Add support for power domains
7 This provides a free software alternative to raspberrypi-power.c's
8 firmware calls to manage power domains. It also exposes a reset line,
9 where previously the vc4 driver had to try to force power off the
10 domain in order to trigger a reset.
12 Signed-off-by: Eric Anholt <eric@anholt.net>
13 Acked-by: Rob Herring <robh@kernel.org>
14 Acked-by: Stefan Wahren <stefan.wahren@i2se.com>
15 Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
16 (cherry picked from commit 670c672608a1ffcbc7ac0f872734843593bb8b15)
18 drivers/mfd/bcm2835-pm.c | 36 +-
19 drivers/soc/bcm/Kconfig | 11 +
20 drivers/soc/bcm/Makefile | 1 +
21 drivers/soc/bcm/bcm2835-power.c | 661 +++++++++++++++++++++++++++
22 include/dt-bindings/soc/bcm2835-pm.h | 28 ++
23 include/linux/mfd/bcm2835-pm.h | 1 +
24 6 files changed, 734 insertions(+), 4 deletions(-)
25 create mode 100644 drivers/soc/bcm/bcm2835-power.c
26 create mode 100644 include/dt-bindings/soc/bcm2835-pm.h
28 --- a/drivers/mfd/bcm2835-pm.c
29 +++ b/drivers/mfd/bcm2835-pm.c
31 * PM MFD driver for Broadcom BCM2835
33 * This driver binds to the PM block and creates the MFD device for
35 + * the WDT and power drivers.
38 #include <linux/delay.h>
39 @@ -21,11 +21,16 @@ static const struct mfd_cell bcm2835_pm_
40 { .name = "bcm2835-wdt" },
43 +static const struct mfd_cell bcm2835_power_devs[] = {
44 + { .name = "bcm2835-power" },
47 static int bcm2835_pm_probe(struct platform_device *pdev)
50 struct device *dev = &pdev->dev;
51 struct bcm2835_pm *pm;
54 pm = devm_kzalloc(dev, sizeof(*pm), GFP_KERNEL);
56 @@ -39,13 +44,36 @@ static int bcm2835_pm_probe(struct platf
58 return PTR_ERR(pm->base);
60 - return devm_mfd_add_devices(dev, -1,
61 - bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs),
63 + ret = devm_mfd_add_devices(dev, -1,
64 + bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs),
69 + /* We'll use the presence of the AXI ASB regs in the
70 + * bcm2835-pm binding as the key for whether we can reference
71 + * the full PM register range and support power domains.
73 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
75 + pm->asb = devm_ioremap_resource(dev, res);
76 + if (IS_ERR(pm->asb))
77 + return PTR_ERR(pm->asb);
79 + ret = devm_mfd_add_devices(dev, -1,
81 + ARRAY_SIZE(bcm2835_power_devs),
90 static const struct of_device_id bcm2835_pm_of_match[] = {
91 { .compatible = "brcm,bcm2835-pm-wdt", },
92 + { .compatible = "brcm,bcm2835-pm", },
95 MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
96 --- a/drivers/soc/bcm/Kconfig
97 +++ b/drivers/soc/bcm/Kconfig
99 menu "Broadcom SoC drivers"
101 +config BCM2835_POWER
102 + bool "BCM2835 power domain driver"
103 + depends on ARCH_BCM2835 || (COMPILE_TEST && OF)
104 + select PM_GENERIC_DOMAINS if PM
105 + select RESET_CONTROLLER
107 + This enables support for the BCM2835 power domains and reset
108 + controller. Any usage of power domains by the Raspberry Pi
109 + firmware means that Linux usage of the same power domain
110 + must be accessed using the RASPBERRYPI_POWER driver
112 config RASPBERRYPI_POWER
113 bool "Raspberry Pi power domain driver"
114 depends on ARCH_BCM2835 || (COMPILE_TEST && OF)
115 --- a/drivers/soc/bcm/Makefile
116 +++ b/drivers/soc/bcm/Makefile
118 +obj-$(CONFIG_BCM2835_POWER) += bcm2835-power.o
119 obj-$(CONFIG_RASPBERRYPI_POWER) += raspberrypi-power.o
120 obj-$(CONFIG_SOC_BRCMSTB) += brcmstb/
122 +++ b/drivers/soc/bcm/bcm2835-power.c
124 +// SPDX-License-Identifier: GPL-2.0+
126 + * Power domain driver for Broadcom BCM2835
128 + * Copyright (C) 2018 Broadcom
131 +#include <dt-bindings/soc/bcm2835-pm.h>
132 +#include <linux/clk.h>
133 +#include <linux/delay.h>
134 +#include <linux/io.h>
135 +#include <linux/mfd/bcm2835-pm.h>
136 +#include <linux/module.h>
137 +#include <linux/platform_device.h>
138 +#include <linux/pm_domain.h>
139 +#include <linux/reset-controller.h>
140 +#include <linux/types.h>
142 +#define PM_GNRIC 0x00
143 +#define PM_AUDIO 0x04
144 +#define PM_STATUS 0x18
145 +#define PM_RSTC 0x1c
146 +#define PM_RSTS 0x20
147 +#define PM_WDOG 0x24
148 +#define PM_PADS0 0x28
149 +#define PM_PADS2 0x2c
150 +#define PM_PADS3 0x30
151 +#define PM_PADS4 0x34
152 +#define PM_PADS5 0x38
153 +#define PM_PADS6 0x3c
154 +#define PM_CAM0 0x44
155 +#define PM_CAM0_LDOHPEN BIT(2)
156 +#define PM_CAM0_LDOLPEN BIT(1)
157 +#define PM_CAM0_CTRLEN BIT(0)
159 +#define PM_CAM1 0x48
160 +#define PM_CAM1_LDOHPEN BIT(2)
161 +#define PM_CAM1_LDOLPEN BIT(1)
162 +#define PM_CAM1_CTRLEN BIT(0)
164 +#define PM_CCP2TX 0x4c
165 +#define PM_CCP2TX_LDOEN BIT(1)
166 +#define PM_CCP2TX_CTRLEN BIT(0)
168 +#define PM_DSI0 0x50
169 +#define PM_DSI0_LDOHPEN BIT(2)
170 +#define PM_DSI0_LDOLPEN BIT(1)
171 +#define PM_DSI0_CTRLEN BIT(0)
173 +#define PM_DSI1 0x54
174 +#define PM_DSI1_LDOHPEN BIT(2)
175 +#define PM_DSI1_LDOLPEN BIT(1)
176 +#define PM_DSI1_CTRLEN BIT(0)
178 +#define PM_HDMI 0x58
179 +#define PM_HDMI_RSTDR BIT(19)
180 +#define PM_HDMI_LDOPD BIT(1)
181 +#define PM_HDMI_CTRLEN BIT(0)
184 +/* The power gates must be enabled with this bit before enabling the LDO in the
187 +#define PM_USB_CTRLEN BIT(0)
189 +#define PM_PXLDO 0x60
190 +#define PM_PXBG 0x64
192 +#define PM_SMPS 0x6c
193 +#define PM_XOSC 0x70
194 +#define PM_SPAREW 0x74
195 +#define PM_SPARER 0x78
196 +#define PM_AVS_RSTDR 0x7c
197 +#define PM_AVS_STAT 0x80
198 +#define PM_AVS_EVENT 0x84
199 +#define PM_AVS_INTEN 0x88
200 +#define PM_DUMMY 0xfc
202 +#define PM_IMAGE 0x108
203 +#define PM_GRAFX 0x10c
204 +#define PM_PROC 0x110
205 +#define PM_ENAB BIT(12)
206 +#define PM_ISPRSTN BIT(8)
207 +#define PM_H264RSTN BIT(7)
208 +#define PM_PERIRSTN BIT(6)
209 +#define PM_V3DRSTN BIT(6)
210 +#define PM_ISFUNC BIT(5)
211 +#define PM_MRDONE BIT(4)
212 +#define PM_MEMREP BIT(3)
213 +#define PM_ISPOW BIT(2)
214 +#define PM_POWOK BIT(1)
215 +#define PM_POWUP BIT(0)
216 +#define PM_INRUSH_SHIFT 13
217 +#define PM_INRUSH_3_5_MA 0
218 +#define PM_INRUSH_5_MA 1
219 +#define PM_INRUSH_10_MA 2
220 +#define PM_INRUSH_20_MA 3
221 +#define PM_INRUSH_MASK (3 << PM_INRUSH_SHIFT)
223 +#define PM_PASSWORD 0x5a000000
225 +#define PM_WDOG_TIME_SET 0x000fffff
226 +#define PM_RSTC_WRCFG_CLR 0xffffffcf
227 +#define PM_RSTS_HADWRH_SET 0x00000040
228 +#define PM_RSTC_WRCFG_SET 0x00000030
229 +#define PM_RSTC_WRCFG_FULL_RESET 0x00000020
230 +#define PM_RSTC_RESET 0x00000102
232 +#define PM_READ(reg) readl(power->base + (reg))
233 +#define PM_WRITE(reg, val) writel(PM_PASSWORD | (val), power->base + (reg))
235 +#define ASB_BRDG_VERSION 0x00
236 +#define ASB_CPR_CTRL 0x04
238 +#define ASB_V3D_S_CTRL 0x08
239 +#define ASB_V3D_M_CTRL 0x0c
240 +#define ASB_ISP_S_CTRL 0x10
241 +#define ASB_ISP_M_CTRL 0x14
242 +#define ASB_H264_S_CTRL 0x18
243 +#define ASB_H264_M_CTRL 0x1c
245 +#define ASB_REQ_STOP BIT(0)
246 +#define ASB_ACK BIT(1)
247 +#define ASB_EMPTY BIT(2)
248 +#define ASB_FULL BIT(3)
250 +#define ASB_AXI_BRDG_ID 0x20
252 +#define ASB_READ(reg) readl(power->asb + (reg))
253 +#define ASB_WRITE(reg, val) writel(PM_PASSWORD | (val), power->asb + (reg))
255 +struct bcm2835_power_domain {
256 + struct generic_pm_domain base;
257 + struct bcm2835_power *power;
262 +struct bcm2835_power {
263 + struct device *dev;
264 + /* PM registers. */
265 + void __iomem *base;
266 + /* AXI Async bridge registers. */
269 + struct genpd_onecell_data pd_xlate;
270 + struct bcm2835_power_domain domains[BCM2835_POWER_DOMAIN_COUNT];
271 + struct reset_controller_dev reset;
274 +static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
276 + u64 start = ktime_get_ns();
278 + /* Enable the module's async AXI bridges. */
279 + ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
280 + while (ASB_READ(reg) & ASB_ACK) {
282 + if (ktime_get_ns() - start >= 1000)
289 +static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
291 + u64 start = ktime_get_ns();
293 + /* Enable the module's async AXI bridges. */
294 + ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
295 + while (!(ASB_READ(reg) & ASB_ACK)) {
297 + if (ktime_get_ns() - start >= 1000)
304 +static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)
306 + struct bcm2835_power *power = pd->power;
308 + /* Enable functional isolation */
309 + PM_WRITE(pm_reg, PM_READ(pm_reg) & ~PM_ISFUNC);
311 + /* Enable electrical isolation */
312 + PM_WRITE(pm_reg, PM_READ(pm_reg) & ~PM_ISPOW);
314 + /* Open the power switches. */
315 + PM_WRITE(pm_reg, PM_READ(pm_reg) & ~PM_POWUP);
320 +static int bcm2835_power_power_on(struct bcm2835_power_domain *pd, u32 pm_reg)
322 + struct bcm2835_power *power = pd->power;
323 + struct device *dev = power->dev;
329 + /* If it was already powered on by the fw, leave it that way. */
330 + if (PM_READ(pm_reg) & PM_POWUP)
333 + /* Enable power. Allowing too much current at once may result
334 + * in POWOK never getting set, so start low and ramp it up as
335 + * necessary to succeed.
338 + for (inrush = PM_INRUSH_3_5_MA; inrush <= PM_INRUSH_20_MA; inrush++) {
340 + (PM_READ(pm_reg) & ~PM_INRUSH_MASK) |
341 + (inrush << PM_INRUSH_SHIFT) |
344 + start = ktime_get_ns();
345 + while (!(powok = !!(PM_READ(pm_reg) & PM_POWOK))) {
347 + if (ktime_get_ns() - start >= 3000)
352 + dev_err(dev, "Timeout waiting for %s power OK\n",
355 + goto err_disable_powup;
358 + /* Disable electrical isolation */
359 + PM_WRITE(pm_reg, PM_READ(pm_reg) | PM_ISPOW);
361 + /* Repair memory */
362 + PM_WRITE(pm_reg, PM_READ(pm_reg) | PM_MEMREP);
363 + start = ktime_get_ns();
364 + while (!(PM_READ(pm_reg) & PM_MRDONE)) {
366 + if (ktime_get_ns() - start >= 1000) {
367 + dev_err(dev, "Timeout waiting for %s memory repair\n",
370 + goto err_disable_ispow;
374 + /* Disable functional isolation */
375 + PM_WRITE(pm_reg, PM_READ(pm_reg) | PM_ISFUNC);
380 + PM_WRITE(pm_reg, PM_READ(pm_reg) & ~PM_ISPOW);
382 + PM_WRITE(pm_reg, PM_READ(pm_reg) & ~(PM_POWUP | PM_INRUSH_MASK));
386 +static int bcm2835_asb_power_on(struct bcm2835_power_domain *pd,
392 + struct bcm2835_power *power = pd->power;
395 + ret = clk_prepare_enable(pd->clk);
397 + dev_err(power->dev, "Failed to enable clock for %s\n",
402 + /* Wait 32 clocks for reset to propagate, 1 us will be enough */
405 + clk_disable_unprepare(pd->clk);
407 + /* Deassert the resets. */
408 + PM_WRITE(pm_reg, PM_READ(pm_reg) | reset_flags);
410 + ret = clk_prepare_enable(pd->clk);
412 + dev_err(power->dev, "Failed to enable clock for %s\n",
414 + goto err_enable_resets;
417 + ret = bcm2835_asb_enable(power, asb_m_reg);
419 + dev_err(power->dev, "Failed to enable ASB master for %s\n",
421 + goto err_disable_clk;
423 + ret = bcm2835_asb_enable(power, asb_s_reg);
425 + dev_err(power->dev, "Failed to enable ASB slave for %s\n",
427 + goto err_disable_asb_master;
432 +err_disable_asb_master:
433 + bcm2835_asb_disable(power, asb_m_reg);
435 + clk_disable_unprepare(pd->clk);
437 + PM_WRITE(pm_reg, PM_READ(pm_reg) & ~reset_flags);
441 +static int bcm2835_asb_power_off(struct bcm2835_power_domain *pd,
447 + struct bcm2835_power *power = pd->power;
450 + ret = bcm2835_asb_disable(power, asb_s_reg);
452 + dev_warn(power->dev, "Failed to disable ASB slave for %s\n",
456 + ret = bcm2835_asb_disable(power, asb_m_reg);
458 + dev_warn(power->dev, "Failed to disable ASB master for %s\n",
460 + bcm2835_asb_enable(power, asb_s_reg);
464 + clk_disable_unprepare(pd->clk);
466 + /* Assert the resets. */
467 + PM_WRITE(pm_reg, PM_READ(pm_reg) & ~reset_flags);
472 +static int bcm2835_power_pd_power_on(struct generic_pm_domain *domain)
474 + struct bcm2835_power_domain *pd =
475 + container_of(domain, struct bcm2835_power_domain, base);
476 + struct bcm2835_power *power = pd->power;
478 + switch (pd->domain) {
479 + case BCM2835_POWER_DOMAIN_GRAFX:
480 + return bcm2835_power_power_on(pd, PM_GRAFX);
482 + case BCM2835_POWER_DOMAIN_GRAFX_V3D:
483 + return bcm2835_asb_power_on(pd, PM_GRAFX,
484 + ASB_V3D_M_CTRL, ASB_V3D_S_CTRL,
487 + case BCM2835_POWER_DOMAIN_IMAGE:
488 + return bcm2835_power_power_on(pd, PM_IMAGE);
490 + case BCM2835_POWER_DOMAIN_IMAGE_PERI:
491 + return bcm2835_asb_power_on(pd, PM_IMAGE,
495 + case BCM2835_POWER_DOMAIN_IMAGE_ISP:
496 + return bcm2835_asb_power_on(pd, PM_IMAGE,
497 + ASB_ISP_M_CTRL, ASB_ISP_S_CTRL,
500 + case BCM2835_POWER_DOMAIN_IMAGE_H264:
501 + return bcm2835_asb_power_on(pd, PM_IMAGE,
502 + ASB_H264_M_CTRL, ASB_H264_S_CTRL,
505 + case BCM2835_POWER_DOMAIN_USB:
506 + PM_WRITE(PM_USB, PM_USB_CTRLEN);
509 + case BCM2835_POWER_DOMAIN_DSI0:
510 + PM_WRITE(PM_DSI0, PM_DSI0_CTRLEN);
511 + PM_WRITE(PM_DSI0, PM_DSI0_CTRLEN | PM_DSI0_LDOHPEN);
514 + case BCM2835_POWER_DOMAIN_DSI1:
515 + PM_WRITE(PM_DSI1, PM_DSI1_CTRLEN);
516 + PM_WRITE(PM_DSI1, PM_DSI1_CTRLEN | PM_DSI1_LDOHPEN);
519 + case BCM2835_POWER_DOMAIN_CCP2TX:
520 + PM_WRITE(PM_CCP2TX, PM_CCP2TX_CTRLEN);
521 + PM_WRITE(PM_CCP2TX, PM_CCP2TX_CTRLEN | PM_CCP2TX_LDOEN);
524 + case BCM2835_POWER_DOMAIN_HDMI:
525 + PM_WRITE(PM_HDMI, PM_READ(PM_HDMI) | PM_HDMI_RSTDR);
526 + PM_WRITE(PM_HDMI, PM_READ(PM_HDMI) | PM_HDMI_CTRLEN);
527 + PM_WRITE(PM_HDMI, PM_READ(PM_HDMI) & ~PM_HDMI_LDOPD);
528 + usleep_range(100, 200);
529 + PM_WRITE(PM_HDMI, PM_READ(PM_HDMI) & ~PM_HDMI_RSTDR);
533 + dev_err(power->dev, "Invalid domain %d\n", pd->domain);
538 +static int bcm2835_power_pd_power_off(struct generic_pm_domain *domain)
540 + struct bcm2835_power_domain *pd =
541 + container_of(domain, struct bcm2835_power_domain, base);
542 + struct bcm2835_power *power = pd->power;
544 + switch (pd->domain) {
545 + case BCM2835_POWER_DOMAIN_GRAFX:
546 + return bcm2835_power_power_off(pd, PM_GRAFX);
548 + case BCM2835_POWER_DOMAIN_GRAFX_V3D:
549 + return bcm2835_asb_power_off(pd, PM_GRAFX,
550 + ASB_V3D_M_CTRL, ASB_V3D_S_CTRL,
553 + case BCM2835_POWER_DOMAIN_IMAGE:
554 + return bcm2835_power_power_off(pd, PM_IMAGE);
556 + case BCM2835_POWER_DOMAIN_IMAGE_PERI:
557 + return bcm2835_asb_power_off(pd, PM_IMAGE,
561 + case BCM2835_POWER_DOMAIN_IMAGE_ISP:
562 + return bcm2835_asb_power_off(pd, PM_IMAGE,
563 + ASB_ISP_M_CTRL, ASB_ISP_S_CTRL,
566 + case BCM2835_POWER_DOMAIN_IMAGE_H264:
567 + return bcm2835_asb_power_off(pd, PM_IMAGE,
568 + ASB_H264_M_CTRL, ASB_H264_S_CTRL,
571 + case BCM2835_POWER_DOMAIN_USB:
572 + PM_WRITE(PM_USB, 0);
575 + case BCM2835_POWER_DOMAIN_DSI0:
576 + PM_WRITE(PM_DSI0, PM_DSI0_CTRLEN);
577 + PM_WRITE(PM_DSI0, 0);
580 + case BCM2835_POWER_DOMAIN_DSI1:
581 + PM_WRITE(PM_DSI1, PM_DSI1_CTRLEN);
582 + PM_WRITE(PM_DSI1, 0);
585 + case BCM2835_POWER_DOMAIN_CCP2TX:
586 + PM_WRITE(PM_CCP2TX, PM_CCP2TX_CTRLEN);
587 + PM_WRITE(PM_CCP2TX, 0);
590 + case BCM2835_POWER_DOMAIN_HDMI:
591 + PM_WRITE(PM_HDMI, PM_READ(PM_HDMI) | PM_HDMI_LDOPD);
592 + PM_WRITE(PM_HDMI, PM_READ(PM_HDMI) & ~PM_HDMI_CTRLEN);
596 + dev_err(power->dev, "Invalid domain %d\n", pd->domain);
602 +bcm2835_init_power_domain(struct bcm2835_power *power,
603 + int pd_xlate_index, const char *name)
605 + struct device *dev = power->dev;
606 + struct bcm2835_power_domain *dom = &power->domains[pd_xlate_index];
608 + dom->clk = devm_clk_get(dev->parent, name);
610 + dom->base.name = name;
611 + dom->base.power_on = bcm2835_power_pd_power_on;
612 + dom->base.power_off = bcm2835_power_pd_power_off;
614 + dom->domain = pd_xlate_index;
615 + dom->power = power;
617 + /* XXX: on/off at boot? */
618 + pm_genpd_init(&dom->base, NULL, true);
620 + power->pd_xlate.domains[pd_xlate_index] = &dom->base;
623 +/** bcm2835_reset_reset - Resets a block that has a reset line in the
626 + * The consumer of the reset controller must have the power domain up
627 + * -- there's no reset ability with the power domain down. To reset
628 + * the sub-block, we just disable its access to memory through the
629 + * ASB, reset, and re-enable.
631 +static int bcm2835_reset_reset(struct reset_controller_dev *rcdev,
634 + struct bcm2835_power *power = container_of(rcdev, struct bcm2835_power,
636 + struct bcm2835_power_domain *pd;
640 + case BCM2835_RESET_V3D:
641 + pd = &power->domains[BCM2835_POWER_DOMAIN_GRAFX_V3D];
643 + case BCM2835_RESET_H264:
644 + pd = &power->domains[BCM2835_POWER_DOMAIN_IMAGE_H264];
646 + case BCM2835_RESET_ISP:
647 + pd = &power->domains[BCM2835_POWER_DOMAIN_IMAGE_ISP];
650 + dev_err(power->dev, "Bad reset id %ld\n", id);
654 + ret = bcm2835_power_pd_power_off(&pd->base);
658 + return bcm2835_power_pd_power_on(&pd->base);
661 +static int bcm2835_reset_status(struct reset_controller_dev *rcdev,
664 + struct bcm2835_power *power = container_of(rcdev, struct bcm2835_power,
668 + case BCM2835_RESET_V3D:
669 + return !PM_READ(PM_GRAFX & PM_V3DRSTN);
670 + case BCM2835_RESET_H264:
671 + return !PM_READ(PM_IMAGE & PM_H264RSTN);
672 + case BCM2835_RESET_ISP:
673 + return !PM_READ(PM_IMAGE & PM_ISPRSTN);
679 +const struct reset_control_ops bcm2835_reset_ops = {
680 + .reset = bcm2835_reset_reset,
681 + .status = bcm2835_reset_status,
684 +static const char *const power_domain_names[] = {
685 + [BCM2835_POWER_DOMAIN_GRAFX] = "grafx",
686 + [BCM2835_POWER_DOMAIN_GRAFX_V3D] = "v3d",
688 + [BCM2835_POWER_DOMAIN_IMAGE] = "image",
689 + [BCM2835_POWER_DOMAIN_IMAGE_PERI] = "peri_image",
690 + [BCM2835_POWER_DOMAIN_IMAGE_H264] = "h264",
691 + [BCM2835_POWER_DOMAIN_IMAGE_ISP] = "isp",
693 + [BCM2835_POWER_DOMAIN_USB] = "usb",
694 + [BCM2835_POWER_DOMAIN_DSI0] = "dsi0",
695 + [BCM2835_POWER_DOMAIN_DSI1] = "dsi1",
696 + [BCM2835_POWER_DOMAIN_CAM0] = "cam0",
697 + [BCM2835_POWER_DOMAIN_CAM1] = "cam1",
698 + [BCM2835_POWER_DOMAIN_CCP2TX] = "ccp2tx",
699 + [BCM2835_POWER_DOMAIN_HDMI] = "hdmi",
702 +static int bcm2835_power_probe(struct platform_device *pdev)
704 + struct bcm2835_pm *pm = dev_get_drvdata(pdev->dev.parent);
705 + struct device *dev = &pdev->dev;
706 + struct bcm2835_power *power;
707 + static const struct {
709 + } domain_deps[] = {
710 + { BCM2835_POWER_DOMAIN_GRAFX, BCM2835_POWER_DOMAIN_GRAFX_V3D },
711 + { BCM2835_POWER_DOMAIN_IMAGE, BCM2835_POWER_DOMAIN_IMAGE_PERI },
712 + { BCM2835_POWER_DOMAIN_IMAGE, BCM2835_POWER_DOMAIN_IMAGE_H264 },
713 + { BCM2835_POWER_DOMAIN_IMAGE, BCM2835_POWER_DOMAIN_IMAGE_ISP },
714 + { BCM2835_POWER_DOMAIN_IMAGE_PERI, BCM2835_POWER_DOMAIN_USB },
715 + { BCM2835_POWER_DOMAIN_IMAGE_PERI, BCM2835_POWER_DOMAIN_CAM0 },
716 + { BCM2835_POWER_DOMAIN_IMAGE_PERI, BCM2835_POWER_DOMAIN_CAM1 },
721 + power = devm_kzalloc(dev, sizeof(*power), GFP_KERNEL);
724 + platform_set_drvdata(pdev, power);
727 + power->base = pm->base;
728 + power->asb = pm->asb;
730 + id = ASB_READ(ASB_AXI_BRDG_ID);
731 + if (id != 0x62726467 /* "BRDG" */) {
732 + dev_err(dev, "ASB register ID returned 0x%08x\n", id);
736 + power->pd_xlate.domains = devm_kcalloc(dev,
737 + ARRAY_SIZE(power_domain_names),
738 + sizeof(*power->pd_xlate.domains),
740 + if (!power->pd_xlate.domains)
743 + power->pd_xlate.num_domains = ARRAY_SIZE(power_domain_names);
745 + for (i = 0; i < ARRAY_SIZE(power_domain_names); i++)
746 + bcm2835_init_power_domain(power, i, power_domain_names[i]);
748 + for (i = 0; i < ARRAY_SIZE(domain_deps); i++) {
749 + pm_genpd_add_subdomain(&power->domains[domain_deps[i].parent].base,
750 + &power->domains[domain_deps[i].child].base);
753 + power->reset.owner = THIS_MODULE;
754 + power->reset.nr_resets = BCM2835_RESET_COUNT;
755 + power->reset.ops = &bcm2835_reset_ops;
756 + power->reset.of_node = dev->parent->of_node;
758 + ret = devm_reset_controller_register(dev, &power->reset);
762 + of_genpd_add_provider_onecell(dev->parent->of_node, &power->pd_xlate);
764 + dev_info(dev, "Broadcom BCM2835 power domains driver");
768 +static int bcm2835_power_remove(struct platform_device *pdev)
773 +static struct platform_driver bcm2835_power_driver = {
774 + .probe = bcm2835_power_probe,
775 + .remove = bcm2835_power_remove,
777 + .name = "bcm2835-power",
780 +module_platform_driver(bcm2835_power_driver);
782 +MODULE_AUTHOR("Eric Anholt <eric@anholt.net>");
783 +MODULE_DESCRIPTION("Driver for Broadcom BCM2835 PM power domains and reset");
784 +MODULE_LICENSE("GPL");
786 +++ b/include/dt-bindings/soc/bcm2835-pm.h
788 +/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
790 +#ifndef _DT_BINDINGS_ARM_BCM2835_PM_H
791 +#define _DT_BINDINGS_ARM_BCM2835_PM_H
793 +#define BCM2835_POWER_DOMAIN_GRAFX 0
794 +#define BCM2835_POWER_DOMAIN_GRAFX_V3D 1
795 +#define BCM2835_POWER_DOMAIN_IMAGE 2
796 +#define BCM2835_POWER_DOMAIN_IMAGE_PERI 3
797 +#define BCM2835_POWER_DOMAIN_IMAGE_ISP 4
798 +#define BCM2835_POWER_DOMAIN_IMAGE_H264 5
799 +#define BCM2835_POWER_DOMAIN_USB 6
800 +#define BCM2835_POWER_DOMAIN_DSI0 7
801 +#define BCM2835_POWER_DOMAIN_DSI1 8
802 +#define BCM2835_POWER_DOMAIN_CAM0 9
803 +#define BCM2835_POWER_DOMAIN_CAM1 10
804 +#define BCM2835_POWER_DOMAIN_CCP2TX 11
805 +#define BCM2835_POWER_DOMAIN_HDMI 12
807 +#define BCM2835_POWER_DOMAIN_COUNT 13
809 +#define BCM2835_RESET_V3D 0
810 +#define BCM2835_RESET_ISP 1
811 +#define BCM2835_RESET_H264 2
813 +#define BCM2835_RESET_COUNT 3
815 +#endif /* _DT_BINDINGS_ARM_BCM2835_PM_H */
816 --- a/include/linux/mfd/bcm2835-pm.h
817 +++ b/include/linux/mfd/bcm2835-pm.h
825 #endif /* BCM2835_MFD_PM_H */