Move DB8500 PRCMU clock policy into the clock subsystem
Subsystems (4)
Linus Walleij
maintainercover Move DB8500 PRCMU clock policy into the clock subsystem
The U8500 clocks will need some extended features going forward and I don't want to force Lee to review clock patches just because there is half a clock driver in the MFD PRCMU driver.
Move ARMSS rate selection and CLKOUT, peripheral, PLL and DSI clock register programming into the Ux500 clock drivers.
The MFD driver continues to own the shared register mapping, SoC PLL/SYSCLK firmware commands and mailbox synchronization.
Drop the unused partial-25% APE mode, which was emulated by changing clock dividers in MFD.
The final patch removes a bit of policy from the PRCMU driver, it will be managed by the clock subsystem.
An LLM helped with the mechanics in this patch series.
This series requires the following prerequisite patch:
"mfd/regulator: db8500-prcmu: Remove EPOD regulators, v2"
https://lore.kernel.org/mfd/20261127-ux500-epod-regulator-removal-v2-1-0ccab0f430fd@kernel.org/
---
Linus Walleij (6):
clk: ux500: Select ARMSS firmware operating points in the clock driver
clk: ux500: Move CLKOUT programming to the clock driver
mfd: db8500-prcmu: Drop unused partial APE clock divider mode
clk: ux500: Move PRCMU clock register handling out of MFD
clk: ux500: Separate the PRCMU DSI clock implementation
mfd: db8500-prcmu: Always submit an explicit APE OPP request
drivers/clk/ux500/Makefile | 2 +- drivers/clk/ux500/clk-prcmu-dsi.c | 352 ++++++++++++++ drivers/clk/ux500/clk-prcmu-hw.c | 492 ++++++++++++++++++++ drivers/clk/ux500/clk-prcmu-hw.h | 39 ++ drivers/clk/ux500/clk-prcmu.c | 163 ++++++- drivers/mfd/db8500-prcmu-regs.h | 128 ------ drivers/mfd/db8500-prcmu.c | 937 +------------------------------------- include/linux/mfd/db8500-prcmu.h | 40 +- 8 files changed, 1041 insertions(+), 1112 deletions(-)
---
base-commit: eaf11176791570b235e10c43bed920659745615b
change-id: 20261125-ux500-prcmu-clock-move-d8efd52065ba
Best regards,
Signature · 1 line
Linus Walleij <[email protected]>
Linus Walleij
maintainerPATCH 1/6 clk: ux500: Select ARMSS firmware operating points in the clock driver
Move the ARMSS frequency-to-OPP mapping out of the PRCMU driver. Use a single table for rounding and setting rates, preserving the separate maximum frequency for U8520 firmware. Keep the actual ARM OPP request and acknowledgement in the PRCMU mailbox driver.
--- drivers/clk/ux500/clk-prcmu.c | 61 ++++++++++++++++++++++++++++++++-- drivers/mfd/db8500-prcmu.c | 76 ------------------------------------------- 2 files changed, 58 insertions(+), 79 deletions(-)
drivers/clk/ux500/clk-prcmu.c +58 -3
@@ -53,11 +53,66 @@ static unsigned long clk_prcmu_recalc_rate(struct clk_hw *hw,return prcmu_clock_rate (clk->cg_sel); } +static const struct { +unsigned long db8500_rate; +unsigned long db8520_rate; +u8 opp; +} armss_opps[] = { + {199680000 ,199680000 ,ARM_EXTCLK }, + {399360000 ,399360000 ,ARM_50_OPP }, + {798720000 ,798720000 ,ARM_100_OPP }, + {998400000 ,1152000000 ,ARM_MAX_OPP }, +}; + +static unsigned long clk_prcmu_armss_rate (unsigned int index) +{ +const struct prcmu_fw_version *fw =prcmu_get_fw_version (); + +if (fw && fw->project ==PRCMU_FW_PROJECT_U8520 ) +return armss_opps[index].db8520_rate; + +return armss_opps[index].db8500_rate; +} + +static unsigned long clk_prcmu_round_armss_rate (unsigned long rate) +{ +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (armss_opps) -1 ; i++) +if (rate <=clk_prcmu_armss_rate (i)) +break ; + +return clk_prcmu_armss_rate (i); +} + +static int clk_prcmu_set_armss_rate (unsigned long rate) +{ +unsigned int i; + +for (i =0 ; i <ARRAY_SIZE (armss_opps); i++) +if (rate ==clk_prcmu_armss_rate (i)) +return db8500_prcmu_set_arm_opp (armss_opps[i].opp); + +return -EINVAL ; +} + +static int clk_prcmu_set_clock_rate (u8 clock,unsigned long rate) +{ +if (clock ==PRCMU_ARMSS ) +return clk_prcmu_set_armss_rate (rate); + +return prcmu_set_clock_rate (clock, rate); +} +static int clk_prcmu_determine_rate (struct clk_hw *hw,struct clk_rate_request *req) {struct clk_prcmu *clk =to_clk_prcmu (hw); - req->rate =prcmu_round_clock_rate (clk->cg_sel, req->rate); + +if (clk->cg_sel ==PRCMU_ARMSS ) + req->rate =clk_prcmu_round_armss_rate (req->rate); +else + req->rate =prcmu_round_clock_rate (clk->cg_sel, req->rate);return 0 ; }
@@ -66,7 +121,7 @@ static int clk_prcmu_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) {struct clk_prcmu *clk =to_clk_prcmu (hw); -return prcmu_set_clock_rate (clk->cg_sel, rate); +return clk_prcmu_set_clock_rate (clk->cg_sel, rate); }static int clk_prcmu_opp_prepare (struct clk_hw *hw)
@@ -217,7 +272,7 @@ static struct clk_hw *clk_reg_prcmu(const char *name, clk->opp_requested =0 ;/* "rate" can be used for changing the initial frequency */ if (rate) -prcmu_set_clock_rate (cg_sel, rate); +clk_prcmu_set_clock_rate (cg_sel, rate); clk_prcmu_init.name = name; clk_prcmu_init.ops = clk_prcmu_ops;
drivers/mfd/db8500-prcmu.c +0 -76
100 lines not on this page · raw message
Signature · 1 line
2.56.1
Linus Walleij
maintainerPATCH 2/6 clk: ux500: Move CLKOUT programming to the clock driver
In reply to Linus WalleijThe programmable clock outputs only use MMIO and have no firmware transaction. Move their register definitions, lock and request bookkeeping next to their CCF operations. Use the existing PRCMU register accessors rather than exposing the mapping.
--- drivers/clk/ux500/clk-prcmu.c | 87 ++++++++++++++++++++++++++++++++++++++-- drivers/mfd/db8500-prcmu-regs.h | 16 -------- drivers/mfd/db8500-prcmu.c | 67 ------------------------------- include/linux/mfd/db8500-prcmu.h | 6 --- 4 files changed, 84 insertions(+), 92 deletions(-)
drivers/clk/ux500/clk-prcmu.c +84 -3
@@ -6,9 +6,11 @@* Author: Ulf Hansson <[email protected]> */ +#include <linux/bits.h> #include <linux/clk-provider.h> #include <linux/mfd/db8500-prcmu.h> #include <linux/slab.h> +#include <linux/spinlock.h> #include <linux/io.h> #include <linux/err.h> #include "clk.h"
@@ -350,13 +352,92 @@ struct clk_hw *clk_reg_prcmu_opp_volt_scalable(const char *name, &clk_prcmu_opp_volt_scalable_ops); } -/* The clkout (external) clock is special and need special ops */ +/* External programmable clock outputs */ + +#define PRCM_CLKOCR 0x1CC +#define PRCM_CLKOCR_CLKODIV0_SHIFT 0 +#define PRCM_CLKOCR_CLKODIV0_MASK GENMASK(5, 0) +#define PRCM_CLKOCR_CLKOSEL0_SHIFT 6 +#define PRCM_CLKOCR_CLKOSEL0_MASK GENMASK(8, 6) +#define PRCM_CLKOCR_CLKODIV1_SHIFT 16 +#define PRCM_CLKOCR_CLKODIV1_MASK GENMASK(21, 16) +#define PRCM_CLKOCR_CLKOSEL1_SHIFT 22 +#define PRCM_CLKOCR_CLKOSEL1_MASK GENMASK(24, 22) +#define PRCM_CLKOCR_CLK1TYPE BIT(28) + +static DEFINE_SPINLOCK (clkout_lock); + +/** +* clk_prcmu_config_clkout - Configure one of the programmable clock outputs. +* @clkout: The CLKOUT number (0 or 1). +* @source: The clock to be used (one of the PRCMU_CLKSRC_*). +* @div: The divider to be applied. +* +* Configures one of the programmable clock outputs (CLKOUTs). +* @div should be in the range [1,63] to request a configuration, or 0 to +* inform that the configuration is no longer requested. +*/ +static int clk_prcmu_config_clkout (u8 clkout,u8 source,u8 div) +{ +static int requests[2 ]; +int r =0 ; +unsigned long flags; +u32 val; +u32 bits; +u32 mask; +u32 div_mask; + +BUG_ON (clkout >1 ); +BUG_ON (div >63 ); +BUG_ON ((clkout ==0 ) && (source >PRCMU_CLKSRC_CLK009 )); + +if (!div && !requests[clkout]) +return -EINVAL ; + +if (clkout ==0 ) { + div_mask =PRCM_CLKOCR_CLKODIV0_MASK ; + mask = (PRCM_CLKOCR_CLKODIV0_MASK |PRCM_CLKOCR_CLKOSEL0_MASK ); + bits = ((source <<PRCM_CLKOCR_CLKOSEL0_SHIFT ) | + (div <<PRCM_CLKOCR_CLKODIV0_SHIFT )); + }else { + div_mask =PRCM_CLKOCR_CLKODIV1_MASK ; + mask = (PRCM_CLKOCR_CLKODIV1_MASK |PRCM_CLKOCR_CLKOSEL1_MASK | +PRCM_CLKOCR_CLK1TYPE ); + bits = ((source <<PRCM_CLKOCR_CLKOSEL1_SHIFT ) | + (div <<PRCM_CLKOCR_CLKODIV1_SHIFT )); + } + bits &= mask; + +spin_lock_irqsave (&clkout_lock, flags); + + val =db8500_prcmu_read (PRCM_CLKOCR ); +if (val & div_mask) { +if (div) { +if ((val & mask) != bits) { + r = -EBUSY ; + goto unlock_and_return; + } + }else { +if ((val & mask & ~div_mask) != bits) { + r = -EINVAL ; + goto unlock_and_return; + } + } + } +db8500_prcmu_write (PRCM_CLKOCR , bits | (val & ~mask)); + requests[clkout] += (div ?1 :-1 ); + +unlock_and_return: +spin_unlock_irqrestore (&clkout_lock, flags); + +return r; +}static int clk_prcmu_clkout_prepare (struct clk_hw *hw) {struct clk_prcmu_clkout *clk =to_clk_prcmu_clkout (hw); -return prcmu_config_clkout (clk->clkout_id, clk->source, clk->divider); +return clk_prcmu_config_clkout (clk->clkout_id, clk->source, clk->divider); }static void clk_prcmu_clkout_unprepare (struct clk_hw *hw)
@@ -365,7 +446,7 @@ static void clk_prcmu_clkout_unprepare(struct clk_hw *hw)int ret;/* The clkout clock is disabled by dividing by 0 */ - ret =prcmu_config_clkout (clk->clkout_id, clk->source,0 ); + ret =clk_prcmu_config_clkout (clk->clkout_id, clk->source,0 );if (ret)pr_err ("clk_prcmu: %s failed to disable %s\n" , __func__,clk_hw_get_name (hw));
drivers/mfd/db8500-prcmu-regs.h +0 -16
@@ -161,12 +161,6 @@#define PRCM_APE_RESETN_DSIPLL_RESETN BIT(14) -#define PRCM_CLKOCR (prcmu_base + 0x1CC) -#define PRCM_CLKOCR_CLKOUT0_REF_CLK (1 << 0) -#define PRCM_CLKOCR_CLKOUT0_MASK BITS(0, 13) -#define PRCM_CLKOCR_CLKOUT1_REF_CLK (1 << 16) -#define PRCM_CLKOCR_CLKOUT1_MASK BITS(16, 29) -/* ePOD and memory power signal control registers */ #define PRCM_EPOD_C_SET (prcmu_base + 0x410)#define PRCM_SRAM_LS_SLEEP (prcmu_base + 0x304)
@@ -189,16 +183,6 @@#define PRCM_TCR_STOP_TIMERS BIT(16)#define PRCM_TCR_DOZE_MODE BIT(17) -#define PRCM_CLKOCR_CLKODIV0_SHIFT 0 -#define PRCM_CLKOCR_CLKODIV0_MASK BITS(0, 5) -#define PRCM_CLKOCR_CLKOSEL0_SHIFT 6 -#define PRCM_CLKOCR_CLKOSEL0_MASK BITS(6, 8) -#define PRCM_CLKOCR_CLKODIV1_SHIFT 16 -#define PRCM_CLKOCR_CLKODIV1_MASK BITS(16, 21) -#define PRCM_CLKOCR_CLKOSEL1_SHIFT 22 -#define PRCM_CLKOCR_CLKOSEL1_MASK BITS(22, 24) -#define PRCM_CLKOCR_CLK1TYPE BIT(28) -#define PRCM_CLK_MGT_CLKPLLDIV_MASK BITS(0, 4)#define PRCM_CLK_MGT_CLKPLLSW_SOC0 BIT(5)#define PRCM_CLK_MGT_CLKPLLSW_SOC1 BIT(6)
drivers/mfd/db8500-prcmu.c +0 -67
79 lines not on this page · raw message
include/linux/mfd/db8500-prcmu.h +0 -6
@@ -706,7 +706,6 @@ void prcmu_configure_auto_pm(struct prcmu_auto_pm_config *sleep, struct prcmu_auto_pm_config *idle);bool prcmu_is_auto_pm_enabled (void ); -int prcmu_config_clkout (u8 clkout,u8 source,u8 div);unsigned long prcmu_clock_rate (u8 clock);long prcmu_round_clock_rate (u8 clock,unsigned long rate);int prcmu_set_clock_rate (u8 clock,unsigned long rate);
@@ -816,11 +815,6 @@ static inline bool prcmu_is_auto_pm_enabled(void)return false; } -static inline int prcmu_config_clkout (u8 clkout,u8 source,u8 div) -{ -return 0 ; -} -static inline unsigned long prcmu_clock_rate (u8 clock) {return 0 ;
Signature · 1 line
2.56.1
Linus Walleij
maintainerPATCH 3/6 mfd: db8500-prcmu: Drop unused partial APE clock divider mode
In reply to Linus WalleijThe vendor partial-25% mode is not a firmware OPP. It emulates one by changing ACLK and DMA clock dividers around the mailbox request, but no in-tree consumer ever selects it. Drop the unused emulation so that the clock register lock can move with its remaining users. Leave the actual APE 50% and 100% requests unchanged.
--- drivers/mfd/db8500-prcmu.c | 55 +--------------------------------------- include/linux/mfd/db8500-prcmu.h | 2 -- 2 files changed, 1 insertion(+), 56 deletions(-)
drivers/mfd/db8500-prcmu.c +1 -54
@@ -781,52 +781,6 @@ int db8500_prcmu_get_ddr_opp(void)return readb (PRCM_DDR_SUBSYS_APE_MINBW ); } -/* Divide the frequency of certain clocks by 2 for APE_50_PARTLY_25_OPP. */ -static void request_even_slower_clocks (bool enable) -{ -u32 clock_reg[] = { -PRCM_ACLK_MGT , -PRCM_DMACLK_MGT - }; -unsigned long flags; -unsigned int i; - -spin_lock_irqsave (&clk_mgt_lock, flags); - -/* Grab the HW semaphore. */ -while ((readl (PRCM_SEM ) &PRCM_SEM_PRCM_SEM ) !=0 ) -cpu_relax (); - -for (i =0 ; i <ARRAY_SIZE (clock_reg); i++) { -u32 val; -u32 div; - - val =readl (prcmu_base + clock_reg[i]); - div = (val &PRCM_CLK_MGT_CLKPLLDIV_MASK ); -if (enable) { -if ((div <=1 ) || (div >15 )) { -pr_err ("prcmu: Bad clock divider %d in %s\n" , - div, __func__); - goto unlock_and_return; - } - div <<=1 ; - }else { -if (div <=2 ) - goto unlock_and_return; - div >>=1 ; - } - val = ((val & ~PRCM_CLK_MGT_CLKPLLDIV_MASK ) | - (div &PRCM_CLK_MGT_CLKPLLDIV_MASK )); -writel (val, prcmu_base + clock_reg[i]); - } - -unlock_and_return: -/* Release the HW semaphore. */ -writel (0 ,PRCM_SEM ); - -spin_unlock_irqrestore (&clk_mgt_lock, flags); -} -/** * db8500_prcmu_set_ape_opp - set the appropriate APE OPP * @opp: The new APE operating point to which transition is to be made
@@ -843,9 +797,6 @@ int db8500_prcmu_set_ape_opp(u8 opp)mutex_lock (&mb1_transfer.lock); -if (mb1_transfer.ape_opp ==APE_50_PARTLY_25_OPP ) -request_even_slower_clocks (false); -if ((opp !=APE_100_OPP ) && (mb1_transfer.ape_opp !=APE_100_OPP )) goto skip_message;
@@ -854,8 +805,7 @@ int db8500_prcmu_set_ape_opp(u8 opp)writeb (MB1H_ARM_APE_OPP , (tcdm_base +PRCM_MBOX_HEADER_REQ_MB1 ));writeb (ARM_NO_CHANGE , (tcdm_base +PRCM_REQ_MB1_ARM_OPP )); -writeb (((opp ==APE_50_PARTLY_25_OPP ) ?APE_50_OPP : opp), - (tcdm_base +PRCM_REQ_MB1_APE_OPP )); +writeb (opp, (tcdm_base +PRCM_REQ_MB1_APE_OPP ));writel (MBOX_BIT (1 ),PRCM_MBOX_CPU_SET );wait_for_completion (&mb1_transfer.work);
@@ -865,9 +815,6 @@ int db8500_prcmu_set_ape_opp(u8 opp) r = -EIO ; skip_message: -if ((!r && (opp ==APE_50_PARTLY_25_OPP )) || - (r && (mb1_transfer.ape_opp ==APE_50_PARTLY_25_OPP ))) -request_even_slower_clocks (true);if (!r) mb1_transfer.ape_opp = opp;
include/linux/mfd/db8500-prcmu.h +0 -2
@@ -521,14 +521,12 @@ enum prcmu_wdog_id {* @APE_NO_CHANGE: The APE operating point is unchanged * @APE_100_OPP: The new APE operating point is ape100opp * @APE_50_OPP: 50% -* @APE_50_PARTLY_25_OPP: 50%, except some clocks at 25%. */ enum ape_opp {APE_OPP_INIT =0x00 ,APE_NO_CHANGE =0x01 ,APE_100_OPP =0x02 ,APE_50_OPP =0x03 , -APE_50_PARTLY_25_OPP =0xFF , };/**
Signature · 1 line
2.56.1
Linus Walleij
maintainerPATCH 4/6 clk: ux500: Move PRCMU clock register handling out of MFD
In reply to Linus WalleijKeep the PRCMU mapping and the SYSCLK and SoC PLL mailbox commands in MFD. Move the gate, timer, PLL rate, DSI and divider handling into the clock driver and use the existing offset-based MMIO accessors.
Preserve the clock management spinlock and the hardware semaphore around shared clock register updates. Leave rate calculation and clock IDs unchanged.
--- drivers/clk/ux500/Makefile | 2 +- drivers/clk/ux500/clk-prcmu-hw.c | 830 +++++++++++++++++++++++++++++++++++++++ drivers/clk/ux500/clk-prcmu-hw.h | 12 + drivers/clk/ux500/clk-prcmu.c | 19 +- drivers/mfd/db8500-prcmu-regs.h | 112 ------ drivers/mfd/db8500-prcmu.c | 725 +--------------------------------- include/linux/mfd/db8500-prcmu.h | 32 +- 7 files changed, 857 insertions(+), 875 deletions(-)
drivers/clk/ux500/Makefile +1 -1
@@ -5,7 +5,7 @@ # Clock types obj-y += clk-prcc.o -obj-y += clk-prcmu.o +obj-y += clk-prcmu.o clk-prcmu-hw.o obj-y += clk-sysctrl.o # Reset control
drivers/clk/ux500/clk-prcmu-hw.c new file +830 -0
830 lines not on this page · raw message
drivers/clk/ux500/clk-prcmu-hw.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef UX500_CLK_PRCMU_HW_H +#define UX500_CLK_PRCMU_HW_H + +#include <linux/types.h> + +int ux500_prcmu_clk_request (u8 clock,bool enable); +unsigned long ux500_prcmu_clk_rate (u8 clock); +long ux500_prcmu_clk_round_rate (u8 clock,unsigned long rate); +int ux500_prcmu_clk_set_rate (u8 clock,unsigned long rate); + +#endif
drivers/clk/ux500/clk-prcmu.c +10 -9
@@ -14,6 +14,7 @@#include <linux/io.h> #include <linux/err.h> #include "clk.h" +#include "clk-prcmu-hw.h" #define to_clk_prcmu (_hw) container_of(_hw, struct clk_prcmu, hw)#define to_clk_prcmu_clkout (_hw) container_of(_hw, struct clk_prcmu_clkout, hw)
@@ -37,13 +38,13 @@ static int clk_prcmu_prepare(struct clk_hw *hw) {struct clk_prcmu *clk =to_clk_prcmu (hw); -return db8500_prcmu_request_clock (clk->cg_sel, true); +return ux500_prcmu_clk_request (clk->cg_sel, true); }static void clk_prcmu_unprepare (struct clk_hw *hw) {struct clk_prcmu *clk =to_clk_prcmu (hw); -if (db8500_prcmu_request_clock (clk->cg_sel, false)) +if (ux500_prcmu_clk_request (clk->cg_sel, false))pr_err ("clk_prcmu: %s failed to disable %s.\n" , __func__,clk_hw_get_name (hw)); }
@@ -52,7 +53,7 @@ static unsigned long clk_prcmu_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) {struct clk_prcmu *clk =to_clk_prcmu (hw); -return prcmu_clock_rate (clk->cg_sel); +return ux500_prcmu_clk_rate (clk->cg_sel); } static const struct {
@@ -103,7 +104,7 @@ static int clk_prcmu_set_clock_rate(u8 clock, unsigned long rate)if (clock ==PRCMU_ARMSS )return clk_prcmu_set_armss_rate (rate); -return prcmu_set_clock_rate (clock, rate); +return ux500_prcmu_clk_set_rate (clock, rate); } static int clk_prcmu_determine_rate(struct clk_hw *hw,
@@ -114,7 +115,7 @@ static int clk_prcmu_determine_rate(struct clk_hw *hw,if (clk->cg_sel ==PRCMU_ARMSS ) req->rate =clk_prcmu_round_armss_rate (req->rate);else - req->rate =prcmu_round_clock_rate (clk->cg_sel, req->rate); + req->rate =ux500_prcmu_clk_round_rate (clk->cg_sel, req->rate);return 0 ; }
@@ -143,7 +144,7 @@ static int clk_prcmu_opp_prepare(struct clk_hw *hw) clk->opp_requested =1 ; } - err =db8500_prcmu_request_clock (clk->cg_sel, true); + err =ux500_prcmu_clk_request (clk->cg_sel, true);if (err) {prcmu_qos_remove_requirement (PRCMU_QOS_APE_OPP , (char *)clk_hw_get_name (hw));
@@ -158,7 +159,7 @@ static void clk_prcmu_opp_unprepare(struct clk_hw *hw) {struct clk_prcmu *clk =to_clk_prcmu (hw); -if (db8500_prcmu_request_clock (clk->cg_sel, false)) { +if (ux500_prcmu_clk_request (clk->cg_sel, false)) {pr_err ("clk_prcmu: %s failed to disable %s.\n" , __func__,clk_hw_get_name (hw));return ;
@@ -186,7 +187,7 @@ static int clk_prcmu_opp_volt_prepare(struct clk_hw *hw) clk->opp_requested =1 ; } - err =db8500_prcmu_request_clock (clk->cg_sel, true); + err =ux500_prcmu_clk_request (clk->cg_sel, true);if (err) {db8500_prcmu_request_ape_opp_100_voltage (false); clk->opp_requested =0 ;
@@ -200,7 +201,7 @@ static void clk_prcmu_opp_volt_unprepare(struct clk_hw *hw) {struct clk_prcmu *clk =to_clk_prcmu (hw); -if (db8500_prcmu_request_clock (clk->cg_sel, false)) { +if (ux500_prcmu_clk_request (clk->cg_sel, false)) {pr_err ("clk_prcmu: %s failed to disable %s.\n" , __func__,clk_hw_get_name (hw));return ;
drivers/mfd/db8500-prcmu-regs.h +0 -112
145 lines not on this page · raw message
drivers/mfd/db8500-prcmu.c +2 -723
755 lines not on this page · raw message
include/linux/mfd/db8500-prcmu.h +2 -30
@@ -704,10 +704,6 @@ void prcmu_configure_auto_pm(struct prcmu_auto_pm_config *sleep, struct prcmu_auto_pm_config *idle);bool prcmu_is_auto_pm_enabled (void ); -unsigned long prcmu_clock_rate (u8 clock); -long prcmu_round_clock_rate (u8 clock,unsigned long rate); -int prcmu_set_clock_rate (u8 clock,unsigned long rate); -int prcmu_set_clock_divider (u8 clock,u8 divider);int db8500_prcmu_config_hotdog (u8 threshold);int db8500_prcmu_config_hotmon (u8 low,u8 high);int db8500_prcmu_start_temp_sense (u16 cycles32k);
@@ -732,7 +728,6 @@ int db8500_prcmu_set_power_state(u8 state, bool keep_ulp_clk, bool keep_ap_pll);u8 db8500_prcmu_get_power_state_result (void );void db8500_prcmu_enable_wakeups (u32 wakeups);int db8500_prcmu_set_epod (u16 epod_id,u8 epod_state); -int db8500_prcmu_request_clock (u8 clock,bool enable);void db8500_prcmu_config_abb_event_readout (u32 abb_events);void db8500_prcmu_get_abb_event_buffer (void __iomem **buf);int db8500_prcmu_config_esram0_deep_sleep (u8 state);
@@ -740,6 +735,8 @@ u16 db8500_prcmu_get_reset_code(void);bool db8500_prcmu_is_ac_wake_requested (void );int db8500_prcmu_set_arm_opp (u8 opp);int db8500_prcmu_get_arm_opp (void ); +int db8500_prcmu_request_pll (u8 clock,bool enable); +int db8500_prcmu_request_sysclk (bool enable);int db8500_prcmu_set_ape_opp (u8 opp);int db8500_prcmu_get_ape_opp (void );int db8500_prcmu_request_ape_opp_100_voltage (bool enable);
@@ -813,26 +810,6 @@ static inline bool prcmu_is_auto_pm_enabled(void)return false; } -static inline unsigned long prcmu_clock_rate (u8 clock) -{ -return 0 ; -} - -static inline long prcmu_round_clock_rate (u8 clock,unsigned long rate) -{ -return 0 ; -} - -static inline int prcmu_set_clock_rate (u8 clock,unsigned long rate) -{ -return 0 ; -} - -static inline int prcmu_set_clock_divider (u8 clock,u8 divider) -{ -return 0 ; -} -static inline int db8500_prcmu_config_hotdog (u8 threshold) {return 0 ;
@@ -898,11 +875,6 @@ static inline int db8500_prcmu_set_epod(u16 epod_id, u8 epod_state)return 0 ; } -static inline int db8500_prcmu_request_clock (u8 clock,bool enable) -{ -return 0 ; -} -static inline int db8500_prcmu_config_esram0_deep_sleep (u8 state) {return 0 ;
Signature · 1 line
2.56.1
Linus Walleij
maintainerPATCH 5/6 clk: ux500: Separate the PRCMU DSI clock implementation
In reply to Linus WalleijKeep DSI PLL lock, clamp, output and escape clock programming in a dedicated implementation. Share the PLL rate decoder and divider arithmetic with the other PRCMU clocks without changing their clock IDs, CCF operations or DT bindings.
--- drivers/clk/ux500/Makefile | 2 +- drivers/clk/ux500/clk-prcmu-dsi.c | 352 ++++++++++++++++++++++++++++++++++ drivers/clk/ux500/clk-prcmu-hw.c | 394 +++----------------------------------- drivers/clk/ux500/clk-prcmu-hw.h | 27 +++ 4 files changed, 408 insertions(+), 367 deletions(-)
drivers/clk/ux500/Makefile +1 -1
@@ -5,7 +5,7 @@ # Clock types obj-y += clk-prcc.o -obj-y += clk-prcmu.o clk-prcmu-hw.o +obj-y += clk-prcmu.o clk-prcmu-hw.o clk-prcmu-dsi.o obj-y += clk-sysctrl.o # Reset control
drivers/clk/ux500/clk-prcmu-dsi.c new file +352 -0
352 lines not on this page · raw message
drivers/clk/ux500/clk-prcmu-hw.c +28 -366
534 lines not on this page · raw message
drivers/clk/ux500/clk-prcmu-hw.h +27 -0
@@ -4,9 +4,36 @@#include <linux/types.h> +#define PRCM_PLL_FREQ_D_SHIFT 0 +#define PRCM_PLL_FREQ_N_SHIFT 8 +#define PRCM_PLL_FREQ_R_SHIFT 16 + +enum { +PLL_RAW , +PLL_FIX , +PLL_DIV +}; +int ux500_prcmu_clk_request (u8 clock,bool enable);unsigned long ux500_prcmu_clk_rate (u8 clock);long ux500_prcmu_clk_round_rate (u8 clock,unsigned long rate);int ux500_prcmu_clk_set_rate (u8 clock,unsigned long rate); +unsigned long ux500_prcmu_pll_rate (unsigned int reg,unsigned long src_rate, +int branch); +u32 ux500_prcmu_clk_divider (unsigned long src_rate,unsigned long rate); + +int ux500_prcmu_request_plldsi (bool enable); +int ux500_prcmu_request_dsiclk (u8 n,bool enable); +int ux500_prcmu_request_dsiescclk (u8 n,bool enable); +unsigned long ux500_prcmu_dsiclk_rate (u8 n); +unsigned long ux500_prcmu_dsiescclk_rate (u8 n); +unsigned long ux500_prcmu_plldsi_rate (void ); +long ux500_prcmu_round_plldsi_rate (unsigned long rate); +long ux500_prcmu_round_dsiclk_rate (unsigned long rate); +long ux500_prcmu_round_dsiescclk_rate (unsigned long rate); +int ux500_prcmu_set_plldsi_rate (unsigned long rate); +void ux500_prcmu_set_dsiclk_rate (u8 n,unsigned long rate); +void ux500_prcmu_set_dsiescclk_rate (u8 n,unsigned long rate); +#endif
Signature · 1 line
2.56.1
Linus Walleij
maintainerPATCH 6/6 mfd: db8500-prcmu: Always submit an explicit APE OPP request
In reply to Linus WalleijDo not infer the hardware state from a cache of previous Linux requests. With firmware starting in an unknown state, the old path could report success for a 50% request without sending it.
Accept the two supported firmware levels and always check the acknowledgment. The clock driver will decide when to request a transition.
--- drivers/mfd/db8500-prcmu.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/mfd/db8500-prcmu.c +2 -12
@@ -366,13 +366,11 @@ static struct {* mb1_transfer - state needed for mailbox 1 communication. * @lock: The transaction lock. * @work: The transaction completion structure. -* @ape_opp: The current APE OPP. * @ack: Reply ("acknowledge") data. */ static struct { struct mutex lock; struct completion work; - u8 ape_opp; struct { u8 header; u8 arm_opp;
@@ -692,14 +690,11 @@ int db8500_prcmu_set_ape_opp(u8 opp) {int r =0 ; -if (opp == mb1_transfer.ape_opp) -return 0 ; +if (opp !=APE_50_OPP && opp !=APE_100_OPP ) +return -EINVAL ;mutex_lock (&mb1_transfer.lock); -if ((opp !=APE_100_OPP ) && (mb1_transfer.ape_opp !=APE_100_OPP )) - goto skip_message; -while (readl (PRCM_MBOX_CPU_VAL ) &MBOX_BIT (1 ))cpu_relax ();
@@ -714,10 +709,6 @@ int db8500_prcmu_set_ape_opp(u8 opp) (mb1_transfer.ack.ape_opp != opp)) r = -EIO ; -skip_message: -if (!r) - mb1_transfer.ape_opp = opp; -mutex_unlock (&mb1_transfer.lock);return r;
@@ -1760,7 +1751,6 @@ void __init db8500_prcmu_early_init(void)init_completion (&mb0_transfer.ac_wake_work);mutex_init (&mb1_transfer.lock);init_completion (&mb1_transfer.work); - mb1_transfer.ape_opp =APE_NO_CHANGE ;mutex_init (&mb2_transfer.lock);init_completion (&mb2_transfer.work);spin_lock_init (&mb2_transfer.auto_pm_lock);
Signature · 1 line
2.56.1
[email protected]
AI reviewSashiko has reviewed this 6-patch series and found no issues.
Sashiko has reviewed this 6-patch series and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]