20 Aug, 2013

1 commit

  • Add core support to allow clock implementations to select the best
    parent clock when rounding a rate, e.g. the one which can provide the
    closest clock rate to that requested. This is by way of adding a new
    clock op, determine_rate(), which is like round_rate() but has an extra
    parameter to allow the clock implementation to optionally select a
    different parent clock. The core then takes care of reparenting the
    clock when setting the rate.

    The parent change takes place with the help of some new private data
    members. struct clk::new_parent specifies a clock's new parent (NULL
    indicates no change), and struct clk::new_child specifies a clock's new
    child (whose new_parent member points back to it). The purpose of these
    are to allow correct walking of the future tree for notifications prior
    to actually reparenting any clocks, specifically to skip child clocks
    who are being reparented to another clock (they will be notified via the
    new parent), and to include any new child clock. These pointers are set
    by clk_calc_subtree(), and the new_child pointer gets cleared when a
    child is actually reparented to avoid duplicate POST_RATE_CHANGE
    notifications.

    Each place where round_rate() is called, determine_rate() is checked
    first and called in preference. This restructures a few of the call
    sites to simplify the logic into if/else blocks.

    Signed-off-by: James Hogan
    Reviewed-by: Stephen Boyd
    Cc: Mike Turquette
    Cc: linux-arm-kernel@lists.infradead.org
    Signed-off-by: Mike Turquette

    James Hogan
     

23 Mar, 2013

1 commit

  • Add a table lookup feature to the mux clock. Also allow arbitrary masks
    instead of the width. This will be used by some clocks on Tegra114. Also
    adapt the tegra periph clk because it uses struct clk_mux directly.

    Signed-off-by: Peter De Schrijver
    Tested-by: Stephen Warren
    Signed-off-by: Mike Turquette

    Peter De Schrijver
     

12 Jul, 2012

2 commits

  • Most platforms end up using a mix of basic clock types and
    some which use clk_hw_foo struct for filling in custom platform
    information when the clocks don't fit into basic types supported.

    In platform code, its useful to know if a clock is using a basic
    type or clk_hw_foo, which helps platforms know if they can
    safely use to_clk_hw_foo to derive the clk_hw_foo pointer from
    clk_hw.

    Mark all basic clocks with a CLK_IS_BASIC flag.

    Signed-off-by: Rajendra Nayak
    Signed-off-by: Mike Turquette

    Rajendra Nayak
     
  • Some divider clks do not have any obvious relationship
    between the divider and the value programmed in the
    register. For instance, say a value of 1 could signify divide
    by 6 and a value of 2 could signify divide by 4 etc.
    Also there are dividers where not all values possible
    based on the bitfield width are valid. For instance
    a 3 bit wide bitfield can be used to program a value
    from 0 to 7. However its possible that only 0 to 4
    are valid values.

    All these cases need the platform code to pass a simple
    table of divider/value tuple, so the framework knows
    the exact value to be written based on the divider
    calculation and can also do better error checking.

    This patch adds support for such rate table based
    dividers and as part of the support adds a new
    registration function 'clk_register_divider_table()'
    and a new macro for static definition
    'DEFINE_CLK_DIVIDER_TABLE'.

    Signed-off-by: Rajendra Nayak
    Signed-off-by: Mike Turquette

    Rajendra Nayak
     

09 May, 2012

1 commit

  • Having fixed factors/dividers in hardware is a common pattern, so
    add a basic clock type doing this. It basically describes a fixed
    factor clock using a nominator and a denominator.

    Signed-off-by: Sascha Hauer
    Reviewed-by: Viresh Kumar
    Tested-by: Shawn Guo
    [mturquette@linaro.org: constify parent_names in static init macro]
    [mturquette@linaro.org: copy/paste bug from mux in static init macro]
    [mturquette@linaro.org: fix error handling in clk_register_fixed_factor]
    [mturquette@linaro.org: improve division accuracy; thanks to Saravana]
    Signed-off-by: Mike Turquette

    Sascha Hauer
     

02 May, 2012

2 commits

  • Create a struct clk_init_data to hold all data that needs to be passed from
    the platfrom specific driver to the common clock framework during clock
    registration. Add a pointer to this struct inside clk_hw.

    This has several advantages:
    * Completely hides struct clk from many clock platform drivers and static
    clock initialization code that don't care for static initialization of
    the struct clks.
    * For platforms that want to do complete static initialization, it removed
    the need to directly mess with the struct clk's fields while still
    allowing to statically allocate struct clk. This keeps the code more
    future proof even if they include clk-private.h.
    * Simplifies the generic clk_register() function and allows adding optional
    fields in the future without modifying the function signature.
    * Simplifies the static initialization of clocks on all platforms by
    removing the need for forward delcarations or convoluted macros.

    Signed-off-by: Saravana Kannan
    [mturquette@linaro.org: kept DEFINE_CLK_* macros and __clk_init]
    Signed-off-by: Mike Turquette
    Cc: Andrew Lunn
    Cc: Rob Herring
    Cc: Russell King
    Cc: Jeremy Kerr
    Cc: Thomas Gleixner
    Cc: Arnd Bergman
    Cc: Paul Walmsley
    Cc: Shawn Guo
    Cc: Sascha Hauer
    Cc: Jamie Iles
    Cc: Richard Zhao
    Cc: Saravana Kannan
    Cc: Magnus Damm
    Cc: Mark Brown
    Cc: Linus Walleij
    Cc: Stephen Boyd
    Cc: Amit Kucheria
    Cc: Deepak Saxena
    Cc: Grant Likely

    Saravana Kannan
     
  • parent name array is now expected to be const char *, make
    the relevent changes in the clk macros which define
    default clock types.

    Signed-off-by: Rajendra Nayak
    Signed-off-by: Mike Turquette

    Rajendra Nayak
     

