Commit Graph

10207 Commits

Author SHA1 Message Date
Kuan-Wei Chiu
1cda2870d5 clk: hi3620: Fix memory leak in hi3620_mmc_clk_init()
[ Upstream commit bfbea9e566 ]

In cases where kcalloc() fails for the 'clk_data->clks' allocation, the
code path does not handle the failure gracefully, potentially leading
to a memory leak. This fix ensures proper cleanup by freeing the
allocated memory for 'clk_data' before returning.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Link: https://lore.kernel.org/r/20231210165040.3407545-1-visitorckw@gmail.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-05 20:14:29 +00:00
Konrad Dybcio
a3fb4404e3 clk: qcom: dispcc-sm8550: Update disp PLL settings
[ Upstream commit febd251d87 ]

The settings in the driver seem to have been taken from an older
release. Update them to match the latest values.

Fixes: 90114ca114 ("clk: qcom: add SM8550 DISPCC driver")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20231218-topic-8550_fixes-v1-8-ce1272d77540@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:38 -08:00
Konrad Dybcio
053f354733 clk: qcom: gcc-sm8550: Mark RCGs shared where applicable
[ Upstream commit 929c75d575 ]

The vast majority of shared RCGs were not marked as such. Fix it.

Fixes: 955f2ea3b9 ("clk: qcom: Add GCC driver for SM8550")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20231218-topic-8550_fixes-v1-6-ce1272d77540@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:38 -08:00
Konrad Dybcio
a7a5ec56a0 clk: qcom: gcc-sm8550: use collapse-voting for PCIe GDSCs
[ Upstream commit 7e77a39265 ]

The PCIe GDSCs can be shared with other masters and should use the APCS
collapse-vote register when updating the power state.

This is specifically also needed to be able to disable power domains
that have been enabled by boot firmware using the vote register.

Following other recent Qualcomm platforms, describe this register and
the corresponding mask for the PCIe (and _phy) GDSCs.

Fixes: 955f2ea3b9 ("clk: qcom: Add GCC driver for SM8550")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20231218-topic-8550_fixes-v1-5-ce1272d77540@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:38 -08:00
Konrad Dybcio
62f53fe9e8 clk: qcom: gcc-sm8550: Mark the PCIe GDSCs votable
[ Upstream commit e7fe73fc6b ]

The PCIe GDSCs on most Qualcomm platforms expect the OS to always
consider collapse requests as successful. This also concerns SM8550.

Add the VOTABLE flag to the GDSCs in question to comply with these
expectations.

Fixes: 955f2ea3b9 ("clk: qcom: Add GCC driver for SM8550")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20231218-topic-8550_fixes-v1-4-ce1272d77540@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:38 -08:00
Konrad Dybcio
b5782964b0 clk: qcom: gcc-sm8550: Add the missing RETAIN_FF_ENABLE GDSC flag
[ Upstream commit 1fe8273c8d ]

All of the 8550's GCC GDSCs can and should use the retain registers so
as not to lose their state when entering lower power modes.

Fixes: 955f2ea3b9 ("clk: qcom: Add GCC driver for SM8550")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20231218-topic-8550_fixes-v1-3-ce1272d77540@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:38 -08:00
Su Hui
1e6132acba clk: si5341: fix an error code problem in si5341_output_clk_set_rate
[ Upstream commit 5607068ae5 ]

regmap_bulk_write() return zero or negative error code, return the value
of regmap_bulk_write() rather than '0'.

Fixes: 3044a860fd ("clk: Add Si5341/Si5340 driver")
Acked-by: Mike Looijmans <mike.looijmans@topic.nl>
Signed-off-by: Su Hui <suhui@nfschina.com>
Link: https://lore.kernel.org/r/20231101031633.996124-1-suhui@nfschina.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:38 -08:00
Marek Vasut
2e4806d2b7 clk: rs9: Fix DIF OEn bit placement on 9FGV0241
[ Upstream commit 29d861b5d2 ]

On 9FGV0241, the DIF OE0 is BIT(1) and DIF OE1 is BIT(2), on the other
chips like 9FGV0441 and 9FGV0841 DIF OE0 is BIT(0) and so on. Increment
the index in BIT() macro instead of the result of BIT() macro to shift
the bit correctly on 9FGV0241.

Fixes: 603df193ec ("clk: rs9: Support device specific dif bit calculation")
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Link: https://lore.kernel.org/r/20231105200642.62792-1-marek.vasut+renesas@mailbox.org
Reviewed-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:37 -08:00
Jay Buddhabhatti
37b6748060 drivers: clk: zynqmp: update divider round rate logic
[ Upstream commit 1fe15be1fb ]

Currently zynqmp divider round rate is considering single parent and
calculating rate and parent rate accordingly. But if divider clock flag
is set to SET_RATE_PARENT then its not trying to traverse through all
parent rate and not selecting best parent rate from that. So use common
divider_round_rate() which is traversing through all clock parents and
its rate and calculating proper parent rate.

Fixes: 3fde0e16d0 ("drivers: clk: Add ZynqMP clock driver")
Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Link: https://lore.kernel.org/r/20231129112916.23125-3-jay.buddhabhatti@amd.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:37 -08:00
Jay Buddhabhatti
9b2dcd1b38 drivers: clk: zynqmp: calculate closest mux rate
[ Upstream commit b782921ddd ]

Currently zynqmp clock driver is not calculating closest mux rate and
because of that Linux is not setting proper frequency for CPU and
not able to set given frequency for dynamic frequency scaling.

E.g., In current logic initial acpu clock parent and frequency as below
apll1                  0    0    0  2199999978    0     0  50000      Y
    acpu0_mux          0    0    0  2199999978    0     0  50000      Y
        acpu0_idiv1    0    0    0  2199999978    0     0  50000      Y
            acpu0      0    0    0  2199999978    0     0  50000      Y

After changing acpu frequency to 549999994 Hz using CPU freq scaling its
selecting incorrect parent which is not closest frequency.
rpll_to_xpd            0    0    0  1599999984    0     0  50000      Y
    acpu0_mux          0    0    0  1599999984    0     0  50000      Y
        acpu0_div1     0    0    0   533333328    0     0  50000      Y
            acpu0      0    0    0   533333328    0     0  50000      Y

Parent should remain same since 549999994 = 2199999978 / 4.

So use __clk_mux_determine_rate_closest() generic function to calculate
closest rate for mux clock. After this change its selecting correct
parent and correct clock rate.
apll1                  0    0    0  2199999978    0     0  50000      Y
    acpu0_mux          0    0    0  2199999978    0     0  50000      Y
        acpu0_div1     0    0    0   549999995    0     0  50000      Y
            acpu0      0    0    0   549999995    0     0  50000      Y

Fixes: 3fde0e16d0 ("drivers: clk: Add ZynqMP clock driver")
Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Link: https://lore.kernel.org/r/20231129112916.23125-2-jay.buddhabhatti@amd.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:37 -08:00
Yang Yingliang
f35668e633 clk: sp7021: fix return value check in sp7021_clk_probe()
[ Upstream commit 1004c346a2 ]

devm_platform_ioremap_resource() never returns NULL pointer,
it will return ERR_PTR() when it fails, so replace the check
with IS_ERR().

Fixes: d54c1fd4a5 ("clk: Add Sunplus SP7021 clock driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20231128133016.2494699-1-yangyingliang@huawei.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:37 -08:00
Satya Priya Kakitapalli
2aea9c0498 clk: qcom: videocc-sm8150: Add missing PLL config property
[ Upstream commit 71f130c919 ]

When the driver was ported upstream, PLL test_ctl_hi1 register value
was omitted. Add it to ensure the PLLs are fully configured.

Fixes: 5658e8cf1a ("clk: qcom: add video clock controller driver for SM8150")
Signed-off-by: Satya Priya Kakitapalli <quic_skakitap@quicinc.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20231201-videocc-8150-v3-3-56bec3a5e443@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:37 -08:00
Satya Priya Kakitapalli
9fcf47d8f9 clk: qcom: videocc-sm8150: Update the videocc resets
[ Upstream commit 1fd9a939db ]

Add all the available resets for the video clock controller
on sm8150.

Fixes: 5658e8cf1a ("clk: qcom: add video clock controller driver for SM8150")
Signed-off-by: Satya Priya Kakitapalli <quic_skakitap@quicinc.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20231201-videocc-8150-v3-2-56bec3a5e443@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:37 -08:00
Claudiu Beznea
0afe652a69 clk: renesas: rzg2l: Check reset monitor registers
[ Upstream commit da235d2fac ]

The hardware manual of both RZ/G2L and RZ/G3S specifies that the reset
monitor registers need to be interrogated when the reset signals are
toggled (chapters "Procedures for Supplying and Stopping Reset Signals"
and "Procedure for Activating Modules").  Without this, there is a
chance that different modules (e.g. Ethernet) are not ready after their
reset signal is toggled, leading to failures (on probe or resume from
deep sleep states).

The same indications are available for RZ/V2M for TYPE-B reset controls.

Fixes: ef3c613ccd ("clk: renesas: Add CPG core wrapper for RZ/G2L SoC")
Fixes: 8090bea324 ("clk: renesas: rzg2l: Add support for RZ/V2M reset monitor reg")
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20231207070700.4156557-2-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:36 -08:00
Claudiu Beznea
fc61c3c5e0 clk: renesas: rzg2l-cpg: Reuse code in rzg2l_cpg_reset()
[ Upstream commit 5f9e29b915 ]

Code in rzg2l_cpg_reset() is equivalent with the combined code of
rzg2l_cpg_assert() and rzg2l_cpg_deassert(). There is no need to have
different versions thus re-use rzg2l_cpg_assert() and rzg2l_cpg_deassert().

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20231120070024.4079344-2-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Stable-dep-of: da235d2fac ("clk: renesas: rzg2l: Check reset monitor registers")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:36 -08:00
Satya Priya Kakitapalli
5e00f6c3a3 clk: qcom: gpucc-sm8150: Update the gpu_cc_pll1 config
[ Upstream commit 6ebd9a4f8b ]

Update the test_ctl_hi_val and test_ctl_hi1_val of gpu_cc_pll1
as per latest HW recommendation.

Fixes: 0cef71f2cc ("clk: qcom: Add graphics clock controller driver for SM8150")
Signed-off-by: Satya Priya Kakitapalli <quic_skakitap@quicinc.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20231122042814.4158076-1-quic_skakitap@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:34 -08:00
Peng Fan
9ccbf0c850 LF-11385 clk: imx95: correct blk ctrl for lvds csr
BIT5 is for LDB PLL clk input, not for output. If BIT5 got cleared, the
LDB PLL will not lock, so we drop it to not touch it as of now. Using
the default reset value 0.

And BIT0 is for phy div, so also add it.

Reviewed-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Nitin Garg <nitin.garg_3@nxp.com>
Tested-by: Ming Qian <ming.qian@nxp.com>
Tested-by: Sandor Yu <Sandor.yu@nxp.com>
Reported-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2024-01-24 11:04:13 +08:00
Weihao Li
8c83431277 clk: rockchip: rk3128: Fix HCLK_OTG gate register
[ Upstream commit c6c5a5580d ]

The HCLK_OTG gate control is in CRU_CLKGATE5_CON, not CRU_CLKGATE3_CON.

Signed-off-by: Weihao Li <cn.liweihao@gmail.com>
Link: https://lore.kernel.org/r/20231031111816.8777-1-cn.liweihao@gmail.com
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-20 11:51:42 +01:00
Chris Morgan
351bcf3a37 clk: rockchip: rk3568: Add PLL rate for 292.5MHz
[ Upstream commit 1af27671f6 ]

Add support for a PLL rate of 292.5MHz so that the Powkiddy RGB30 panel
can run at a requested 60hz (59.96, close enough).

I have confirmed this rate fits with all the constraints
listed in the TRM for the VPLL (as an integer PLL) in Part 1 "Chapter
2 Clock & Reset Unit (CRU)."

Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
Link: https://lore.kernel.org/r/20231018153357.343142-2-macroalpha82@gmail.com
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-20 11:51:42 +01:00
Alex Bee
c33fc69553 clk: rockchip: rk3128: Fix SCLK_SDMMC's clock name
[ Upstream commit 99fe9ee56b ]

SCLK_SDMMC is the parent for SCLK_SDMMC_DRV and SCLK_SDMMC_SAMPLE, but
used with the (more) correct name sclk_sdmmc. SD card tuning does currently
fail as the parent can't be found under that name.
There is no need to suffix the name with '0' since RK312x SoCs do have a
single sdmmc controller - so rename it to the name which is already used
by it's children.

Fixes: f6022e88fa ("clk: rockchip: add clock controller for rk3128")
Signed-off-by: Alex Bee <knaerzche@gmail.com>
Link: https://lore.kernel.org/r/20231127181415.11735-6-knaerzche@gmail.com
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-10 17:16:58 +01:00
Finley Xiao
b58d2fc1f9 clk: rockchip: rk3128: Fix aclk_peri_src's parent
[ Upstream commit 98dcc6be38 ]

According to the TRM there are no specific gpll_peri, cpll_peri,
gpll_div2_peri or gpll_div3_peri gates, but a single clk_peri_src gate.
Instead mux_clk_peri_src directly connects to the plls respectively the pll
divider clocks.
Fix this by creating a single gated composite.

Also rename all occurrences of aclk_peri_src to clk_peri_src, since it
is the parent for peri aclks, pclks and hclks. That name also matches
the one used in the TRM.

Fixes: f6022e88fa ("clk: rockchip: add clock controller for rk3128")
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
[renamed aclk_peri_src -> clk_peri_src and added commit message]
Signed-off-by: Alex Bee <knaerzche@gmail.com>
Link: https://lore.kernel.org/r/20231127181415.11735-4-knaerzche@gmail.com
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-10 17:16:58 +01:00
Marek Vasut
eaab31dceb clk: si521xx: Increase stack based print buffer size in probe
[ Upstream commit 7e52b1164a ]

Increase the size of temporary print buffer on stack to fix the
following warnings reported by LKP.

Since all the input parameters of snprintf() are under control
of this driver, it is not possible to trigger and overflow here,
but since the print buffer is on stack and discarded once driver
probe() finishes, it is not an issue to increase it by 10 bytes
and fix the warning in the process. Make it so.

"
   drivers/clk/clk-si521xx.c: In function 'si521xx_probe':
>> drivers/clk/clk-si521xx.c:318:26: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=]
      snprintf(name, 6, "DIFF%d", i);
                             ^~
   drivers/clk/clk-si521xx.c:318:21: note: directive argument in the range [0, 2147483647]
      snprintf(name, 6, "DIFF%d", i);
                        ^~~~~~~~
   drivers/clk/clk-si521xx.c:318:3: note: 'snprintf' output between 6 and 15 bytes into a destination of size 6
      snprintf(name, 6, "DIFF%d", i);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"

