linux.git
7 years agoMerge branches 'clk-spreadtrum', 'clk-mvebu-dvfs', 'clk-qoriq', 'clk-imx' and 'clk...
Stephen Boyd [Sat, 27 Jan 2018 00:41:47 +0000 (16:41 -0800)]
Merge branches 'clk-spreadtrum', 'clk-mvebu-dvfs', 'clk-qoriq', 'clk-imx' and 'clk-qcom-ipq8074' into clk-next

* clk-spreadtrum:
  clk: sprd: add clocks support for SC9860
  clk: sprd: Add dt-bindings include file for SC9860
  dt-bindings: Add Spreadtrum clock binding documentation
  clk: sprd: add adjustable pll support
  clk: sprd: add composite clock support
  clk: sprd: add divider clock support
  clk: sprd: add mux clock support
  clk: sprd: add gate clock support
  clk: sprd: Add common infrastructure
  clk: move clock common macros out from vendor directories

* clk-mvebu-dvfs:
  clk: mvebu: armada-37xx-periph: add DVFS support for cpu clocks
  clk: mvebu: armada-37xx-periph: prepare cpu clk to be used with DVFS
  clk: mvebu: armada-37xx-periph: cosmetic changes

* clk-qoriq:
  clk: qoriq: add more divider clocks support

* clk-imx:
  clk: imx51: uart4, uart5 gates only exist on imx50, imx53

* clk-qcom-ipq8074:
  clk: qcom: ipq8074: add misc resets for PCIE and NSS
  dt-bindings: clock: qcom: add misc resets for PCIE and NSS
  clk: qcom: ipq8074: add GP and Crypto clocks
  clk: qcom: ipq8074: add NSS ethernet port clocks
  clk: qcom: ipq8074: add NSS clocks
  clk: qcom: ipq8074: add PCIE, USB and SDCC clocks
  clk: qcom: ipq8074: add remaining PLL’s
  dt-bindings: clock: qcom: add remaining clocks for IPQ8074
  clk: qcom: ipq8074: fix missing GPLL0 divider width
  clk: qcom: add parent map for regmap mux
  clk: qcom: add read-only divider operations

7 years agoMerge branches 'clk-qcom-alpha-pll', 'clk-check-ops-ptr', 'clk-protect-rate' and...
Stephen Boyd [Sat, 27 Jan 2018 00:41:39 +0000 (16:41 -0800)]
Merge branches 'clk-qcom-alpha-pll', 'clk-check-ops-ptr', 'clk-protect-rate' and 'clk-omap' into clk-next

* clk-qcom-alpha-pll:
  clk: qcom: add read-only alpha pll post divider operations
  clk: qcom: support for 2 bit PLL post divider
  clk: qcom: support Brammo type Alpha PLL
  clk: qcom: support Huayra type Alpha PLL
  clk: qcom: support for dynamic updating the PLL
  clk: qcom: support for alpha mode configuration
  clk: qcom: flag for 64 bit CONFIG_CTL
  clk: qcom: fix 16 bit alpha support calculation
  clk: qcom: support for alpha pll properties

* clk-check-ops-ptr:
  clk: check ops pointer on clock register

* clk-protect-rate:
  clk: fix set_rate_range when current rate is out of range
  clk: add clk_rate_exclusive api
  clk: cosmetic changes to clk_summary debugfs entry
  clk: add clock protection mechanism to clk core
  clk: use round rate to bail out early in set_rate
  clk: rework calls to round and determine rate callbacks
  clk: add clk_core_set_phase_nolock function
  clk: take the prepare lock out of clk_core_set_parent
  clk: fix incorrect usage of ENOSYS

* clk-omap:
  clk: ti: Drop legacy clk-3xxx-legacy code

7 years agoclk: qcom: ipq8074: add misc resets for PCIE and NSS
Abhishek Sahu [Wed, 13 Dec 2017 14:25:42 +0000 (19:55 +0530)]
clk: qcom: ipq8074: add misc resets for PCIE and NSS

PCIE and NSS has MISC reset register in which single register has
multiple reset bit. The patch adds these resets with its
corresponding reset bits.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agodt-bindings: clock: qcom: add misc resets for PCIE and NSS
Abhishek Sahu [Wed, 13 Dec 2017 14:25:41 +0000 (19:55 +0530)]
dt-bindings: clock: qcom: add misc resets for PCIE and NSS

PCIE and NSS has MISC reset register in which single register has
multiple reset bit. The patch adds the DT bindings for these MISC
resets.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: ipq8074: add GP and Crypto clocks
Abhishek Sahu [Wed, 13 Dec 2017 14:25:40 +0000 (19:55 +0530)]
clk: qcom: ipq8074: add GP and Crypto clocks

- It has 3 general purpose clock controller which supplies
  the clock in GPIO pins.
- It has Crypto Engine which has AXI, AHB and Core clocks.
  Other non APSS processors can also use Crypto Engine so
  these clocks are marked as VOTED clocks.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: ipq8074: add NSS ethernet port clocks
Abhishek Sahu [Wed, 13 Dec 2017 14:25:39 +0000 (19:55 +0530)]
clk: qcom: ipq8074: add NSS ethernet port clocks

IPQ8074 has 6 ethernet ports which supports all ethernet speeds
from 10Mpbs to 10 Gpbs and each speed requires different clock
rates. Each port has separate TX and RX clocks. These clocks
use separate external UNIPHY PLL’s which will be registered with
separate NSS driver. The clock frequency is 125 Mhz for UNIPHY0
and 312.5 Mhz for UNIPHY1 and UNIPHY2.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: ipq8074: add NSS clocks
Abhishek Sahu [Wed, 13 Dec 2017 14:25:38 +0000 (19:55 +0530)]
clk: qcom: ipq8074: add NSS clocks

IPQ8074 has NSS (Network Switching System) which has 2 UBI cores
and hardware crypto engine. Some clocks are separate for each UBI
core and remaining NSS clocks are common. The BIAS_PLL (300 Mhz)
and BIAS_PLL_NSS_NOC (416.5 Mhz) are external fixed clocks and
will be registered from dtsi or NSS driver.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: ipq8074: add PCIE, USB and SDCC clocks
Abhishek Sahu [Wed, 13 Dec 2017 14:25:37 +0000 (19:55 +0530)]
clk: qcom: ipq8074: add PCIE, USB and SDCC clocks

