Commit Graph

991 Commits

Author SHA1 Message Date
Sylwester Nawrocki
e5ca8fb4cc clk: Fix minor errors in of_clk_init() function comments
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-27 16:48:14 -07:00
Sylwester Nawrocki
3f6d439f20 clk: reverse default clk provider initialization order in of_clk_init()
This restores the default clocks registration order as parsed from
devicetree, i.e. as before commit 1771b10d60
"clk: respect the clock dependencies in of_clk_init", for when there
is no explicit parent clock dependencies between clock providers
specified in the device tree.

It prevents regressions (boot failure, division by 0 errors) on
imx and exynos platforms.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-27 16:48:06 -07:00
Barry Song
7736692993 clk: sirf: update copyright years to 2014
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-26 21:47:35 -07:00
Chao Xie
5d26c15d3b clk: mmp: try to use closer one when do round rate
The orignal code will use the bigger rate between
"previous rate" and "current rate" when caculate the
rate.
In fact, hardware cares about the closest one.
So choose the closer rate between "previous rate" and
"current rate".

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-26 20:59:27 -07:00
Chao Xie
c45693a648 clk: mmp: fix the wrong calculation formula
The formula is numerator/denominator = Fin / (Fout * factor)
So
Fout = Fin * denominator / (numerator * factor).
Current clk_factor_round_rate and clk_factor_recalc_rate use
wrong formula. This patch will fix them.

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-26 20:59:27 -07:00
Chao Xie
7433ab43fa clk: mmp: fix wrong mask when calculate denominator
The code has typo when calculate denominator. It should use
den_mask instead of num_mask.

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-26 20:59:26 -07:00
Gabriel FERNANDEZ
ab35dc139a clk: st: Support for A9 MUX clocks
The patch supports the A9-mux clocks used by ClockGenA9

A9-mux clock : Multiplexer inside ClockGenA9. A9 clock can be driven by
either PLL or External clock (with an optional divide-by-2). This is
implemented as 3-parent clock : PLL, Ext-clk OR Ext-clk/2

Signed-off-by: Pankaj Dev <pankaj.dev@st.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-25 15:59:23 -07:00
Gabriel FERNANDEZ
ec8d27b41e clk: st: Support for ClockGenA9/DDR/GPU
The patch added support for DT registration of ClockGenA9/DDR/GPU

ClockgenA9/DDR : It includes c32 type PLL (also in ClockgenA1x), hence
only CLK_OF_DECLARE implementation is required.

ClockgenGPU : It includes c65 type PLL (also in ClockgenAx), hence
only CLK_OF_DECLARE implementation is required.

Signed-off-by: Pankaj Dev <pankaj.dev@st.com>
Signed-off-by: Gabriel Fernandez <gabriel.fernandez@st.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-25 15:59:17 -07:00
Gabriel FERNANDEZ
5f7aa9071e clk: st: Support for QUADFS inside ClockGenB/C/D/E/F
The patch supports the 216/432/660 type Quad Frequency Synthesizers
used by ClockGenB/C/D/E/F

QUADFS clock : It includes support for all 216/432/660 type Quad
Frequency Synthesizers : implemented as Fixed Parent / Rate / Gate clock,
with clock rate calculated reading H/w settings done at BOOT.

QuadFS have 4 outputs : chan0 chan1 chan2 chan3

Signed-off-by: Pankaj Dev <pankaj.dev@st.com>
Signed-off-by: Gabriel Fernandez <gabriel.fernandez@st.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-25 15:59:09 -07:00
Gabriel FERNANDEZ
44993d3840 clk: st: Support for VCC-mux and MUX clocks
The patch supports the VCC-mux and MUX clocks used by ClockGenC/F

VCC-mux clock : Divider-Multiplexer-Gate inside ClockGenC/F
It includes support for each channel : 4-parent Multiplexer, Post Divide
by 1, 2, 4 or 8, Gate to switch OFF the output channel. The clock is
implemented using generic clocks implemented in the kernel clk_divider, clk_mux,
clk_gate and clk_composite (to combine all)

MUX clock : 2-parent clock used inside ClockGenC/F. The clock is implemented
using generic clocks implemented in the kernel clk_mux.

