Immutable branch between MFD and SoC due for the v5.20 merge window

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmLFdx8ACgkQUa+KL4f8
 d2H8RxAAqTUJPtcFTM3Yy3xBJo4kdVHac/aok5nn+GOQ4yP+UmZgsl6PA35Ly2dL
 fuNmGZonlMxiQ56S0vX1/AxJukTGDPti6bO1uIl2hd+9hk3CQLMEbu4l1FQ0sFW1
 6iUxKKu8VcfYqEVck6Hew2hn7xa/SlpaUcnb3bUj8+w/+0m9ejOQ2MjQD8WdvlFy
 QEDl4CY5MF/tYUCzqFbvMTGhpoCRi6XK0DTV9BIt9kogsYV7gmaIp0E3nr67BaUX
 hR9+yBfzjFqzzrqyMsVu+8kLeMi9rBFSKgiCn6Uvmgkpn6lz8wk2gQurs6bJSGo4
 B94DwaWpYCMBC6pv5VHCRESPSIbLbwiB8ct26TW2FWroVsp26G+ssXRpst2hn272
 ByVjyv3waewFTzCAmvXYrbdgBp7lvBvsnodEfPcaCfGdKOAe28j2qD1iutQUhA8S
 MwabDnhNr1X9zrtKfh0p+xJXQTby88euBnRBZn0r/gFH14mMiJiYHiU8u7+HedLH
 S/WypbJbhlNSXvhVrkaWP1krJfoD1eeuqlERvoADXHqquZQHaL2V2/9P0wwr0wFr
 2x4gROE8jmd+zKkuWNHCHgMl6AUOmoDOmZE7P3SVvh4f9tCcR/KO0uDT9DwW/cQk
 qWGdEcxGIeRyrEIoCOZs6LBEjNKHWg1e+Zau0pSPlJIbtugxjpI=
 =a2u7
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEm+Rq3+YGJdiR9yuFh9CWnEQHBwQFAmLFtcYACgkQh9CWnEQH
 BwTaog/+OO0ibxO2+okYcxVM5JQN3eYEc5iMGvNH53kyIe6+vA5S7hq2ceOkhkCs
 n6K0KyblYP9aqk9RXKFT41vXN1A3vdDc1Hbm0G+H8uPRmzkmgUAzoKp5H7cypGLB
 vq0x0QFgYau0HxDgTmr2BEes247SOFKj3t18CMn3WaUgGipbO4xIcL4ghHTPWgYc
 21NYupCBobikzZEGlDSl8N1J/MH8IpmaJyCeFzLySsL+Q2TpbtXsCGp/z4hm2KXn
 LcQONpL3aRKmGw91F2kgV3Hj1gVYLGD1dC62R+KtmFLfUW42+mLl32zQjVfEe5xm
 CdnEL3X4J2yyPxEU33dNCAldV6uq3UGjOdXCjn5pOSF9ZROer8Xuq7TEw7lrZYEP
 XCwyfmbddYtIXNk99IdupQz2QiGi9H8MBYjG4Mqw4xL/dw2wBvalNOWKnJc6kqOD
 dNvtlQEYxN7FOZILJmGF2K2rCNYi1AOmGRAlA1cBk3a0+ylL+T3TVALUlfpQAqN4
 Oro9HXeKBA9L09mNyK3by3ZgmpP8flYwmKbpwtINgIWMPzoirgZx4m5BK6XqVaMB
 LJ7RvxqYjroptAiAV+nZzlFF3a/gLQhu1SByDLP5phySnJIzPSmiP2Z9VzCld3k7
 /O8jMj+qTI7VoTqVLP7b5OjboMEfzTtfoWmt+DEqG+f4RbYYX6Q=
 =nZ56
 -----END PGP SIGNATURE-----

Merge tag 'tags/ib-mfd-soc-bcm-v5.20' into drivers/next

Immutable branch between MFD and SoC due for the v5.20 merge window

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
This commit is contained in:
Florian Fainelli 2022-07-06 09:18:05 -07:00
commit 681f872a2e
3 changed files with 103 additions and 44 deletions

View File