25 Apr, 2012

5 commits

  • All macros used for creating different kind of clocks have similar code for
    initializing struct clk. This patch removes those redundant lines and create
    another macro DEFINE_CLK.

    Signed-off-by: Viresh Kumar
    Signed-off-by: Mike Turquette

    Viresh Kumar
     
  • This patch cleans up clk_register and solves a few bugs by teaching
    clk_register and __clk_init to return error codes (instead of just NULL)
    to better align with the existing clk.h api.

    Along with that change this patch also introduces a new behavior whereby
    clk_register copies the parent_names array, thus allowing platforms to
    declare their parent_names arrays as __initdata.

    Signed-off-by: Mike Turquette

    Mike Turquette
     
  • Drivers should be able to declare their arrays of parent names as const
    so the APIs need to accept const arguments.

    Signed-off-by: Mark Brown
    [mturquette@linaro.org: constified gate]
    Signed-off-by: Mike Turquette

    Mark Brown
     
  • Besides the static initialization, the clk_ops of basic clks could
    also be used by particular clk type being subclass of the basic clks.

    For example, clk_busy_divider has the same clk_ops as clk_divider,
    except it has to wait for a busy bit before return success with
    .set_rate. clk_busy_divider will somehow reuse clk_ops of clk_divider.

    Since clk-provider.h is included by clk-private.h, it's safe to move
    those clk_ops declaration of basic clks form clk-private.h into
    clk-provider.h, so that implementation of clks like clk_busy_divider
    above do not need to include clk-private.h to access those clk_ops.

    Signed-off-by: Shawn Guo
    Signed-off-by: Mike Turquette

    Shawn Guo
     
  • The clk_ops of basic clks should have "const" to match the definition
    in "struct clk" and clk_register prototype.

    Signed-off-by: Shawn Guo
    Signed-off-by: Mike Turquette

    Shawn Guo
     

17 Mar, 2012

2 commits

  • Many platforms support simple gateable clocks, fixed-rate clocks,
    adjustable divider clocks and multi-parent multiplexer clocks.

    This patch introduces basic clock types for the above-mentioned hardware
    which share some common characteristics.

    Based on original work by Jeremy Kerr and contribution by Jamie Iles.
    Dividers and multiplexor clocks originally contributed by Richard Zhao &
    Sascha Hauer.

    Signed-off-by: Mike Turquette
    Signed-off-by: Mike Turquette
    Reviewed-by: Andrew Lunn
    Tested-by: Andrew Lunn
    Reviewed-by: Rob Herring
    Cc: Russell King
    Cc: Jeremy Kerr
    Cc: Thomas Gleixner
    Cc: Arnd Bergman
    Cc: Paul Walmsley
    Cc: Shawn Guo
    Cc: Sascha Hauer
    Cc: Jamie Iles
    Cc: Richard Zhao
    Cc: Saravana Kannan
    Cc: Magnus Damm
    Cc: Mark Brown
    Cc: Linus Walleij
    Cc: Stephen Boyd
    Cc: Amit Kucheria
    Cc: Deepak Saxena
    Cc: Grant Likely
    Signed-off-by: Arnd Bergmann

    Mike Turquette
     
  • The common clock framework defines a common struct clk useful across
    most platforms as well as an implementation of the clk api that drivers
    can use safely for managing clocks.

    The net result is consolidation of many different struct clk definitions
    and platform-specific clock framework implementations.

    This patch introduces the common struct clk, struct clk_ops and an
    implementation of the well-known clock api in include/clk/clk.h.
    Platforms may define their own hardware-specific clock structure and
    their own clock operation callbacks, so long as it wraps an instance of
    struct clk_hw.

    See Documentation/clk.txt for more details.

    This patch is based on the work of Jeremy Kerr, which in turn was based
    on the work of Ben Herrenschmidt.

    Signed-off-by: Mike Turquette
    Signed-off-by: Mike Turquette
    Reviewed-by: Thomas Gleixner
    Tested-by: Andrew Lunn
    Reviewed-by: Rob Herring calxeda.com>
    Cc: Russell King
    Cc: Jeremy Kerr
    Cc: Arnd Bergman
    Cc: Paul Walmsley
    Cc: Shawn Guo
    Cc: Sascha Hauer
    Cc: Richard Zhao
    Cc: Saravana Kannan
    Cc: Magnus Damm
    Cc: Mark Brown
    Cc: Linus Walleij
    Cc: Stephen Boyd
    Cc: Amit Kucheria
    Cc: Deepak Saxena
    Cc: Grant Likely
    Signed-off-by: Arnd Bergmann

    Mike Turquette