]> git.baikalelectronics.ru Git - kernel.git/log
kernel.git
7 years agoMerge branches 'clk-aspeed', 'clk-lock-UP', 'clk-mediatek' and 'clk-allwinner' into...
Stephen Boyd [Sat, 27 Jan 2018 00:43:39 +0000 (16:43 -0800)]
Merge branches 'clk-aspeed', 'clk-lock-UP', 'clk-mediatek' and 'clk-allwinner' into clk-next

* clk-aspeed:
  clk: aspeed: Handle inverse polarity of USB port 1 clock gate
  clk: aspeed: Fix return value check in aspeed_cc_init()
  clk: aspeed: Add reset controller
  clk: aspeed: Register gated clocks
  clk: aspeed: Add platform driver and register PLLs
  clk: aspeed: Register core clocks
  clk: Add clock driver for ASPEED BMC SoCs
  dt-bindings: clock: Add ASPEED constants

* clk-lock-UP:
  clk: fix reentrancy of clk_enable() on UP systems

* clk-mediatek:
  clk: mediatek: adjust dependency of reset.c to avoid unexpectedly being built
  clk: mediatek: Fix all warnings for missing struct clk_onecell_data
  clk: mediatek: fixup test-building of MediaTek clock drivers
  clk: mediatek: group drivers under indpendent menu

* clk-allwinner:
  clk: sunxi-ng: a83t: Add M divider to TCON1 clock
  clk: sunxi-ng: fix the A64/H5 clock description of DE2 CCU
  clk: sunxi-ng: add support for Allwinner H3 DE2 CCU
  dt-bindings: fix the binding of Allwinner DE2 CCU of A83T and H3
  clk: sunxi-ng: sun8i: a83t: Use sigma-delta modulation for audio PLL
  clk: sunxi-ng: sun8i: a83t: Add /2 fixed post divider to audio PLL
  clk: sunxi-ng: Support fixed post-dividers on NM style clocks
  clk: sunxi-ng: sun50i: a64: Add 2x fixed post-divider to MMC module clocks
  clk: sunxi-ng: Support fixed post-dividers on MP style clocks
  clk: sunxi: Use PTR_ERR_OR_ZERO()

7 years agoMerge branches 'clk-remove-asm-clkdev', 'clk-debugfs-fixes', 'clk-renesas' and 'clk...
Stephen Boyd [Sat, 27 Jan 2018 00:43:32 +0000 (16:43 -0800)]
Merge branches 'clk-remove-asm-clkdev', 'clk-debugfs-fixes', 'clk-renesas' and 'clk-meson' into clk-next

* clk-remove-asm-clkdev:
  clk: Move __clk_{get,put}() into private clk.h API
  clk: sunxi: Use CLK_IS_CRITICAL flag for critical clks
  arch: Remove clkdev.h asm-generic from Kbuild
  clk: Prepare to remove asm-generic/clkdev.h
  blackfin: Use generic clkdev.h header

* clk-debugfs-fixes:
  clk: Simplify debugfs registration
  clk: Fix debugfs_create_*() usage
  clk: Show symbolic clock flags in debugfs
  clk: Improve flags doc for of_clk_detect_critical()

* clk-renesas:
  clk: renesas: r8a7796: Add FDP clock
  clk: renesas: cpg-mssr: Keep wakeup sources active during system suspend
  clk: renesas: mstp: Keep wakeup sources active during system suspend
  clk: renesas: r8a77970: Add LVDS clock

* clk-meson:
  clk: meson-axg: fix potential NULL dereference in axg_clkc_probe()
  clk: meson-axg: make local symbol axg_gp0_params_table static
  clk: meson-axg: fix return value check in axg_clkc_probe()
  clk: meson: mpll: use 64-bit maths in params_from_rate
  clk: meson-axg: add clock controller drivers
  clk: meson-axg: add clocks dt-bindings required header
  dt-bindings: clock: add compatible variant for the Meson-AXG
  clk: meson: make the spinlock naming more specific
  clk: meson: gxbb: remove IGNORE_UNUSED from mmc clocks
  clk: meson: gxbb: fix wrong clock for SARADC/SANA

7 years agoMerge branch 'clk-divider-container' into clk-next
Stephen Boyd [Sat, 27 Jan 2018 00:42:03 +0000 (16:42 -0800)]
Merge branch 'clk-divider-container' into clk-next

* clk-divider-container:
  clk: divider: fix incorrect usage of container_of

Plus fixup sprd/div.c to pass the width too.

7 years agoMerge branches 'clk-iproc', 'clk-mvebu' and 'clk-qcom-a53' into clk-next
Stephen Boyd [Sat, 27 Jan 2018 00:41:58 +0000 (16:41 -0800)]
Merge branches 'clk-iproc', 'clk-mvebu' and 'clk-qcom-a53' into clk-next

* clk-iproc:
  clk: iproc: Minor tidy up of iproc pll data structures
  clk: iproc: Allow plls to do minor rate changes without reset
  clk: iproc: Fix error in the pll post divider rate calculation
  clk: iproc: Allow iproc pll to runtime calculate vco parameters

* clk-mvebu:
  clk: mvebu: armada-37xx-periph: Use PTR_ERR_OR_ZERO()

* clk-qcom-a53:
  clk: qcom: Add APCS clock controller support
  clk: qcom: Add regmap mux-div clocks support
  clk: qcom: Add A53 PLL support

7 years agoMerge branches 'clk-at91', 'clk-imx7ulp', 'clk-axigen', 'clk-si5351' and 'clk-pxa...
Stephen Boyd [Sat, 27 Jan 2018 00:41:52 +0000 (16:41 -0800)]
Merge branches 'clk-at91', 'clk-imx7ulp', 'clk-axigen', 'clk-si5351' and 'clk-pxa' into clk-next