Signed-off-by: Pankaj Dev <pankaj.dev@st.com>
Signed-off-by: Gabriel Fernandez <gabriel.fernandez@st.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-25 15:59:02 -07:00
Gabriel FERNANDEZ
b9b8e614b5 clk: st: Support for PLLs inside ClockGenA(s)
The patch supports the c65/c32 type PLLs used by ClockGenA(s)

PLL clock : It includes support for all c65/c32 type PLLs
inside ClockGenA(s) : implemented as Fixed Parent / Fixed Rate clock,
with clock rate calculated reading H/w settings done at BOOT.

c65 PLLs have 2 outputs : HS and LS
c32 PLLs have 1-4 outputs : ODFx

Signed-off-by: Pankaj Dev <pankaj.dev@st.com>
Signed-off-by: Gabriel Fernandez <gabriel.fernandez@st.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-25 15:58:56 -07:00
Gabriel FERNANDEZ
94885faf9d clk: st: Support for DIVMUX and PreDiv Clocks
The patch supports the DIVMUX and PreDiv clocks used by ClockGenA(s)

DIVMUX clock : Divider-Multiplexer-Gate inside ClockGenA(s)
It includes support for each channel : 3-parent Multiplexer,
Divider for each Parent, Gate to switch OFF the output channel. The
clock is implemented using generic clocks implemented in the kernel
clk_divider and clk_mux.

PreDiv clock : Fixed Divider Clock used inside ClockGenA(s) to divide
the oscillator clock by factor-of-16. The clock is implemented using
generic clocks implemented in the kernel clk_divider.

Signed-off-by: Pankaj Dev <pankaj.dev@st.com>
Signed-off-by: Gabriel Fernandez <gabriel.fernandez@st.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-25 15:58:47 -07:00
Alex Elder
c646cbf10f clk: support hardware-specific debugfs entries
Add a new clk_ops->debug_init method to allow a clock hardware
driver to populate the clock's debugfs directory with entries
beyond those common for every clock.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-24 17:10:07 -07:00
Krzysztof Kozlowski
afbd1a0c30 clk: s2mps11: Use of_get_child_by_name
of_find_node_by_name() walks over all nodes and can thus walk outside of
the parent node. Use of_get_child_by_name() instead.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-24 15:11:27 -07:00
Krzysztof Kozlowski
238e14055d clk: s2mps11: Fix possible NULL pointer dereference
If parent device does not have of_node set the s2mps11_clk_parse_dt()
returned NULL. This NULL was later passed to of_clk_add_provider() which
dereferenced it in pr_debug() call.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-24 15:11:27 -07:00
Zhangfei Gao
c115b13b85 clk: hisilicon: fix warning from smatch
drivers/clk/hisilicon/clk-hi3620.c:338
mmc_clk_delay() warn: always true condition '(para >= 0) => (0-u32max >= 0)'

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-20 19:05:39 -07:00
Wolfram Sang
a665962e8f clk: shmobile: add CPG driver for rz-platforms
Signed-off-by: Wolfram Sang <wsa@sang-engineering.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-20 18:22:36 -07:00
Sascha Hauer
f736386160 clk: turn rate change failed warning into pr_debug
If a rate change failed it's the opportunity of the caller to handle
this. Do not spam the log with a message.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-20 14:44:47 -07:00
Gregory CLEMENT
1771b10d60 clk: respect the clock dependencies in of_clk_init
Until now the clock providers were initialized in the order found in
the device tree. This led to have the dependencies between the clocks
not respected: children clocks could be initialized before their
parent clocks.

Instead of forcing each platform to manage its own initialization order,
this patch adds this work inside the framework itself.

Using the data of the device tree the of_clk_init function now delayed
the initialization of a clock provider if its parent provider was not
ready yet.

The strict dependency check (all parents of a given clk must be
initialized) was added by Boris BREZILLON

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-19 17:15:29 -07:00
Tang Yuantian
00fa6e5d13 clk: mpc85xx: Update the driver to align to new clock bindings
The clock bindings for Freescale CoreNet platform are updated.
So, the driver needs to be updated accordingly.
The main changes include:
	- Added a new node to present the input system clock
	- Changed PLL and MUX's compatible string

Signed-off-by: Tang Yuantian <Yuantian.Tang@freescale.com>
Acked-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-19 17:04:14 -07:00
Jean-Jacques Hiblot
141c71dd2c clk: at91: optimization of the set_rate callback
Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-19 15:22:02 -07:00
Jean-Jacques Hiblot
cce6db80a0 clk: at91: fix programmable clk irq handling
The PCKRDY bit is not set until the system clock is enabled.
This patch moves the management of the ready status in the system clock
driver.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-19 15:21:56 -07:00
Boris BREZILLON
693bb3d99d clk: at91: propagate rate change on system clks
System clks are just gates, and thus do not provide any rate operations.
Authorize clk rate change to be propagated to system clk parents.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-19 15:21:52 -07:00
Boris BREZILLON
419f612932 clk: at91: replace prog clk round_rate with determine_rate
Implement the determine_rate callback to choose the best parent clk that
fulfills the requested rate.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-19 15:21:39 -07:00
Mike Turquette
7876114798 updating clock drivers for Hisilicon
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.14 (GNU/Linux)
 
 iQIcBAABAgAGBQJTKUozAAoJELXbXY/c+iv2BxQP/RR9EpIQ+JpNlE4ib2cGlKt4
 x+9nlCN/rZzKNUDE5fJm5knOksR1Jlv7xD4Gtz81i0hMXRz13qu5kQHftnIVyOUX
 0bkMsEnuRKY2DuPV+1FbC1hi7jnfOxqHAWWl7Sk+bTqhQeH+ZWMk8V+vRbib2SKk
 ilr3XZStCd7kxoGBxJuCV389boQESvS46juPTl1fe9UZUjL1l9MnozyVAjgvF4Le
 N0iG8FNyoX2Sj1Mm8Qg4OIrVRryRzNv5Q8uSPbEY7Qzx0fl0y+fZ/1AlzQXnrwBo
 MJd32fLPnpE1wQB4z4vpI0bNSYfC6KjbP6JY2cBBWYBN/7HJnCXtzgtTGgMZh+8Y
 1LXoD4WxOQ18M3QWuiCtAoOqi9it920n7gzbfIu0zpiMwKOvQOZX1+npEkbBC6AP
 +em5cFGsBmtjQ5kARywtLTTkE3MDJIAlht7px53mdoxP0fCR3moRx4hsMbji+9Y4
 /bEG64JYLQN8GjAYLdVtb1JLTnUux6dgerxuciFFthV2mqXqEF59rMR/aVZE5LF1
 V+uZdxNoJI+Gn1dkFXbSQHqAMgEaqX8FaElRannrLUkUPVNLT+wTFFaGy7zGKWt8
 RLSKzg7+LROkxgXIRdJw/mR7TPHILaFrYkvx4XFYP+dle7VNwRSPKb46jQhYQAIG
 NjVgl2hBb6fMGEPrSUFx
 =GNi8
 -----END PGP SIGNATURE-----

Merge tag 'clk-hisi' of https://git.kernel.org/pub/scm/linux/kernel/git/hzhuang1/linux into clk-next-hisilcon

updating clock drivers for Hisilicon
2014-03-19 12:54:03 -07:00
Emilio López
9ce71ca10f clk: sunxi: fix thinko in comment
This should read MOD0 and not MMC; MMC is just one example of a MOD0
clock.

Signed-off-by: Emilio López <emilio@elopez.com.ar>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-19 12:35:07 -07:00
Emilio López
2226013972 clk: sunxi: fix some calculations
Some divisor calculations were misrounded, causing higher than requested
rates on some clocks. Fix them up using DIV_ROUND_UP, and replace one
homebrew instance of it as well with the right macro.

Reported-by: Boris BREZILLON <b.brezillon.dev@gmail.com>
Signed-off-by: Emilio López <emilio@elopez.com.ar>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-19 12:34:56 -07:00
Emilio López
5a8ddf2682 clk: sunxi: fix A20 PLL4 calculation
Allwinner actually reworked the PLL4 on A20; now it's compatible with
the sun4i PLL5/6 design previous to any divisions, as well as to the new
PLL8 in sun7i.

Signed-off-by: Emilio López <emilio@elopez.com.ar>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-19 12:34:39 -07:00
Mike Turquette
df21f62bbb Merge tag 'sunxi-clk-for-3.15' of https://bitbucket.org/emiliolopez/linux into clk-next-sunxi
Allwinner sunXi SoCs clock changes

This adds support for the new, more correct clock node naming and gets
the A10 compatibles in line with the rest of the other SoCs. It also
adds support for the USB, GMAC and A31's PLL6 clocks. Some of these
changes also require DT modifications that will be merged via arm-soc.
2014-03-19 12:14:11 -07:00
Haojian Zhuang
75af25f581 clk: hisi: remove static variable
Remove the static variable. So these common clock register helper could
be used in more SoCs.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
2014-03-19 15:31:27 +08:00
Haojian Zhuang
d3e6573c48 clk: hip04: add clock driver
Now only fixed rate clocks are appended into the clock driver.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
2014-03-19 15:23:53 +08:00
Haojian Zhuang
16d1c8991c clk: hisi: assign missing clk to table
The fixed rate and fixed factor clock isn't registered to clk table.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
2014-03-19 15:23:32 +08:00
Dinh Nguyen
95bb9f515f clk: socfpga: Fix section mismatch warning
WARNING: drivers/clk/socfpga/built-in.o(.data+0xc0): Section mismatch in
reference from the variable socfpga_child_clocks to the function
.init.text:socfpga_pll_init()
The variable socfpga_child_clocks references
the function __init socfpga_pll_init()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

WARNING: drivers/clk/socfpga/built-in.o(.data+0x184): Section mismatch in
reference from the variable socfpga_child_clocks to the function
.init.text:socfpga_periph_init()
The variable socfpga_child_clocks references
the function __init socfpga_periph_init()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

WARNING: drivers/clk/socfpga/built-in.o(.data+0x248): Section mismatch in
reference from the variable socfpga_child_clocks to the function
.init.text:socfpga_gate_init()
The variable socfpga_child_clocks references
the function __init socfpga_gate_init()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

