Commit c494a447 authored by Stefan Wahren's avatar Stefan Wahren Committed by Lee Jones

soc: bcm: bcm2835-power: Refactor ASB control

The functions to control the async AXI bridges are almost identical.
So define a general function to handle it and keep the original ones as
wrapper. This should make this driver easier to extend.
Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: default avatarPeter Robinson <pbrobinson@gmail.com>
Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220625113619.15944-9-stefan.wahren@i2se.com
parent df762342
...@@ -148,7 +148,7 @@ struct bcm2835_power { ...@@ -148,7 +148,7 @@ struct bcm2835_power {
struct reset_controller_dev reset; 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)
{ {
u64 start; u64 start;
...@@ -158,7 +158,12 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) ...@@ -158,7 +158,12 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
start = ktime_get_ns(); start = ktime_get_ns();
/* Enable the module's async AXI bridges. */ /* Enable the module's async AXI bridges. */
ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP); if (enable) {
ASB_WRITE(reg, ASB_READ(reg) & ~ASB_REQ_STOP);
} else {
ASB_WRITE(reg, ASB_READ(reg) | ASB_REQ_STOP);
}
while (ASB_READ(reg) & ASB_ACK) { while (ASB_READ(reg) & ASB_ACK) {
cpu_relax(); cpu_relax();
if (ktime_get_ns() - start >= 1000) if (ktime_get_ns() - start >= 1000)
...@@ -168,24 +173,14 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) ...@@ -168,24 +173,14 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
return 0; return 0;
} }
static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg) static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg)
{ {
u64 start; return bcm2835_asb_control(power, reg, true);
}
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; static int bcm2835_asb_disable(struct bcm2835_power *power, u32 reg)
{
return bcm2835_asb_control(power, reg, false);
} }
static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg) static int bcm2835_power_power_off(struct bcm2835_power_domain *pd, u32 pm_reg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment