Patches for QCOM IPQ4019 clock driver
v4 cover Patches for QCOM IPQ4019 clock driver
These patches are related to Qualcomm IPQ4019 GCC (Global Clock Controller) driver code mainly adding the nodes for clock marked as fixed in current IPQ4019 clock driver and support for multiple CPU frequencies.
[V4]
1. Addressed the review comments given in v3 patches.
2. Removed the intermediate VCO clocks and make VCO as part of final divider clock.
3. Changed some variable and structure names.
4. Removed intermediate frequency change patch and merged in the main patch itself.
5. Added the APSS CPU frequency change notifier patch
6. Removed i2c node frequency table which is already reviewed.
[V3]
1. Addressed the review comments given in v2 patches.
2. Replaced the do_div with normal division.
3. Marked the PCNOC node as critical.
4. Modified the frequency values for the recent change done in IPQ4019 bootloader.
5. Changed the i2c node frequency table for 19.05 MHz clock.
[V2]
1. Removed the fixed clock references and add the same as clock nodes with recalc_rate operation.
Abhishek Sahu (6):
clk: qcom: ipq4019: remove fixed clocks and add pll clocks
clk: qcom: ipq4019: Add the apss cpu pll divider clock node
clk: qcom: ipq4019: Add the nodes for pcnoc
clk: qcom: ipq4019: correct sdcc frequency and parent name
clk: qcom: ipq4019: Add all the frequencies for apss cpu
clk: qcom: ipq4019: Add the cpu clock frequency change notifier
drivers/clk/qcom/gcc-ipq4019.c | 484 ++++++++++++++++++++++++++- include/dt-bindings/clock/qcom,gcc-ipq4019.h | 11 + 2 files changed, 481 insertions(+), 14 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v4 1/6 clk: qcom: ipq4019: remove fixed clocks and add pll clocks
The current ipq4019 clock driver registered the PLL clocks and dividers as fixed clock. These fixed clock needs to be removed from driver probe function and same need to be registered with clock framework. These PLL clocks should be programmed only once and the same are being programmed already by the boot loader so the set rate operation is not required for these clocks. Only the rate can be calculated by clock operations in clock driver file so this patch adds the same.
The PLL takes the reference clock from XO and generates the intermediate VCO frequency. This VCO frequency will be divided down by different PLL internal dividers. Some of the PLL internal dividers are fixed while other are programmable.
--- drivers/clk/qcom/gcc-ipq4019.c | 254 +++++++++++++++++++++++++-- include/dt-bindings/clock/qcom,gcc-ipq4019.h | 9 + 2 files changed, 252 insertions(+), 11 deletions(-)
drivers/clk/qcom/gcc-ipq4019.c +243 -11
@@ -20,6 +20,7 @@#include <linux/clk-provider.h> #include <linux/regmap.h> #include <linux/reset-controller.h> +#include <linux/math64.h> #include <dt-bindings/clock/qcom,gcc-ipq4019.h>
@@ -28,6 +29,13 @@#include "clk-rcg.h" #include "clk-branch.h" #include "reset.h" +#include "clk-regmap-divider.h" + +#define to_clk_regmap_div (_hw) container_of(to_clk_regmap(_hw),\ + struct clk_regmap_div, clkr) + +#define to_clk_fepll (_hw) container_of(to_clk_regmap_div(_hw),\ + struct clk_fepll, cdiv)enum {P_XO ,
@@ -40,6 +48,41 @@ enum { P_DDRPLLAPSS, }; +/* +* struct clk_fepll_vco - vco feedback divider corresponds for FEPLL clocks +* @fdbkdiv_shift: lowest bit for FDBKDIV +* @fdbkdiv_width: number of bits in FDBKDIV +* @refclkdiv_shift: lowest bit for REFCLKDIV +* @refclkdiv_width: number of bits in REFCLKDIV +* @reg: PLL_DIV register address +*/ +struct clk_fepll_vco { +u32 fdbkdiv_shift; +u32 fdbkdiv_width; +u32 refclkdiv_shift; +u32 refclkdiv_width; +u32 reg; +}; + +/* +* struct clk_fepll - clk divider corresponds to FEPLL clocks +* @fixed_div: fixed divider value if divider is fixed +* @parent_map: map from software's parent index to hardware's src_sel field +* @cdiv: divider values for PLL_DIV +* @pll_vco: vco feedback divider +* @div_table: mapping for actual divider value to register divider value +* in case of non fixed divider +* @freq_tbl: frequency table +*/ +struct clk_fepll { +u32 fixed_div; +const u8 *parent_map; +struct clk_regmap_div cdiv; +const struct clk_fepll_vco *pll_vco; +const struct clk_div_table *div_table; +const struct freq_tbl *freq_tbl; +}; +static struct parent_map gcc_xo_200_500_map[] = { {P_XO ,0 }, {P_FEPLL200 ,1 },
@@ -1155,6 +1198,198 @@ enum { }, }; +/* Calculates the VCO rate for FEPLL. */ +static u64 clk_fepll_vco_calc_rate (struct clk_fepll *pll_div, +unsigned long parent_rate) +{ +const struct clk_fepll_vco *pll_vco = pll_div->pll_vco; +u32 fdbkdiv, refclkdiv, cdiv; +u64 vco; + +regmap_read (pll_div->cdiv.clkr.regmap, pll_vco->reg, &cdiv); + refclkdiv = (cdiv >> pll_vco->refclkdiv_shift) & + (BIT (pll_vco->refclkdiv_width) -1 ); + fdbkdiv = (cdiv >> pll_vco->fdbkdiv_shift) & + (BIT (pll_vco->fdbkdiv_width) -1 ); + + vco = parent_rate / refclkdiv; + vco *=2 ; + vco *= fdbkdiv; + +return vco; +} + +static const struct clk_fepll_vco gcc_apss_ddrpll_vco = { + .fdbkdiv_shift =16 , + .fdbkdiv_width =8 , + .refclkdiv_shift =24 , + .refclkdiv_width =5 , + .reg =0x2e020 , +}; + +static const struct clk_fepll_vco gcc_fepll_vco = { + .fdbkdiv_shift =16 , + .fdbkdiv_width =8 , + .refclkdiv_shift =24 , + .refclkdiv_width =5 , + .reg =0x2f020 , +}; + +/* Calculates the rate for PLL divider. +* If the divider value is not fixed then it gets the actual divider value +* from divider table. Then, it calculate the clock rate by dividing the +* parent rate with actual divider value. +*/ +static unsigned long +clk_regmap_clk_div_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct clk_fepll *pll =to_clk_fepll (hw); +u32 cdiv, pre_div =1 ; +u64 rate; +const struct clk_div_table *clkt; + +if (pll->fixed_div) { + pre_div = pll->fixed_div; + }else { +regmap_read (pll->cdiv.clkr.regmap, pll->cdiv.reg, &cdiv); + cdiv = (cdiv >> pll->cdiv.shift) & (BIT (pll->cdiv.width) -1 ); + +for (clkt = pll->div_table; clkt->div; clkt++) { +if (clkt->val == cdiv) + pre_div = clkt->div; + } + } + + rate =clk_fepll_vco_calc_rate (pll, parent_rate); +do_div (rate, pre_div); + +return rate; +}; + +static const struct clk_ops clk_fepll_div_ops = { + .recalc_rate = clk_regmap_clk_div_recalc_rate, +}; + +static struct clk_fepll gcc_apss_sdcc_clk = { + .fixed_div =28 , + .cdiv.clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="ddrpllsdcc" , + .parent_names = (const char *[]){ +"xo" , + }, + .num_parents =1 , + .ops = &clk_fepll_div_ops, + }, + }, + .pll_vco = &gcc_apss_ddrpll_vco, +}; + +static struct clk_fepll gcc_fepll125_clk = { + .fixed_div =32 , + .cdiv.clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="fepll125" , + .parent_names = (const char *[]){ +"xo" , + }, + .num_parents =1 , + .ops = &clk_fepll_div_ops, + }, + }, + .pll_vco = &gcc_fepll_vco, +}; + +static struct clk_fepll gcc_fepll125dly_clk = { + .fixed_div =32 , + .cdiv.clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="fepll125dly" , + .parent_names = (const char *[]){ +"xo" , + }, + .num_parents =1 , + .ops = &clk_fepll_div_ops, + }, + }, + .pll_vco = &gcc_fepll_vco, +}; + +static struct clk_fepll gcc_fepll200_clk = { + .fixed_div =20 , + .cdiv.clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="fepll200" , + .parent_names = (const char *[]){ +"xo" , + }, + .num_parents =1 , + .ops = &clk_fepll_div_ops, + }, + }, + .pll_vco = &gcc_fepll_vco, +}; + +static struct clk_fepll gcc_fepll500_clk = { + .fixed_div =8 , + .cdiv.clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="fepll500" , + .parent_names = (const char *[]){ +"xo" , + }, + .num_parents =1 , + .ops = &clk_fepll_div_ops, + }, + }, + .pll_vco = &gcc_fepll_vco, +}; + +static const struct clk_div_table fepllwcss_clk_div_table[] = { + {0 ,15 }, + {1 ,16 }, + {2 ,18 }, + {3 ,20 }, + { }, +}; + +static struct clk_fepll gcc_fepllwcss2g_clk = { + .cdiv.reg =0x2f020 , + .cdiv.shift =8 , + .cdiv.width =2 , + .cdiv.clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="fepllwcss2g" , + .parent_names = (const char *[]){ +"xo" , + }, + .num_parents =1 , + .ops = &clk_fepll_div_ops, + }, + }, + .div_table = fepllwcss_clk_div_table, + .pll_vco = &gcc_fepll_vco, +}; + +static struct clk_fepll gcc_fepllwcss5g_clk = { + .cdiv.reg =0x2f020 , + .cdiv.shift =12 , + .cdiv.width =2 , + .cdiv.clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="fepllwcss5g" , + .parent_names = (const char *[]){ +"xo" , + }, + .num_parents =1 , + .ops = &clk_fepll_div_ops, + }, + }, + .div_table = fepllwcss_clk_div_table, + .pll_vco = &gcc_fepll_vco, +}; +static struct clk_regmap *gcc_ipq4019_clocks[] = { [AUDIO_CLK_SRC ] = &audio_clk_src.clkr, [BLSP1_QUP1_I2C_APPS_CLK_SRC ] = &blsp1_qup1_i2c_apps_clk_src.clkr,
@@ -1215,6 +1450,13 @@ enum { [GCC_WCSS5G_CLK] = &gcc_wcss5g_clk.clkr, [GCC_WCSS5G_REF_CLK] = &gcc_wcss5g_ref_clk.clkr, [GCC_WCSS5G_RTC_CLK] = &gcc_wcss5g_rtc_clk.clkr, + [GCC_SDCC_PLLDIV_CLK] = &gcc_apss_sdcc_clk.cdiv.clkr, + [GCC_FEPLL125_CLK] = &gcc_fepll125_clk.cdiv.clkr, + [GCC_FEPLL125DLY_CLK] = &gcc_fepll125dly_clk.cdiv.clkr, + [GCC_FEPLL200_CLK] = &gcc_fepll200_clk.cdiv.clkr, + [GCC_FEPLL500_CLK] = &gcc_fepll500_clk.cdiv.clkr, + [GCC_FEPLL_WCSS2G_CLK] = &gcc_fepllwcss2g_clk.cdiv.clkr, + [GCC_FEPLL_WCSS5G_CLK] = &gcc_fepllwcss5g_clk.cdiv.clkr, };static const struct qcom_reset_map gcc_ipq4019_resets[] = {
@@ -1295,7 +1537,7 @@ enum { .reg_bits = 32, .reg_stride = 4, .val_bits = 32, - .max_register = 0x2dfff, + .max_register = 0x2ffff, .fast_io = true, };
@@ -1315,16 +1557,6 @@ enum {static int gcc_ipq4019_probe (struct platform_device *pdev) { -struct device *dev = &pdev->dev; - -clk_register_fixed_rate (dev,"fepll125" ,"xo" ,0 ,200000000 ); -clk_register_fixed_rate (dev,"fepll125dly" ,"xo" ,0 ,200000000 ); -clk_register_fixed_rate (dev,"fepllwcss2g" ,"xo" ,0 ,200000000 ); -clk_register_fixed_rate (dev,"fepllwcss5g" ,"xo" ,0 ,200000000 ); -clk_register_fixed_rate (dev,"fepll200" ,"xo" ,0 ,200000000 ); -clk_register_fixed_rate (dev,"fepll500" ,"xo" ,0 ,200000000 ); -clk_register_fixed_rate (dev,"ddrpllapss" ,"xo" ,0 ,666000000 ); -return qcom_cc_probe (pdev, &gcc_ipq4019_desc); }
include/dt-bindings/clock/qcom,gcc-ipq4019.h +9 -0
@@ -81,6 +81,15 @@#define GCC_WCSS5G_CLK 62#define GCC_WCSS5G_REF_CLK 63#define GCC_WCSS5G_RTC_CLK 64 +#define GCC_APSS_DDRPLL_VCO 65 +#define GCC_SDCC_PLLDIV_CLK 66 +#define GCC_FEPLL_VCO 67 +#define GCC_FEPLL125_CLK 68 +#define GCC_FEPLL125DLY_CLK 69 +#define GCC_FEPLL200_CLK 70 +#define GCC_FEPLL500_CLK 71 +#define GCC_FEPLL_WCSS2G_CLK 72 +#define GCC_FEPLL_WCSS5G_CLK 73#define WIFI0_CPU_INIT_RESET 0#define WIFI0_RADIO_SRIF_RESET 1
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Stephen Boyd
AppliedRe: [PATCH v4 1/6] clk: qcom: ipq4019: remove fixed clocks and add pll clocks
Quoted 9 lines · Abhishek Sahu
The current ipq4019 clock driver registered the PLL clocks and dividers as fixed clock. These fixed clock needs to be removed from driver probe function and same need to be registered with clock framework. These PLL clocks should be programmed only once and the same are being programmed already by the boot loader so the set rate operation is not required for these clocks. Only the rate can be calculated by clock operations in clock driver file so this patch adds the same.
Quoted 7 lines
The PLL takes the reference clock from XO and generates the intermediate VCO frequency. This VCO frequency will be divided down by different PLL internal dividers. Some of the PLL internal dividers are fixed while other are programmable.
Signed-off-by Abhishek Sahu <[email protected]>---
Applied to clk-ipq4019 and merged into clk-next.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v4 2/6 clk: qcom: ipq4019: Add the apss cpu pll divider clock node
In reply to Abhishek SahuThe current ipq4019 clock driver does not have support for all the frequency supported by APSS CPU. APSS CPU frequency is provided with APSS CPU PLL divider which divides down the VCO frequency. This divider is nonlinear and specific to IPQ4019 so the standard divider code cannot be used for this.
--- drivers/clk/qcom/gcc-ipq4019.c | 132 +++++++++++++++++++++++++++ include/dt-bindings/clock/qcom,gcc-ipq4019.h | 1 + 2 files changed, 133 insertions(+)
drivers/clk/qcom/gcc-ipq4019.c +132 -0
@@ -21,6 +21,7 @@#include <linux/regmap.h> #include <linux/reset-controller.h> #include <linux/math64.h> +#include <linux/delay.h> #include <dt-bindings/clock/qcom,gcc-ipq4019.h>
@@ -585,6 +586,7 @@ struct clk_fepll { .parent_names = gcc_xo_ddr_500_200, .num_parents = 4, .ops = &clk_rcg2_ops, + .flags = CLK_SET_RATE_PARENT, }, };
@@ -1235,6 +1237,135 @@ static u64 clk_fepll_vco_calc_rate(struct clk_fepll *pll_div, .reg = 0x2f020, }; +/* +* Round rate function for APSS CPU PLL Clock divider. +* It looks up the frequency table and returns the next higher frequency +* supported in hardware. +*/ +static long clk_cpu_div_round_rate (struct clk_hw *hw,unsigned long rate, +unsigned long *p_rate) +{ +struct clk_fepll *pll =to_clk_fepll (hw); +struct clk_hw *p_hw; +const struct freq_tbl *f; + + f =qcom_find_freq (pll->freq_tbl, rate); +if (!f) +return -EINVAL ; + + p_hw =clk_hw_get_parent_by_index (hw, f->src); + *p_rate =clk_hw_get_rate (p_hw); + +return f->freq; +}; + +/* +* Clock set rate function for APSS CPU PLL Clock divider. +* It looks up the frequency table and updates the PLL divider to corresponding +* divider value. +*/ +static int clk_cpu_div_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) +{ +struct clk_fepll *pll =to_clk_fepll (hw); +const struct freq_tbl *f; +u32 mask; +int ret; + + f =qcom_find_freq (pll->freq_tbl, rate); +if (!f) +return -EINVAL ; + + mask = (BIT (pll->cdiv.width) -1 ) << pll->cdiv.shift; + ret =regmap_update_bits (pll->cdiv.clkr.regmap, + pll->cdiv.reg, mask, + f->pre_div << pll->cdiv.shift); +/* +* There is no status bit which can be checked for successful CPU +* divider update operation so using delay for the same. +*/ +udelay (1 ); + +return 0 ; +}; + +/* +* Clock frequency calculation function for APSS CPU PLL Clock divider. +* This clock divider is nonlinear so this function calculates the actual +* divider and returns the output frequency by dividing VCO Frequency +* with this actual divider value. +*/ +static unsigned long +clk_cpu_div_recalc_rate (struct clk_hw *hw, +unsigned long parent_rate) +{ +struct clk_fepll *pll =to_clk_fepll (hw); +u32 cdiv, pre_div; +u64 rate; + +regmap_read (pll->cdiv.clkr.regmap, pll->cdiv.reg, &cdiv); + cdiv = (cdiv >> pll->cdiv.shift) & (BIT (pll->cdiv.width) -1 ); + +/* +* Some dividers have value in 0.5 fraction so multiply both VCO +* frequency(parent_rate) and pre_div with 2 to make integer +* calculation. +*/ +if (cdiv >10 ) + pre_div = (cdiv +1 ) *2 ; +else + pre_div = cdiv +12 ; + + rate =clk_fepll_vco_calc_rate (pll, parent_rate) *2 ; +do_div (rate, pre_div); + +return rate; +}; + +static const struct clk_ops clk_regmap_cpu_div_ops = { + .round_rate = clk_cpu_div_round_rate, + .set_rate = clk_cpu_div_set_rate, + .recalc_rate = clk_cpu_div_recalc_rate, +}; + +static const struct freq_tbl ftbl_apss_ddr_pll[] = { + {384000000 ,P_XO ,0xd ,0 ,0 }, + {413000000 ,P_XO ,0xc ,0 ,0 }, + {448000000 ,P_XO ,0xb ,0 ,0 }, + {488000000 ,P_XO ,0xa ,0 ,0 }, + {512000000 ,P_XO ,0x9 ,0 ,0 }, + {537000000 ,P_XO ,0x8 ,0 ,0 }, + {565000000 ,P_XO ,0x7 ,0 ,0 }, + {597000000 ,P_XO ,0x6 ,0 ,0 }, + {632000000 ,P_XO ,0x5 ,0 ,0 }, + {672000000 ,P_XO ,0x4 ,0 ,0 }, + {716000000 ,P_XO ,0x3 ,0 ,0 }, + {768000000 ,P_XO ,0x2 ,0 ,0 }, + {823000000 ,P_XO ,0x1 ,0 ,0 }, + {896000000 ,P_XO ,0x0 ,0 ,0 }, + { } +}; + +static struct clk_fepll gcc_apss_cpu_plldiv_clk = { + .cdiv.reg =0x2e020 , + .cdiv.shift =4 , + .cdiv.width =4 , + .cdiv.clkr = { + .enable_reg =0x2e000 , + .enable_mask =BIT (0 ), + .hw.init = &(struct clk_init_data ){ + .name ="ddrpllapss" , + .parent_names = (const char *[]){ +"xo" , + }, + .num_parents =1 , + .ops = &clk_regmap_cpu_div_ops, + }, + }, + .freq_tbl = ftbl_apss_ddr_pll, + .pll_vco = &gcc_apss_ddrpll_vco, +}; +/* Calculates the rate for PLL divider. * If the divider value is not fixed then it gets the actual divider value * from divider table. Then, it calculate the clock rate by dividing the
@@ -1457,6 +1588,7 @@ static u64 clk_fepll_vco_calc_rate(struct clk_fepll *pll_div, [GCC_FEPLL500_CLK] = &gcc_fepll500_clk.cdiv.clkr, [GCC_FEPLL_WCSS2G_CLK] = &gcc_fepllwcss2g_clk.cdiv.clkr, [GCC_FEPLL_WCSS5G_CLK] = &gcc_fepllwcss5g_clk.cdiv.clkr, + [GCC_APSS_CPU_PLLDIV_CLK] = &gcc_apss_cpu_plldiv_clk.cdiv.clkr, };static const struct qcom_reset_map gcc_ipq4019_resets[] = {
include/dt-bindings/clock/qcom,gcc-ipq4019.h +1 -0
@@ -90,6 +90,7 @@#define GCC_FEPLL500_CLK 71#define GCC_FEPLL_WCSS2G_CLK 72#define GCC_FEPLL_WCSS5G_CLK 73 +#define GCC_APSS_CPU_PLLDIV_CLK 74#define WIFI0_CPU_INIT_RESET 0#define WIFI0_RADIO_SRIF_RESET 1
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Stephen Boyd
AppliedRe: [PATCH v4 2/6] clk: qcom: ipq4019: Add the apss cpu pll divider clock node
Quoted 8 lines · Abhishek Sahu
The current ipq4019 clock driver does not have support for all the frequency supported by APSS CPU. APSS CPU frequency is provided with APSS CPU PLL divider which divides down the VCO frequency. This divider is nonlinear and specific to IPQ4019 so the standard divider code cannot be used for this.
Signed-off-by Abhishek Sahu <[email protected]>---
Applied to clk-ipq4019 and merged into clk-next.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v4 3/6 clk: qcom: ipq4019: Add the nodes for pcnoc
In reply to Abhishek SahuThe current ipq4019 clock driver does not have the node for PCNOC so this patch adds and registers the PCNOC clock nodes. This PCNOC clock is critical and should not be turned off so setting CRITICAL flag also.
--- drivers/clk/qcom/gcc-ipq4019.c | 39 ++++++++++++++++++++++++++++ include/dt-bindings/clock/qcom,gcc-ipq4019.h | 1 + 2 files changed, 40 insertions(+)
drivers/clk/qcom/gcc-ipq4019.c +39 -0
@@ -1521,6 +1521,43 @@ static int clk_cpu_div_set_rate(struct clk_hw *hw, unsigned long rate, .pll_vco = &gcc_fepll_vco, }; +static const struct freq_tbl ftbl_gcc_pcnoc_ahb_clk[] = { +F (48000000 ,P_XO ,1 ,0 ,0 ), +F (100000000 ,P_FEPLL200 ,2 ,0 ,0 ), + { } +}; + +static struct clk_rcg2 gcc_pcnoc_ahb_clk_src = { + .cmd_rcgr =0x21024 , + .hid_width =5 , + .parent_map = gcc_xo_200_500_map, + .freq_tbl = ftbl_gcc_pcnoc_ahb_clk, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="gcc_pcnoc_ahb_clk_src" , + .parent_names = gcc_xo_200_500, + .num_parents =3 , + .ops = &clk_rcg2_ops, + }, +}; + +static struct clk_branch pcnoc_clk_src = { + .halt_reg =0x21030 , + .clkr = { + .enable_reg =0x21030 , + .enable_mask =BIT (0 ), + .hw.init = &(struct clk_init_data ){ + .name ="pcnoc_clk_src" , + .parent_names = (const char *[]){ +"gcc_pcnoc_ahb_clk_src" , + }, + .num_parents =1 , + .ops = &clk_branch2_ops, + .flags =CLK_SET_RATE_PARENT | +CLK_IS_CRITICAL , + }, + }, +}; +static struct clk_regmap *gcc_ipq4019_clocks[] = { [AUDIO_CLK_SRC ] = &audio_clk_src.clkr, [BLSP1_QUP1_I2C_APPS_CLK_SRC ] = &blsp1_qup1_i2c_apps_clk_src.clkr,
@@ -1589,6 +1626,8 @@ static int clk_cpu_div_set_rate(struct clk_hw *hw, unsigned long rate, [GCC_FEPLL_WCSS2G_CLK] = &gcc_fepllwcss2g_clk.cdiv.clkr, [GCC_FEPLL_WCSS5G_CLK] = &gcc_fepllwcss5g_clk.cdiv.clkr, [GCC_APSS_CPU_PLLDIV_CLK] = &gcc_apss_cpu_plldiv_clk.cdiv.clkr, + [GCC_PCNOC_AHB_CLK_SRC] = &gcc_pcnoc_ahb_clk_src.clkr, + [GCC_PCNOC_AHB_CLK] = &pcnoc_clk_src.clkr, };static const struct qcom_reset_map gcc_ipq4019_resets[] = {
include/dt-bindings/clock/qcom,gcc-ipq4019.h +1 -0
@@ -91,6 +91,7 @@#define GCC_FEPLL_WCSS2G_CLK 72#define GCC_FEPLL_WCSS5G_CLK 73#define GCC_APSS_CPU_PLLDIV_CLK 74 +#define GCC_PCNOC_AHB_CLK_SRC 75#define WIFI0_CPU_INIT_RESET 0#define WIFI0_RADIO_SRIF_RESET 1
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Stephen Boyd
AppliedRe: [PATCH v4 3/6] clk: qcom: ipq4019: Add the nodes for pcnoc
Quoted 7 lines · Abhishek Sahu
The current ipq4019 clock driver does not have the node for PCNOC so this patch adds and registers the PCNOC clock nodes. This PCNOC clock is critical and should not be turned off so setting CRITICAL flag also.
Signed-off-by Abhishek Sahu <[email protected]>---
Applied to clk-ipq4019 and merged into clk-next.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v4 4/6 clk: qcom: ipq4019: correct sdcc frequency and parent name
In reply to Abhishek Sahu1. The parent for sdcc clock is sdccpll.
2. The frequency value was wrong so modified the same.
--- drivers/clk/qcom/gcc-ipq4019.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-ipq4019.c +2 -2
@@ -124,7 +124,7 @@ struct clk_fepll {static const char *const gcc_xo_sdcc1_500[] = {"xo" , -"ddrpll" , +"ddrpllsdcc" ,"fepll500" , };
@@ -550,7 +550,7 @@ struct clk_fepll {F (25000000 ,P_FEPLL500 ,1 ,1 ,20 ),F (50000000 ,P_FEPLL500 ,1 ,1 ,10 ),F (100000000 ,P_FEPLL500 ,1 ,1 ,5 ), - F(193000000, P_DDRPLL, 1, 0, 0), + F(192000000, P_DDRPLL, 1, 0, 0), { } };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v4 5/6 clk: qcom: ipq4019: Add all the frequencies for apss cpu
In reply to Abhishek SahuThe APSS CPU clock does not contain all the frequencies in its frequency table so this patch adds the same.
--- drivers/clk/qcom/gcc-ipq4019.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-ipq4019.c +12 -2
@@ -569,10 +569,20 @@ struct clk_fepll { };static const struct freq_tbl ftbl_gcc_apps_clk[] = { -F (48000000 ,P_XO ,1 ,0 ,0 ), +F (48000000 ,P_XO ,1 ,0 ,0 ),F (200000000 ,P_FEPLL200 ,1 ,0 ,0 ), +F (384000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ), +F (413000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ), +F (448000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ), +F (488000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ),F (500000000 ,P_FEPLL500 ,1 ,0 ,0 ), -F (626000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ), +F (512000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ), +F (537000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ), +F (565000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ), +F (597000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ), +F (632000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ), +F (672000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ), +F (716000000 ,P_DDRPLLAPSS ,1 ,0 ,0 ), { } };
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 6/6 clk: qcom: ipq4019: Add the cpu clock frequency change notifier
In reply to Abhishek SahuThe current driver code gives the crash or gets hang while switching the CPU frequency some time. The APSS CPU Clock divider is not glitch free so it the APPS clock need to be switched for stable clock during the change.
This patch adds the frequency change notifier for APSS CPU clock. It changes the parent of this clock to stable PLL FEPLL500 when it gets for PRE_RATE_CHANGE event. This event will be generated before actual clock set operations. The clock set operation will again change its corresponding parent by getting the same from frequency table.
--- drivers/clk/qcom/gcc-ipq4019.c | 45 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
drivers/clk/qcom/gcc-ipq4019.c +44 -1
@@ -22,6 +22,7 @@#include <linux/reset-controller.h> #include <linux/math64.h> #include <linux/delay.h> +#include <linux/clk.h> #include <dt-bindings/clock/qcom,gcc-ipq4019.h>
@@ -1736,13 +1737,55 @@ static int clk_cpu_div_set_rate(struct clk_hw *hw, unsigned long rate, };MODULE_DEVICE_TABLE (of, gcc_ipq4019_match_table); +/* Contains index for safe clock during APSS freq change */ +static int gcc_ipq4019_cpu_safe_parent; +static int +gcc_ipq4019_cpu_clk_notifier_fn (struct notifier_block *nb, +unsigned long action,void *data) +{ +int err =0 ; + +if (action ==PRE_RATE_CHANGE ) + err = clk_rcg2_ops.set_parent (&apps_clk_src.clkr.hw, + gcc_ipq4019_cpu_safe_parent); + +return notifier_from_errno (err); +} + +static struct notifier_block gcc_ipq4019_cpu_clk_notifier = { + .notifier_call = gcc_ipq4019_cpu_clk_notifier_fn, +}; +static int gcc_ipq4019_probe (struct platform_device *pdev) { -return qcom_cc_probe (pdev, &gcc_ipq4019_desc); +int err; + + err =qcom_cc_probe (pdev, &gcc_ipq4019_desc); +if (err) +return err; + + gcc_ipq4019_cpu_safe_parent =qcom_find_src_index (&apps_clk_src.clkr.hw, + apps_clk_src.parent_map, +P_FEPLL500 ); +if (gcc_ipq4019_cpu_safe_parent <0 ) + err = gcc_ipq4019_cpu_safe_parent; + +if (!err) + err =clk_notifier_register (apps_clk_src.clkr.hw.clk, + &gcc_ipq4019_cpu_clk_notifier); + +return err; +} + +static int gcc_ipq4019_remove (struct platform_device *pdev) +{ +return clk_notifier_unregister (apps_clk_src.clkr.hw.clk, + &gcc_ipq4019_cpu_clk_notifier); }static struct platform_driver gcc_ipq4019_driver = { .probe = gcc_ipq4019_probe, + .remove = gcc_ipq4019_remove, .driver = { .name ="qcom,gcc-ipq4019" , .of_match_table = gcc_ipq4019_match_table,
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v4 6/6] clk: qcom: ipq4019: Add the cpu clock frequency change notifier
Quoted 5 lines · Abhishek Sahu
drivers/clk/qcom/gcc-ipq4019.c +1
-0@@ -1736,13 +1737,55 @@ static int clk_cpu_div_set_rate(struct clk_hw *hw, unsigned long rate, };MODULE_DEVICE_TABLE (of, gcc_ipq4019_match_table); +/* Contains index for safe clock during APSS freq change */
drivers/clk/qcom/gcc-ipq4019.c static int clk_cpu_div_set_rate(struct clk_hw *hw, unsigned long rate, · line 1750
Quoted 10 lines
drivers/clk/qcom/gcc-ipq4019.c +10
-0+static int gcc_ipq4019_cpu_safe_parent; +static int +gcc_ipq4019_cpu_clk_notifier_fn (struct notifier_block *nb, +unsigned long action,void *data) +{ +int err =0 ; + +if (action ==PRE_RATE_CHANGE ) + err = clk_rcg2_ops.set_parent (&apps_clk_src.clkr.hw, + gcc_ipq4019_cpu_safe_parent);
Why can't we hardcode this? It's not like this safe parent is going to change across boards.
Quoted 12 lines
drivers/clk/qcom/gcc-ipq4019.c +9
-1+ +return notifier_from_errno (err); +} + +static struct notifier_block gcc_ipq4019_cpu_clk_notifier = { + .notifier_call = gcc_ipq4019_cpu_clk_notifier_fn, +}; +static int gcc_ipq4019_probe (struct platform_device *pdev) { -return qcom_cc_probe (pdev, &gcc_ipq4019_desc); +int err;
drivers/clk/qcom/gcc-ipq4019.c static int clk_cpu_div_set_rate(struct clk_hw *hw, unsigned long rate, · line 1771
Quoted 10 lines
drivers/clk/qcom/gcc-ipq4019.c +10
-0+ + err =qcom_cc_probe (pdev, &gcc_ipq4019_desc); +if (err) +return err; + + gcc_ipq4019_cpu_safe_parent =qcom_find_src_index (&apps_clk_src.clkr.hw, + apps_clk_src.parent_map, +P_FEPLL500 ); +if (gcc_ipq4019_cpu_safe_parent <0 ) + err = gcc_ipq4019_cpu_safe_parent;
Then we don't need to do this.
Quoted 8 lines
drivers/clk/qcom/gcc-ipq4019.c +8
-0+ +if (!err) + err =clk_notifier_register (apps_clk_src.clkr.hw.clk, + &gcc_ipq4019_cpu_clk_notifier); + +return err; +} +
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html