* clk-at91:
  clk: at91: pmc: Support backup for programmable clocks
  clk: at91: pmc: Save SCSR during suspend
  clk: at91: pmc: Wait for clocks when resuming

* clk-imx7ulp:
  clk: Don't touch hardware when reparenting during registration

* clk-axigen:
  clk: axi-clkgen: Round closest in round_rate() and recalc_rate()
  clk: axi-clkgen: Correctly handle nocount bit in recalc_rate()

* clk-si5351:
  clk: si5351: _si5351_clkout_reset_pll() can be static
  clk: si5351: Do not enable parent clocks on probe
  clk: si5351: Rename internal plls to avoid name collisions
  clk: si5351: Apply PLL soft reset before enabling the outputs
  clk: si5351: Add DT property to enable PLL reset
  clk: si5351: implement remove handler

* clk-pxa:
  clk: pxa: unbreak lookup of CLK_POUT

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: aspeed: Handle inverse polarity of USB port 1 clock gate
Benjamin Herrenschmidt [Fri, 12 Jan 2018 05:48:01 +0000 (16:48 +1100)]
clk: aspeed: Handle inverse polarity of USB port 1 clock gate

The USB port 1 clock gate control has an inversed polarity
from all the other clock gates in the chip. This makes the
aspeed_clk_{enable,disable} functions honor the flag
CLK_GATE_SET_TO_DISABLE and set that flag appropriately
so it's set for all clocks except USB port 1.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: aspeed: Fix return value check in aspeed_cc_init()
Wei Yongjun [Fri, 5 Jan 2018 01:41:01 +0000 (01:41 +0000)]
clk: aspeed: Fix return value check in aspeed_cc_init()

In case of error, the function of_iomap() returns NULL pointer not
ERR_PTR(). The IS_ERR() test in the return value check should be
replaced with NULL test.

Fixes: a2e230c7b2ea ("clk: Add clock driver for ASPEED BMC SoCs")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: aspeed: Add reset controller
Joel Stanley [Fri, 22 Dec 2017 02:45:22 +0000 (13:15 +1030)]
clk: aspeed: Add reset controller

There are some resets that are not associated with gates. These are
represented by a reset controller.

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: aspeed: Register gated clocks
Joel Stanley [Fri, 22 Dec 2017 02:45:21 +0000 (13:15 +1030)]
clk: aspeed: Register gated clocks

The majority of the clocks in the system are gates paired with a reset
controller that holds the IP in reset.

This borrows from clk_hw_register_gate, but registers two 'gates', one
to control the clock enable register and the other to control the reset
IP. This allows us to enforce the ordering:

 1. Place IP in reset
 2. Enable clock
 3. Delay
 4. Release reset

There are some gates that do not have an associated reset; these are
handled by using -1 as the index for the reset.

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: aspeed: Add platform driver and register PLLs
Joel Stanley [Fri, 22 Dec 2017 02:45:20 +0000 (13:15 +1030)]
clk: aspeed: Add platform driver and register PLLs

This registers a platform driver to set up all of the non-core clocks.

The clocks that have configurable rates are now registered.

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: aspeed: Register core clocks
Joel Stanley [Fri, 22 Dec 2017 02:45:19 +0000 (13:15 +1030)]
clk: aspeed: Register core clocks

This registers the core clocks; those which are required to calculate
the rate of the timer peripheral so the system can load a clocksource
driver.

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: Add clock driver for ASPEED BMC SoCs
Joel Stanley [Fri, 22 Dec 2017 02:45:18 +0000 (13:15 +1030)]
clk: Add clock driver for ASPEED BMC SoCs

This adds the stub of a driver for the ASPEED SoCs. The clocks are
defined and the static registration is set up.

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoMerge tag 'sunxi-clk-for-4.16-2' of https://git.kernel.org/pub/scm/linux/kernel/git...
Stephen Boyd [Wed, 10 Jan 2018 22:45:33 +0000 (14:45 -0800)]
Merge tag 'sunxi-clk-for-4.16-2' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux into clk-allwinner

Pull Allwinner clock changes from Chen-Yu Tsai:

 - Fix hardware description for the DE2 clocks on the A64 and H5 SoCs
 - Support DE2 clocks on the H3
 - Fix description for the TCON1 clock on A83T

All these are non-critical, as they have no users.

* tag 'sunxi-clk-for-4.16-2' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux:
  clk: sunxi-ng: a83t: Add M divider to TCON1 clock
  clk: sunxi-ng: fix the A64/H5 clock description of DE2 CCU
  clk: sunxi-ng: add support for Allwinner H3 DE2 CCU
  dt-bindings: fix the binding of Allwinner DE2 CCU of A83T and H3

7 years agoclk: mediatek: adjust dependency of reset.c to avoid unexpectedly being built
Sean Wang [Fri, 5 Jan 2018 08:14:06 +0000 (16:14 +0800)]
clk: mediatek: adjust dependency of reset.c to avoid unexpectedly being built

Changes from v1->v2:
Add 'select RESET_CONTROLLER' under COMMON_CLK_MEDIATEK and enable
reset.c to be built when COMMON_CLK_MEDIATEK is selected. That should
be quite reasonable because the reset controller is tightly embedded
inside and exported from these clock subsystems. At least it can be found
on infracfg and pericfg subsystem that both are really fundamental block
lots of devices must depend on.