@ -25,9 +25,52 @@ static const struct mfd_cell bcm2835_power_devs[] = {
{ .name = "bcm2835-power" },
};
static int bcm2835_pm_get_pdata(struct platform_device *pdev,
struct bcm2835_pm *pm)
{
if (of_find_property(pm->dev->of_node, "reg-names", NULL)) {
struct resource *res;
pm->base = devm_platform_ioremap_resource_byname(pdev, "pm");
if (IS_ERR(pm->base))
return PTR_ERR(pm->base);
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "asb");
if (res) {
pm->asb = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(pm->asb))
pm->asb = NULL;
}
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
"rpivid_asb");
if (res) {
pm->rpivid_asb = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(pm->rpivid_asb))
pm->rpivid_asb = NULL;
}
return 0;
}
/* If no 'reg-names' property is found we can assume we're using old DTB. */
pm->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(pm->base))
return PTR_ERR(pm->base);
pm->asb = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(pm->asb))
pm->asb = NULL;
pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
if (IS_ERR(pm->rpivid_asb))
pm->rpivid_asb = NULL;
return 0;
}
static int bcm2835_pm_probe(struct platform_device *pdev)
{
struct resource *res;
struct device *dev = &pdev->dev;
struct bcm2835_pm *pm;
int ret;
@ -39,10 +82,9 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
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);
ret = bcm2835_pm_get_pdata(pdev, pm);
if (ret)
return ret;
ret = devm_mfd_add_devices(dev, -1,
bcm2835_pm_devs, ARRAY_SIZE(bcm2835_pm_devs),
@ -50,30 +92,22 @@ 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
/*
* 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;
}
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,bcm2711-pm", },
{},
};
MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);

View File

@ -126,8 +126,7 @@
#define ASB_AXI_BRDG_ID 0x20
#define ASB_READ(reg) readl(power->asb + (reg))
#define ASB_WRITE(reg, val) writel(PM_PASSWORD | (val), power->asb + (reg))
#define BCM2835_BRDG_ID 0x62726467
struct bcm2835_power_domain {
struct generic_pm_domain base;
@ -142,24 +141,41 @@ struct bcm2835_power {
void __iomem *base;
/* AXI Async bridge registers. */
void __iomem *asb;
/* RPiVid bridge registers. */
void __iomem *rpivid_asb;
struct genpd_onecell_data pd_xlate;
struct bcm2835_power_domain domains[BCM2835_POWER_DOMAIN_COUNT];
struct reset_controller_dev reset;
};
static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
{
void __iomem *base = power->asb;
u64 start;
u32 val;
if (!reg)
switch (reg) {
case 0:
return 0;
case ASB_V3D_S_CTRL:
case ASB_V3D_M_CTRL:
if (power->rpivid_asb)
base = power->rpivid_asb;
break;
}
start = ktime_get_ns();
/* Enable the module's async AXI bridges. */
ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
while (ASB_READ(reg) & ASB_ACK) {
if (enable) {
val = readl(base + reg) & ~ASB_REQ_STOP;
} else {
val = readl(base + reg) | ASB_REQ_STOP;
}
writel(PM_PASSWORD | val, base + reg);
while (readl(base + reg) & ASB_ACK) {
cpu_relax();
if (ktime_get_ns() - start >= 1000)
return -ETIMEDOUT;
@ -168,30 +184,24 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
return 0;
}
static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
{
return bcm2835_asb_control(power, reg, true);
}
static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
{
u64 start;
if (!reg)
return 0;
start = ktime_get_ns();
/* Enable the module's async AXI bridges. */
ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
while (!(ASB_READ(reg) & ASB_ACK)) {
cpu_relax();
if (ktime_get_ns() - start >= 1000)
return -ETIMEDOUT;
}
return 0;
return bcm2835_asb_control(power, reg, false);
}
static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)
{
struct bcm2835_power *power = pd->power;
/* We don't run this on BCM2711 */
if (power->rpivid_asb)
return 0;
/* Enable functional isolation */
PM_WRITE(pm_reg, PM_READ(pm_reg) & ~PM_ISFUNC);
@ -213,6 +223,10 @@ static int bcm2835_power_power_on(struct bcm2835_power_domain *pd, u32 pm_reg)
int inrush;
bool powok;
/* We don't run this on BCM2711 */
if (power->rpivid_asb)
return 0;
/* If it was already powered on by the fw, leave it that way. */
if (PM_READ(pm_reg) & PM_POWUP)
return 0;
@ -626,13 +640,23 @@ static int bcm2835_power_probe(struct platform_device *pdev)
power->dev = dev;
power->base = pm->base;
power->asb = pm->asb;
power->rpivid_asb = pm->rpivid_asb;
id = ASB_READ(ASB_AXI_BRDG_ID);
if (id != 0x62726467 /* "BRDG" */) {
id = readl(power->asb + ASB_AXI_BRDG_ID);
if (id != BCM2835_BRDG_ID /* "BRDG" */) {
dev_err(dev, "ASB register ID returned 0x%08x\n", id);
return -ENODEV;
}
if (power->rpivid_asb) {
id = readl(power->rpivid_asb + ASB_AXI_BRDG_ID);
if (id != BCM2835_BRDG_ID /* "BRDG" */) {
dev_err(dev, "RPiVid ASB register ID returned 0x%08x\n",
id);
return -ENODEV;
}
}
power->pd_xlate.domains = devm_kcalloc(dev,
ARRAY_SIZE(power_domain_names),
sizeof(*power->pd_xlate.domains),

View File

@ -9,6 +9,7 @@ struct bcm2835_pm {
struct device *dev;
void __iomem *base;
void __iomem *asb;
void __iomem *rpivid_asb;
};
#endif /* BCM2835_MFD_PM_H */