Fixes: edc12763a3 ("clk: si521xx: Clock driver for Skyworks Si521xx I2C PCIe clock generators")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202310260412.AGASjFN4-lkp@intel.com/
Signed-off-by: Marek Vasut <marex@denx.de>
Link: https://lore.kernel.org/r/20231027085840.30098-1-marex@denx.de
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-10 17:16:55 +01:00
Peng Fan
f2997f872d LF-11124-2 clk: imx95-blk-ctrl: drop IMX95_CLK_CAMBLK_ISI_AXI
The BIT2 is reserved in RM, drop this clock.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
2023-12-26 09:49:20 +08:00
Peng Fan
ff133185d8 LF-10954 clk: imx: imx8m: remove CLK_SET_PARENT_RATE for DISP PIXEL
Allowing set parent rate will cause the PLL rate out of Spec allowed
range and cause issue, so drop the clk set parent flag for now.

Fixes: 46a974433e ("clk: imx: Let IMX8MN_CLK_DISP_PIXEL set parent rate")
Fixes: 5fe6ec93f1 ("clk: imx8mm: Let IMX8MM_CLK_LCDIF_PIXEL set parent rate")
Acked-by: Jacky Bai <ping.bai@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
2023-12-22 10:45:00 +08:00
Peng Fan
6c6057ca5f LF-11052 clk: imx: imx95-blk-ctrl: correct parent names
The parents names not match the name exported by scmi clk, correct them,
otherwise these clocks will be orphan clocks

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
2023-12-19 10:29:43 +08:00
Ming Qian
34150a8c9d LF-10938: clk: imx95-blk-ctrl: enable runtime pm for vpu_blk_ctrl
We want to enable the runtime pm for vpu, and the power domain
IMX95_PD_VPU is set for vpu_blk_ctrl and vpu and jpeg. vpu and jpeg has
enabled runtime pm, but the vpu_blk_ctrl doesn't, so we can't power off
the vpu power as required.

Enable the runtime pm for vpu_blk_ctrl, then vpu power is runtime enabled.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: TaoJiang <tao.jiang_2@nxp.com>
2023-12-12 16:36:50 +09:00
Shengjiu Wang
46963dc448 LF-10797: clk: imx: pll14xx: use rate_table for audio plls
The generated clock frequency may not accurate, for example
the expected rate is 361267200U, but result is 361267199U.
Add rate_table for audio clocks to avoid such issue.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
2023-12-01 15:42:37 +08:00
Shengjiu Wang
d5fc850bfd LF-10705: clk: imx: pll14xx: Add constraint for fvco frequency
The fvco frequency range is between 1600MHz and 3200MHz, without
this constraint the fvco may out of range, then the real output
frequency is no accurate.

Aslo correct the name for fvco and fout clock.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Acked-by: Jacky Bai <ping.bai@nxp.com>
Tested-by: Chancel Liu <chancel.liu@nxp.com>
2023-11-30 14:07:43 +08:00
Jason Liu
f75d905095 Merge tag 'v6.6.3' into lf-6.6.y
This is the 6.6.3 stable release

* tag 'v6.6.3': (526 commits)
  Linux 6.6.3
  drm/amd/display: Change the DMCUB mailbox memory location from FB to inbox
  drm/amd/display: Clear dpcd_sink_ext_caps if not set
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>

 Conflicts:
	arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi
	drivers/usb/dwc3/core.c
2023-11-30 09:41:12 -06:00
Jason Liu
6d09067baf Merge tag 'v6.6.2' into lf-6.6.y
This is the 6.6.2 stable release

* tag 'v6.6.2': (634 commits)
  Linux 6.6.2
  btrfs: make found_logical_ret parameter mandatory for function queue_scrub_stripe()
  btrfs: use u64 for buffer sizes in the tree search ioctls
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>

Conflicts:
	drivers/clk/imx/clk-imx8mq.c
	drivers/clk/imx/clk-imx8qxp.c
	drivers/media/i2c/ov5640.c
	drivers/misc/pci_endpoint_test.c
2023-11-30 09:40:58 -06:00
Pengfei Li
17a42f3150 LF-10748: clk: imx: fracn-gppll: fix fractional part of PLL getting lost
Fractional part of PLL getting lost after re-enabling the PLL. the
MFN can NOT be automatically loaded when doing frac PLL enable/disable,
So when re enabling PLL, configure mfn through software

Signed-off-by: Pengfei Li <pengfei.li_1@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
2023-11-30 08:01:03 +08:00
Kathiravan Thirumoorthy
7d7ba4b888 clk: qcom: ipq6018: drop the CLK_SET_RATE_PARENT flag from PLL clocks
commit 99cd4935cb upstream.

GPLL, NSS crypto PLL clock rates are fixed and shouldn't be scaled based
on the request from dependent clocks. Doing so will result in the
unexpected behaviour. So drop the CLK_SET_RATE_PARENT flag from the PLL
clocks.

Cc: stable@vger.kernel.org
Fixes: d9db07f088 ("clk: qcom: Add ipq6018 Global Clock Controller support")
Signed-off-by: Kathiravan Thirumoorthy <quic_kathirav@quicinc.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20230913-gpll_cleanup-v2-2-c8ceb1a37680@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:01 +00:00
Kathiravan Thirumoorthy
9466443cd6 clk: qcom: ipq8074: drop the CLK_SET_RATE_PARENT flag from PLL clocks
commit e641a07013 upstream.

GPLL, NSS crypto PLL clock rates are fixed and shouldn't be scaled based
on the request from dependent clocks. Doing so will result in the
unexpected behaviour. So drop the CLK_SET_RATE_PARENT flag from the PLL
clocks.

Cc: stable@vger.kernel.org
Fixes: b8e7e51962 ("clk: qcom: ipq8074: add remaining PLL’s")
Signed-off-by: Kathiravan Thirumoorthy <quic_kathirav@quicinc.com>
Link: https://lore.kernel.org/r/20230913-gpll_cleanup-v2-1-c8ceb1a37680@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:01 +00:00
Gustavo A. R. Silva
c21a0913da clk: visconti: Fix undefined behavior bug in struct visconti_pll_provider
commit 5ad1e217a2 upstream.

`struct clk_hw_onecell_data` is a flexible structure, which means that
it contains flexible-array member at the bottom, in this case array
`hws`:

include/linux/clk-provider.h:
1380 struct clk_hw_onecell_data {
1381         unsigned int num;
1382         struct clk_hw *hws[] __counted_by(num);
1383 };

This could potentially lead to an overwrite of the objects following
`clk_data` in `struct visconti_pll_provider`, in this case
`struct device_node *node;`, at run-time:

drivers/clk/visconti/pll.h:
 16 struct visconti_pll_provider {
 17         void __iomem *reg_base;
 18         struct clk_hw_onecell_data clk_data;
 19         struct device_node *node;
 20 };

Notice that a total of 56 bytes are allocated for flexible-array `hws`
at line 328. See below:

include/dt-bindings/clock/toshiba,tmpv770x.h:
 14 #define TMPV770X_NR_PLL		7

drivers/clk/visconti/pll-tmpv770x.c:
 69 ctx = visconti_init_pll(np, reg_base, TMPV770X_NR_PLL);

drivers/clk/visconti/pll.c:
321 struct visconti_pll_provider * __init visconti_init_pll(struct device_node *np,
322                                                         void __iomem *base,
323                                                         unsigned long nr_plls)
324 {
325         struct visconti_pll_provider *ctx;
...
328         ctx = kzalloc(struct_size(ctx, clk_data.hws, nr_plls), GFP_KERNEL);

`struct_size(ctx, clk_data.hws, nr_plls)` above translates to
sizeof(struct visconti_pll_provider) + sizeof(struct clk_hw *) * 7 ==
24 + 8 * 7 == 24 + 56
		  ^^^^
		   |
	allocated bytes for flex array `hws`

$ pahole -C visconti_pll_provider drivers/clk/visconti/pll.o
struct visconti_pll_provider {
	void *                     reg_base;             /*     0     8 */
	struct clk_hw_onecell_data clk_data;             /*     8     8 */
	struct device_node *       node;                 /*    16     8 */

	/* size: 24, cachelines: 1, members: 3 */
	/* last cacheline: 24 bytes */
};

And then, after the allocation, some data is written into all members
of `struct visconti_pll_provider`:

332         for (i = 0; i < nr_plls; ++i)
333                 ctx->clk_data.hws[i] = ERR_PTR(-ENOENT);
334
335         ctx->node = np;
336         ctx->reg_base = base;
337         ctx->clk_data.num = nr_plls;

Fix all these by placing the declaration of object `clk_data` at the
end of `struct visconti_pll_provider`. Also, add a comment to make it
clear that this object must always be last in the structure, and
prevent this bug from being introduced again in the future.

-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

Fixes: b4cbe606dc ("clk: visconti: Add support common clock driver and reset driver")
Cc: stable@vger.kernel.org
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/57a831d94ee2b3889b11525d4ad500356f89576f.1697492890.git.gustavoars@kernel.org
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:00 +00:00
Gustavo A. R. Silva
b0a660d46d clk: socfpga: Fix undefined behavior bug in struct stratix10_clock_data
commit d761bb01c8 upstream.

`struct clk_hw_onecell_data` is a flexible structure, which means that
it contains flexible-array member at the bottom, in this case array
`hws`:

include/linux/clk-provider.h:
1380 struct clk_hw_onecell_data {
1381         unsigned int num;
1382         struct clk_hw *hws[] __counted_by(num);
1383 };

This could potentially lead to an overwrite of the objects following
`clk_data` in `struct stratix10_clock_data`, in this case
`void __iomem *base;` at run-time:

drivers/clk/socfpga/stratix10-clk.h:
  9 struct stratix10_clock_data {
 10         struct clk_hw_onecell_data      clk_data;
 11         void __iomem            *base;
 12 };

There are currently three different places where memory is allocated for
`struct stratix10_clock_data`, including the flex-array `hws` in
`struct clk_hw_onecell_data`:

drivers/clk/socfpga/clk-agilex.c:
469         clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
470                                 num_clks), GFP_KERNEL);

drivers/clk/socfpga/clk-agilex.c:
509         clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
510                                 num_clks), GFP_KERNEL);

drivers/clk/socfpga/clk-s10.c:
400         clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
401                                                  num_clks), GFP_KERNEL);

I'll use just one of them to describe the issue. See below.

Notice that a total of 440 bytes are allocated for flexible-array member
`hws` at line 469:

include/dt-bindings/clock/agilex-clock.h:
 70 #define AGILEX_NUM_CLKS	55

drivers/clk/socfpga/clk-agilex.c:
459         struct stratix10_clock_data *clk_data;
460         void __iomem *base;
...
466
467         num_clks = AGILEX_NUM_CLKS;
468
469         clk_data = devm_kzalloc(dev, struct_size(clk_data, clk_data.hws,
470                                 num_clks), GFP_KERNEL);

`struct_size(clk_data, clk_data.hws, num_clks)`	above translates to
sizeof(struct stratix10_clock_data) + sizeof(struct clk_hw *) * 55 ==
16 + 8 * 55 == 16 + 440
		    ^^^
		     |
	allocated bytes for flex-array `hws`

474         for (i = 0; i < num_clks; i++)
475                 clk_data->clk_data.hws[i] = ERR_PTR(-ENOENT);
476
477         clk_data->base = base;

and then some data is written into both `hws` and `base` objects.

Fix this by placing the declaration of object `clk_data` at the end of
`struct stratix10_clock_data`. Also, add a comment to make it clear
that this object must always be last in the structure.

-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

Fixes: ba7e258425 ("clk: socfpga: Convert to s10/agilex/n5x to use clk_hw")
Cc: stable@vger.kernel.org
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/1da736106d8e0806aeafa6e471a13ced490eae22.1698117815.git.gustavoars@kernel.org
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:20:00 +00:00
Dong Aisheng
b0ccc637e0 Merge branch 'firmware/next' into next
* firmware/next: (55 commits)
  LF-10339-13 pmdomain: imx: scu-pd: drop unused IMX_SC_R_MLB_0
  LF-10339-12 firmware: imx: add back IMX_SC_IRQ_X macro definitions
  LF-10669-2 firmware: arm_scmi: mailbox: enlarge rx timeout
  LF-10610-1 firmware: imx95: make EdgeLock Enclave Firmware available to i.MX95
  LF-10523-16-1 pinctrl: scmi: support extended imx dt map
  ...
2023-11-22 17:04:48 +08:00
Dong Aisheng
8edc700dd5 Merge branch 'clock/next' into next
* clock/next: (73 commits)
  LF-5658-1: clk: imx95-blk-ctrl: Update lvds csr clock tree
  LF-10523-12 clk: imx: add i.MX95 blk ctrl clk driver
  clk: Add clk support for S32V234
  LF-10270-3: clk: imx: clk-audiomix: add shift bits definition
  MA-21685 dt-bindings: clock: imx8mp: CONFIG_UBSAN_TRAP cause kernel panic
  ...
2023-11-22 17:04:45 +08:00
Dong Aisheng
174ebc860d Merge remote-tracking branch 'origin/clock/s32' into clock/next
* origin/clock/s32:
  clk: Add clk support for S32V234
2023-11-22 17:03:57 +08:00
Sandor Yu
cdecc11a33 LF-5658-1: clk: imx95-blk-ctrl: Update lvds csr clock tree
vds ch0, ch1 and lvds di0, di1 clocks are all source from LDBPLL,
They should in the same clock rate when multi lvds panels enabled.
In the patch those clocks will combined:
Combine lvds ch0 and ch1 clocks into one clock IMX95_CLK_DISPMIX_LVDS_CH_GATE.
Combine lvds di0 and di1 clock into one IMX95_CLK_DISPMIX_PIX_DI_GATE.
They are easy be maintained by both lvds and display controller driver.

Parent IMX95_CLK_DISPMIX_LVDS_PLL_GATE to SM clock PDBPLL.

Remove IMX95_CLK_DISPMIX_LVDS_PLL_DIV1_2 clock, it will be management by
imx95 ldb driver.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
2023-11-22 16:00:55 +08:00
Sudeep Holla
a4e6c35936 clk: scmi: Free scmi_clk allocated when the clocks with invalid info are skipped
[ Upstream commit 3537a75e73 ]

Add the missing devm_kfree() when we skip the clocks with invalid or
missing information from the firmware.

Cc: Cristian Marussi <cristian.marussi@arm.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Fixes: 6d6a1d82ea ("clk: add support for clocks provided by SCMI")
Link: https://lore.kernel.org/r/20231004193600.66232-1-sudeep.holla@arm.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:16 +01:00
Dan Carpenter
5a938500cd clk: mediatek: fix double free in mtk_clk_register_pllfh()
[ Upstream commit bd54ccc0f1 ]

The mtk_clk_register_pll_ops() currently frees the "pll" parameter.
The function has two callers, mtk_clk_register_pll() and
mtk_clk_register_pllfh().  The first one, the _pll() function relies on
the free, but for the second _pllfh() function it causes a double free
bug.

Really the frees should be done in the caller because that's where
the allocation is.

Fixes: d7964de8a8 ("clk: mediatek: Add new clock driver to handle FHCTL hardware")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/cd7fa365-28cc-4c34-ac64-6da57c98baa6@moroto.mountain
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:07 +01:00
Kathiravan Thirumoorthy
ed02ca7ff3 clk: qcom: ipq5332: drop the CLK_SET_RATE_PARENT flag from GPLL clocks
[ Upstream commit 5635ef0bd1 ]

GPLL clock rates are fixed and shouldn't be scaled based on the
request from dependent clocks. Doing so will result in the unexpected
behaviour. So drop the CLK_SET_RATE_PARENT flag from the GPLL clocks.

Fixes: 3d89d52970 ("clk: qcom: add Global Clock controller (GCC) driver for IPQ5332 SoC")
Signed-off-by: Kathiravan Thirumoorthy <quic_kathirav@quicinc.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20230913-gpll_cleanup-v2-5-c8ceb1a37680@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:07 +01:00
Kathiravan Thirumoorthy
4720809ee9 clk: qcom: ipq9574: drop the CLK_SET_RATE_PARENT flag from GPLL clocks
[ Upstream commit 99a8f8764b ]

GPLL clock rates are fixed and shouldn't be scaled based on the request
from dependent clocks. Doing so will result in the unexpected behaviour.
So drop the CLK_SET_RATE_PARENT flag from the GPLL clocks.

----
Changes in V2:
	- No changes

Fixes: d75b82cff4 ("clk: qcom: Add Global Clock Controller driver for IPQ9574")
Signed-off-by: Kathiravan Thirumoorthy <quic_kathirav@quicinc.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20230913-gpll_cleanup-v2-4-c8ceb1a37680@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:07 +01:00
Kathiravan Thirumoorthy
c9bf9bd6b3 clk: qcom: ipq5018: drop the CLK_SET_RATE_PARENT flag from GPLL clocks
[ Upstream commit 01a5e4c673 ]

GPLL clock rates are fixed and shouldn't be scaled based on the
request from dependent clocks. Doing so will result in the unexpected
behaviour. So drop the CLK_SET_RATE_PARENT flag from the GPLL clocks.

----
Changes in V2:
	- New patch

Fixes: e3fdbef1ba ("clk: qcom: Add Global Clock controller (GCC) driver for IPQ5018")
Signed-off-by: Kathiravan Thirumoorthy <quic_kathirav@quicinc.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20230913-gpll_cleanup-v2-3-c8ceb1a37680@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:07 +01:00
Varadarajan Narayanan
1b4e973c68 clk: qcom: apss-ipq-pll: Fix 'l' value for ipq5332_pll_config
[ Upstream commit 5b7a4d3d2b ]

The earlier 'l' value of 0x3e is for 1.5GHz. Not all SKUs support
this frequency. Hence set it to 0x2d to get 1.1GHz which is
supported in all SKUs.

The frequency can still increase above this initial configuration
made here when the cpufreq driver picks a different OPP.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Fixes: c7ef7fbb1c ("clk: qcom: apss-ipq-pll: add support for IPQ5332")
Signed-off-by: Kathiravan T <quic_kathirav@quicinc.com>
Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
Link: https://lore.kernel.org/r/00e6be6cb9cee56628123a64ade118d0a752018b.1697781921.git.quic_varada@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:07 +01:00
Varadarajan Narayanan
b2173e49ca clk: qcom: apss-ipq-pll: Use stromer plus ops for stromer plus pll
[ Upstream commit 267e291984 ]

The set rate and determine rate operations are different between
Stromer and Stromer Plus PLLs. Since the programming sequence is
different, the PLLs dont get configured properly and random,
inexplicable crash/freeze is seen. Hence, use stromer plus ops
for ipq_pll_stromer_plus.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Fixes: c7ef7fbb1c ("clk: qcom: apss-ipq-pll: add support for IPQ5332")
Signed-off-by: Kathiravan T <quic_kathirav@quicinc.com>
Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
Link: https://lore.kernel.org/r/c86ecaa23dc4f39650bcf4a3bd54a617a932e4fd.1697781921.git.quic_varada@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:07 +01:00
Varadarajan Narayanan
92ad878d54 clk: qcom: clk-alpha-pll: introduce stromer plus ops
[ Upstream commit 84da48921a ]

Stromer plus APSS PLL does not support dynamic frequency scaling.
To switch between frequencies, we have to shut down the PLL,
configure the L and ALPHA values and turn on again. So introduce the
separate set of ops for Stromer Plus PLL.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Kathiravan T <quic_kathirav@quicinc.com>
Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
Link: https://lore.kernel.org/r/2affa6c63ff0c4342230623a7d4eef02ec7c02d4.1697781921.git.quic_varada@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Stable-dep-of: 267e291984 ("clk: qcom: apss-ipq-pll: Use stromer plus ops for stromer plus pll")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Varadarajan Narayanan
3f4bcf359a clk: qcom: config IPQ_APSS_6018 should depend on QCOM_SMEM
[ Upstream commit 6a15647d0a ]

The config IPQ_APSS_6018 should depend on QCOM_SMEM, to
avoid the following error reported by 'kernel test robot'

	loongarch64-linux-ld: drivers/clk/qcom/apss-ipq6018.o: in function `apss_ipq6018_probe':
	>> apss-ipq6018.c:(.text+0xd0): undefined reference to `qcom_smem_get_soc_id'

Fixes: 5e77b4ef1b ("clk: qcom: Add ipq6018 apss clock controller")
Reported-by: kernel test robot <yujie.liu@intel.com>
Closes: https://lore.kernel.org/r/202310181650.g8THtfsm-lkp@intel.com/
Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
Link: https://lore.kernel.org/r/f4c4d65a7cb71e807d6d472c63c7718408c8f5f0.1697781921.git.quic_varada@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Jiasheng Jiang
1bf9c204ae clk: mediatek: clk-mt2701: Add check for mtk_alloc_clk_data
[ Upstream commit 0d6e24b422 ]

Add the check for the return value of mtk_alloc_clk_data() in order to
avoid NULL pointer dereference.