commit 74cb0d6dde8 ("clk: mediatek: fixup test-building of MediaTek clock
drivers") can let the build system looking into the directory where the
clock drivers resides and then allow test-building the drivers.

But the change also gives rise to certain incorrect behavior which is
reset.c being built even not depending on either COMPILE_TEST or
ARCH_MEDIATEK alternative dependency. To get rid of reset.c being built
unexpectedly on the other platforms, it would be a good change that the
file should be built depending on its own specific configuration rather
than just on generic RESET_CONTROLLER one.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Cc: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: fix reentrancy of clk_enable() on UP systems
David Lechner [Fri, 5 Jan 2018 01:46:08 +0000 (19:46 -0600)]
clk: fix reentrancy of clk_enable() on UP systems

Reentrant calls to clk_enable() are not working on UP systems. This is
caused by the fact spin_trylock_irqsave() always returns true when
CONFIG_SMP=n (and CONFIG_DEBUG_SPINLOCK=n) which causes the reference
counting to not work correctly when clk_enable_lock() is called twice
before clk_enable_unlock() is called (this happens when clk_enable()
is called from within another clk_enable()).

This fixes the problem by skipping the call to spin_trylock_irqsave() on UP
systems and relying solely on reference counting. We also make sure to set
flags in this case so that we are not returning an uninitialized value.

Suggested-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: meson-axg: fix potential NULL dereference in axg_clkc_probe()
weiyongjun (A) [Fri, 5 Jan 2018 01:50:59 +0000 (01:50 +0000)]
clk: meson-axg: fix potential NULL dereference in axg_clkc_probe()

platform_get_resource() may return NULL, add proper
check to avoid potential NULL dereferencing.

This is detected by Coccinelle semantic patch.

@@
expression pdev, res, n, t, e, e1, e2;
@@

res = platform_get_resource(pdev, t, n);
+ if (!res)
+   return -EINVAL;
... when != res == NULL
e = devm_ioremap(e1, res->start, e2);

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoMerge tag 'clk-renesas-for-v4.16-tag2' of git://git.kernel.org/pub/scm/linux/kernel...
Stephen Boyd [Wed, 10 Jan 2018 21:23:06 +0000 (13:23 -0800)]
Merge tag 'clk-renesas-for-v4.16-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers into clk-renesas

Pull Renesas clk driver update from Geert Uytterhoeven:

  - Add support for the FDP1-0 module clock on R-Car M3-W

* tag 'clk-renesas-for-v4.16-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers:
  clk: renesas: r8a7796: Add FDP clock

7 years agoclk: Simplify debugfs registration
Stephen Boyd [Thu, 4 Jan 2018 00:44:37 +0000 (16:44 -0800)]
clk: Simplify debugfs registration

We don't need a goto here. Drop it.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: Fix debugfs_create_*() usage
Geert Uytterhoeven [Wed, 3 Jan 2018 11:06:15 +0000 (12:06 +0100)]
clk: Fix debugfs_create_*() usage

When exposing data access through debugfs, the correct
debugfs_create_*() functions must be used, matching the data
types.

Remove all casts from data pointers passed to debugfs_create_*()
functions, as such casts prevent the compiler from flagging bugs.

clk_core.rate and .accuracy are "unsigned long", hence casting
their addresses to "u32 *" exposed the wrong halves on big-endian
64-bit systems. Fix this by using debugfs_create_ulong() instead.

Octal permissions are preferred, as they are easier to read than
symbolic permissions. Hence replace "S_IRUGO" by "0444"
throughout.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
[sboyd@codeaurora.org: Squash the octal change in too]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: Show symbolic clock flags in debugfs
Geert Uytterhoeven [Wed, 3 Jan 2018 11:06:16 +0000 (12:06 +0100)]
clk: Show symbolic clock flags in debugfs

Currently the virtual "clk_flags" file in debugfs shows the numeric
value of the top-level framework flags for the specified clock.
Hence the user must manually interpret these values.

Moreover, on big-endian 64-bit systems, the wrong half of the value is
shown, due to the cast from "unsigned long *" to "u32 *".

Fix both issues by showing the symbolic flag names instead.
Any non-standard flags are shown as a hex number.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: renesas: r8a7796: Add FDP clock
ABE Hiroshige [Thu, 14 Dec 2017 13:50:55 +0000 (22:50 +0900)]
clk: renesas: r8a7796: Add FDP clock

This patch adds FDP1-0 clock to the R8A7796 SoC.

Signed-off-by: ABE Hiroshige <hiroshige.abe.zc@renesas.com>
Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com>
[geert: s/fdp0/fdp1-0/]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 years agoclk: Move __clk_{get,put}() into private clk.h API
Stephen Boyd [Wed, 3 Jan 2018 00:54:16 +0000 (16:54 -0800)]
clk: Move __clk_{get,put}() into private clk.h API

We can move these APIs into the private header file now that we
don't have any users of the __clk_get() and __clk_put() APIs
outside of clkdev.c and clk.c.

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: sunxi: Use CLK_IS_CRITICAL flag for critical clks
Stephen Boyd [Wed, 3 Jan 2018 00:50:27 +0000 (16:50 -0800)]
clk: sunxi: Use CLK_IS_CRITICAL flag for critical clks

We'd like to privatize __clk_get(), but the sunxi clk driver is
calling this function to keep a reference held on the clk and
call clk_prepare_enable() on it. We support this design in the
clk core now with the CLK_IS_CRITICAL flag, so let's just use
that instead.

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: Improve flags doc for of_clk_detect_critical()
Geert Uytterhoeven [Wed, 3 Jan 2018 11:06:14 +0000 (12:06 +0100)]
clk: Improve flags doc for of_clk_detect_critical()

The "flags" parameter passed to of_clk_detect_critical() cannot be a
pointer to a real clk_core.flags field, as clk_core is private to the
clock framework internals.

Change the comment to refer to top-level framework flags instead.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoarch: Remove clkdev.h asm-generic from Kbuild
Stephen Boyd [Tue, 2 Jan 2018 23:50:06 +0000 (15:50 -0800)]
arch: Remove clkdev.h asm-generic from Kbuild

Now that every architecture is using the generic clkdev.h file
and we no longer include asm/clkdev.h anywhere in the tree, we
can remove it.

Cc: Russell King <linux@armlinux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: <linux-arch@vger.kernel.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> [m68k]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: sunxi-ng: a83t: Add M divider to TCON1 clock
Jernej Škrabec [Sat, 30 Dec 2017 21:01:54 +0000 (22:01 +0100)]
clk: sunxi-ng: a83t: Add M divider to TCON1 clock

TCON1 also has M divider, contrary to TCON0. And the mux is only
2 bits wide, instead of 3.

Fixes: 05359be1176b ("clk: sunxi-ng: Add driver for A83T CCU")
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
[wens@csie.org: Add description about mux width difference]
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
7 years agoMerge tag 'meson-clk-for-v4.16-3' of git://github.com/BayLibre/clk-meson into clk...
Stephen Boyd [Wed, 3 Jan 2018 01:51:29 +0000 (17:51 -0800)]
Merge tag 'meson-clk-for-v4.16-3' of git://github.com/BayLibre/clk-meson into clk-meson

Pull Amlogic clk driver update from Jerome Brunet:

 - Fix overflow in the mpll driver on 32bits arch

* tag 'meson-clk-for-v4.16-3' of git://github.com/BayLibre/clk-meson:
  clk: meson: mpll: use 64-bit maths in params_from_rate

7 years agoMerge tag 'aspeed-4.16-clk-binding' of git://git.kernel.org/pub/scm/linux/kernel...
Stephen Boyd [Wed, 3 Jan 2018 01:38:33 +0000 (17:38 -0800)]
Merge tag 'aspeed-4.16-clk-binding' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/aspeed into HEAD

dt-bindings: Clock binding for ASPEED SoCs

This tag is required for the ARM SoC and clk trees in the 4.16 merge
window. It contains the clock binding header that is used by the ASPEED
clk driver and the device trees.

* tag 'aspeed-4.16-clk-binding' of git://git.kernel.org/pub/scm/linux/kernel/git/joel/aspeed:
  dt-bindings: clock: Add ASPEED constants

7 years agoclk: Prepare to remove asm-generic/clkdev.h
Stephen Boyd [Tue, 2 Jan 2018 23:47:07 +0000 (15:47 -0800)]
clk: Prepare to remove asm-generic/clkdev.h

Now that all the users of asm/clkdev.h have been replaced with
the generic file we can get rid of the asm-generic file as well
and implement that code directly where it's used.

We only have one caller of __clkdev_alloc(), in clkdev.c so we
can easily remove that and drop the include of asm/clkdev.h in
linux/clkdev.h by putting the __clk_get/__clk_put inlines in
their respective location.

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoblackfin: Use generic clkdev.h header
Stephen Boyd [Wed, 27 Jan 2016 22:18:02 +0000 (14:18 -0800)]
blackfin: Use generic clkdev.h header

The generic header file is equivalent to the blackfin version, so
just use the generic one.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: Add APCS clock controller support
Georgi Djakov [Tue, 5 Dec 2017 15:47:01 +0000 (17:47 +0200)]
clk: qcom: Add APCS clock controller support

Add a driver for the APCS clock controller. It is part of the APCS
hardware block, which among other things implements also a combined
mux and half integer divider functionality. It can choose between a
fixed-rate clock or the dedicated APCS (A53) PLL. The source and the
divider can be set both at the same time.

This is required for enabling CPU frequency scaling on MSM8916-based
platforms.

Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Tested-by: Amit Kucheria <amit.kucheria@linaro.org>
[sboyd@codeaurora.org: Include rcg header for parent_map, drop
multiple unneeded includes, add COMPILE_TEST to APCS depends,
made tristate/modular]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: Add regmap mux-div clocks support
Georgi Djakov [Tue, 5 Dec 2017 15:46:59 +0000 (17:46 +0200)]
clk: qcom: Add regmap mux-div clocks support

Add support for hardware that can switch both parent clock and divider
at the same time. This avoids generating intermediate frequencies from
either the old parent clock and new divider or new parent clock and
old divider combinations.

Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
Tested-by: Amit Kucheria <amit.kucheria@linaro.org>
[sboyd@codeaurora.org: Change a comment style, drop parent_map in
favor of a u32 array instead, export symbols for clk_ops and mux
function]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: qcom: Add A53 PLL support
Georgi Djakov [Tue, 5 Dec 2017 15:46:58 +0000 (17:46 +0200)]
clk: qcom: Add A53 PLL support

The CPUs on Qualcomm MSM8916-based platforms are clocked by two PLLs,
a primary (A53) CPU PLL and a secondary fixed-rate GPLL0. These sources
are connected to a mux and half-integer divider, which is feeding the
CPU cores.

This patch adds support for the primary CPU PLL which generates the
higher range of frequencies above 1GHz.

Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Tested-by: Amit Kucheria <amit.kucheria@linaro.org>
[sboyd@codeaurora.org: Move to devm provider registration,
NUL terminate frequency table, made tristate/modular]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: sunxi-ng: fix the A64/H5 clock description of DE2 CCU
Icenowy Zheng [Fri, 22 Dec 2017 12:22:35 +0000 (20:22 +0800)]
clk: sunxi-ng: fix the A64/H5 clock description of DE2 CCU

The clocks of A64/H5 SoCs in the DE2 CCU is the same as the clocks in H3
DE2 CCU rather than the A83T DE2 CCU (the parent of them is the DE
module clock).

Fix this by change the clock descriptions to use the clocks of H3.

Fixes: 763c5bd045b1 ("clk: sunxi-ng: add support for DE2 CCU")
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
7 years agoclk: sunxi-ng: add support for Allwinner H3 DE2 CCU
Icenowy Zheng [Fri, 22 Dec 2017 12:22:34 +0000 (20:22 +0800)]
clk: sunxi-ng: add support for Allwinner H3 DE2 CCU

Allwinner H3 features a DE2 CCU like the one on A83T, however the
parent of the clocks is the DE module clock, not the PLL_DE clock.

Add support for it.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
7 years agodt-bindings: fix the binding of Allwinner DE2 CCU of A83T and H3
Icenowy Zheng [Fri, 22 Dec 2017 12:22:33 +0000 (20:22 +0800)]
dt-bindings: fix the binding of Allwinner DE2 CCU of A83T and H3

The DE2 CCU is different on A83T and H3 -- the parent of the clocks on
A83T is PLL_DE but on H3 it's the DE module clock. This is not noticed
when I develop the DE2 CCU driver.

Fix the binding by using different compatibles for A83T and H3, adding
notes for the PLL_DE usage on A83T, and change the binding example's
compatible from A83T to H3 (as it specifies the DE module clock).

Fixes: ed74f8a8a679 ("dt-bindings: add binding for the Allwinner DE2 CCU")
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
7 years agoclk: divider: fix incorrect usage of container_of
Jerome Brunet [Thu, 21 Dec 2017 16:30:54 +0000 (17:30 +0100)]
clk: divider: fix incorrect usage of container_of

divider_recalc_rate() is an helper function used by clock divider of
different types, so the structure containing the 'hw' pointer is not
always a 'struct clk_divider'

At the following line:
> div = _get_div(table, val, flags, divider->width);

in several cases, the value of 'divider->width' is garbage as the actual
structure behind this memory is not a 'struct clk_divider'

Fortunately, this width value is used by _get_val() only when
CLK_DIVIDER_MAX_AT_ZERO flag is set. This has never been the case so
far when the structure is not a 'struct clk_divider'. This is probably
why we did not notice this bug before

Fixes: afe76c8fd030 ("clk: allow a clk divider with max divisor when zero")
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Sylvain Lemieux <slemieux.tyco@gmail.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: mvebu: armada-37xx-periph: Use PTR_ERR_OR_ZERO()
Gomonovych, Vasyl [Tue, 28 Nov 2017 23:04:06 +0000 (00:04 +0100)]
clk: mvebu: armada-37xx-periph: Use PTR_ERR_OR_ZERO()

Fix ptr_ret.cocci warnings:
drivers/clk/mvebu/armada-37xx-periph.c:362:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

Generated by: scripts/coccinelle/api/ptr_ret.cocci

Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: iproc: Minor tidy up of iproc pll data structures
Lori Hikichi [Mon, 14 Aug 2017 19:00:41 +0000 (12:00 -0700)]
clk: iproc: Minor tidy up of iproc pll data structures

There were a few fields in the iproc pll data structures that were
holding information that was not true state information.
Using stack variables is sufficient and simplifies the structure.
There are not any functional changes in this commit.

Signed-off-by: Lori Hikichi <lori.hikichi@broadcom.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: iproc: Allow plls to do minor rate changes without reset
Lori Hikichi [Mon, 14 Aug 2017 19:00:40 +0000 (12:00 -0700)]
clk: iproc: Allow plls to do minor rate changes without reset

The iproc plls are capable of doing small rate changes without the
need for a full reset and re-lock procedure.  This feature will
allow for small tweaks to the PLL rate to occur smoothly.

Signed-off-by: Lori Hikichi <lori.hikichi@broadcom.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: iproc: Fix error in the pll post divider rate calculation
Lori Hikichi [Mon, 14 Aug 2017 19:00:39 +0000 (12:00 -0700)]
clk: iproc: Fix error in the pll post divider rate calculation

The pll post divider code was using DIV_ROUND_UP when determining the
divider value best suited to produce the target frequency.
Using DIV_ROUND_CLOSEST will give us better divider values when
the division results in a small remainder.
Also, change the post divider clock over to the determine_rate api
instead of round_rate.

Signed-off-by: Simran Rai <ssimran@broadcom.com>
Signed-off-by: Lori Hikichi <lori.hikichi@broadcom.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: iproc: Allow iproc pll to runtime calculate vco parameters
Lori Hikichi [Mon, 14 Aug 2017 19:00:38 +0000 (12:00 -0700)]
clk: iproc: Allow iproc pll to runtime calculate vco parameters

Add the ability for the iproc pll to calculate the pll parameters at
runtime instead of only using predefined tables. This ability allows
the clock users to select from the full range of vco frequencies.
The old method of table based programming is retained so that existing
users will retain expected behavior. The flag IPROC_CLK_PLL_CALC_PARAM
will need to be set to enable the new runtime calculation method.
Currently, this is only being enabled for the audio pll.

This feature also revealed a problem with the driver using the
round_rate api.  The round_rate api does not allow for frequencies larger
than 2^31 to be returned.  Those large frequencies are interpreted as an
error code. Therefore, we are moving to the determine_rate api which
solves this problem.

Signed-off-by: Simran Rai <ssimran@broadcom.com>
Signed-off-by: Lori Hikichi <lori.hikichi@broadcom.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: si5351: _si5351_clkout_reset_pll() can be static
Wu Fengguang [Wed, 27 Dec 2017 04:25:13 +0000 (12:25 +0800)]
clk: si5351: _si5351_clkout_reset_pll() can be static

Fixes: b26ff127c52c ("clk: si5351: Apply PLL soft reset before enabling the outputs")
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoMerge tag 'sunxi-clk-for-4.16' of https://git.kernel.org/pub/scm/linux/kernel/git...
Stephen Boyd [Thu, 28 Dec 2017 18:46:56 +0000 (10:46 -0800)]
Merge tag 'sunxi-clk-for-4.16' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux into clk-allwinner

Pull Allwinner clock changes from Chen-Yu Tsai:

 "Fixed-post-divider support is added for two types of our clocks.
  This in turn is used to support odd clocks on some of our SoCs.
  On the A64, the MMC module clocks have a hidden post-divider.
  On the A83T, a post-divider is needed to support programming
  sigma-delta modulation with known fixed parameters from the
  BSP kernel for the audio PLL.

  There's also a small cleanup to use the shorter PTR_ERR_OR_ZERO
  macro in various functions."

* tag 'sunxi-clk-for-4.16' of https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux:
  clk: sunxi-ng: sun8i: a83t: Use sigma-delta modulation for audio PLL
  clk: sunxi-ng: sun8i: a83t: Add /2 fixed post divider to audio PLL
  clk: sunxi-ng: Support fixed post-dividers on NM style clocks
  clk: sunxi-ng: sun50i: a64: Add 2x fixed post-divider to MMC module clocks
  clk: sunxi-ng: Support fixed post-dividers on MP style clocks
  clk: sunxi: Use PTR_ERR_OR_ZERO()

7 years agoclk: pxa: unbreak lookup of CLK_POUT
Igor Grinberg [Tue, 26 Dec 2017 13:30:36 +0000 (15:30 +0200)]
clk: pxa: unbreak lookup of CLK_POUT

Since switching to clk drivers, the CLK_POUT cannot be searched for by
clk_get() API and thus it returns with ENOENT.
Register it with the clk_lookup and thus unbreak the users of it.

Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: meson-axg: make local symbol axg_gp0_params_table static
weiyongjun (A) [Thu, 28 Dec 2017 03:18:30 +0000 (03:18 +0000)]
clk: meson-axg: make local symbol axg_gp0_params_table static

Fixes the following sparse warning:

drivers/clk/meson/axg.c:260:25: warning:
 symbol 'axg_gp0_params_table' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: meson-axg: fix return value check in axg_clkc_probe()
weiyongjun (A) [Thu, 28 Dec 2017 02:40:49 +0000 (02:40 +0000)]
clk: meson-axg: fix return value check in axg_clkc_probe()

In case of error, the function devm_ioremap() returns NULL pointer
not ERR_PTR(). The IS_ERR() test in the return value check should be
replaced with NULL test.

Fixes: 78b4af312f91 ("clk: meson-axg: add clock controller drivers")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: mediatek: Fix all warnings for missing struct clk_onecell_data
Sean Wang [Mon, 25 Dec 2017 08:03:57 +0000 (16:03 +0800)]
clk: mediatek: Fix all warnings for missing struct clk_onecell_data

Even though the header file linux/clk-provider.h is already being properly
included in clk-mtk.h, the definition of struct clk_onecell_data still
must depend on CONFIG_COMMON_CLK defined and thus it's possible that
below build warnings occur when CONFIG_COMMON_CLK is not being selected.

Therefore, these functions which need struct clk_onecell_data without
declaring that structure first requires simply declaring that this struct
exists prior to referencing it in clk-mtk.h

Changes from v1->v2:
enhance v1 based on two useful solutions Jean Delvare kindly suggested.

All warnings (new ones prefixed by >>):

In file included from drivers/clk/mediatek/reset.c:22:0:
>>drivers/clk/mediatek/clk-mtk.h:44:19: warning: 'struct clk_onecell_data'
declared inside parameter list will not be visible outside of
this definition or declaration
  int num, struct clk_onecell_data *clk_data);
  ^~~~~~~~~~~~~~~~
