Message ID | 20220515202032.3046-9-stefan.wahren@i2se.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | soc: bcm2835-power: Prepare BCM2711 V3D support | expand |
On Sun, May 15, 2022 at 9:21 PM Stefan Wahren <stefan.wahren@i2se.com> wrote: > > 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: Stefan Wahren <stefan.wahren@i2se.com> Reviewed-by: Peter Robinson <pbrobinson@gmail.com> > --- > drivers/soc/bcm/bcm2835-power.c | 31 +++++++++++++------------------ > 1 file changed, 13 insertions(+), 18 deletions(-) > > diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c > index 1e0041ec8132..77dc9e62b207 100644 > --- a/drivers/soc/bcm/bcm2835-power.c > +++ b/drivers/soc/bcm/bcm2835-power.c > @@ -148,7 +148,7 @@ struct bcm2835_power { > 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; > > @@ -158,7 +158,12 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) > start = ktime_get_ns(); > > /* 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) { > cpu_relax(); > if (ktime_get_ns() - start >= 1000) > @@ -168,24 +173,14 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) > 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; > - > - 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 bcm2835_asb_control(power, reg, true); > +} > > - 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) > -- > 2.25.1 >
diff --git a/drivers/soc/bcm/bcm2835-power.c b/drivers/soc/bcm/bcm2835-power.c index 1e0041ec8132..77dc9e62b207 100644 --- a/drivers/soc/bcm/bcm2835-power.c +++ b/drivers/soc/bcm/bcm2835-power.c @@ -148,7 +148,7 @@ struct bcm2835_power { 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; @@ -158,7 +158,12 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) start = ktime_get_ns(); /* 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) { cpu_relax(); if (ktime_get_ns() - start >= 1000) @@ -168,24 +173,14 @@ static int bcm2835_asb_enable(struct bcm2835_power *power, u32 reg) 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; - - 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 bcm2835_asb_control(power, reg, true); +} - 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)
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: Stefan Wahren <stefan.wahren@i2se.com> --- drivers/soc/bcm/bcm2835-power.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-)