aboutsummaryrefslogtreecommitdiff
path: root/drivers/clk/clk-mux.c
AgeCommit message (Collapse)AuthorFilesLines
2020-01-06clk: mux: Add support for specifying parents via DT/pointersStephen Boyd1-40/+18
After commit fc0c209c147f ("clk: Allow parents to be specified without string names") we can use DT or direct clk_hw pointers to specify parents. Create a generic function that shouldn't be used very often to encode the multitude of ways of registering a mux clk with different parent information. Then add a bunch of wrapper macros that only pass down what needs to be passed down to the generic function to support this with less arguments. Note: the msm drm driver passes an anonymous array through the macro which seems to confuse my compiler. Adding a parenthesis around the whole thing at the call site seems to fix it but it must be wrong. Maybe it's better to split this patch and pick out the array bits there? Cc: Rob Clark <[email protected]> Cc: Sean Paul <[email protected]> Cc: Manivannan Sadhasivam <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
2019-11-22clk: Zero init clk_init_data in helpersManivannan Sadhasivam1-1/+1
The clk_init_data struct needs to be initialized to zero for the new parent_map implementation to work correctly. Otherwise, the member which is available first will get processed. Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
2019-05-07Merge branch 'clk-ti' into clk-nextStephen Boyd1-1/+1
* clk-ti: clk: Remove CLK_IS_BASIC clk flag clk: ti: dra7: disable the RNG and TIMER12 clkctrl clocks on HS devices clk: ti: dra7x: prevent non-existing clkctrl clocks from registering ARM: omap2+: hwmod: drop CLK_IS_BASIC flag usage clk: ti: export the omap2_clk_is_hw_omap call
2019-04-26clk: Remove CLK_IS_BASIC clk flagStephen Boyd1-1/+1
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 <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Paul Burton <[email protected]> Cc: James Hogan <[email protected]> Cc: <[email protected]> Cc: Thierry Reding <[email protected]> Cc: Kevin Hilman <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Acked-by: Thierry Reding <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
2019-04-23clk: core: replace clk_{readl,writel} with {readl,writel}Jonas Gorski1-2/+2
Now that clk_{readl,writel} is just an alias for {readl,writel}, we can switch all users of clk_* to use the accessors directly and remove the helpers. Signed-off-by: Jonas Gorski <[email protected]> [[email protected]: Also convert renesas file so that this can be compile independently] Signed-off-by: Stephen Boyd <[email protected]>
2019-04-23clk: mux: add explicit big endian supportJonas Gorski1-3/+19
Add a clock specific flag to switch register accesses to big endian, to allow runtime configuration of big endian mux clocks. Signed-off-by: Jonas Gorski <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
2018-12-11clk: Tag basic clk types with SPDXStephen Boyd1-4/+1
These are all GPL-2.0 files per the existing license text. Replace the boiler plate with the tag. Signed-off-by: Stephen Boyd <[email protected]>
2018-04-16clk: honor CLK_MUX_ROUND_CLOSEST in generic clk muxJerome Brunet1-1/+9
CLK_MUX_ROUND_CLOSEST is part of the clk_mux documentation but clk_mux directly calls __clk_mux_determine_rate(), which overrides the flag. As result, if clk_mux is instantiated with CLK_MUX_ROUND_CLOSEST, the flag will be ignored and the clock rounded down. To solve this, this patch expose clk_mux_determine_rate_flags() in the clk-provider API and uses it in the determine_rate() callback of clk_mux. Fixes: 15a02c1f6dd7 ("clk: Add __clk_mux_determine_rate_closest") Signed-off-by: Jerome Brunet <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
2018-03-12clk: mux: add helper function for index/value translationJerome Brunet1-32/+43
Add helper functions for the translation between parent index and register value in the generic multiplexer function. The purpose of this change is avoid duplicating the code in other clock providers, using the same generic logic. Signed-off-by: Jerome Brunet <[email protected]> Signed-off-by: Michael Turquette <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
2017-11-13clk: clk-mux: Improve a size determination in clk_hw_register_mux_table()Markus Elfring1-1/+1
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
2017-11-13clk: clk-mux: Delete an error message for a failed memory allocationMarkus Elfring1-3/+1
Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <[email protected]> [[email protected]: Cleanup commit text] Signed-off-by: Stephen Boyd <[email protected]>
2016-04-19clk: mux: Add hw based registration APIsStephen Boyd1-6/+51
Add registration APIs in the clk mux code to return struct clk_hw pointers instead of struct clk pointers. This way we hide the struct clk pointer from providers unless they need to use consumer facing APIs. Signed-off-by: Stephen Boyd <[email protected]>
2016-01-29clk: move the common clock's to_clk_*(_hw) macros to clk-provider.hGeliang Tang1-2/+0
to_clk_*(_hw) macros have been repeatedly defined in many places. This patch moves all the to_clk_*(_hw) definitions in the common clock framework to public header clk-provider.h, and drop the local definitions. Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
2015-12-22clk: fix codying style of if ... else blocksMasahiro Yamada1-3/+2
This code is unreadable due to the blank line between if and else blocks. Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Michael Turquette <[email protected]>
2015-08-24clk: Replace __clk_get_num_parents with clk_hw_get_num_parents()Stephen Boyd1-1/+1
Mostly converted with the following semantic patch: @@ struct clk_hw *E; @@ -__clk_get_num_parents(E->clk) +clk_hw_get_num_parents(E) Acked-by: Boris Brezillon <[email protected]> Cc: Chao Xie <[email protected]> Cc: Krzysztof Kozlowski <[email protected]> Cc: Javier Martinez Canillas <[email protected]> Cc: Tomasz Figa <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: "Emilio López" <[email protected]> Acked-by: Tero Kristo <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Acked-by: Sylwester Nawrocki <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
2015-07-28clk: basic-type: Silence warnings about lock imbalancesStephen Boyd1-0/+4
The basic clock types use conditional locking for the register accessor spinlocks. Add __acquire() and __release() markings in the right locations so that sparse isn't tripped up on the conditional locking. drivers/clk/clk-mux.c:68:12: warning: context imbalance in 'clk_mux_set_parent' - different lock contexts for basic block drivers/clk/clk-divider.c:379:12: warning: context imbalance in 'clk_divider_set_rate' - different lock contexts for basic block drivers/clk/clk-gate.c:71:9: warning: context imbalance in 'clk_gate_endisable' - different lock contexts for basic block drivers/clk/clk-fractional-divider.c:36:9: warning: context imbalance in 'clk_fd_recalc_rate' - different lock contexts for basic block drivers/clk/clk-fractional-divider.c:68:12: warning: context imbalance in 'clk_fd_set_rate' - different lock contexts for basic block Cc: Andy Shevchenko <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
2015-07-20clk: mux: Remove clk.h includeStephen Boyd1-1/+0
Clock provider drivers generally shouldn't include clk.h because it's the consumer API. Remove the include here because this is a provider driver. Signed-off-by: Stephen Boyd <[email protected]>
2015-05-05clk: make strings in parent name arrays constSascha Hauer1-2/+4
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 <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Tested-by: Krzysztof Kozlowski <[email protected]> Acked-by: Uwe Kleine-König <[email protected]> [[email protected]: Squelch 80-character checkpatch warnings] Signed-off-by: Stephen Boyd <[email protected]>
2015-01-17clk: Add clk_unregister_{divider, gate, mux} to close memory leakKrzysztof Kozlowski1-0/+16
The common clk_register_{divider,gate,mux} functions allocated memory for internal data which wasn't freed anywhere. Drivers using these helpers could only unregister clocks but the memory would still leak. Add corresponding unregister functions which will release all resources. Signed-off-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Signed-off-by: Michael Turquette <[email protected]>
2014-11-19clk_mux: Fix set_parent doing the wrong thing when INDEX_BIT && index >= 3Hans de Goede1-1/+1
If CLK_MUX_INDEX_BIT is set, then each bit turns on / off a single parent, so theoretically multiple parents could be enabled at the same time, but in practice only one bit should ever be 1. So to select parent 0, set the register (*) to 0x01, to select parent 1 set it 0x02, parent 2, 0x04, parent 3, 0x08, etc. But the current code does: if (mux->flags & CLK_MUX_INDEX_BIT) index = (1 << ffs(index)); Which means that: For an input index of 0, ffs returns 0, so we set the register to 0x01, ok. For an input index of 1, ffs returns 1, so we set the register to 0x02, ok. For an input index of 2, ffs returns 2, so we set the register to 0x04, ok. For an input index of 3, ffs returns 1, so we set the register to 0x02, not good! The code should simply be: if (mux->flags & CLK_MUX_INDEX_BIT) index = 1 << index; Which always does the right thing, this commit fixes this. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Michael Turquette <[email protected]>
2013-08-27clk: wrap I/O access for improved portabilityGerhard Sittig1-3/+3
the common clock drivers were motivated/initiated by ARM development and apparently assume little endian peripherals wrap register/peripherals access in the common code (div, gate, mux) in preparation of adding COMMON_CLK support for other platforms Signed-off-by: Gerhard Sittig <[email protected]> Signed-off-by: Mike Turquette <[email protected]>
2013-08-19clk: clk-mux: implement remuxing on set_rateJames Hogan1-0/+1
Implement clk-mux remuxing if the CLK_SET_RATE_NO_REPARENT flag isn't set. This implements determine_rate for clk-mux to propagate to each parent and to choose the best one (like clk-divider this chooses the parent which provides the fastest rate <= the requested rate). The determine_rate op is implemented as a core helper function so that it can be easily used by more complex clocks which incorporate muxes. Signed-off-by: James Hogan <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Cc: Mike Turquette <[email protected]> Cc: [email protected] Signed-off-by: Mike Turquette <[email protected]>
2013-08-16clk: export fixed-factor, gate & mux registrationMike Turquette1-0/+2
These registration calls may be used by loadable modules. Export them. Signed-off-by: Mike Turquette <[email protected]>
2013-08-05clk: mux: Add support for read-only muxes.Tomasz Figa1-1/+9
Some platforms have read-only clock muxes that are preconfigured at reset and cannot be changed at runtime. This patch extends mux clock driver to allow handling such read-only muxes by adding new CLK_MUX_READ_ONLY mux flag. Signed-off-by: Tomasz Figa <[email protected]> Signed-off-by: Mike Turquette <[email protected]>
2013-06-15clk: mux: add CLK_MUX_HIWORD_MASKHaojian Zhuang1-2/+15
In both Hisilicon & Rockchip Cortex-A9 based chips, they don't use the paradigm of reading-changing-writing the register contents. Instead they use a hiword mask to indicate the changed bits. When b01 should be set as switching mux, it also needs to indicate the change by setting hiword mask (b11 << 16). The patch adds mux flag for this usage. Signed-off-by: Heiko Stuebner <[email protected]> Signed-off-by: Haojian Zhuang <[email protected]> Signed-off-by: Mike Turquette <[email protected]>
2013-03-22clk: add table lookup to muxPeter De Schrijver1-11/+39
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 <[email protected]> Tested-by: Stephen Warren <[email protected]> Signed-off-by: Mike Turquette <[email protected]>
2012-07-11clk: Add CLK_IS_BASIC flag to identify basic clocksRajendra Nayak1-1/+1
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 <[email protected]> Signed-off-by: Mike Turquette <[email protected]>
2012-05-08clk: mux: assign init dataMike Turquette1-0/+1
The original conversion to struct clk_hw_init failed to add the pointer assignment in clk_register_mux. Signed-off-by: Mike Turquette <[email protected]> Reported-by: Sascha Hauer <[email protected]>
2012-05-01clk: Use a separate struct for holding init data.Saravana Kannan1-2/+8
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 <[email protected]> [[email protected]: kept DEFINE_CLK_* macros and __clk_init] Signed-off-by: Mike Turquette <[email protected]> Cc: Andrew Lunn <[email protected]> Cc: Rob Herring <[email protected]> Cc: Russell King <[email protected]> Cc: Jeremy Kerr <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Arnd Bergman <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Sascha Hauer <[email protected]> Cc: Jamie Iles <[email protected]> Cc: Richard Zhao <[email protected]> Cc: Saravana Kannan <[email protected]> Cc: Magnus Damm <[email protected]> Cc: Mark Brown <[email protected]> Cc: Linus Walleij <[email protected]> Cc: Stephen Boyd <[email protected]> Cc: Amit Kucheria <[email protected]> Cc: Deepak Saxena <[email protected]> Cc: Grant Likely <[email protected]>
2012-04-24clk: basic: improve parent_names & return errorsMike Turquette1-2/+8
This patch is the basic clk version of 'clk: core: copy parent_names & return error codes'. The registration functions are changed to allow the core code to copy the array of strings and allow platforms to declare those arrays as __initdata. This patch also converts all of the basic clk registration functions to return error codes which better aligns them with the existing clk.h api. Signed-off-by: Mike Turquette <[email protected]>
2012-04-24clk: Constify parent name arraysMark Brown1-1/+1
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 <[email protected]> [[email protected]: constified gate] Signed-off-by: Mike Turquette <[email protected]>
2012-04-24clk: add "const" for clk_ops of basic clksShawn Guo1-1/+1
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 <[email protected]> Signed-off-by: Mike Turquette <[email protected]>
2012-04-24clk: remove unnecessary EXPORT_SYMBOL_GPLShawn Guo1-2/+0
It makes no sense to have EXPORT_SYMBOL_GPL on static functions. Signed-off-by: Shawn Guo <[email protected]> Signed-off-by: Mike Turquette <[email protected]>
2012-04-24clk: use kzalloc in clk_register_muxShawn Guo1-1/+1
Change clk_register_mux to use kzalloc, just like what all other basic clk registration functions do. Signed-off-by: Shawn Guo <[email protected]> Signed-off-by: Mike Turquette <[email protected]>
2012-03-16clk: basic clock hardware typesMike Turquette1-0/+116
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 <[email protected]> Signed-off-by: Mike Turquette <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Tested-by: Andrew Lunn <[email protected]> Reviewed-by: Rob Herring <[email protected]> Cc: Russell King <[email protected]> Cc: Jeremy Kerr <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Arnd Bergman <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Sascha Hauer <[email protected]> Cc: Jamie Iles <[email protected]> Cc: Richard Zhao <[email protected]> Cc: Saravana Kannan <[email protected]> Cc: Magnus Damm <[email protected]> Cc: Mark Brown <[email protected]> Cc: Linus Walleij <[email protected]> Cc: Stephen Boyd <[email protected]> Cc: Amit Kucheria <[email protected]> Cc: Deepak Saxena <[email protected]> Cc: Grant Likely <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>