- It has 2 instances of PCIE which uses AXI, AHB, AUX, SYS NOC
  AXI and PIPE clocks.
- It has 2 instances of USB 3.0 which uses AUX, SLEEP, PIPE,
  SYS NOC, mock UTMI and master clocks.
- It has 2 instances of SDCC which uses APSS and AHB clock.
  SDCC1 requires ICE core clock also.
- All the PIPE clocks are external clocks which will be
  registered in clock framework by PHY drivers. The enabling
  and disabling of PIPE RCG clocks are dependent upon PHY
  initialization sequence so BRANCH_HALT_DELAY flag is required for
  these clocks.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: ipq8074: add remaining PLL’s
Abhishek Sahu [Wed, 13 Dec 2017 14:25:36 +0000 (19:55 +0530)]
clk: qcom: ipq8074: add remaining PLL’s

- GPLL2, GPLL4 and GPLL6 are general PLL clocks and parent
  for all core peripherals.
- UBI PLL is mainly used by NSS (Network Switching System).
  IPQ8074 has 2 instances of NSS UBI cores and UBI PLL will
  be used to control the core frequency.
- NSS Crypto PLL is mainly used by NSS Crypto Engine which
  supports the multiple cryptographic algorithm used in
  Ethernet.
- IPQ8074 frequency plan does not require change in PLL post
  dividers so marked the same as read-only.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agodt-bindings: clock: qcom: add remaining clocks for IPQ8074
Abhishek Sahu [Wed, 13 Dec 2017 14:25:35 +0000 (19:55 +0530)]
dt-bindings: clock: qcom: add remaining clocks for IPQ8074

This patch adds the DT bindings for following IPQ8074 clocks

 - General PLL’s, NSS UBI PLL and NSS Crypto PLL.
 - 2 instances of PCIE, USB, SDCC.
 - 2 NSS UBI core and common NSS clocks. NSS is network switching
   system which accelerates the ethernet traffic. IPQ8074
   NSS has two UBI cores. Some clocks are separate for each UBI core
   and remaining NSS clocks are common.
 - NSS ethernet port clocks. IPQ8074 has 6 ethernet ports and
   each port uses different TX and RX clocks.
 - Crypto engine clocks.
 - General purpose clocks which comes over GPIO.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: ipq8074: fix missing GPLL0 divider width
Abhishek Sahu [Wed, 13 Dec 2017 14:25:34 +0000 (19:55 +0530)]
clk: qcom: ipq8074: fix missing GPLL0 divider width

GPLL0 uses 4 bits post divider which should be specified
in clock driver structure.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: add parent map for regmap mux
Abhishek Sahu [Wed, 13 Dec 2017 14:25:33 +0000 (19:55 +0530)]
clk: qcom: add parent map for regmap mux

Currently the driver assumes the register configuration value
is identical to its index in the parent map. This patch adds
the parent map field in regmap mux clock node which contains
the mapping of parent index with actual register configuration
value. If regmap node contains this parent map then the
configuration value will be taken from this
parent map instead of simply writing the index value.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: add read-only divider operations
Abhishek Sahu [Wed, 13 Dec 2017 14:25:32 +0000 (19:55 +0530)]
clk: qcom: add read-only divider operations

Some of the divider settings are preconfigured and should not
be changed by the clock framework during frequency change. This
patch adds the read-only divider operation for QCOM dividers
which is equivalent to generic divider operations in
'commit 79c6ab509558 ("clk: divider: add CLK_DIVIDER_READ_ONLY flag")'.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: imx51: uart4, uart5 gates only exist on imx50, imx53
Philipp Zabel [Wed, 13 Dec 2017 11:57:48 +0000 (12:57 +0100)]
clk: imx51: uart4, uart5 gates only exist on imx50, imx53

i.MX51 only has 3 UARTs and no CCGR7 register. In place of the CCGR7
register on i.MX50/i.MX53 that contains the ipg and per clock gates
for UARTs 4 and 5, on i.MX51 there is the CMEOR register.

Without this patch, the code disabling the UART clocks would also clear
the mod_en_ov_vpu bit in the CMEOR register, among others, which causes
register accesses to the VPU to lock up the system.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qoriq: add more divider clocks support
Yuantian Tang [Wed, 22 Nov 2017 01:40:53 +0000 (09:40 +0800)]
clk: qoriq: add more divider clocks support

More divider clocks are needed by IP. So enlarge the PLL divider
array to accommodate more divider clocks.

Signed-off-by: Tang Yuantian <andy.tang@nxp.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: mvebu: armada-37xx-periph: add DVFS support for cpu clocks
Gregory CLEMENT [Thu, 30 Nov 2017 13:40:29 +0000 (14:40 +0100)]
clk: mvebu: armada-37xx-periph: add DVFS support for cpu clocks

When DVFS is enabled the CPU clock setting is done using an other set of
registers.

These Power Management registers are exposed through a syscon as they
will also be used by other drivers such as the cpufreq.

This patch add the possibility to modify the CPU frequency using the
associate load level matching the target frequency. Then all the
frequency switch is handle by the hardware.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
[sboyd@codeaurora.org: Grow a local variable for regmap pointer
to keep lines shorter]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: mvebu: armada-37xx-periph: prepare cpu clk to be used with DVFS
Gregory CLEMENT [Thu, 30 Nov 2017 13:40:28 +0000 (14:40 +0100)]
clk: mvebu: armada-37xx-periph: prepare cpu clk to be used with DVFS

When DVFS will be enabled then the cpu clk will use a different set of
register at run time. That means that we won't be able to use the common
callback and need to use our own ones.

This patch prepares this change by switching on our own set of callbacks
without modifying the behavior of the clocks.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: mvebu: armada-37xx-periph: cosmetic changes
Gregory CLEMENT [Thu, 30 Nov 2017 13:40:27 +0000 (14:40 +0100)]
clk: mvebu: armada-37xx-periph: cosmetic changes

This patches fixes few cosmetic issues such as alignment, blank lines
and required space.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: sprd: add clocks support for SC9860
Chunyan Zhang [Thu, 7 Dec 2017 12:57:13 +0000 (20:57 +0800)]
clk: sprd: add clocks support for SC9860

