27 Apr, 2019

1 commit

  • This flag was historically used to indicate that a clk is a "basic" type
    of clk like a mux, divider, gate, etc. This never turned out to be very
    useful though because it was hard to cleanly split "basic" clks from
    other clks in a system. This one flag was a way for type introspection
    and it just didn't scale. If anything, it was used by the TI clk driver
    to indicate that a clk_hw wasn't contained in the SoC specific clk
    structure. We can get rid of this define now that TI is finding those
    clks a different way.

    Cc: Tero Kristo
    Cc: Ralf Baechle
    Cc: Paul Burton
    Cc: James Hogan
    Cc:
    Cc: Thierry Reding
    Cc: Kevin Hilman
    Cc:
    Cc:
    Acked-by: Thierry Reding
    Signed-off-by: Stephen Boyd

    Stephen Boyd
     

12 Dec, 2018

1 commit


22 Apr, 2016

3 commits

  • * 'clk-hw-register' (early part):
    clk: fixed-rate: Add hw based registration APIs
    clk: gpio: Add hw based registration APIs
    clk: composite: Add hw based registration APIs
    clk: fractional-divider: Add hw based registration APIs
    clk: fixed-factor: Add hw based registration APIs
    clk: mux: Add hw based registration APIs
    clk: gate: Add hw based registration APIs
    clk: divider: Add hw based registration APIs
    clkdev: Add clk_hw based registration APIs
    clk: Add clk_hw OF clk providers
    clk: Add {devm_}clk_hw_{register,unregister}() APIs
    clkdev: Remove clk_register_clkdevs()

    Stephen Boyd
     
  • * clk-composite-unregister:
    clk: composite: Add unregister function

    Stephen Boyd
     
  • The composite clock didn't have any unregistration function, which forced
    us to use clk_unregister directly on it.

    While it was already not great from an API point of view, it also meant
    that we were leaking the clk_composite structure allocated in
    clk_register_composite.

    Add a clk_unregister_composite function to fix this.

    Signed-off-by: Maxime Ripard
    Signed-off-by: Stephen Boyd

    Maxime Ripard
     

20 Apr, 2016

1 commit


16 Apr, 2016

1 commit

  • When changing the clock-rate, currently a new parent is set first and a
    divider adapted thereafter. This may result in the clock-rate overflowing
    its target rate for a short time if the new parent has a higher rate than
    the old parent.

    While this often doesn't produce negative effects, it can affect components
    in a voltage-scaling environment, like the GPU on the rk3399 socs, where
    the voltage than simply is to low for the temporarily to high clock rate.

    For general clock hirarchies this may need more extensive adaptions to
    the common clock-framework, but at least for composite clocks having
    both parent and rate settings it is easy to create a short-term solution to
    make sure the clock-rate does not overflow the target.

    Signed-off-by: Finley Xiao
    Reviewed-by: Heiko Stuebner
    Signed-off-by: Stephen Boyd

    Finley Xiao
     

30 Jan, 2016

1 commit


25 Aug, 2015

3 commits


28 Jul, 2015

2 commits

  • Some determine_rate implementations are not returning an error
    when they failed to adapt the rate according to the rate request.
    Fix them so that they return an error instead of silently
    returning 0.

    Signed-off-by: Boris Brezillon
    CC: Jonathan Corbet
    CC: Tony Lindgren
    CC: Ralf Baechle
    CC: "Emilio López"
    CC: Maxime Ripard
    Cc: Tero Kristo
    CC: Peter De Schrijver
    CC: Prashant Gaikwad
    CC: Stephen Warren
    CC: Thierry Reding
    CC: Alexandre Courbot
    CC: linux-doc@vger.kernel.org
    CC: linux-kernel@vger.kernel.org
    CC: linux-arm-kernel@lists.infradead.org
    CC: linux-omap@vger.kernel.org
    CC: linux-mips@linux-mips.org
    CC: linux-tegra@vger.kernel.org
    Signed-off-by: Stephen Boyd

    Boris Brezillon
     
  • Clock rates are stored in an unsigned long field, but ->determine_rate()
    (which returns a rounded rate from a requested one) returns a long
    value (errors are reported using negative error codes), which can lead
    to long overflow if the clock rate exceed 2Ghz.

    Change ->determine_rate() prototype to return 0 or an error code, and pass
    a pointer to a clk_rate_request structure containing the expected target
    rate and the rate constraints imposed by clk users.

    The clk_rate_request structure might be extended in the future to contain
    other kind of constraints like the rounding policy, the maximum clock
    inaccuracy or other things that are not yet supported by the CCF
    (power consumption constraints ?).

    Signed-off-by: Boris Brezillon
    CC: Jonathan Corbet
    CC: Tony Lindgren
    CC: Ralf Baechle
    CC: "Emilio López"
    CC: Maxime Ripard
    Acked-by: Tero Kristo
    CC: Peter De Schrijver
    CC: Prashant Gaikwad
    CC: Stephen Warren
    CC: Thierry Reding
    CC: Alexandre Courbot
    CC: linux-doc@vger.kernel.org
    CC: linux-kernel@vger.kernel.org
    CC: linux-arm-kernel@lists.infradead.org
    CC: linux-omap@vger.kernel.org
    CC: linux-mips@linux-mips.org
    CC: linux-tegra@vger.kernel.org
    [sboyd@codeaurora.org: Fix parent dereference problem in
    __clk_determine_rate()]
    Signed-off-by: Stephen Boyd
    Tested-by: Romain Perier
    Signed-off-by: Heiko Stuebner
    [sboyd@codeaurora.org: Folded in fix from Heiko for fixed-rate
    clocks without parents or a rate determining op]
    Signed-off-by: Stephen Boyd

    Boris Brezillon
     