Fixes: e986211827 ("clk: mediatek: Add MT2701 clock support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20230901024658.23405-1-jiasheng@iscas.ac.cn
Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Jiasheng Jiang
5fbea47eeb clk: mediatek: clk-mt7629: Add check for mtk_alloc_clk_data
[ Upstream commit 2befa515c1 ]

Add the check for the return value of mtk_alloc_clk_data() in order to
avoid NULL pointer dereference.

Fixes: 3b5e748615 ("clk: mediatek: add clock support for MT7629 SoC")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20230912093407.21505-5-jiasheng@iscas.ac.cn
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Jiasheng Jiang
1639072f62 clk: mediatek: clk-mt7629-eth: Add check for mtk_alloc_clk_data
[ Upstream commit 0884393c63 ]

Add the check for the return value of mtk_alloc_clk_data() in order to
avoid NULL pointer dereference.

Fixes: 3b5e748615 ("clk: mediatek: add clock support for MT7629 SoC")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20230912093407.21505-4-jiasheng@iscas.ac.cn
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Jiasheng Jiang
122ac6496e clk: mediatek: clk-mt6797: Add check for mtk_alloc_clk_data
[ Upstream commit 606f6366a3 ]

Add the check for the return value of mtk_alloc_clk_data() in order to
avoid NULL pointer dereference.

Fixes: 96596aa066 ("clk: mediatek: add clk support for MT6797")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20230912093407.21505-3-jiasheng@iscas.ac.cn
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Jiasheng Jiang
f6a7c51cf0 clk: mediatek: clk-mt6779: Add check for mtk_alloc_clk_data
[ Upstream commit 1f57f78fba ]

Add the check for the return value of mtk_alloc_clk_data() in order to
avoid NULL pointer dereference.

Fixes: 710774e048 ("clk: mediatek: Add MT6779 clock support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20230912093407.21505-2-jiasheng@iscas.ac.cn
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Jiasheng Jiang
b5ff3e89b4 clk: mediatek: clk-mt6765: Add check for mtk_alloc_clk_data
[ Upstream commit b826810427 ]

Add the check for the return value of mtk_alloc_clk_data() in order to
avoid NULL pointer dereference.

Fixes: 1aca9939bf ("clk: mediatek: Add MT6765 clock support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20230912093407.21505-1-jiasheng@iscas.ac.cn
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Jonathan Neuschäfer
db81fa4ab3 clk: npcm7xx: Fix incorrect kfree
[ Upstream commit bbc5080bef ]

The corresponding allocation is:

> npcm7xx_clk_data = kzalloc(struct_size(npcm7xx_clk_data, hws,
> 			     NPCM7XX_NUM_CLOCKS), GFP_KERNEL);

... so, kfree should be applied to npcm7xx_clk_data, not
npcm7xx_clk_data->hws.

Fixes: fcfd143698 ("clk: npcm7xx: add clock controller")
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Link: https://lore.kernel.org/r/20230923133127.1815621-1-j.neuschaefer@gmx.net
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Dan Carpenter
46e12284c6 clk: ti: fix double free in of_ti_divider_clk_setup()
[ Upstream commit 7af5b9eadd ]

The "div" pointer is freed in _register_divider() and again in
of_ti_divider_clk_setup().  Delete the free in _register_divider()

Fixes: fbbc185915 ("clk: ti: divider: cleanup _register_divider and ti_clk_get_div_table")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/6d36eeec-6c8a-4f11-a579-aa3cd7c38749@moroto.mountain
Reviewed-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Dan Carpenter
82fce5143b clk: keystone: pll: fix a couple NULL vs IS_ERR() checks
[ Upstream commit a5d14f8b55 ]

The clk_register_divider() and clk_register_mux() functions returns
error pointers on error but this code checks for NULL.  Fix that.

Fixes: b9e0d40c0d ("clk: keystone: add Keystone PLL clock driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/d9da4c97-0da9-499f-9a21-1f8e3f148dc1@moroto.mountain
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Sergio Paracuellos
3634faabed clk: ralink: mtmips: quiet unused variable warning
[ Upstream commit 6191023134 ]

When CONFIG_OF is disabled then the matching table is not referenced and
the following warning appears:

drivers/clk/ralink/clk-mtmips.c:821:34: warning: unused variable 'mtmips_of_match' [-Wunused-const-variable]
821 |   static const struct of_device_id mtmips_of_match[] = {
    |                          ^

There are two match tables in the driver: one for the clock driver and the
other for the reset driver. The only difference between them is that the
clock driver uses 'data' and does not have 'ralink,rt2880-reset' compatible.
Both just can be merged into a single one just by adding the compatible
'ralink,rt2880-reset' entry to 'mtmips_of_match[]', which will allow it to
be used for 'mtmips_clk_driver' (which doesn't use the data) as well as for
'mtmips_clk_init()' (which doesn't need get called for 'ralink,rt2880-reset').

Doing in this way ensures that 'CONFIG_OF' is not disabled anymore so the
above warning disapears.

Fixes: 6f3b15586e ("clk: ralink: add clock and reset driver for MTMIPS SoCs")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202307242310.CdOnd2py-lkp@intel.com/
Suggested-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Link: https://lore.kernel.org/r/20230827023932.501102-1-sergio.paracuellos@gmail.com
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:06 +01:00
Claudiu Beznea
a8454ab79e clk: renesas: rzg2l: Fix computation formula
[ Upstream commit a2b2315949 ]

According to the hardware manual for RZ/G2L
(r01uh0914ej0130-rzg2l-rzg2lc.pdf), the computation formula for PLL rate
is as follows:

    Fout = ((m + k/65536) * Fin) / (p * 2^s)

and k has values in the range [-32768, 32767].  Dividing k by 65536 with
integer arithmetic gives zero all the time, causing slight differences
b/w what has been set vs. what is displayed.  Thus, get rid of this and
decompose the formula before dividing k by 65536.

Fixes: ef3c613ccd ("clk: renesas: Add CPG core wrapper for RZ/G2L SoC")
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230929053915.1530607-6-claudiu.beznea@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:05 +01:00
Claudiu Beznea
da8862f717 clk: renesas: rzg2l: Use FIELD_GET() for PLL register fields
[ Upstream commit 72977f07b0 ]

Use FIELD_GET() for PLL register fields.  This is its purpose.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230912045157.177966-14-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Stable-dep-of: a2b2315949 ("clk: renesas: rzg2l: Fix computation formula")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:05 +01:00
Claudiu Beznea
cd7231cd7a clk: renesas: rzg2l: Trust value returned by hardware
[ Upstream commit bf51d3b2d0 ]

The onitial value of the CPG_PL2SDHI_DSEL bits 0..1 or 4..6 is 01b.  The
hardware user's manual (r01uh0914ej0130-rzg2l-rzg2lc.pdf) specifies that
setting 0 is prohibited.  Hence rzg2l_cpg_sd_clk_mux_get_parent() should
just read CPG_PL2SDHI_DSEL, trust the value, and return the proper clock
parent index based on the value read.

Fixes: eaff33646f ("clk: renesas: rzg2l: Add SDHI clk mux support")
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230929053915.1530607-5-claudiu.beznea@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:05 +01:00
Claudiu Beznea
f92905170c clk: renesas: rzg2l: Lock around writes to mux register
[ Upstream commit d2692ed490 ]

The SD MUX output (SD0) is further divided by 4 in G2{L,UL}.  The
divided clock is SD0_DIV4. SD0_DIV4 is registered with
CLK_SET_RATE_PARENT which means a rate request for it is propagated to
the MUX and could reach rzg2l_cpg_sd_clk_mux_set_parent() concurrently
with the users of SD0.
Add proper locking to avoid concurrent accesses on SD MUX set rate
registers.

Fixes: eaff33646f ("clk: renesas: rzg2l: Add SDHI clk mux support")
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230929053915.1530607-4-claudiu.beznea@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:05 +01:00
Claudiu Beznea
75b64863e3 clk: renesas: rzg2l: Wait for status bit of SD mux before continuing
[ Upstream commit 549f4ae260 ]

The hardware user manual for RZ/G2L (r01uh0914ej0130-rzg2l-rzg2lc.pdf,
chapter 7.4.7 Procedure for Switching Clocks by the Dynamic Switching
Frequency Selectors) specifies that we need to check CPG_PL2SDHI_DSEL
for SD clock switching status.

Fixes: eaff33646f ("clk: renesas: rzg2l: Add SDHI clk mux support")
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230929053915.1530607-3-claudiu.beznea@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:05 +01:00
Dirk Behme
ca781d499d clk: renesas: rcar-gen3: Extend SDnH divider table
[ Upstream commit d5252d9697 ]

The clock dividers might be used with clock stop bit enabled or not.
Current tables only support recommended values from the datasheet.  This
might result in warnings like below because no valid clock divider is
found. Resulting in a 0 divider.

There are Renesas ARM Trusted Firmware version out there which e.g.
configure 0x201 (shifted logical right by 2: 0x80) and with this match
the added { STPnHCK | 0, 1 }:

https://github.com/renesas-rcar/arm-trusted-firmware/blob/rcar_gen3_v2.3/drivers/renesas/rcar/emmc/emmc_init.c#L108

------------[ cut here ]------------
sd1h: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set
WARNING: CPU: 1 PID: 1 at drivers/clk/clk-divider.c:141 divider_recalc_rate+0x48/0x70
Modules linked in:
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.1.52 #1
Hardware name: Custom board based on r8a7796 (DT)
pstate: 40000005 (nZcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : divider_recalc_rate+0x48/0x70
...
------------[ cut here ]------------

Fixes: bb6d3fa98a ("clk: renesas: rcar-gen3: Switch to new SD clock handling")
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
[wsa: extended the table to 5 entries, added comments, reword commit message a little]
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Dirk Behme <dirk.behme@de.bosch.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230928080317.28224-1-wsa+renesas@sang-engineering.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:05 +01:00
Robert Chiras
7ebc604e16 clk: imx: imx8qxp: Fix elcdif_pll clock
[ Upstream commit 15cee75dac ]

Move the elcdif_pll clock initialization before the lcd_clk, since the
elcdif_clk needs to be initialized ahead of lcd_clk, being its parent.
This change fixes issues with the LCD clocks during suspend/resume.

Fixes: babfaa9556 ("clk: imx: scu: add more scu clocks")
Suggested-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
Acked-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Abel Vesa <abel.vesa@linaro.org>
Link: https://lore.kernel.org/r/20230912-imx8-clk-v1-v1-2-69a34bcfcae1@nxp.com
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:05 +01:00
Peng Fan
e6b727efdc clk: imx: imx8mq: correct error handling path
[ Upstream commit 577ad16996 ]

Avoid memory leak in error handling path. It does not make
much sense for the SoC without clk driver, to make program behavior
correct, let's fix it.

Fixes: b80522040c ("clk: imx: Add clock driver for i.MX8MQ CCM")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202309240551.e46NllPa-lkp@intel.com/
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20231001122618.194498-1-peng.fan@oss.nxp.com
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:05 +01:00
Christophe JAILLET
47923f48f2 clk: imx: imx8: Fix an error handling path in imx8_acm_clk_probe()
[ Upstream commit e9a164e367 ]

If an error occurs after a successful clk_imx_acm_attach_pm_domains() call,
it must be undone.

Add an explicit error handling path, re-order the code and add the missing
clk_imx_acm_detach_pm_domains() call.

Fixes: d3a0946d7a ("clk: imx: imx8: add audio clock mux driver")
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:05 +01:00
Christophe JAILLET
93f3e23323 clk: imx: imx8: Fix an error handling path if devm_clk_hw_register_mux_parent_data_table() fails
[ Upstream commit 9a0108acdb ]

If a devm_clk_hw_register_mux_parent_data_table() call fails, it is likely
that the probe should fail with an error code.

Set 'ret' before leaving the function.

Fixes: d3a0946d7a ("clk: imx: imx8: add audio clock mux driver")
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:05 +01:00
Christophe JAILLET
b7af93485a clk: imx: imx8: Fix an error handling path in clk_imx_acm_attach_pm_domains()
[ Upstream commit 156624e2cf ]

If a dev_pm_domain_attach_by_id() call fails, previously allocated
resources need to be released.

Fixes: d3a0946d7a ("clk: imx: imx8: add audio clock mux driver")
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:05 +01:00
Abel Vesa
b53ae564d4 clk: imx: Select MXC_CLK for CLK_IMX8QXP
[ Upstream commit 317e69c49b ]

If the i.MX8QXP clock provider is built-in but the MXC_CLK is
built as module, build fails:

aarch64-linux-ld: drivers/clk/imx/clk-imx8-acm.o: in function `imx8_acm_clk_probe':
clk-imx8-acm.c:(.text+0x3d0): undefined reference to `imx_check_clk_hws'

Fix that by selecting MXC_CLK in case of CLK_IMX8QXP.

Fixes: c2cccb6d0b ("clk: imx: add imx8qxp clk driver")
Closes: https://lore.kernel.org/all/8b77219e-b59e-40f1-96f1-980a0b2debcf@infradead.org/
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:04 +01:00
Danila Tikhonov
f171bab88e clk: qcom: gcc-sm8150: Fix gcc_sdcc2_apps_clk_src
[ Upstream commit 7138c244fb ]

Set .flags = CLK_OPS_PARENT_ENABLE to fix "gcc_sdcc2_apps_clk_src: rcg
didn't update its configuration" error.

Fixes: 2a1d7eb854 ("clk: qcom: gcc: Add global clock controller driver for SM8150")
Tested-by: Arseniy Velikanov <adomerlee@gmail.com>
Signed-off-by: Danila Tikhonov <danila@jiaxyga.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20230913175612.8685-1-danila@jiaxyga.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:04 +01:00
Konrad Dybcio
0a3406df43 clk: qcom: mmcc-msm8998: Fix the SMMU GDSC
[ Upstream commit 1fc62c8347 ]

The SMMU GDSC doesn't have to be ALWAYS-ON and shouldn't feature the
HW_CTRL flag (it's separate from hw_ctrl_addr).  In addition to that,
it should feature a cxc entry for bimc_smmu_axi_clk and be marked as
votable.

Fix all of these issues.

Fixes: d14b15b593 ("clk: qcom: Add MSM8998 Multimedia Clock Controller (MMCC) driver")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Link: https://lore.kernel.org/r/20230531-topic-8998_mmssclk-v3-5-ba1b1fd9ee75@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:04 +01:00
Konrad Dybcio
f947dca2e8 clk: qcom: mmcc-msm8998: Don't check halt bit on some branch clks
[ Upstream commit 9906c41408 ]

Some branch clocks are governed externally and we're only supposed to
send a request concerning their shutdown, not actually ensure it happens.

Use the BRANCH_HALT_SKIP define to skip checking the halt bit.

Fixes: d14b15b593 ("clk: qcom: Add MSM8998 Multimedia Clock Controller (MMCC) driver")
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20230531-topic-8998_mmssclk-v3-4-ba1b1fd9ee75@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:04 +01:00
Devi Priya
50b5ee6f7e clk: qcom: clk-rcg2: Fix clock rate overflow for high parent frequencies
[ Upstream commit f7b7d30158 ]

If the parent clock rate is greater than unsigned long max/2 then
integer overflow happens when calculating the clock rate on 32-bit systems.
As RCG2 uses half integer dividers, the clock rate is first being
multiplied by 2 which will overflow the unsigned long max value.
Hence, replace the common pattern of doing 64-bit multiplication
and then a do_div() call with simpler mult_frac call.

Fixes: bcd61c0f53 ("clk: qcom: Add support for root clock generators (RCGs)")
Signed-off-by: Devi Priya <quic_devipriy@quicinc.com>
Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
Link: https://lore.kernel.org/r/20230901073640.4973-1-quic_devipriy@quicinc.com
[bjorn: Also drop unnecessary {} around single statements]
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:04 +01:00
Konrad Dybcio
cceba34c7f clk: qcom: gcc-msm8996: Remove RPM bus clocks
[ Upstream commit 4afda5f6bc ]

The GCC driver contains clocks that are owned (meaning configured and
scaled) by the RPM core.

Remove them from Linux to stop interjecting the RPM's logic.

Fixes: b1e010c073 ("clk: qcom: Add MSM8996 Global Clock Control (GCC) driver")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230830-topic-rpmbusclocks8996gcc-v1-1-9e99bedcdc3b@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:04 +01:00
Varadarajan Narayanan
7c619b827c clk: qcom: ipq5332: Drop set rate parent from gpll0 dependent clocks
[ Upstream commit ccd8ab0306 ]

IPQ5332's GPLL0's nominal/turbo frequency is 800MHz.
This must not be scaled based on the requirement of
dependent clocks. Hence remove the CLK_SET_RATE_PARENT
flag.

Fixes: 3d89d52970 ("clk: qcom: add Global Clock controller (GCC) driver for IPQ5332 SoC")
Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
Reviewed-by: Kathiravan T <quic_kathirav@quicinc.com>
Link: https://lore.kernel.org/r/1693474133-10467-1-git-send-email-quic_varada@quicinc.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:59:04 +01:00
Peng Fan
387c5cea9c LF-10523-12 clk: imx: add i.MX95 blk ctrl clk driver
i.MX95 has several blk ctrls, each blk ctrl has some clk settings,
such as gate/div/mux. So add them all here.

TODO: revisit this for upstream

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Nitin Garg <nitin.garg_3@nxp.com>
2023-11-16 14:49:43 +08:00
Viorel Suman
9d52e212d9 LF-6409: sync SCFW and kernel rsrc.h defines
Synchronize SCFW and kernel resources defines.
Add also SCFW defines required for backward compatibility.

SCFW branch: master, commit: 3567a47ac

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
[Leo: Most of the patch upstreamed. Might need to change description.]
Signed-off-by: Li Yang <leoyang.li@nxp.com>
2023-11-12 22:26:16 +08:00
Sudeep Holla
cfc47c05e2 clk: scmi: Free scmi_clk allocated when the clocks with invalid info are skipped
Add the missing devm_kfree() when we skip the clocks with invalid or
missing information from the firmware.

Cc: Cristian Marussi <cristian.marussi@arm.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Fixes: 6d6a1d82ea ("clk: add support for clocks provided by SCMI")
Link: https://lore.kernel.org/r/20231004193600.66232-1-sudeep.holla@arm.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2023-11-12 04:40:21 +08:00
Peng Fan
5c56499884 clk: scmi: Add support for clock {set,get}_parent
SCMI v3.2 adds set/get parent clock commands, so update the SCMI clock
driver to support them.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20231004-scmi-clock-v3-v5-2-1b8a1435673e@nxp.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2023-11-12 04:40:21 +08:00
Cristian Marussi
3d01c5bfc1 clk: scmi: Add support for .is_enabled clk_ops
Add support for .is_enabled atomic clk_ops using the related SCMI Clock
operation in atomic mode, if available.

Note that the .is_enabled callback will be supported by this SCMI Clock
driver only if the configured underlying SCMI transport does support atomic
operations.

CC: Michael Turquette <mturquette@baylibre.com>
CC: Stephen Boyd <sboyd@kernel.org>
CC: linux-clk@vger.kernel.org
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20230826125308.462328-6-cristian.marussi@arm.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2023-11-12 04:37:02 +08:00
Cristian Marussi
46af09e694 firmware: arm_scmi: Simplify enable/disable Clock operations
SCMI Clock enable/disable operations come in 2 different flavours which
simply just differ in how the underlying SCMI transactions is carried on:
atomic or not.

Currently we expose such SCMI operations through 2 distinctly named
wrappers, that, in turn, are wrapped into another couple of similarly and
distinctly named callbacks inside SCMI Clock driver user.

Reduce the churn of duplicated wrappers by adding a param to SCMI Clock
enable/disable operations to ask for atomic operation while removing the
_atomic version of such operations.

No functional change.

CC: Michael Turquette <mturquette@baylibre.com>
CC: Stephen Boyd <sboyd@kernel.org>
CC: linux-clk@vger.kernel.org
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20230826125308.462328-2-cristian.marussi@arm.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
2023-11-12 04:37:00 +08:00
Stefan-Gabriel Mirea
942f532800 clk: Add clk support for S32V234
Add clock framework for Treerunner (S32V234), based on code from the i.MX
3.10.17 codebase[1]. Add clock definitions that are used in the clocks
vector (tree). At this point, the only PLL enabled is PERIPH-PLL.

[1] https://source.codeaurora.org/external/imx/linux-imx/tree/?h=imx_3.10.17_1.0.0_ga_caf

Signed-off-by: Stoica Cosmin-Stefan <cosmin.stoica@nxp.com>
Signed-off-by: Larisa Grigore <Larisa.Grigore@nxp.com>
Signed-off-by: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
2023-10-30 15:31:27 +08:00
Shengjiu Wang
e05eb93907 LF-10270-3: clk: imx: clk-audiomix: add shift bits definition
The clock index may different with shift bits index.
So need to add shift bits definition to avoid issue.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
2023-10-30 15:30:39 +08:00
Shengjiu Wang
565d9e8c08 LF-10270-1: clk: imx: clk-audiomix: Fix parent for some clocks
parent clock for earc_phy should be "sai_pll_out_div2"

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
2023-10-30 15:30:38 +08:00
Zhipeng Wang
0831bdd5ef MA-21538-2 clk: imx: clk-imx8qxp: Parent should be initialized earlier than the clock
The initialization order of SCU clocks affects the sequence of SCU clock
resume. If there are no other effects, the earlier the initialization,
the earlier the resume. During SCU clock resume, the clock rate is
restored. As SCFW guidelines, it is imperative to configure the parent
clock rate before configuring the child rate.

Change-Id: Ib475396c86fd8e2f8ee5107ee681dc24fabefb93
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:38 +08:00
Ye Li
9a13cc51c6 LF-9533 clk: imx: clk-composite-7ulp: Check the PCC present bit
When some module is disabled by fuse, its PCC PR bit is default 0 and
PCC is not operational. Any write to this PCC will cause SError.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:38 +08:00
Jacky Bai
6a2b69657e LF-9567 clk: imx: fracn-gppll: update the pll table
Update the pll table for 800MHz config that will be
used by ARM PLL.

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
2023-10-30 15:30:38 +08:00
Jacky Bai
204947744a LF-8692 clk: imx: keep all the root clock on when m4 enabled
when m4 is enabled, we should keep the clock root on by default.

Fixes: f121cca26c ("clk: imx: Rework all clk_hw_register_gate wrappers")
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
2023-10-30 15:30:38 +08:00
Florin Pavelescu
67ffe3ea3c LF-6017: potential integer overflow eliminated by casting to u64
Cast to u64, so that multiplications and additions will be done
in 64-bit arithmetic (and the results will also be 64-bit)
and the possibility of integer overflow is eliminated.

Fix coverity issue: Coverity Issues: 21652353 Unintentional integer overflow
http://coverity1.nxp.com/query/defects.htm?projectId=10289&cid=21652353

Signed-off-by: Florin Pavelescu <florin.pavelescu@nxp.com>
Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
2023-10-30 15:30:38 +08:00
Peng Fan
a1207bd3a4 LF-10009-10 clk: imx: clk-audiomix: remove sdma root clock
There is hardware issue: TKT0535653
SDMA3 can't work without setting AUDIOMIX_CLKEN0[SDMA2] (bit-26) to 1

The workaround is:
As the reset state of AUDIOMIX_CLKEN0[SDMA2] is enabled,
we just need to keep it on as reset state, don't touch it
in kernel, then every thing is same as before, if we register
the clock in clk-audiomix, then kernel will try to disable
it in idle.

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:38 +08:00
Shengjiu Wang
f6186c1727 LF-10009-9 clk: imx: clk-audiomix: pdm should be shared
pdm_ipg_clk and pdm_root_clk should be shared.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:38 +08:00
Shengjiu Wang
6d800d8f2b LF-10009-8 clk: imx: clk-audiomix: add reset controller
add reset controller

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:38 +08:00
Peng Fan
e29d7b605d LF-10009-7 clk: imx: clk-audiomix: enable runtime pm
Follow legacy clk-blk-ctrl driver to enable runtime pm for the new
audiomix clk driver

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:38 +08:00
Oliver F. Brown
6d9059fa40 LF-7981-1: clk: imx: clk-imx8qxp: Add clock muxes for MIPI and PHY ref clocks
The MIPI Pixel and PHY Reference can use the bypass clock as a source. The
MIPI bypass clock is the Pixel clock from the Display controller via the
pixel link. Using the pixel clock for the PHY reference allows the MIPI bit
clock match the pixel rate exactly.

The MIPI pixel clock is currently set to be source from the bypass clock in
the SCFW. This patch allows the pixel clock parent to be set by the kernel
in the event that the SCFW default clock parent may change in the future.

Signed-off-by: Oliver F. Brown <oliver.brown@oss.nxp.com>
Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
2023-10-30 15:30:38 +08:00
Jacky Bai
d6b1767173 LF-8757 clk: imx: Add 1039.5MHz frequency support for imx9 pll
For video pll, it may need to 1039.5MHz clock to fulfill
the LVDS display 148.5MHz * 7 requirement. So add 1039.5MHz
frequency config support for i.MX9 video PLL.

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:38 +08:00
Zhipeng Wang
8daaca8451 MA-19930 clk: imx8mp: fix clock tree update of TF-A managed clocks
On the i.MX8M*, the TF-A exposes a SiP (Silicon Provider) service
for DDR frequency scaling. The imx8m-ddrc-devfreq driver calls the
SiP and then does clk_set_parent on the DDR muxes to synchronize
the clock tree.

Since 936c383673 ("clk: imx: fix composite peripheral flags"),
these TF-A managed muxes have SET_PARENT_GATE set, which results
in imx8m-ddrc-devfreq's clk_set_parent after SiP failing with -EBUSY:

clk_set_parent(dram_apb_src, sys1_pll_40m);(busfreq-imx8mq.c)

This is safe to do, because updating the Linux clock tree to reflect
reality will always be glitch-free.

Since 926bf91248dd12b5f936("clk: imx8m: fix clock tree update of TF-A
managed clocks"), it adds this method and enables 8mm, 8mn and 8mq. I
think 8mp is also needed.

Another reason I added this patch is that powersave image BT music
requires dram to be 400MTS, so clk_set_parent(dram_alt_src,
sys1_pll_800m); is required. Without this patch, it will not succeed.

Change-Id: I4f07573dea4ac9a8a88b04cf795b346299940635
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
2023-10-30 15:30:38 +08:00
Oliver F. Brown
2b3f1739b0 LF-7344: clk: imx: clk-imx8qxp: Move LVDS pixel and phy clocks
In order to fix "MIPI DSI no display after suspend/resume". The LVDS pixel
and phy clocks must be initialized before the MIPI tx_esacpe and rx_escape
clocks. LVDS phy, LVDS pixel, tx_escape, and rx_esacpe are all on the same
MSLICE. They all share the same clock parent. So, setting the parent source
or rate affects all of these clocks. In the LVDS use case the MIPI tx_escape
and rx_escape are not saved and restored. So, LVDS works for either clock
initialization order. For MIPI case, LVDS must be initialized first.

This patch can be squashed into "LF-7054-1: clk: imx: clk-imx8qxp: Add LVDS
bypass clocks" which should not have changed the initialization order.

Signed-off-by: Oliver F. Brown <oliver.brown@oss.nxp.com>
Reviewed-by: Liu Ying <victor.liu@nxp.com>
2023-10-30 15:30:37 +08:00
Ranjani Vaidyanathan
439aab2acc LF-7054-1: clk: imx: clk-imx8qxp: Add LVDS bypass clocks
For iMX8QXP and iMX8QM, add bypass clocks and register some of the LVDS clocks
with imx_clk_scu2 as the parent needs to explicitly set.

Signed-off-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
Signed-off-by: Oliver F. Brown <oliver.brown@oss.nxp.com>
2023-10-30 15:30:37 +08:00
Jacky Bai
1158de0077 LF-6840 clk: imx: Add some delay before deassert the reset
Some of the PCCs on i.MX8ULP have a sw_rst bit to control
the peripheral reset through SW method. For peripherals like GPU
that need sync reset, some delay is necessary befere & after release
the reset to make sure the HW is reset into known status. So add
some delay before & after release reset.

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:37 +08:00
Shenwei Wang
af86b40c25 LF-6101: clk: imx: clk-imx8qxp: correct the enet clocks for imx8dxl
The SC_PM_CLK_MISC0 clock is not available for the resources of ENET0/1 on
imx8dxl. Using the clock device compatible string to identify the platform
and only initiate the enetX_rgmii_rx_clk clock for non imx8dxl platform.

Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
Reviewed-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
2023-10-30 15:30:37 +08:00
Alice Guo
ae6bcbb377 MLK-25931-1 clk: imx93: add imx_clk_init_on()
When we support dual Linux with jailhouse, it relys on the first Linux
to configure the clock used by the second Linux because there is no
clock controller in the inmate cell.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Alice Guo <alice.guo@nxp.com>
(cherry picked from commit 7762a36d33)
2023-10-30 15:30:37 +08:00
Peng Fan
822b932f12 LF-6723-9 clk: imx93: add clk ignore unused flag for usb/enet
This is a workaround to make
 - usb resume when suspend/resume,
 - enet work proper
after the device tree and driver update to handle the clocks,
this patch could be dropped.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
(cherry picked from commit 5afce040ac)
2023-10-30 15:30:37 +08:00
Viorel Suman
7dfc379234 clk: imx8dxl: rsrc: keep sorted in the ascending order
Entries in imx8dxl_clk_scu_rsrc_table must be kept in the ascending
order, and IMX_SC_R_M4_0_UART < IMX_SC_R_M4_0_I2C.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
2023-10-30 15:30:37 +08:00
Abel Vesa
8779e515fa clk: imx: Add imx_dev_clk_hw_gate_shared to be used by clk-blk-ctl
The imx_dev_clk_hw_gate_shared passes on the dev, but also uses
one bit for control. So lets use cgr_val for both mask and control
bits in __imx_clk_hw_gate2. This will not impact the other wrappers
since they always pass cgr_val 0x3.

Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
2023-10-30 15:30:37 +08:00
Abel Vesa
218cb9804e clk: imx: Pass dev to __imx_clk_hw_gate2
The clk-blk-ctl clock driver needs to pass the dev to
clk_hw_register_gate2.

Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
2023-10-30 15:30:37 +08:00
Shenwei Wang
bda5e99a32 MLK-25302: clk: imx8qxp: whitelist M4 lpuart
Add m4 lpuart0 to the array of imx8qxp_clk_scu_rsrc_table.

Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
2023-10-30 15:30:37 +08:00
Robert Chiras
efc17c7583 LF-4020: clk: imx8qxp: Fix elcdif_pll clock
Move the elcdif_pll clock initialization before the lcd_clk, since the
elcdif_clk needs to be initialized ahead of lcd_clk, being its parent.
This change fixes issues with the LCD clocks during suspend/resume.

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
Suggested-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
Acked-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2023-10-30 15:30:37 +08:00
Jacky Bai
dc82a432ce MLK-25558-04 clk: imx: Add the pcc reset controller support on imx8ulp
On i.MX8ULP, for some of the PCCs, it has a peripheral SW RST bit
resides in the same registers as the clock controller. So add this
SW RST controller support alongs with the pcc clock initialization.

the reset and clock shared the same register, to avoid  accessing
the same register by reset control and clock control concurrently,
locking is necessary, so reuse the imx_ccm_lock spinlock to simplify
the code.

Suggested-by: Liu Ying <victor.liu@nxp.com>
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Robin Gong <yibin.gong@nxp.com>
2023-10-30 15:30:37 +08:00
Richard Zhu
099619456b LF-3464 clk: imx6q: specify the rate of eim_slow clock
Specify the clock rate of EIM_SLOW clock.
During the kernel updates, some codes of the following two commits are
missing. Re-collect them here again.

commit e01216753ee1 ("MLK-11602 arm: imx: set imx6qdl eim_slow clk to 135Mhz")
commit dc4d6e04f02a ("MLK-12013 arm: imx: set eim_slow clk to 132Mhz only for MXC_CPU_IMX6Q")

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
Reviewed-by: Jun Li <jun.li@nxp.com>
2023-10-30 15:30:36 +08:00
Fancy Fang
9e69c8434d LF-3090-2 clk: imx7d: add 'CLK_SET_RATE_PARENT' for 'lcdif_pixel_src'
Add flag 'CLK_SET_RATE_PARENT' to 'IMX7D_LCDIF_PIXEL_ROOT_SRC' to
propagate rate changes from LCDIF pixel clock to video PLL which
can provide more accurate clock rate for LCDIF pixel clock.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:30:36 +08:00
Jacky Bai
b132e4d9ba MLK-24980 clk: imx8mp: Add audio pll debug monitor on imx8mp
this support is similar as i.MX8MM.

   for userspace monitor control of the K-divider dynamically,
    we provide two interfaces to userspace: delta_k & pll_parameter

    1): delta_k is used to adjust the K divider in PLL based on small
        steps;
    2): the pll_parameter interface is used for get PLL's current
        M-divider, P-divider, S-divider & K-divider setting in PLL register

    example for the usage of these two interfaces:
    A): Get the current PLL setting of dividers:
            root@imx8mmevk:~# cat /sys/kernel/debug/audio_pll_monitor/audio_pll1/pll_parameter
            Mdiv: 0x106; Pdiv: 0x2; Sdiv: 0x3; Kdiv: 0x24dd

    B): if want to adjust the K-divider by a delta_k '1', then
            echo 0x1 > /sys/kernel/debug/audio_pll_monitor/audio_pll1/delta_k;

            root@imx8mmevk:~# cat /sys/kernel/debug/audio_pll_monitor/audio_pll1/pll_parameter
            Mdiv: 0x106; Pdiv: 0x2; Sdiv: 0x3; Kdiv: 0x24de

    C): if want to adjust the K-divider by a delta_k '-1', then
            echo -1 > /sys/kernel/debug/audio_pll_monitor/audio_pll1/delta_k;

            root@imx8mmevk:~# cat /sys/kernel/debug/audio_pll_monitor/audio_pll1/pll_parameter
            Mdiv: 0x106; Pdiv: 0x2; Sdiv: 0x3; Kdiv: 0x24dc

Squashed: LF-3016-1 clk: imx8mp: check hws in pll_debug_init

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Tested-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Anson Huang <anson.huang@nxp.com>
Reviewed-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:36 +08:00
Anson Huang
13a314c5f0 LF-2803 clk: imx7d: Remove CLK_SET_PARENT_GATE for DRAM mux
For i.MX7D DRAM related mux clock, the clock source change is ONLY done
in busfreq low level asm code, and then calling clk API to sync the HW
clock status with clk tree, it never touches real clock source switch
via clk API, so CLK_SET_PARENT_GATE flag should NOT be added, otherwise,
DRAM's clock parent will be disabled when DRAM is active after audio
bus clock change, and system will hang.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
2023-10-30 15:30:36 +08:00
Clark Wang
b41ed090e4 LF-2594-3 clk: imx8: remove MLB support
Remove all MLB clock setting for imx8qm/qxp.

Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
2023-10-30 15:30:36 +08:00
Jacky Bai
f2a9d6d7ae MLK-23751 clk: imx: Add audio PLL debug fs for K-divider monitor control
for userspace monitor control of the K-divider dynamically,
we provide two interfaces to userspace: delta_k & pll_parameter

1): delta_k is used to adjust the K divider in PLL based on small
    steps;
2): the pll_parameter interface is used for get PLL's current
    M-divider, P-divider, S-divider & K-divider setting in PLL register

example for the usage of these two interfaces:
A): Get the current PLL setting of dividers:
	root@imx8mmevk:~# cat /sys/kernel/debug/audio_pll_monitor/audio_pll1/pll_parameter
	Mdiv: 0x106; Pdiv: 0x2; Sdiv: 0x3; Kdiv: 0x24dd

B): if want to adjust the K-divider by a delta_k '1', then
	echo 0x1 > /sys/kernel/debug/audio_pll_monitor/audio_pll1/delta_k;

	root@imx8mmevk:~# cat /sys/kernel/debug/audio_pll_monitor/audio_pll1/pll_parameter
	Mdiv: 0x106; Pdiv: 0x2; Sdiv: 0x3; Kdiv: 0x24de

C): if want to adjust the K-divider by a delta_k '-1', then
	echo -1 > /sys/kernel/debug/audio_pll_monitor/audio_pll1/delta_k;

	root@imx8mmevk:~# cat /sys/kernel/debug/audio_pll_monitor/audio_pll1/pll_parameter
	Mdiv: 0x106; Pdiv: 0x2; Sdiv: 0x3; Kdiv: 0x24dc