This patch added the list of clocks for Spreadtrum's SC9860 SoC,
together with clock initialization code.

Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: sprd: Add dt-bindings include file for SC9860
Chunyan Zhang [Thu, 7 Dec 2017 12:57:12 +0000 (20:57 +0800)]
clk: sprd: Add dt-bindings include file for SC9860

This file defines all SC9860 clock indexes, it should be included in the
device tree in which there's device using the clocks.

Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agodt-bindings: Add Spreadtrum clock binding documentation
Chunyan Zhang [Thu, 7 Dec 2017 12:57:11 +0000 (20:57 +0800)]
dt-bindings: Add Spreadtrum clock binding documentation

Introduce a new binding with its documentation for Spreadtrum clock
sub-framework.

Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: sprd: add adjustable pll support
Chunyan Zhang [Thu, 7 Dec 2017 12:57:10 +0000 (20:57 +0800)]
clk: sprd: add adjustable pll support

Introduced a common adjustable pll clock driver for Spreadtrum SoCs.

Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: sprd: add composite clock support
Chunyan Zhang [Thu, 7 Dec 2017 12:57:09 +0000 (20:57 +0800)]
clk: sprd: add composite clock support

This patch introduced composite driver for Spreadtrum's SoCs. The
functions of this composite clock simply consist of divider and
mux clocks.

Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: sprd: add divider clock support
Chunyan Zhang [Thu, 7 Dec 2017 12:57:08 +0000 (20:57 +0800)]
clk: sprd: add divider clock support

This is a feature that can also be found in sprd composite clocks,
provide a bunch of helpers that can be reused later on.

Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: sprd: add mux clock support
Chunyan Zhang [Thu, 7 Dec 2017 12:57:07 +0000 (20:57 +0800)]
clk: sprd: add mux clock support

This patch adds clock multiplexor support for Spreadtrum platforms,
the mux clocks also can be found in sprd composite clocks, so
provides two helpers that can be reused later on.

Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: sprd: add gate clock support
Chunyan Zhang [Thu, 7 Dec 2017 12:57:06 +0000 (20:57 +0800)]
clk: sprd: add gate clock support

Some clocks on the Spreadtrum's SoCs are just simple gates. Add
support for those clocks.

Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: sprd: Add common infrastructure
Chunyan Zhang [Thu, 7 Dec 2017 12:57:05 +0000 (20:57 +0800)]
clk: sprd: Add common infrastructure

Added Spreadtrum's clock driver framework together with common
structures and interface functions.

Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: move clock common macros out from vendor directories
Chunyan Zhang [Thu, 7 Dec 2017 12:57:04 +0000 (20:57 +0800)]
clk: move clock common macros out from vendor directories

These macros are used by more than one SoC vendor platforms, avoid to
have many copies of these code, this patch moves them to the common
header file which every clock drivers can access to.

Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoMerge tag 'omap-for-v4.16/clk-omap3-legacy-signed' of git://git.kernel.org/pub/scm...
Michael Turquette [Thu, 21 Dec 2017 17:00:53 +0000 (09:00 -0800)]
Merge tag 'omap-for-v4.16/clk-omap3-legacy-signed' of git://git./linux/kernel/git/tmlind/linux-omap into clk-omap

Drop unused omap3 clock data

We have been booting omap3 in device tree only mode for a while now,
so this is all unused now.

7 years agoclk: fix set_rate_range when current rate is out of range
Jerome Brunet [Fri, 1 Dec 2017 21:52:00 +0000 (22:52 +0100)]
clk: fix set_rate_range when current rate is out of range

Calling clk_core_set_rate() with core->req_rate is basically a no-op
because of the early bail-out mechanism.

This may leave the clock in inconsistent state if the rate is out the
requested range. Calling clk_core_set_rate() with the closest rate
limit could solve the problem but:
- The underlying determine_rate() callback needs to account for this
  corner case (rounding within the range, if possible)
- if only round_rate() is available, we rely on luck unfortunately.

Fixes: 1c8e600440c7 ("clk: Add rate constraints to clocks")
Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20171201215200.23523-11-jbrunet@baylibre.com

7 years agoclk: add clk_rate_exclusive api
Jerome Brunet [Fri, 1 Dec 2017 21:51:59 +0000 (22:51 +0100)]
clk: add clk_rate_exclusive api

Using clock rate protection, we can now provide a way for clock consumer
to claim exclusive control over the rate of a producer

So far, rate change operations have been a "last write wins" affair. This
changes allows drivers to explicitly protect against this behavior, if
required.

Of course, if exclusivity over a producer is claimed more than once, the
rate is effectively locked as exclusivity cannot be preempted

Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20171201215200.23523-10-jbrunet@baylibre.com

7 years agoclk: cosmetic changes to clk_summary debugfs entry
Jerome Brunet [Fri, 1 Dec 2017 21:51:57 +0000 (22:51 +0100)]
clk: cosmetic changes to clk_summary debugfs entry

clk_summary debugfs entry was already well over the traditional 80
characters per line limit but it grew even larger with the addition of
clock protection.

   clock                         enable_cnt  prepare_cnt  protect_cnt        rate   accuracy   phase
----------------------------------------------------------------------------------------------------
 wifi32k                                  1            1            0       32768          0 0
 vcpu                                     0            0            0  2016000000          0 0
 xtal                                     5            5            0    24000000          0 0

This patch reduce the width a bit:
                                 enable  prepare  protect
   clock                          count    count    count        rate   accuracy   phase
----------------------------------------------------------------------------------------
 wifi32k                              1        1        0       32768          0 0
 vcpu                                 0        0        0  2016000000          0 0
 xtal                                 5        5        0    24000000          0 0

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20171201215200.23523-8-jbrunet@baylibre.com

7 years agoclk: add clock protection mechanism to clk core
Jerome Brunet [Fri, 1 Dec 2017 21:51:56 +0000 (22:51 +0100)]
clk: add clock protection mechanism to clk core

The patch adds clk_core_protect and clk_core_unprotect to the internal
CCF API. These functions allow to set a new constraint along the clock
tree to prevent any change, even indirect, which may result in rate
change or glitch.

Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20171201215200.23523-7-jbrunet@baylibre.com