15 May, 2015

1 commit


06 May, 2015

1 commit

  • The clk functions and structs declare the parent_name arrays as
    'const char **parent_names' which means the parent name strings
    are const, but the array itself is not. Use
    'const char * const * parent_names' instead which also makes
    the array const. This allows us to put the parent_name arrays into
    the __initconst section.

    Signed-off-by: Sascha Hauer
    Reviewed-by: Krzysztof Kozlowski
    Tested-by: Krzysztof Kozlowski
    Acked-by: Uwe Kleine-König
    [sboyd@codeaurora.org: Squelch 80-character checkpatch warnings]
    Signed-off-by: Stephen Boyd

    Sascha Hauer
     

19 Feb, 2015

1 commit

  • The change in the clk API to return a per-user clock instance, moved
    the clock state to struct clk_core so now the struct clk_hw .core field
    is used instead of .clk for most operations.

    So for hardware clocks that needs to share the same clock state, both
    the .core and .clk pointers have to be assigned but currently only the
    .clk is set. This leads to NULL pointer dereference when the operations
    try to access the hw clock .core. For example, the composite clock rate
    and mux components didn't have a .core set which leads to this error:

    Unable to handle kernel NULL pointer dereference at virtual address 00000034
    pgd = c0004000
    [00000034] *pgd=00000000
    Internal error: Oops: 5 [#1] PREEMPT SMP ARM
    Modules linked in:
    CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.19.0-next-20150211-00002-g1fb7f0e1150d #423
    Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
    task: ee480000 ti: ee488000 task.ti: ee488000
    PC is at clk_mux_determine_rate_flags+0x14/0x19c
    LR is at __clk_mux_determine_rate+0x24/0x2c
    pc : [] lr : [] psr: a0000113
    sp : ee489ce8 ip : ee489d84 fp : ee489d84
    r10: 0000005c r9 : 00000001 r8 : 016e3600
    r7 : 00000000 r6 : 00000000 r5 : ee442200 r4 : ee440c98
    r3 : ffffffff r2 : 00000000 r1 : 016e3600 r0 : ee440c98
    Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
    Control: 10c5387d Table: 4000406a DAC: 00000015
    Process swapper/0 (pid: 1, stack limit = 0xee488210)
    Stack: (0xee489ce8 to 0xee48a000)
    9ce0: 00000000 ffffffff 60000113 ee440c98 ee442200 00000000
    9d00: 016e3600 ffffffff 00000001 0000005c ee489d84 c03a3734 ee489d80 ee489d84
    9d20: 00000000 c048b130 00000400 c03a5798 ee489d80 ee489d84 c0607f60 ffffffea
    9d40: 00000001 00000001 ee489d5c c003f844 c06e3340 ee402680 ee440d0c ed935000
    9d60: 016e3600 00000003 00000001 0000005c eded3700 c03a11a0 ee489d80 ee489d84
    9d80: 016e3600 ee402680 c05b413a eddc9900 016e3600 c03a1228 00000000 ffffffff
    9da0: ffffffff eddc9900 016e3600 c03a1c1c ffffffff 016e3600 ed8c6710 c03d6ce4
    9dc0: eded3400 00000000 00000000 c03c797c 00000001 0000005c eded3700 eded3700
    9de0: 000005e0 00000001 0000005c c03db8ac c06e7e54 c03c8f08 00000000 c06e7e64
    9e00: c06b6e74 c06e7f64 000005e0 c06e7df8 c06e5100 00000000 c06e7e6c c06e7f54
    9e20: 00000000 00000000 eebd9550 00000000 c06e7da0 c06e7e54 ee7b5010 c06e7da0
    9e40: eddc9690 c06e7db4 c06b6e74 00000097 00000000 c03d4398 00000000 ee7b5010
    9e60: eebd9550 c06e7da0 00000000 c03db824 ee7b5010 fffffffe c06e7db4 c0299c7c
    9e80: ee7b5010 c072a05c 00000000 c0298858 ee7b5010 c06e7db4 ee7b5044 00000000
    9ea0: eddc9580 c0298a04 c06e7db4 00000000 c0298978 c02971d4 ee405c78 ee732b40
    9ec0: c06e7db4 eded3800 c06d6738 c0298044 c0608300 c06e7db4 00000000 c06e7db4
    9ee0: 00000000 c06beb58 c06beb58 c0299024 00000000 c068dd00 00000000 c0008944
    9f00: 00000038 c049013c ee462200 c0711920 ee480000 60000113 c06c2cb0 00000000
    9f20: 00000000 c06c2cb0 60000113 00000000 ef7fcafc 00000000 c0640194 c00389ec
    9f40: c05ec3a8 c063f824 00000006 00000006 c06c2c50 c0696444 00000006 c0696424
    9f60: c06ee1c0 c066b588 c06b6e74 00000097 00000000 c066bd44 00000006 00000006
    9f80: c066b588 c003d684 00000000 c0481938 00000000 00000000 00000000 00000000
    9fa0: 00000000 c0481940 00000000 c000e680 00000000 00000000 00000000 00000000
    9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
    [] (clk_mux_determine_rate_flags) from [] (__clk_mux_determine_rate+0x24/0x2c)
    [] (__clk_mux_determine_rate) from [] (clk_composite_determine_rate+0xbc/0x238)
    [] (clk_composite_determine_rate) from [] (clk_core_round_rate_nolock+0x5c/0x9c)
    [] (clk_core_round_rate_nolock) from [] (__clk_round_rate+0x38/0x40)
    [] (__clk_round_rate) from [] (clk_round_rate+0x20/0x38)
    [] (clk_round_rate) from [] (max98090_dai_set_sysclk+0x34/0x118)
    [] (max98090_dai_set_sysclk) from [] (snd_soc_dai_set_sysclk+0x38/0x80)
    [] (snd_soc_dai_set_sysclk) from [] (snow_late_probe+0x24/0x48)
    [] (snow_late_probe) from [] (snd_soc_register_card+0xf04/0x1070)
    [] (snd_soc_register_card) from [] (devm_snd_soc_register_card+0x30/0x64)
    [] (devm_snd_soc_register_card) from [] (snow_probe+0x68/0xcc)
    [] (snow_probe) from [] (platform_drv_probe+0x48/0x98)
    [] (platform_drv_probe) from [] (driver_probe_device+0x114/0x234)
    [] (driver_probe_device) from [] (__driver_attach+0x8c/0x90)
    [] (__driver_attach) from [] (bus_for_each_dev+0x54/0x88)
    [] (bus_for_each_dev) from [] (bus_add_driver+0xd8/0x1cc)
    [] (bus_add_driver) from [] (driver_register+0x78/0xf4)
    [] (driver_register) from [] (do_one_initcall+0x80/0x1d0)
    [] (do_one_initcall) from [] (kernel_init_freeable+0x10c/0x1d8)
    [] (kernel_init_freeable) from [] (kernel_init+0x8/0xe4)
    [] (kernel_init) from [] (ret_from_fork+0x14/0x34)
    Code: e24dd00c e5907000 e1a08001 e88d000c (e5970034)

    The changes were made using the following cocinelle semantic patch:

    @i@
    @@

    @depends on i@
    identifier dst;
    @@

    - dst->clk = hw->clk;
    + __clk_hw_set_clk(dst, hw);

    @depends on i@
    identifier dst;
    @@

    - dst->hw.clk = hw->clk;
    + __clk_hw_set_clk(&dst->hw, hw);

    Fixes: 035a61c314eb3 ("clk: Make clk API return per-user struct clk instances")
    Signed-off-by: Javier Martinez Canillas
    Reviewed-by: Stephen Boyd
    Signed-off-by: Michael Turquette

    Javier Martinez Canillas
     

03 Feb, 2015

1 commit

  • Adds a way for clock consumers to set maximum and minimum rates. This
    can be used for thermal drivers to set minimum rates, or by misc.
    drivers to set maximum rates to assure a minimum performance level.

    Changes the signature of the determine_rate callback by adding the
    parameters min_rate and max_rate.

    Signed-off-by: Tomeu Vizoso
    Signed-off-by: Stephen Boyd
    [sboyd@codeaurora.org: set req_rate in __clk_init]
    Signed-off-by: Michael Turquette
    [mturquette@linaro.org: min/max rate for sun6i_ahb1_clk_determine_rate
    migrated clk-private.h changes to clk.c]

    Tomeu Vizoso
     

04 Dec, 2014

1 commit


14 Jul, 2014

3 commits

  • The function pointer population and sanity checking logic got a bit ugly
    with the advent of the .determine_rate callback. Clean it up.

    Signed-off-by: Mike Turquette

    Mike Turquette
     
  • This allows readl-only composite clocks by making mux_ops->set_parent and
    divider_ops->round_rate/set_rate optional.

    Signed-off-by: Heiko Stuebner
    Acked-By: Max Schwarz
    Tested-By: Max Schwarz
    Signed-off-by: Mike Turquette

    Heiko Stübner
     
  • In case the rate_hw does not implement determine_rate, but only round_rate
    we fallback to best_parent selection if mux_hw is present and support
    reparenting.

    This also fixes a rate calculation problem when using the standard div and
    mux ops, as in this case currently only the mux->determine_rate is used
    in the composite rate calculation.
    So when for example the composite clock has two parents at 600 and 800MHz,
    the requested rate is 75MHz, which the divider could provide, without this
    change the rate would be set 600MHz ignoring the divider completely.
    This may be way out of spec for the component.

    Signed-off-by: Boris BREZILLON
    Signed-off-by: Heiko Stuebner
    [heiko@sntech.de: fixed output return a rate instead of the diff]
    Acked-By: Max Schwarz
    Tested-By: Max Schwarz
    Tested-by: Gabriel Fernandez
    Signed-off-by: Mike Turquette

    Boris BREZILLON
     

15 Jan, 2014

1 commit

  • The composite clock's .determine_rate implementation can call the
    underyling .determine_rate callback corresponding to rate_hw or the
    underlying .determine_rate callback corresponding to mux_hw. In both
    cases we pass in rate_hw, which is wrong. Fixed by passing mux_hw into
    the correct callback.

    Reported-by: Lemon Dai
    Signed-off-by: Mike Turquette

    Mike Turquette
     

10 Nov, 2013

1 commit

  • This commit adds .determine_rate support to the composite clock. It will
    use the .determine_rate callback from the rate component if available,
    and fall back on the mux component otherwise. This allows composite
    clocks to enjoy the benefits of automatic clock reparenting.

    Signed-off-by: Emilio López
    Signed-off-by: Maxime Ripard

    Emilio López
     

13 Apr, 2013

2 commits

  • The composite clock assumes that any clock implementing the .recalc_rate
    callback will also implement .round_rate and .set_rate. This is not
    always true; the basic fixed-rate clock will only implement .recalc_rate
    and a fixed-divider clock may choose to implement .recalc_rate and
    .round_rate but not .set_rate.

    Fix this by conditionally registering .round_rate and .set_rate
    callbacks based on the rate_ops passed in to clk_composite_register.

    Signed-off-by: Mike Turquette
    Cc: Prashant Gaikwad
    Tested-by: Emilio López
    Cc: Gregory CLEMENT

    Mike Turquette
     
  • Rename all div_hw and div_ops related variables and functions to use
    rate_hw, rate_ops, etc. This is to make the rate-change portion of the
    composite clk implementation more generic. A patch following this one
    will allow for fixed-rate clocks to reuse this infrastructure.

    Signed-off-by: Mike Turquette
    Reviewed-by: Prashant Gaikwad
    Tested-by: Emilio López
    Cc: Gregory CLEMENT

    Mike Turquette
     

27 Mar, 2013

1 commit

  • Not all clocks are required to be decomposed into basic clock
    types but at the same time want to use the functionality
    provided by these basic clock types instead of duplicating.

    For example, Tegra SoC has ~100 clocks which can be decomposed
    into Mux -> Div -> Gate clock types making the clock count to
    ~300. Also, parent change operation can not be performed on gate
    clock which forces to use mux clock in driver if want to change
    the parent.

    Instead aggregate the basic clock types functionality into one
    clock and just use this clock for all operations. This clock
    type re-uses the functionality of basic clock types and not
    limited to basic clock types but any hardware-specific
    implementation.

    Signed-off-by: Prashant Gaikwad
    Signed-off-by: Mike Turquette

    Prashant Gaikwad