Squashed:
LF-2587 clk: imx8mm: check hws before using it
MA-19046 clk: imx8mm: Support building clk-imx8mm driver as module

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Alice Guo <alice.guo@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
2023-10-30 15:30:36 +08:00
Jacky Bai
f8b717aae8 LF-2366 clk: imx: Add m4 enable check for imx8mp
Check if Cortex-M is enabled to make sure the root
clocks used by M4 are on by default.

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:36 +08:00
Adrian Alonso
c8b14616e8 MLK-24334: clk: imx8mn: add sai7_ipg_clk clock settings
Add sai7_ipg_clk clock settings, fixes use of SAI7
interface on imx8mn SoC.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Adrian Alonso <adrian.alonso@nxp.com>
2023-10-30 15:30:36 +08:00
Guoniu.zhou
0394c688a9 MLK-23315-1: clk: imx8qxp: add clocks for i2c controller of CI_PI ss
Add clocks for i2c controller of CI_PI subsystem

Squashed: MLK-23698: clk: imx: correct clock order for CI_PI subsystem

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:36 +08:00
Shengjiu Wang
ccd493b713 clk: imx: Add imx_dev_clk_mux interface
Add imx_dev_clk_mux interface that allow attach device to
clk mux.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
2023-10-30 15:30:36 +08:00
Robin Gong
c6637c50b9 LF-857-2: clk: imx: clk-pllv3: remove usleep()
Remove usleep_range in case m4 enabled on i.mx6sx since usleep is not
permitted before imx_sema4_mutex_unlock now.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Anson Huang <anson.huang@nxp.com>
[ Aisheng : change to readl_relaxed_poll_timeout_atomic ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:35 +08:00
Shengjiu Wang
03f5ce34f1 MLK-14679-1: ARM: clk: spdif clock rate is too high for asrc
spdif clock is one of the asrc clock source, which is used
for ideal ratio mode. when set to 98.304MHz, it cause the
divider of asrc input clock and output clock exceed the
maximum value, and asrc driver saturate the value to maximum
value, which will cause the ASRC's performance very bad.
So we need to set spdif clock to a proper rate. which make asrc
divider not exceed maximum value, at least one of divider not
exceed maximum value.
The target is spdif clock rate / output(or input) sample rate
less than 1024(which is maximum divider).

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
2023-10-30 15:30:35 +08:00
Jacky Bai
067afc2451 clk: imx: Add m4 enable check for imx8mn
Check if M4 is enabled to make sure the root
clocks used by M4 are on by default.

Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
2023-10-30 15:30:35 +08:00
Jacky Bai
45063ca7ef clk: imx8mm: Change the 'nand_usdhc_bus' clock to non-critical one
The 'nand_usdhc_bus' clock is only need to be enabled when usdhc
or nand module is active, so change it to non-critical clock type.

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
2023-10-30 15:30:35 +08:00
Peng Fan
4fc5ce9bc1 clk: imx8mm/mn/mq: add imx_clk_init_on
When we need to support dual linux with jailhouse, there is no clock
controller in 2nd inmate linux cell, it relys on the first linux to
configure the clock ready and on. So we add those clocks required for
the 2nd linux in dts to make them prepare enabled, and pass
clk_ignore_unused to the 1st linux, then the 1st linux will not gated
off the clocks. So the 2nd linux could use IPs without touching clocks.

Squashed:
LF-1011-6 clk: imx: imx8mm: fix imx_clk_init_on
LF-1011-7 clk: imx: imx8mn: fix imx_clk_init_on
LF-1011-8 clk: imx: imx8mq: fix imx_clk_init_on
LF-1162-3: clk: imx: imx8mm: add back required clk.h headfile
LF-1162-6: clk: imx: imx8mq: add back required clk.h headfile
LF-1162-5: clk: imx: imx8mm: add back required clk.h headfile
LF-1808 clk: imx: imx8m: fix memory leak
LF-2601 clk: imx8mp: add missed imx_clk_init_on()
LF-4521-01 clk: imx: Fix section mismatch build warning due to __init
MA-17597 clk: imx8mp: remove __init in imx_clk_init_on

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Alice Guo <alice.guo@nxp.com>
Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
2023-10-30 15:30:35 +08:00
Robby Cai
33e05a055e clock: imx8mq: change csi's parent clock to get desired value
change csi's parent clock to get desired value

Squashed: LF-1011-11 clk: imx8mq: convert the remain clocks to clk_hw

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:35 +08:00
Robby Cai
0f6031bcaf clk: imx8mm: adjust csi's parent clock to get desired value
adjust csi's parent clock to get desired value

Squashed: LF-1011-9 clk: imx8mm: convert the remain clocks to clk_hw

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:35 +08:00
Shengjiu Wang
10a2bfead3 clk: imx8mn: Set AUDIO_AHB and IPG_AUDIO_ROOT to 400MHz
Set AUDIO_AHB and IPG_AUDIO_ROOT to 400MHz

Squashed: LF-1011-10 clk: imx8mn: convert the remain clocks to clk_hw

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:35 +08:00
Jacky Bai
27adfdbd25 clk: imx: unbypass all the plls by default on imx8mq
Unbypass all the PLLs by default on i.MX8MQ.

Squashed: LF-1011-11 clk: imx8mq: convert the remain clocks to clk_hw

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:35 +08:00
Robby Cai
e3358eb71d clk: imx6sl: configure epdc clock to get desired value
configure epdc clock to get desired value

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:30:35 +08:00
Jacky Bai
9de756994c clk: imx: update the audio pll rate table on imx8mm
Audio PLL is a frac pll, the config for this PLL should follow
below limitation:
    Fout = ((m + k / 65536) * FIN) / (p * 2^s),
    Fvco = ((m + k / 65536) * FIN) / p
    Fref = FIN / p

    a). 6MHz <= Fref <= 25MHz;
    b). 1 <= p <= 63;
    c). 64 <= m <= 1023;
    d). 0 <= s <= 6;
    e). -32768 <= k <= 32767;