7 years agoclk: use round rate to bail out early in set_rate
Jerome Brunet [Fri, 1 Dec 2017 21:51:55 +0000 (22:51 +0100)]
clk: use round rate to bail out early in set_rate

The current implementation of clk_core_set_rate_nolock() bails out early
if the requested rate is exactly the same as the one set. It should bail
out if the request would not result in a rate a change. This is important
when the rate is not exactly what is requested, which is fairly common
with PLLs.

Ex: provider able to give any rate with steps of 100Hz
 - 1st consumer request 48000Hz and gets it.
 - 2nd consumer request 48010Hz as well. If we were to perform the usual
   mechanism, we would get 48000Hz as well. The clock would not change so
   there is no point performing any checks to make sure the clock can
   change, we know it won't.

This is important to prepare the addition of the clock protection
mechanism

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20171201215200.23523-6-jbrunet@baylibre.com

7 years agoclk: rework calls to round and determine rate callbacks
Jerome Brunet [Fri, 1 Dec 2017 21:51:54 +0000 (22:51 +0100)]
clk: rework calls to round and determine rate callbacks

Rework the way the callbacks round_rate() and determine_rate() are called.
The goal is to do this at a single point and make it easier to add
conditions before calling them.

Because of this factorization, rate returned by determine_rate() is also
checked against the min and max rate values

This rework is done to ease the integration of "protected" clock
functionality.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20171201215200.23523-5-jbrunet@baylibre.com

7 years agoclk: add clk_core_set_phase_nolock function
Jerome Brunet [Fri, 1 Dec 2017 21:51:53 +0000 (22:51 +0100)]
clk: add clk_core_set_phase_nolock function

Create a core function for set_phase, as it is done for set_rate and
set_parent.

This rework is done to ease the integration of "protected" clock
functionality.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20171201215200.23523-4-jbrunet@baylibre.com

7 years agoclk: take the prepare lock out of clk_core_set_parent
Jerome Brunet [Fri, 1 Dec 2017 21:51:52 +0000 (22:51 +0100)]
clk: take the prepare lock out of clk_core_set_parent

Rework set_parent core function so it can be called when the prepare lock
is already held by the caller.

This rework is done to ease the integration of the "protected" clock
functionality.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20171201215200.23523-3-jbrunet@baylibre.com

7 years agoclk: fix incorrect usage of ENOSYS
Jerome Brunet [Fri, 1 Dec 2017 21:51:51 +0000 (22:51 +0100)]
clk: fix incorrect usage of ENOSYS

ENOSYS is special and should only be used for incorrect syscall number.
It does not seem to be the case here.

Reported by checkpatch.pl while working on clock protection.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20171201215200.23523-2-jbrunet@baylibre.com

7 years agoclk: check ops pointer on clock register
Jerome Brunet [Tue, 19 Dec 2017 08:33:29 +0000 (09:33 +0100)]
clk: check ops pointer on clock register

Nothing really prevents a provider from (trying to) register a clock
without providing the clock ops structure.

We do check the individual fields before using them, but not the
structure pointer itself. This may have the usual nasty consequences when
the pointer is dereferenced, most likely when checking one the field
during the initialization.

This is fixed by returning an error on clock register if the ops pointer
is NULL.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20171219083329.24746-1-jbrunet@baylibre.com

7 years agoclk: ti: Drop legacy clk-3xxx-legacy code
Tony Lindgren [Thu, 14 Dec 2017 16:32:06 +0000 (08:32 -0800)]
clk: ti: Drop legacy clk-3xxx-legacy code

We have now had omap3 booting in device tree only mode for a while
and all this code is unused.

Acked-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
7 years agoclk: qcom: add read-only alpha pll post divider operations
Abhishek Sahu [Thu, 28 Sep 2017 17:50:50 +0000 (23:20 +0530)]
clk: qcom: add read-only alpha pll post divider operations

Some of the divider settings are preconfigured and should not
be changed by the clock framework during frequency change. This
patch adds the read-only divider operation for QCOM alpha pll
post divider which is equivalent to generic divider operations in
'commit 79c6ab509558 ("clk: divider: add CLK_DIVIDER_READ_ONLY flag")'.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: support for 2 bit PLL post divider
Abhishek Sahu [Thu, 28 Sep 2017 17:50:49 +0000 (23:20 +0530)]
clk: qcom: support for 2 bit PLL post divider

Current PLL driver only supports 4 bit PLL post divider so
modified the PLL divider operations to support 2 bit PLL
post divider.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: support Brammo type Alpha PLL
Abhishek Sahu [Thu, 28 Sep 2017 17:50:48 +0000 (23:20 +0530)]
clk: qcom: support Brammo type Alpha PLL

The Brammo type of Alpha PLL doesn't allow configuration of a
VCO, but it does support dynamic update in which the frequency
can be changed dynamically without turning off the PLL.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: support Huayra type Alpha PLL
Abhishek Sahu [Thu, 28 Sep 2017 17:50:46 +0000 (23:20 +0530)]
clk: qcom: support Huayra type Alpha PLL

The Huayra type Alpha PLL  has a 16 bit alpha value, and
depending on the alpha_mode, the alpha value can be treated as
M/N value or as a two’s compliment number. This PLL supports
dynamic programming.

Since the decoding of alpha val and dynamic programming are
completely different from other Alpha PLLs we add separate
functions for Huayra PLLs.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: support for dynamic updating the PLL
Abhishek Sahu [Thu, 28 Sep 2017 17:50:45 +0000 (23:20 +0530)]
clk: qcom: support for dynamic updating the PLL

Some of the Alpha PLLs support dynamic update in which the
frequency can be changed dynamically without turning off the PLL.

This dynamic update requires the following sequence:

 1. Write the desired values to L_VAL and ALPHA_VAL registers
 2. Toggle pll_latch_input from low to high
 3. Wait for pll_ack_latch to transition from low to high
    The new L and alpha values have been latched. It may
    take some time for the PLL to fully settle with these
    new values.
 4. Pull pll_latch_input low

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: support for alpha mode configuration
Abhishek Sahu [Thu, 28 Sep 2017 17:50:44 +0000 (23:20 +0530)]
clk: qcom: support for alpha mode configuration