drivers/clk/mediatek/clk-mtk.h:63:19: warning: 'struct clk_onecell_data'
declared inside parameter list will not be visible outside of
this definition or declaration
  int num, struct clk_onecell_data *clk_data);
  ^~~~~~~~~~~~~~~~
drivers/clk/mediatek/clk-mtk.h:145:10: warning: 'struct clk_onecell_data'
declared inside parameter list will not be visible outside of
this definition or declaration
  struct clk_onecell_data *clk_data);
 ^~~~~~~~~~~~~~~~
drivers/clk/mediatek/clk-mtk.h:164:11: warning: 'struct clk_onecell_data'
declared inside parameter list will not be visible outside of
this definition or declaration
   struct clk_onecell_data *clk_data);
  ^~~~~~~~~~~~~~~~
drivers/clk/mediatek/clk-mtk.h:190:12: warning: 'struct clk_onecell_data'
declared inside parameter list will not be visible outside of this
definition or declaration
    struct clk_onecell_data *clk_data);
   ^~~~~~~~~~~~~~~~

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Cc: kbuild-all@01.org
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Jean Delvare <jdelvare@suse.de>
Cc: linux-clk@vger.kernel.org
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: meson: mpll: use 64-bit maths in params_from_rate
Martin Blumenstingl [Sat, 23 Dec 2017 21:38:32 +0000 (22:38 +0100)]
clk: meson: mpll: use 64-bit maths in params_from_rate