due to the frac part calculation deviation, frac pll 'recalc_rate'
is updated to look up the pll rate from table first.

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
2023-10-30 15:30:35 +08:00
Robby Cai
3a0f6a987f clk: imx6sll: configure epdc clock to get desired value
configure epdc clock to get desired value

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:30:35 +08:00
Liu Ying
3c1c98600b clk: imx6q: Forward some IPUv3 and LDB clock changes from imx_4.19.y kernel
This patch forwards some IPUv3 and LDB clock changes from imx_4.19.y kernel,
as needed to enable internal IPUv3 fb and LVDS displays.

Signed-off-by: Liu Ying <victor.liu@nxp.com>
2023-10-30 15:30:35 +08:00
Robby Cai
ca084f4e9e clk: imx7d: set PLL_SYS_MAIN as parent clock of epdc pixel clock
set PLL_SYS_MAIN as EPDC pixel_clock's parent clock to get desired clock

Signed-off-by: Robby Cai <robby.cai@nxp.com>
2023-10-30 15:30:34 +08:00
Robby Cai
33e935ee79 clk: imx7d: add pxp ipg clock and axi clock
add pxp ipg/axi clock on imx7d

Squashed: LF-1197-1 clk: imx: remove the unused IMX7D_PXP_CLK definition

Signed-off-by: Robby Cai <robby.cai@nxp.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:34 +08:00
Anson Huang
dffe462122 clk: imx8qxp: Remove gpt0_clk to avoid warning during kernel boot up
The gpt0 is assigned to ATF previously due to LPCG, context
save/restore etc. for cpu-idle feature, remove gpt0_clk to
avoid below warning during kernel boot up, if gpt0 is going
to be used in future, need to remove corresponding operations
in ATF and add it back in kernel.