The current configuration does not fully configure PLL alpha mode
and values so this patch

1. Configures PLL_ALPHA_VAL_U for PLL which supports 40 bit alpha.
2. Adds alpha enable and alpha mode configuration support.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: flag for 64 bit CONFIG_CTL
Abhishek Sahu [Thu, 28 Sep 2017 17:50:43 +0000 (23:20 +0530)]
clk: qcom: flag for 64 bit CONFIG_CTL

Some of the Alpha PLLs (like Spark and Brammo) don't have a
CONFIG_CTL_U register. Add logic to detect when PLLs don't have
this second config register and skip programming it during PLL
initialization.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: fix 16 bit alpha support calculation
Abhishek Sahu [Thu, 28 Sep 2017 17:50:41 +0000 (23:20 +0530)]
clk: qcom: fix 16 bit alpha support calculation

The alpha value calculation has been written for 40-bit alpha
values which doesn't work work properly for 16-bit ones. The
alpha value is calculated on the basis of ALPHA_BITWIDTH to make
the computation easy for 40 bit alpha. After calculating the 32
bit alpha, it is converted to 40 bit alpha by making lower bits
zero. But if actual alpha register width is less than
ALPHA_BITWIDTH, then the actual width can be used for
calculation. This also means, during the 40 bit alpha pll set
rate path, the lower alpha register is not configured

Change the code to calculate the rate and register values from
'alpha_width' instead of hard-coding it so that it can work for
the different widths that are supported.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: support for alpha pll properties
Abhishek Sahu [Thu, 28 Sep 2017 17:50:40 +0000 (23:20 +0530)]
clk: qcom: support for alpha pll properties

Alpha PLL is a generic name used for QCOM PLLs which uses L and
Alpha values for configuring the integer and fractional part.
QCOM SoCs use different types of Alpha PLLs for which basic
software configuration part is common with following differences.

  1. All these PLLs have the same basic registers like
     PLL_MODE, L_VAL, ALPHA_VAL but some of the register offsets are
     different between PLLs types.

  2. The dynamic programming sequence is different in some
     of the Alpha PLLs

  3. Some of the PLLs don’t have 64 bit config control, 64 bit
     user control, VCO configuration, etc.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoMerge branch '4.15-rc1-clkctrl-driver' of https://github.com/t-kristo/linux-pm into...
Stephen Boyd [Thu, 7 Dec 2017 07:09:59 +0000 (23:09 -0800)]
Merge branch '4.15-rc1-clkctrl-driver' of https://github.com/t-kristo/linux-pm into clk-next

* '4.15-rc1-clkctrl-driver' of https://github.com/t-kristo/linux-pm: (28 commits)
  clk: ti: omap4: clkctrl data fixes for opt-clocks
  clk: ti: dm816: add clkctrl clock data
  dt-bindings: clk: add dm816 clkctrl definitions
  clk: ti: dm814: add clkctrl clock data
  dt-bindings: clk: add dm814 clkctrl definitions
  clk: ti: am43xx: add clkctrl clock data
  dt-bindings: clk: add am43xx clkctrl definitions
  clk: ti: am33xx: add clkctrl clock data
  dt-bindings: clk: add am33xx clkctrl definitions
  clk: ti: dra7: add clkctrl clock data
  dt-bindings: clk: add dra7 clkctrl definitions
  clk: ti: omap5: add clkctrl clock data
  dt-bindings: clk: add omap5 clkctrl definitions
  clk: ti: omap3: cleanup unnecessary clock aliases
  clk: ti: am43xx: cleanup unnecessary clock aliases
  clk: ti: am33xx: cleanup unnecessary clock aliases
  clk: ti: dm816x: cleanup unnecessary clock aliases
  clk: ti: dm814x: cleanup unnecessary clock aliases
  clk: ti: omap5: cleanup unnecessary clock aliases
  clk: ti: dra7: drop unnecessary clock aliases
  ...

7 years agoMerge branch 'clk-stm32-copyright' into clk-next
Stephen Boyd [Thu, 7 Dec 2017 07:09:13 +0000 (23:09 -0800)]
Merge branch 'clk-stm32-copyright' into clk-next

* clk-stm32-copyright:
  clk: stm32-h7: fix copyright

7 years agoclk: stm32-h7: fix copyright
Benjamin Gaignard [Thu, 30 Nov 2017 08:41:08 +0000 (09:41 +0100)]
clk: stm32-h7: fix copyright

Uniformize STMicroelectronics copyrights header
Add SPDX identifier

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Acked-by: Alexandre TORGUE <alexandre.torgue@st.com>
CC: Gabriel Fernandez <gabriel.fernandez@st.com>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Gabriel Fernandez <gabriel.fernandez@st.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoMerge branch 'clk-hi3660-stub' into clk-next
Stephen Boyd [Thu, 7 Dec 2017 07:06:22 +0000 (23:06 -0800)]
Merge branch 'clk-hi3660-stub' into clk-next

* clk-hi3660-stub:
  clk: hisilicon: Add support for Hi3660 stub clocks
  dt-bindings: clk: Hi3660: Document stub clock

7 years agoclk: hisilicon: Add support for Hi3660 stub clocks
Kaihua Zhong [Fri, 17 Nov 2017 09:27:31 +0000 (17:27 +0800)]
clk: hisilicon: Add support for Hi3660 stub clocks

Hi3660 has four stub clocks, which are big and LITTLE cluster clocks,
GPU clock and DDR clock.  These clocks ask MCU for frequency scaling
by sending message through mailbox.

This commit adds support for stub clocks, it requests the dedicated
mailbox channel at initialization; then later uses this channel to send
message to MCU to execute frequency scaling. The four stub clocks share
the same mailbox channel, but every stub clock has its own command id so
MCU can distinguish the requirement coming for which clock.

A shared memory is used to present effective frequency value, so the
clock driver uses I/O mapping for the memory and reads back rate value.