"rem * SDM_DEN" can easily overflow on the 32-bit Meson8 and Meson8b
SoCs if the "remainder" (after the division operation) is greater than
262143Hz. This is likely to happen since the input clock for the MPLLs
on Meson8 and Meson8b is "fixed_pll", which is running at a rate of
2550MHz.

One example where this was observed to be problematic was the Ethernet
clock calculation (which takes MPLL2 as input). When requesting a rate
of 125MHz there is a remainder of 2500000Hz.
The resulting MPLL2 rate before this patch was 127488329Hz.
The resulting MPLL2 rate after this patch is 124999103Hz.

Commit b609338b26f5 ("clk: meson: mpll: use 64bit math in
rate_from_params") already fixed a similar issue in rate_from_params.

Fixes: 007e6e5c5f01d3 ("clk: meson: mpll: add rw operation")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
7 years agoclk: si5351: Do not enable parent clocks on probe
Sergej Sawazki [Tue, 25 Jul 2017 18:32:11 +0000 (20:32 +0200)]
clk: si5351: Do not enable parent clocks on probe

The si5351 driver should not prepare or enable other clocks in the tree on
probe. Let the clients decide when to prepare or enable the clocks.

Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Rabeeh Khoury <rabeeh@solid-run.com>
Signed-off-by: Sergej Sawazki <ce3a@gmx.de>
[sboyd@codeaurora.org: Remove most of the .remove function too]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: si5351: Rename internal plls to avoid name collisions
Sergej Sawazki [Tue, 25 Jul 2017 21:21:02 +0000 (23:21 +0200)]
clk: si5351: Rename internal plls to avoid name collisions

This drivers probe fails due to a clock name collision if a clock named
'plla' or 'pllb' is already registered when registering this drivers
internal plls.

Fix it by renaming internal plls to avoid name collisions.

Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Rabeeh Khoury <rabeeh@solid-run.com>
Signed-off-by: Sergej Sawazki <sergej@taudac.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: si5351: Apply PLL soft reset before enabling the outputs
Sergej Sawazki [Sat, 16 Sep 2017 11:44:42 +0000 (13:44 +0200)]
clk: si5351: Apply PLL soft reset before enabling the outputs

The "Si5351A/B/C Data Sheet" states to apply a PLL soft reset before
enabling the output clocks [1]. This is required to get a deterministic
phase relationship between the output clocks.

Without resetting the PLL, the phase relationship between the clocks is
unpredictable. Fix this by resetting the PLL in si5351_clkout_prepare().

References:
[1] https://www.silabs.com/Support%20Documents/TechnicalDocs/Si5351-B.pdf
    Figure 12 ("I2C Programming Procedure")

Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Rabeeh Khoury <rabeeh@solid-run.com>
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Sergej Sawazki <sergej@taudac.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: si5351: Add DT property to enable PLL reset
Sergej Sawazki [Sat, 16 Sep 2017 11:44:41 +0000 (13:44 +0200)]
clk: si5351: Add DT property to enable PLL reset

Add optional output clock DT property to enable PLL reset when a clock
output is enabled.

Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Rabeeh Khoury <rabeeh@solid-run.com>
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Sergej Sawazki <sergej@taudac.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: si5351: implement remove handler
Alexey Khoroshilov [Fri, 15 Sep 2017 22:30:30 +0000 (01:30 +0300)]
clk: si5351: implement remove handler

The driver has no remove function, so it does not cleanup
resources that are not under devm management.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: axi-clkgen: Round closest in round_rate() and recalc_rate()
Lars-Peter Clausen [Tue, 5 Sep 2017 09:32:41 +0000 (11:32 +0200)]
clk: axi-clkgen: Round closest in round_rate() and recalc_rate()

To minimize the rounding error round to the closest integer when
calculating the result in the recalc_rate() and set_rate() callbacks.

Also in order to improve precision multiply first and then divide.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: axi-clkgen: Correctly handle nocount bit in recalc_rate()
Lars-Peter Clausen [Tue, 5 Sep 2017 09:32:40 +0000 (11:32 +0200)]
clk: axi-clkgen: Correctly handle nocount bit in recalc_rate()

If the nocount bit is set the divider is bypassed and the settings for the
divider count should be ignored and a divider value of 1 should be assumed.
Handle this correctly in the driver recalc_rate() callback.

While the driver sets up the part so that the read back dividers values
yield the correct result the power-on reset settings of the part might not
reflect this and hence calling e.g. clk_get_rate() without prior calls to
clk_set_rate() will yield the wrong result.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: Don't touch hardware when reparenting during registration
Stephen Boyd [Thu, 2 Nov 2017 07:36:09 +0000 (00:36 -0700)]
clk: Don't touch hardware when reparenting during registration

The orphan clocks reparent operation shouldn't touch the hardware
if clocks are enabled, otherwise it may get a chance to disable a
newly registered critical clock which triggers the warning below.

Assuming we have two clocks: A and B, B is the parent of A.
Clock A has flag: CLK_OPS_PARENT_ENABLE
Clock B has flag: CLK_IS_CRITICAL

Step 1:
Clock A is registered, then it becomes orphan.

Step 2:
Clock B is registered. Before clock B reach the critical clock enable
operation, orphan A will find the newly registered parent B and do
reparent operation, then parent B will be finally disabled in
__clk_set_parent_after() due to CLK_OPS_PARENT_ENABLE flag as there's
still no users of B which will then trigger the following warning.

WARNING: CPU: 0 PID: 0 at drivers/clk/clk.c:597 clk_core_disable+0xb4/0xe0
Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.11.0-rc1-00056-gdff1f66-dirty #1373
Hardware name: Generic DT based system
Backtrace:
[<c010c4bc>] (dump_backtrace) from [<c010c764>] (show_stack+0x18/0x1c)
 r6:600000d3 r5:00000000 r4:c0e26358 r3:00000000
[<c010c74c>] (show_stack) from [<c040599c>] (dump_stack+0xb4/0xe8)
[<c04058e8>] (dump_stack) from [<c0125c94>] (__warn+0xd8/0x104)
 r10:c0c21cd0 r9:c048aa78 r8:00000255 r7:00000009 r6:c0c1cd90 r5:00000000
 r4:00000000 r3:c0e01d34
[<c0125bbc>] (__warn) from [<c0125d74>] (warn_slowpath_null+0x28/0x30)
 r9:00000000 r8:ef00bf80 r7:c165ac4c r6:ef00bf80 r5:ef00bf80 r4:ef00bf80
[<c0125d4c>] (warn_slowpath_null) from [<c048aa78>] (clk_core_disable+0xb4/0xe0)
[<c048a9c4>] (clk_core_disable) from [<c048be88>] (clk_core_disable_lock+0x20/0x2c)
 r4:000000d3 r3:c0e0af00
[<c048be68>] (clk_core_disable_lock) from [<c048c224>] (clk_core_disable_unprepare+0x14/0x28)
 r5:00000000 r4:ef00bf80
[<c048c210>] (clk_core_disable_unprepare) from [<c048c270>] (__clk_set_parent_after+0x38/0x54)
 r4:ef00bd80 r3:000010a0
[<c048c238>] (__clk_set_parent_after) from [<c048daa8>] (clk_register+0x4d0/0x648)
 r6:ef00d500 r5:ef00bf80 r4:ef00bd80 r3:ef00bfd4
[<c048d5d8>] (clk_register) from [<c048dc30>] (clk_hw_register+0x10/0x1c)
 r9:00000000 r8:00000003 r7:00000000 r6:00000824 r5:00000001 r4:ef00d500
[<c048dc20>] (clk_hw_register) from [<c048e698>] (_register_divider+0xcc/0x120)
[<c048e5cc>] (_register_divider) from [<c048e730>] (clk_register_divider+0x44/0x54)
 r10:00000004 r9:00000003 r8:00000001 r7:00000000 r6:00000003 r5:00000001
 r4:f0810030
[<c048e6ec>] (clk_register_divider) from [<c0d3ff58>] (imx7ulp_clocks_init+0x558/0xe98)
 r7:c0e296f8 r6:c165c808 r5:00000000 r4:c165c808
[<c0d3fa00>] (imx7ulp_clocks_init) from [<c0d24db0>] (of_clk_init+0x118/0x1e0)
 r10:00000001 r9:c0e01f68 r8:00000000 r7:c0e01f60 r6:ef7f8974 r5:ef0035c0
 r4:00000006
[<c0d24c98>] (of_clk_init) from [<c0d04a50>] (time_init+0x2c/0x38)
 r10:efffed40 r9:c0d61a48 r8:c0e78000 r7:c0e07900 r6:ffffffff r5:c0e78000
 r4:00000000
[<c0d04a24>] (time_init) from [<c0d00b8c>] (start_kernel+0x218/0x394)
[<c0d00974>] (start_kernel) from [<6000807c>] (0x6000807c)
 r10:00000000 r9:410fc075 r8:6000406a r7:c0e0c930 r6:c0d61a44 r5:c0e07918
 r4:c0e78294

We know that the clk isn't enabled with any sort of prepare_count
here so we don't need to enable anything to prevent a race. And
we're holding the prepare mutex so set_rate/set_parent can't race
here either. Based on an earlier patch by Dong Aisheng.

Fixes: fc8726a2c021 ("clk: core: support clocks which requires parents enable (part 2)")
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Reported-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: mediatek: fixup test-building of MediaTek clock drivers
Sean Wang [Wed, 20 Dec 2017 06:42:59 +0000 (14:42 +0800)]
clk: mediatek: fixup test-building of MediaTek clock drivers

Let the build system looking into the directiory where the clock drivers
resides for the COMPILE_TEST alternative dependency allows test-building
the drivers.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: mediatek: group drivers under indpendent menu
Sean Wang [Wed, 20 Dec 2017 06:42:58 +0000 (14:42 +0800)]
clk: mediatek: group drivers under indpendent menu

Getting much MediaTek clock driver have been added to CCF, so it's
better adding the cleanup for grouping drivers under the independent
menu to simplify configuration selection. In addition, really trivial
fixups for typos are added in the same patch.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: at91: pmc: Support backup for programmable clocks
Romain Izard [Mon, 11 Dec 2017 16:55:35 +0000 (17:55 +0100)]
clk: at91: pmc: Support backup for programmable clocks

When an AT91 programmable clock is declared in the device tree, register
it into the Power Management Controller driver. On entering suspend mode,
the driver saves and restores the Programmable Clock registers to support
the backup mode for these clocks.

Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: at91: pmc: Save SCSR during suspend
Romain Izard [Mon, 11 Dec 2017 16:55:34 +0000 (17:55 +0100)]
clk: at91: pmc: Save SCSR during suspend

The contents of the System Clock Status Register (SCSR) needs to be
restored into the System Clock Enable Register (SCER).

As the bootloader will restore some clocks by itself, the issue can be
missed as only the USB controller, the LCD controller, the Image Sensor
controller and the programmable clocks will be impacted.

Fix the obvious typo in the suspend/resume code, as the IMR register
does not need to be saved twice.

Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoclk: at91: pmc: Wait for clocks when resuming
Romain Izard [Mon, 11 Dec 2017 16:55:33 +0000 (17:55 +0100)]
clk: at91: pmc: Wait for clocks when resuming

Wait for the syncronization of all clocks when resuming, not only the
UPLL clock. Do not use regmap_read_poll_timeout, as it will call BUG()
when interrupts are masked, which is the case in here.

Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
7 years agoMerge tag 'clk-renesas-for-v4.16-tag1' of git://git.kernel.org/pub/scm/linux/kernel...
Stephen Boyd [Fri, 22 Dec 2017 00:31:13 +0000 (16:31 -0800)]
Merge tag 'clk-renesas-for-v4.16-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers into clk-renesas

Pull Renesas clk driver updates from Geert Uytterhoeven:

  - Add support for the LVDS module clock on R-Car V3M,
  - Keep wakeup sources in Clock Domains active during system suspend,
    which will allow removing workarounds from drivers later.

* tag 'clk-renesas-for-v4.16-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers:
  clk: renesas: cpg-mssr: Keep wakeup sources active during system suspend
  clk: renesas: mstp: Keep wakeup sources active during system suspend
  clk: renesas: r8a77970: Add LVDS clock

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.kernel.org/pub/scm/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 agodt-bindings: clock: Add ASPEED constants
Joel Stanley [Mon, 11 Dec 2017 04:54:37 +0000 (15:24 +1030)]
dt-bindings: clock: Add ASPEED constants

These will be used by the clock driver and device trees.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
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