Reported-by: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Dinh Nguyen <dinguyen@altera.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-18 23:42:35 -07:00
Mike Turquette
06fa5ab32a clock: mvebu new SoC changes for v3.15 (incremental pull #2)
- mvebu (Armada 375)
     - fix ratio register offest
 
  - mvebu (Armada 380)
     - expand core divider clock driver to support 380 SoC (enables nand support)
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJTIwnaAAoJEP45WPkGe8ZnqzcQALBc089kYIWoWK4aQanMxUPb
 o86G/p3bUYiOQOI/jLCDlaSxRPehQzSns/II1PgOjbRVCXi+6HEqrOy5yVhRW3JL
 8RPaIdZvZlTYOxcF7Zelni2s/j1YPUbgfzXtawzNH9QdM+iQuSLMXCrStoIkJXUz
 rCcg2KBNNW5aBcmQtLcDgavdNtT/QCa524uGYQTR5YZNFQlL8a78GrqjkUkgD6e0
 RH0guVmu5Wd5l7McHjq/mbcMg6gguPJI7Y3ddDjdB+02zAoKzlQ05HJLfDp6sybS
 8e7DPYnA7TRJV2LG2jwsA5yGy3yrW5nmPBlfogZD7KlKl/pbTgEXyzf0OiP+OiDQ
 7DGFAnSX7mDX3gRiwaac6YbyLCC6aVnPPsPzO/9zm5jy2c+u3BJjC6QHN4CVciYk
 OMyZzllrEJ3iGubFZb3I0smZcmopmoDyZMIz+abnqFi71jQmWZnjpjoE7qHJqSCe
 RObuI4V9w6kcJjhriPI8HRK2sMiQQwfZ+OGofffHiyWLJ/EtvruTyayO5IIjjVXE
 aDuHKa0z8s7sS/QDRyIFqr2N32T4mPczPaUvk4B3OmF6z1m5v3kKSYj4kzgZFOYx
 3DwBdxKITxcWqlHuNU0lGmV2n75cTISH3NXCO3bIsC1ZQAKjzLRuqBzypxrHzE6m
 CyRu1U7m5LHo7yqSg4gv
 =tx7z
 -----END PGP SIGNATURE-----

Merge tag 'clk-mvebu-3xx-3.15-2' of git://git.infradead.org/linux-mvebu into clk-next-mvebu

clock: mvebu new SoC changes for v3.15 (incremental pull #2)

 - mvebu (Armada 375)
    - fix ratio register offest

 - mvebu (Armada 380)
    - expand core divider clock driver to support 380 SoC (enables nand support)
2014-03-18 21:34:45 -07:00
Tushar Behera
e8e6b840c4 clk: clk-s2mps11: Add support for clocks in S5M8767 MFD
Since clock operation within S2MPS11 and S5M8767 are similar, we can
support both the devices within a single driver.

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Reviewed-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-18 17:13:24 -07:00
Tushar Behera
64d64c3573 clk: clk-s2mps11: Refactor for including support for other MFD clocks
The clocks in S2MPS11 and S5M8767 are managed in the same way, baring
a difference in the register offset. It would be better to update
existing S2MPS11 driver to support the clocks in S5M8767, rather than
creating an almost duplicate driver altogether.

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Reviewed-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-18 17:13:16 -07:00
Jonas Jensen
c7bb4fc16e clk: add MOXA ART SoCs clock driver
MOXA ART SoCs allow to determine PLL output and APB frequencies
by reading registers holding multiplier and divisor information.

Add a clock driver for this SoC.

Signed-off-by: Jonas Jensen <jonas.jensen@gmail.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-03-18 17:13:14 -07:00
Ezequiel Garcia
0737c15ff5 clk: mvebu: Support Armada 380 SoC on the core divider clock
This commit adds support for the Core Divider clocks of the Armada
380 SoCs. Similarly to Armada 370 and XP, the Core Divider clocks of
the 380 have gate capabilities. The only difference is the register layout.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Link: https://lkml.kernel.org/r/1394742273-5113-2-git-send-email-ezequiel.garcia@free-electrons.com
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2014-03-13 23:24:23 +00:00
Ezequiel Garcia
8230a5ab43 clk: mvebu: Fix ratio register offset on A375 SoC
This commit fixes the ratio register offset which is 0x4,
as per the Armada 375 SoC specification.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Link: https://lkml.kernel.org/r/1394638901-13368-2-git-send-email-ezequiel.garcia@free-electrons.com
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2014-03-13 23:20:27 +00:00
Mike Turquette
5ba8dac012 Merge branch 'clk-fixes' into clk-next 2014-02-26 18:33:51 -08:00
Tomi Valkeinen
7e50e7e176 clk: ti/divider: fix rate calculation for fractional rates
ti/clk-divider.c does not calculate the rates consistently at the moment.

As an example, on OMAP3 we have a clock divider with a source clock of
864000000 Hz. With dividers 6, 7 and 8 the theoretical rates are:

6: 144000000
7: 123428571.428571...
8: 108000000

Calling clk_round_rate() with the rate in the first column will give the
rate in the second column:

144000000 -> 144000000
143999999 -> 123428571
123428572 -> 123428571
123428571 -> 108000000

Note how clk_round_rate() returns 123428571 for rates from 123428572 to
143999999, which is mathematically correct, but when clk_round_rate() is
called with 123428571, the returned value is surprisingly 108000000.

This means that the following code works a bit oddly:

rate = clk_round_rate(clk, 123428572);
clk_set_rate(clk, rate);

As clk_set_rate() also does clock rate rounding, the result is that the
clock is set to the rate of 108000000, not 123428571 returned by the
clk_round_rate.

This patch changes the ti/clk-divider.c to use DIV_ROUND_UP when
calculating the rate. This gives the following behavior which fixes the
inconsistency:

144000000 -> 144000000
143999999 -> 123428572
123428572 -> 123428572
123428571 -> 108000000

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-02-26 18:23:58 -08:00
Tomi Valkeinen
b11d282dbe clk: divider: fix rate calculation for fractional rates
clk-divider.c does not calculate the rates consistently at the moment.

As an example, on OMAP3 we have a clock divider with a source clock of
864000000 Hz. With dividers 6, 7 and 8 the theoretical rates are:

6: 144000000
7: 123428571.428571...
8: 108000000

Calling clk_round_rate() with the rate in the first column will give the
rate in the second column:

144000000 -> 144000000
143999999 -> 123428571
123428572 -> 123428571
123428571 -> 108000000

Note how clk_round_rate() returns 123428571 for rates from 123428572 to
143999999, which is mathematically correct, but when clk_round_rate() is
called with 123428571, the returned value is surprisingly 108000000.

This means that the following code works a bit oddly:

rate = clk_round_rate(clk, 123428572);
clk_set_rate(clk, rate);

As clk_set_rate() also does clock rate rounding, the result is that the
clock is set to the rate of 108000000, not 123428571 returned by the
clk_round_rate.

This patch changes the clk-divider.c to use DIV_ROUND_UP when
calculating the rate. This gives the following behavior which fixes the
inconsistency:

144000000 -> 144000000
143999999 -> 123428572
123428572 -> 123428572
123428571 -> 108000000

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-02-26 18:23:46 -08:00
Masanari Iida
f63fcc90a3 clk:at91: Fix memory leak in of_at91_clk_master_setup()
cppcheck detected following error
[clk-master.c:245]: (error) Memory leak: characteristics

The original code forgot to free characteristics when
irq_of_parse_and_map() failed.

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Acked-by Boris BREZILLON <b.brezillon@overkiz.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-02-26 18:00:56 -08:00
Lars-Peter Clausen
1887c3a64f clk: axi-clkgen: Add support for v2
This patch adds support for the new v2 version of the axi-clkgen core.
Unfortunately the method of accessing the registers is quite different on v2,
while the content still stays largely the same. So the patch adds a small
abstraction layer which implements the specific read and write functions for v1
and v2 in callback functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2014-02-26 17:02:29 -08:00
Zhangfei Gao
62ac983b61 clk: hisilicon: add hi3620_mmc_clks
Suggest by Arnd: abstract mmc tuning as clock behavior,
also because different soc have different tuning method and registers.
hi3620_mmc_clks is added to handle mmc clock specifically on hi3620.

Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-02-26 16:03:56 -08:00
Dinh Nguyen
b89cd950cb clk: socfpga: Support multiple parents for the pll clocks
The PLLs can be from 3 different sources: osc1, osc2, or the f2s_ref_clk.
Update the clock driver to be able to get the correct parent.

Signed-off-by: Dinh Nguyen <dinguyen@altera.com>
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-02-26 12:23:40 -08:00
Dinh Nguyen
5585f73175 clk: socfpga: Fix integer overflow in clock calculation
Use 64-bit integer for calculating clock rate. Also use do_div for the
64-bit division.

Signed-off-by: Graham Moore <grmoore@altera.com>
Signed-off-by: Dinh Nguyen <dinguyen@altera.com>
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-02-26 12:23:29 -08:00
Linus Walleij
ec6deea1a1 clk: nomadik: fix multiplatform problem
The Nomadik debugfs screws up multiplatform boots if debugfs
is enabled on the multiplatform image, since it's a simple
initcall that is unconditionally executed and reads from certain
memory locations.

Fix this by checking that the driver has been properly
initialized, so a base offset to the Nomadik SRC controller
exists, before proceeding to register debugfs files.

Reported-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-02-26 11:14:44 -08:00
Michal Simek
2c97ec5842 clk: zynq: Use clk_readl/clk_writel helper function
Do not use readl/writel directly because the whole
clk subsystem is using clk_readl/clk_writel functions.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Acked-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-02-25 14:08:48 -08:00
Wolfram Sang
95aa4f9b5f clk: shmobile: div6: use proper description in kernel doc
These variable clocks have nothing to do with MSTP gating, probably a
copy&paste leftover.

Signed-off-by: Wolfram Sang <wsa@sang-engineering.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-02-25 00:26:37 -08:00