Reviewed-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Kai Zhao <zhaokai1@hisilicon.com>
Signed-off-by: Tao Wang <kevin.wangtao@hisilicon.com>
Signed-off-by: Ruyi Wang <wangruyi@huawei.com>
Signed-off-by: Kaihua Zhong <zhongkaihua@huawei.com>
[sboyd: Fix possible out of bounds access in hi3660_stub_clk_hw_get(),
        use devm_of_clk_add_hw_provider(), devm_ioremap() returns
NULL not error pointers]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agodt-bindings: clk: Hi3660: Document stub clock
Leo Yan [Fri, 17 Nov 2017 09:27:30 +0000 (17:27 +0800)]
dt-bindings: clk: Hi3660: Document stub clock

Document the DT binding for stub clock which is used for CPU,
GPU and DDR frequency scaling.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoMerge branch 'clk-pr-err' into clk-next
Stephen Boyd [Thu, 7 Dec 2017 06:41:44 +0000 (22:41 -0800)]
Merge branch 'clk-pr-err' into clk-next

* clk-pr-err:
  clk: h8300: pr_err() strings should end with newlines
  clk: h8s2678: pr_err() strings should end with newlines
  SPEAr: clk: pr_err() strings should end with newlines
  clk: SPEAr: pr_err() strings should end with newlines
  clk: lpc32xx: pr_err() strings should end with newlines
  clk: stm32f4: pr_err() strings should end with newlines

7 years agoclk: h8300: pr_err() strings should end with newlines
Arvind Yadav [Fri, 24 Nov 2017 06:55:33 +0000 (12:25 +0530)]
clk: h8300: pr_err() strings should end with newlines

pr_err() messages should end with a new-line to avoid other messages
being concatenated.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: h8s2678: pr_err() strings should end with newlines
Arvind Yadav [Fri, 24 Nov 2017 06:55:32 +0000 (12:25 +0530)]
clk: h8s2678: pr_err() strings should end with newlines

pr_err() messages should end with a new-line to avoid other messages
being concatenated.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoSPEAr: clk: pr_err() strings should end with newlines
Arvind Yadav [Fri, 24 Nov 2017 06:55:31 +0000 (12:25 +0530)]
SPEAr: clk: pr_err() strings should end with newlines

pr_err() messages should end with a new-line to avoid other messages
being concatenated.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: SPEAr: pr_err() strings should end with newlines
Arvind Yadav [Fri, 24 Nov 2017 06:55:30 +0000 (12:25 +0530)]
clk: SPEAr: pr_err() strings should end with newlines

pr_err() messages should end with a new-line to avoid other messages
being concatenated.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: lpc32xx: pr_err() strings should end with newlines
Arvind Yadav [Fri, 24 Nov 2017 06:55:29 +0000 (12:25 +0530)]
clk: lpc32xx: pr_err() strings should end with newlines

pr_err() messages should end with a new-line to avoid other messages
being concatenated.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Acked-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: stm32f4: pr_err() strings should end with newlines
Arvind Yadav [Fri, 24 Nov 2017 06:55:28 +0000 (12:25 +0530)]
clk: stm32f4: pr_err() strings should end with newlines

pr_err() messages should end with a new-line to avoid other messages
being concatenated.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoMerge branch 'clk-qcom-spmi-div' into clk-next
Stephen Boyd [Thu, 7 Dec 2017 06:39:19 +0000 (22:39 -0800)]
Merge branch 'clk-qcom-spmi-div' into clk-next

* clk-qcom-spmi-div:
  clk: qcom: Add spmi_pmic clock divider support
  dt-bindings: Add qcom spmi_pmic clock divider bindings

7 years agoMerge branch 'clk-qcom-audio-fixes' into clk-next
Stephen Boyd [Thu, 7 Dec 2017 06:39:05 +0000 (22:39 -0800)]
Merge branch 'clk-qcom-audio-fixes' into clk-next

* clk-qcom-audio-fixes:
  clk: qcom: msm8916: add 12.288 MHz support to codec dig clk
  clk: qcom: msm8916: fix mnd_width for codec_digcodec
  clk: qcom: msm8916: Fix i2s clk rates required for mclk

7 years agoclk: qcom: msm8916: add 12.288 MHz support to codec dig clk
Srinivas Kandagatla [Wed, 6 Dec 2017 12:11:39 +0000 (12:11 +0000)]
clk: qcom: msm8916: add 12.288 MHz support to codec dig clk

This patch adds 12.288 MHz suport to codec digital clk, this clock.
Some external PA requires a 12.288 MHz to work.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: msm8916: fix mnd_width for codec_digcodec
Srinivas Kandagatla [Wed, 6 Dec 2017 12:11:38 +0000 (12:11 +0000)]
clk: qcom: msm8916: fix mnd_width for codec_digcodec

This patch fixes missing mnd_width for codec_digital clk, this is now set to
8 inline with datasheet.