[    0.291286]  gpt0: failed to power up resource 207 ret -13
[    0.291355] imx-scu-clk: probe of gpt0_clk failed with error -5

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
2023-10-30 15:30:34 +08:00
Joakim Zhang
f210bcbc3d clk: imx8qm: add clock for CAN1/2
Add clock for CAN1/2 on imx8qm.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
2023-10-30 15:30:34 +08:00
Richard Zhu
791351a2c8 clk: imx8m: make a check the m4 is enabled or not
Make a check that the M4 is enabled or not.
Otherwise, the clocks of the M4 maybe turned off later.

The UART clock used by M4 maybe turned off by Linux side, after the
initialization of the clocks. Enable the UART2 clock when M4 is enabled.

Squashed: clk: imx7d: enable uart2 clock when m4 is enabled

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2023-10-30 15:30:34 +08:00
Jacky Bai
de712e2af2 clk: imx: Add uart from osc support on imx6ul/ull
Add 'uart_from_osc' support on i.MX6UL/ULL.

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
[ Aisheng: update to CLK HW APIs ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:34 +08:00
Anson Huang
d99a6e3b60 clk: imx7d: add A7-M4 AMP power management support
When M4 is active, Linux needs to take care of the power management
considering M4 status, this patch adds runtime check for clock
management for M4 active case.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
[ Aisheng: update to CLK HW APIs ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:34 +08:00
Anson Huang
d703591065 clk: imx6sx: add AMP clock management support
i.MX6SX has A9 and M4 inside, they can run independently,
this patch adds shared clock management for AMP system.

Squashed: clk: imx: remove use of ioremap_nocache()

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
[ Aisheng: update to CLK HW APIs ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
2023-10-30 15:30:34 +08:00
Anson Huang
aefc00e00d clk: imx6sx: support low power idle
Add uart_from_osc bootargs and change PLL1 bypass clock
to fix clock to support low power idle

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
2023-10-30 15:30:34 +08:00
Anson Huang
52ce709da8 clk: imx6sx: support suspend/resume with FastMix off
Add M4 related APIs for suspend/resume support, and make
MMDC P1 IPG clock always ON, as it is required during resume
with FastMix OFF.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
[ Aisheng: update to CLK HW APIs and add FIXME]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:34 +08:00
Anson Huang
65ba28acc9 clk: imx6sx: keep OCRAM_S always ON
OCRAM_S is used as iram tlb table for low power modes, clock
needs to be always ON.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
[ Aisheng: update to CLK HW APIs ]
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:34 +08:00
Dong Aisheng
d3b0c8e713 clk: imx: imx8qxp: support LPCG bit-offset instead of clock-indice
Back to support LPCG bit-offset property instead of clock indice.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:33 +08:00
Peng Fan
3440db800d LF-446 clk: imx: lpcg-scu: SW workaround for errata (e10858)
Back-to-back LPCG writes can be ignored by the LPCG register due to
a HW bug. The writes need to be seperated by at least 4 cycles of
the gated clock.

The workaround is implemented as follows:
1. For clocks running greater than or equal to 24MHz, a read
followed by the write will provide sufficient delay.
2. For clocks running below 24MHz, add a delay of 4 clock cylces
after the write to the LPCG register.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:33 +08:00
Anson Huang
5bddf093d2 clk: imx: Skip HDMI LPCG clock save/restore
On i.MX8QM, HDMI LPCG clocks operation needs SCU clock "hdmi_ipg_clk"
to be ON, while during noirq suspend phase, "hdmi_ipg_clk" is disabled
by HDMI IRQ STEER driver, so SError will be triggered.

Skip all HDMI LPCG clocks save/restore to avoid this SError during
system suspend/resume, it will NOT introduce additional power consumption
as their parent clock is disabled when suspend.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
2023-10-30 15:30:33 +08:00
Dong Aisheng
037abf1d72 clk: imx: scu: remove legacy lpcg clock binding support
remove legacy lpcg clock binding support to avoid confusing

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
2023-10-30 15:30:33 +08:00
Peng Fan
35bb1cd50f MLK-23960-1 clk: imx: scu: not attach pd for UART_0 in xen dom0
Since linux itself create clk scu devices which is not available
to xen, xen not able to disable this device.

However UART_0 device has been occupied by xen.

So avoid runtime pd disable this power domain, ignore it for xen dom0.

Otherwise system will hang.

Acked-by: Alice Guo <alice.guo@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
2023-10-30 15:30:33 +08:00
Peng Fan
544fe95967 LF-202-3 clk: imx: scu: ignore clks not owned
Not register clks that not owned to current partition.

Squashed: LF-279 clk: imx: scu: ignore cpu resources when do owned check

CPU resources are specical resources, it is assigned in ATF, not
non-secure OS, but we still need to allow cpu freq, so return
true for non-secure OS for cpu resources.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Tested-by: Anson Huang <anson.huang@nxp.com>
Reviewed-by: Leonard Crestez <leonard.crestez@nxp.com>
2023-10-30 15:30:33 +08:00
Linus Torvalds
67d4c87945 Three fixes, one for the clk framework and two for clk drivers:
- Avoid an oops in possible_parent_show() by checking for no parent
    properly when a DT index based lookup is used
  - Handle errors returned from divider_ro_round_rate() in
    clk_stm32_composite_determine_rate()
  - Fix clk_ops::determine_rate() implementation of socfpga's gateclk_ops
    that was ruining uart output because the divider was forgotten about
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEE9L57QeeUxqYDyoaDrQKIl8bklSUFAmU8aqARHHNib3lkQGtl
 cm5lbC5vcmcACgkQrQKIl8bklSV9Ew/+LbRC35Dp9liQnF/kpggdfvr1QKDP+bWz
 m6Kp9+ZQ6xWcVDV+0Fjbrs/0+QB5R8PS9U/GIQTGcMce0QJwoOnK2eWf22h1H59i
 h6nHAUBuDURAotPOIITKn/1McLkznvW+6XUOJ/yBFCsjlqspYlnR222RXOqZrhH1
 k/p1LE0dCXeiR07oJSoCsfVA5+ZzoFMRhpijoqjqOwMraMcX34CY3adOdM0WDvvH
 j10+9L0Bg5I/Y2NrP5ZfO2zmVVDFRrXuEfB6FlB54o9UDFLydCv6M96S1G4jmFcE
 s51mhoVhnxM+DG2Z9DNivPM5e8s1Q3yzvZko045kl86PqNwPw+LiezXwPSGcckKq
 5eD6+08yKXgDlHzvCj5/hXO3X/1+HthdxCXXim4/oe+1PYn0tm3gYbyJ/RNMbHRP
 x7fYslZXB0rIOV5owO2UfYWqZ3SGpxe+WHdEOnfxyePmx4tVPEccNGDyV4BFBDBE
 hUrDrnoJBT6rKFYyvt7V0s5y11tdNOA0/TrzkZuwXNPDWeBLGGpEm0iHcBakrGjP
 TWHgFYYdABxwIgcB6aMvzfj1n3vETQKWpCd0nBI73RKz+ZP9ZmVTThSe17yCSjoj
 PhozYiv09gZ0ZfJWj6WHj/roJKErkM+Vk+9aC6dM8N3/CyJ5GofXUSf9lrquqBoy
 /BFyI4siNO4=
 =Hghf
 -----END PGP SIGNATURE-----

Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux

Pull clk fixes from Stephen Boyd:
 "Three fixes, one for the clk framework and two for clk drivers:

   - Avoid an oops in possible_parent_show() by checking for no parent
     properly when a DT index based lookup is used

   - Handle errors returned from divider_ro_round_rate() in
     clk_stm32_composite_determine_rate()

   - Fix clk_ops::determine_rate() implementation of socfpga's
     gateclk_ops that was ruining uart output because the divider
     was forgotten about"

* tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
  clk: stm32: Fix a signedness issue in clk_stm32_composite_determine_rate()
  clk: Sanitize possible_parent_show to Handle Return Value of of_clk_get_parent_name
  clk: socfpga: gate: Account for the divider in determine_rate
2023-10-27 16:52:51 -10:00