Fixes: 3966fab8b6ab ("clk: qcom: Add MSM8916 Global Clock Controller support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: msm8916: Fix i2s clk rates required for mclk
Srinivas Kandagatla [Wed, 29 Nov 2017 18:25:25 +0000 (18:25 +0000)]
clk: qcom: msm8916: Fix i2s clk rates required for mclk

lpaif i2s clk rates in the freq table are not accurate enough
for I2S mclk. Fix the inaccurate ones and add few more clock
rates that are used in LPASS audio driver.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: Add spmi_pmic clock divider support
Tirupathi Reddy [Tue, 21 Nov 2017 09:11:04 +0000 (14:41 +0530)]
clk: qcom: Add spmi_pmic clock divider support

Clkdiv module provides a clock output on the PMIC with CXO as
the source. This clock can be routed through PMIC GPIOs. Add
a device driver to configure this clkdiv module.

Signed-off-by: Tirupathi Reddy <tirupath@codeaurora.org>
[sboyd: Simplified code and moved to devm clk provider APIs]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agodt-bindings: Add qcom spmi_pmic clock divider bindings
Tirupathi Reddy [Tue, 21 Nov 2017 09:11:05 +0000 (14:41 +0530)]
dt-bindings: Add qcom spmi_pmic clock divider bindings

This patch adds device tree bindings for Qualcomm SPMI PMIC
clock divider module.

Signed-off-by: Tirupathi Reddy <tirupath@codeaurora.org>
[sboyd: Moved file to match compatible of binding]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoMerge branch 'clk-fixes' into clk-next
Stephen Boyd [Tue, 5 Dec 2017 23:30:09 +0000 (15:30 -0800)]
Merge branch 'clk-fixes' into clk-next

* clk-fixes:
  clk: fix a panic error caused by accessing NULL pointer
  clk: Manage proper runtime PM state in clk_change_rate()

7 years agoclk: fix a panic error caused by accessing NULL pointer
Cai Li [Tue, 21 Nov 2017 09:24:38 +0000 (17:24 +0800)]
clk: fix a panic error caused by accessing NULL pointer

In some cases the clock parent would be set NULL when doing re-parent,
it will cause a NULL pointer accessing if clk_set trace event is
enabled.

This patch sets the parent as "none" if the input parameter is NULL.

Fixes: dfc202ead312 (clk: Add tracepoints for hardware operations)
Signed-off-by: Cai Li <cai.li@spreadtrum.com>
Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: Manage proper runtime PM state in clk_change_rate()
Marek Szyprowski [Thu, 30 Nov 2017 12:14:51 +0000 (13:14 +0100)]
clk: Manage proper runtime PM state in clk_change_rate()

clk_change_rate() propagates rate change down to all its children. Such
operation requires managing proper runtime PM state of each child, what
was missing. Add needed calls to clk_pm_runtime*() to ensure that
set_rate() clock callback is called on runtime active clock.

This fixes following issue found on Exynos5433 TM2 board with devfreq
enabled:

Synchronous External Abort: synchronous external abort (0x96000210) at 0xffffff80093f5600
Internal error: : 96000210 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 5 Comm: kworker/u16:0 Not tainted 4.15.0-rc1-next-20171129+ #4
Hardware name: Samsung TM2 board (DT)
Workqueue: devfreq_wq devfreq_monitor
task: ffffffc0ca96b600 task.stack: ffffff80093a8000
pstate: a0000085 (NzCv daIf -PAN -UAO)
pc : clk_divider_set_rate+0x54/0x118
lr : clk_divider_set_rate+0x44/0x118
...
Process kworker/u16:0 (pid: 5, stack limit = 0xffffff80093a8000)
Call trace:
 clk_divider_set_rate+0x54/0x118
 clk_change_rate+0xfc/0x4e0
 clk_change_rate+0x1f0/0x4e0
 clk_change_rate+0x1f0/0x4e0
 clk_change_rate+0x1f0/0x4e0
 clk_core_set_rate_nolock+0x138/0x148
 clk_set_rate+0x28/0x50
 exynos_bus_passive_target+0x6c/0x11c
 update_devfreq_passive+0x58/0xb4
 devfreq_passive_notifier_call+0x50/0x5c
 notifier_call_chain+0x4c/0x88
 __srcu_notifier_call_chain+0x54/0x80
 srcu_notifier_call_chain+0x14/0x1c
 update_devfreq+0x100/0x1b4
 devfreq_monitor+0x2c/0x88
 process_one_work+0x148/0x3d8
 worker_thread+0x13c/0x3f8
 kthread+0x100/0x12c
 ret_from_fork+0x10/0x18

Reported-by: Chanwoo Choi <cw00.choi@samsung.com>
Fixes: 9a34b45397e5 ("clk: Add support for runtime PM")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: ti: omap4: clkctrl data fixes for opt-clocks
Tero Kristo [Tue, 26 Sep 2017 12:36:43 +0000 (15:36 +0300)]
clk: ti: omap4: clkctrl data fixes for opt-clocks

Re-route all opt-clocks to use the new clkctrl clocks also, instead of
depending on the old dt clocks. Also, add aliases for certain clkctrl
clocks that hwmod core depends upon. The alias list can be stripped
down once hwmod database no longer needs these.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: dm816: add clkctrl clock data
Tero Kristo [Thu, 24 Aug 2017 12:44:14 +0000 (15:44 +0300)]
clk: ti: dm816: add clkctrl clock data

Add data for dm816 clkctrl clocks, and register it within the clkctrl
driver.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agodt-bindings: clk: add dm816 clkctrl definitions
Tero Kristo [Thu, 24 Aug 2017 12:43:43 +0000 (15:43 +0300)]
dt-bindings: clk: add dm816 clkctrl definitions

Contains offsets for all dm816 clkctrl main and optional clocks.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: dm814: add clkctrl clock data
Tero Kristo [Thu, 24 Aug 2017 12:41:37 +0000 (15:41 +0300)]
clk: ti: dm814: add clkctrl clock data

Add data for dm814 clkctrl clocks, and register it within the clkctrl
driver.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agodt-bindings: clk: add dm814 clkctrl definitions
Tero Kristo [Thu, 24 Aug 2017 12:40:58 +0000 (15:40 +0300)]
dt-bindings: clk: add dm814 clkctrl definitions

Contains offsets for all dm814 clkctrl main and optional clocks.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: am43xx: add clkctrl clock data
Tero Kristo [Thu, 10 Aug 2017 13:11:06 +0000 (16:11 +0300)]
clk: ti: am43xx: add clkctrl clock data

Add data for am43xx clkctrl clocks, and register it within the clkctrl
driver.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Acked-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agodt-bindings: clk: add am43xx clkctrl definitions
Tero Kristo [Thu, 10 Aug 2017 13:09:59 +0000 (16:09 +0300)]
dt-bindings: clk: add am43xx clkctrl definitions

Contains offsets for all am43xx clkctrl main and optional clocks.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: am33xx: add clkctrl clock data
Tero Kristo [Wed, 9 Aug 2017 08:59:29 +0000 (11:59 +0300)]
clk: ti: am33xx: add clkctrl clock data

Add data for am33xx clkctrl clocks, and register it within the clkctrl
driver.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agodt-bindings: clk: add am33xx clkctrl definitions
Tero Kristo [Wed, 9 Aug 2017 08:58:21 +0000 (11:58 +0300)]
dt-bindings: clk: add am33xx clkctrl definitions

Contains offsets for all am33xx clkctrl main and optional clocks.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: dra7: add clkctrl clock data
Tero Kristo [Fri, 4 Aug 2017 14:25:08 +0000 (17:25 +0300)]
clk: ti: dra7: add clkctrl clock data

Add data for dra7 clkctrl clocks, and register it within the clkctrl
driver.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agodt-bindings: clk: add dra7 clkctrl definitions
Tero Kristo [Wed, 16 Aug 2017 08:48:24 +0000 (11:48 +0300)]
dt-bindings: clk: add dra7 clkctrl definitions

Contains offsets for all dra7 clkctrl main and optional clocks.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: omap5: add clkctrl clock data
Tero Kristo [Mon, 31 Jul 2017 09:16:24 +0000 (12:16 +0300)]
clk: ti: omap5: add clkctrl clock data

Add data for omap5 clkctrl clocks, and register it within the clkctrl
driver.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agodt-bindings: clk: add omap5 clkctrl definitions
Tero Kristo [Mon, 31 Jul 2017 09:01:32 +0000 (12:01 +0300)]
dt-bindings: clk: add omap5 clkctrl definitions

Contains offsets for all omap5 clkctrl main and optional clocks.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: omap3: cleanup unnecessary clock aliases
Tero Kristo [Thu, 24 Aug 2017 12:33:01 +0000 (15:33 +0300)]
clk: ti: omap3: cleanup unnecessary clock aliases

Most of the clock aliases are no longer needed, only leave the ones
required by OMAP timer code in place.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: am43xx: cleanup unnecessary clock aliases
Tero Kristo [Thu, 24 Aug 2017 12:32:21 +0000 (15:32 +0300)]
clk: ti: am43xx: cleanup unnecessary clock aliases

Most of the clock aliases are no longer needed, only leave the ones
required by OMAP timer code in place.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: am33xx: cleanup unnecessary clock aliases
Tero Kristo [Thu, 24 Aug 2017 12:31:42 +0000 (15:31 +0300)]
clk: ti: am33xx: cleanup unnecessary clock aliases

Most of the clock aliases are no longer needed, only leave the ones
required by OMAP timer code in place.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: dm816x: cleanup unnecessary clock aliases
Tero Kristo [Thu, 24 Aug 2017 12:31:08 +0000 (15:31 +0300)]
clk: ti: dm816x: cleanup unnecessary clock aliases

Most of the clock aliases are no longer needed, only leave the ones
required by OMAP timer code in place.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: dm814x: cleanup unnecessary clock aliases
Tero Kristo [Thu, 24 Aug 2017 12:29:36 +0000 (15:29 +0300)]
clk: ti: dm814x: cleanup unnecessary clock aliases

Most of the clock aliases are no longer needed, only leave the ones
required by OMAP timer code in place.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: omap5: cleanup unnecessary clock aliases
Tero Kristo [Mon, 21 Aug 2017 08:05:46 +0000 (11:05 +0300)]
clk: ti: omap5: cleanup unnecessary clock aliases

Most of the clock aliases are no longer needed, only leave the ones
required by OMAP timer code in place.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: dra7: drop unnecessary clock aliases
Tero Kristo [Mon, 21 Aug 2017 08:04:53 +0000 (11:04 +0300)]
clk: ti: dra7: drop unnecessary clock aliases

Most of the clock aliases are no longer needed, only leave the ones
required by OMAP timer handling in place.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: omap4: cleanup unnecessary clock aliases
Tero Kristo [Mon, 21 Aug 2017 07:25:38 +0000 (10:25 +0300)]
clk: ti: omap4: cleanup unnecessary clock aliases

Most of the clock aliases are no longer needed, only leave the
timer_32k_ck one in place which is required by OMAP timer code.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: clkctrl: fix flags for mux and divider opt clocks
Tero Kristo [Wed, 11 Oct 2017 14:56:10 +0000 (17:56 +0300)]
clk: ti: clkctrl: fix flags for mux and divider opt clocks

Flag handling was missing for these two, so add it.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: clkctrl: add support for retrying failed init
Tero Kristo [Thu, 12 Oct 2017 07:55:29 +0000 (10:55 +0300)]
clk: ti: clkctrl: add support for retrying failed init

In case the clkctrl node contains assigned-clock-* entries, registering
the provider can fail with -EPROBE_DEFER. In this case, add the
provider to the retry_init clock list so it will be cleaned up later.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Acked-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: ti: convert retry_init param to use void data type
Tero Kristo [Mon, 6 Nov 2017 07:43:16 +0000 (09:43 +0200)]
clk: ti: convert retry_init param to use void data type

User data should be void type, as the core framework doesn't need to
know what is passed through.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Acked-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: ti: clkctrl: use fallback udelay approach if timekeeping is suspended
Tero Kristo [Tue, 15 Aug 2017 08:42:17 +0000 (11:42 +0300)]
clk: ti: clkctrl: use fallback udelay approach if timekeeping is suspended

In certain cases it is possible that the timekeeping has been suspended
already when attempting to disable/enable a clkctrl clock. This will
happen at least on am43xx platform when attempting to enable / disable
the clockevent source itself, burping out a warning from timekeeping core.

The sequence of events leading to this:
-> timekeeping_suspend()
 -> clockevents_suspend()
  -> omap_clkevt_idle()
   -> omap_hwmod_idle()
    -> _omap4_clkctrl_clk_disable()
     -> _omap4_is_timeout()

Avoid the issue by checking if the timekeeping is suspended and using
the fallback udelay approach for checking timeouts.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Acked-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: ti: add support for clkctrl aliases
Tero Kristo [Tue, 26 Sep 2017 12:34:27 +0000 (15:34 +0300)]
clk: ti: add support for clkctrl aliases

hwmod core still depends on certain clocks being found by name, so we
need to add support for adding clkctrl clock aliases. This patch can
be reverted when no longer needed by hwmod core code.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: clkctrl: add support for clkdm init for clkctrl clocks
Tero Kristo [Mon, 18 Sep 2017 18:02:24 +0000 (21:02 +0300)]
clk: ti: clkctrl: add support for clkdm init for clkctrl clocks

Clkctrl clocks now support clockdomain init also. This will be needed
so that hwmod core can drop the support for clockdomain handling.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
7 years agoclk: ti: clkctrl: fix error messages to print out node name properly
Tero Kristo [Mon, 18 Sep 2017 18:01:26 +0000 (21:01 +0300)]
clk: ti: clkctrl: fix error messages to print out node name properly

Current node name does not convey any information, as it is always "clk".
Instead, print out the full node path, which will tell us better where
something went wrong.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>