clk: sunxi: Improve MMC clocks support
Subsystems (6)
cover clk: sunxi: Improve MMC clocks support
Hi everyone,
Here is an attempt at improving the MMC clock support in the Allwinner SoCs.
Until now, the MMC clocks were having a custom phase function that was directly setting an obscure value in the right register, because we were not really having any idea of what these values were.
Now that we have more informations, we can introduce a common function call to get and set the phase of a particular clock, and use this in both our provider and our client.
Another issue we had so far on the A13 was that, out of reset, the PLL6 driving the MMC was running too high to be working. We can solve that by adding two new properties in the DT to setup the rate constraints we might have on a clock.
Thanks,
Maxime
Maxime Ripard (13):
clk: Introduce new frequency boundaries properties
clk: sunxi: factors: Implement clock min and max frequencies
ARM: sunxi: sun5i: Enforce max frequency on PLL6
clk: Add a function to retrieve phase
clk: sunxi: factors: Invert the probing logic
clk: sunxi: Introduce mbus compatible
ARM: sunxi: dt: Switch to the new mbus compatible
clk: sunxi: Move mod0 clock to a file of its own
clk: sunxi: Move mbus to mod0 file
ARM: sunxi: dt: Add sample and output mmc clocks
clk: sunxi: mod0: Introduce MMC proper phase handling
mmc: sunxi: Convert MMC driver to the standard clock phase API
clk: sunxi: Remove custom phase function
Mike Turquette (1):
clk: introduce clk_set_phase function & callback
.../devicetree/bindings/clock/clock-bindings.txt | 2 + Documentation/devicetree/bindings/clock/sunxi.txt | 3 + .../devicetree/bindings/mmc/sunxi-mmc.txt | 8 +- arch/arm/boot/dts/sun4i-a10.dtsi | 104 +++++++- arch/arm/boot/dts/sun5i-a10s.dtsi | 81 +++++- arch/arm/boot/dts/sun5i-a13.dtsi | 83 +++++- arch/arm/boot/dts/sun6i-a31.dtsi | 104 +++++++- arch/arm/boot/dts/sun7i-a20.dtsi | 106 +++++++- drivers/clk/clk.c | 95 ++++++- drivers/clk/sunxi/Makefile | 1 + drivers/clk/sunxi/clk-factors.c | 129 +++++++++- drivers/clk/sunxi/clk-factors.h | 18 +- drivers/clk/sunxi/clk-mod0.c | 283 +++++++++++++++++++++ drivers/clk/sunxi/clk-sunxi.c | 189 +------------- drivers/mmc/host/sunxi-mmc.c | 72 ++++-- include/linux/clk-private.h | 1 + include/linux/clk-provider.h | 10 + include/linux/clk.h | 29 +++ include/linux/clk/sunxi.h | 22 -- 19 files changed, 1050 insertions(+), 290 deletions(-) create mode 100644 drivers/clk/sunxi/clk-mod0.c delete mode 100644 include/linux/clk/sunxi.h
Signature · 1 line
2.0.1
PATCH 1/14 clk: Introduce new frequency boundaries properties
Introduce the properties clock-min-frequency and clock-max frequency to be able to set constraints on the range of frequency usable by the clock, even though the hardware might be able to program frequencies outside of thes bounds.
--- Documentation/devicetree/bindings/clock/clock-bindings.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/clock/clock-bindings.txt +2 -0
@@ -19,6 +19,8 @@ Required properties: clock outputs. Optional properties: +clock-min-frequency: Minimum operating frequency of the clock in hertz +clock-max-frequency: Maximum operating frequency of the clock in hertz clock-output-names: Recommended to be a list of strings of clock output signal names indexed by the first cell in the clock specifier. However, the meaning of clock-output-names is domain
Signature · 1 line
2.0.1
PATCH 2/14 clk: sunxi: factors: Implement clock min and max frequencies
In reply to Maxime RipardIn the A13, the out of reset frequency for the PLL6 is too high to be actually working.
Hence, we need to be able to lower down its frequency whenever we need to use the clock to some acceptable frequency.
This patch adds two new properties in the clock-nodes, clk-min-frequency and clk-max-frequency, to specify acceptable boundaries for proper clock operations.
It also adds supports in the sunxi factor clocks driver to use these boundaries, enforce them at prepare time to make sure that the drivers will have a decent frequency, even though it never called set_rate, but also make sure we never cross these boundaries.
--- drivers/clk/sunxi/clk-factors.c | 28 ++++++++++++++++++++++++++++ drivers/clk/sunxi/clk-factors.h | 2 ++ 2 files changed, 30 insertions(+)
drivers/clk/sunxi/clk-factors.c +28 -0
@@ -39,6 +39,25 @@#define FACTOR_SET (bit, len, reg, val) \ (((reg) & CLRMASK(len, bit)) | (val << (bit))) +static int clk_factors_prepare (struct clk_hw *hw) +{ +struct clk_factors *factors =to_clk_factors (hw); +unsigned long rate =__clk_get_rate (hw->clk); +unsigned long new_rate; + +if (factors->min_rate && (rate < factors->min_rate)) + new_rate = factors->min_rate; +else if (factors->max_rate && (rate > factors->max_rate)) + new_rate = factors->max_rate; +else +return 0 ; + +pr_info ("Initial rate of %s out of boundaries.. Changing rate from %lu to %lu\n" , +__clk_get_name (hw->clk), rate, new_rate); + +return clk_set_rate (hw->clk, rate); +} +static unsigned long clk_factors_recalc_rate (struct clk_hw *hw,unsigned long parent_rate) {
@@ -74,6 +93,11 @@ static long clk_factors_round_rate(struct clk_hw *hw, unsigned long rate, factors->get_factors ((u32 *)&rate, (u32)*parent_rate,NULL ,NULL ,NULL ,NULL ); +if (factors->max_rate && (rate > factors->max_rate)) + rate = factors->max_rate; +else if (factors->min_rate && (rate < factors->min_rate)) + rate = factors->min_rate; +return rate; }
@@ -123,6 +147,9 @@ static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate, factors->get_factors ((u32 *)&rate, (u32 )parent_rate, &n, &k, &m, &p); +if ((rate > factors->max_rate) || (rate < factors->min_rate)) +return -EINVAL ; +if (factors->lock)spin_lock_irqsave (factors->lock, flags);
@@ -149,6 +176,7 @@ static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate,const struct clk_ops clk_factors_ops = { .determine_rate = clk_factors_determine_rate, + .prepare = clk_factors_prepare, .recalc_rate = clk_factors_recalc_rate, .round_rate = clk_factors_round_rate, .set_rate = clk_factors_set_rate,
drivers/clk/sunxi/clk-factors.h +2 -0
@@ -24,6 +24,8 @@ struct clk_factors {struct clk_factors_config *config;void (*get_factors) (u32 *rate,u32 parent,u8 *n,u8 *k,u8 *m,u8 *p);spinlock_t *lock; +unsigned long max_rate; +unsigned long min_rate; };extern const struct clk_ops clk_factors_ops;
Signature · 1 line
2.0.1
Emilio López
maintainerPATCH 2/14 clk: sunxi: factors: Implement clock min and max frequencies
Hi Maxime,
El 17/07/14 06:08, Maxime Ripard escribi?:
Quoted 9 lines
In the A13, the out of reset frequency for the PLL6 is too high to be actually working.
Hence, we need to be able to lower down its frequency whenever we need to use the clock to some acceptable frequency.
This patch adds two new properties in the clock-nodes, clk-min-frequency and clk-max-frequency, to specify acceptable boundaries for proper clock operations.
This paragraph looks out of place
Quoted 8 lines
It also adds supports in the sunxi factor clocks driver to use these boundaries, enforce them at prepare time to make sure that the drivers will have a decent frequency, even though it never called
set_rate, but also make sure we never cross these boundaries.Signed-off-by Maxime Ripard <[email protected]>---
(...)
drivers/clk/sunxi/clk-factors.c static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate, · line 151
Quoted 7 lines
drivers/clk/sunxi/clk-factors.c +2
-0@@ -123,6 +147,9 @@ static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate, factors->get_factors ((u32 *)&rate, (u32 )parent_rate, &n, &k, &m, &p); +if ((rate > factors->max_rate) || (rate < factors->min_rate)) +return -EINVAL ;
Printing an error message here may come in handy in the future, what do you think?
Thanks for working on this!
Emilio
PATCH 3/14 ARM: sunxi: sun5i: Enforce max frequency on PLL6
In reply to Maxime RipardPLL6 out of reset is running at 2.4GHz, which is outside of its operating boundaries.
Enforce its maximum frequency as set in the datasheet to make sure we stays within these bounds.
--- arch/arm/boot/dts/sun5i-a13.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/sun5i-a13.dtsi +1 -0
@@ -97,6 +97,7 @@ reg = <0x01c20028 0x4>; clocks = <&osc24M>; clock-output-names = "pll6_sata", "pll6_other", "pll6"; + clock-max-frequency = <1200000000>; }; /* dummy is 200M */
Signature · 1 line
2.0.1
Emilio López
maintainerPATCH 3/14 ARM: sunxi: sun5i: Enforce max frequency on PLL6
Hi Maxime,
El 17/07/14 06:08, Maxime Ripard escribi?:
Quoted 17 lines
PLL6 out of reset is running at 2.4GHz, which is outside of its operating boundaries.
Enforce its maximum frequency as set in the datasheet to make sure we stays within these bounds.
Signed-off-by Maxime Ripard <[email protected]>--- arch/arm/boot/dts/sun5i-a13.dtsi | 1 + 1 file changed, 1 insertion(+)arch/arm/boot/dts/sun5i-a13.dtsi +0
-0
arch/arm/boot/dts/sun5i-a13.dtsi line 103
Quoted 7 lines
arch/arm/boot/dts/sun5i-a13.dtsi +1
-0@@ -97,6 +97,7 @@ reg = <0x01c20028 0x4>; clocks = <&osc24M>; clock-output-names = "pll6_sata", "pll6_other", "pll6"; + clock-max-frequency = <1200000000>; }; /* dummy is 200M */
This patch itself is ok, but I'm not seeing so far where is "clock-max-frequency" read from the DT and passed to the clock for later verification. Did you leave that out by mistake when shuffling patches?
Cheers!
Emilio
PATCH 4/14 clk: introduce clk_set_phase function & callback
In reply to Maxime RipardFrom: Mike Turquette <[email protected]>
A common operation for a clock signal generator is to shift the phase of that signal. This patch introduces a new function to the clk.h API to dynamically adjust the phase of a clock signal. Additionally this patch introduces support for the new function in the common clock framework via the .set_phase call back in struct clk_ops.
--- drivers/clk/clk.c | 84 +++++++++++++++++++++++++++++++++++++++++--- include/linux/clk-private.h | 1 + include/linux/clk-provider.h | 5 +++ include/linux/clk.h | 29 +++++++++++++++ 4 files changed, 115 insertions(+), 4 deletions(-)
drivers/clk/clk.c +80 -4
@@ -106,11 +106,11 @@ static void clk_summary_show_one(struct seq_file *s, struct clk *c, int level)if (!c)return ; -seq_printf (s,"%*s%-*s %11d %12d %11lu %10lu\n" , +seq_printf (s,"%*s%-*s %11d %12d %11lu %10lu %-3d\n" , level *3 +1 ,"" ,30 - level *3 , c->name, c->enable_count, c->prepare_count,clk_get_rate (c), -clk_get_accuracy (c)); +clk_get_accuracy (c),clk_get_phase (c)); } static void clk_summary_show_subtree(struct seq_file *s, struct clk *c,
@@ -131,8 +131,8 @@ static int clk_summary_show(struct seq_file *s, void *data) {struct clk *c; -seq_puts (s," clock enable_cnt prepare_cnt rate accuracy\n" ); -seq_puts (s,"--------------------------------------------------------------------------------\n" ); +seq_puts (s," clock enable_cnt prepare_cnt rate accuracy phase\n" ); +seq_puts (s,"----------------------------------------------------------------------------------------\n" );clk_prepare_lock ();
@@ -170,6 +170,7 @@ static void clk_dump_one(struct seq_file *s, struct clk *c, int level)seq_printf (s,"\"prepare_count\": %d," , c->prepare_count);seq_printf (s,"\"rate\": %lu" ,clk_get_rate (c));seq_printf (s,"\"accuracy\": %lu" ,clk_get_accuracy (c)); +seq_printf (s,"\"phase\": %d" ,clk_get_phase (c)); }static void clk_dump_subtree (struct seq_file *s,struct clk *c,int level)
@@ -256,6 +257,11 @@ static int clk_debug_create_one(struct clk *clk, struct dentry *pdentry)if (!d) goto err_out; + d =debugfs_create_u32 ("clk_phase" ,S_IRUGO , clk->dentry, + (u32 *)&clk->phase); +if (!d) + goto err_out; + d =debugfs_create_x32 ("clk_flags" ,S_IRUGO , clk->dentry, (u32 *)&clk->flags);if (!d)
@@ -1768,6 +1774,76 @@ out:EXPORT_SYMBOL_GPL (clk_set_parent);/** +* clk_set_phase - adjust the phase shift of a clock signal +* @clk: clock signal source +* @degrees: number of degrees the signal is shifted +* +* Shifts the phase of a clock signal by the specified degrees. Returns 0 on +* success, -EERROR otherwise. +* +* This function makes no distiction about the input or reference signal that +* we adjust the clock signal phase against. For example phase locked-loop +* clock signal generators we may shift phase with respect to feedback clock +* signal input, but for other cases the clock phase may be shifted with +* respect to some other, unspecified signal. +* +* Additionally the concept of phase shift does not propagate through the clock +* tree hierarchy, which sets it appart from clock rates and clock accuracy. A +* parent clock phase attribute does not have an impact on the phase attribute +* of a child clock. +*/ +int clk_set_phase (struct clk *clk,int degrees) +{ +int ret =0 ; + +if (!clk) + goto out; + +/* sanity check degrees */ + degrees %=360 ; +if (degrees <0 ) + degrees +=360 ; + +clk_prepare_lock (); + +if (!clk->ops->set_phase) + goto out_unlock; + + ret = clk->ops->set_phase (clk->hw, degrees); + +if (!ret) + clk->phase = degrees; + +out_unlock: +clk_prepare_unlock (); + +out: +return ret; +} + +/** +* clk_get_phase - return the phase shift of a clock signal +* @clk: clock signal source +* +* Returns the phase shift of a clock node in degrees, otherwise returns +* -EERROR. +*/ +int clk_get_phase (struct clk *clk) +{ +int ret =0 ; + +if (!clk) + goto out; + +clk_prepare_lock (); + ret = clk->phase; +clk_prepare_unlock (); + +out: +return ret; +} + +/** * __clk_init - initialize the data structures in a struct clk * @dev: device initializing this clk, placeholder for now * @clk: clk being initialized
include/linux/clk-private.h +1 -0
@@ -46,6 +46,7 @@ struct clk {unsigned int enable_count;unsigned int prepare_count;unsigned long accuracy; +int phase;struct hlist_head children;struct hlist_node child_node;unsigned int notifier_count;
include/linux/clk-provider.h +5 -0
@@ -129,6 +129,10 @@ struct dentry;* set then clock accuracy will be initialized to parent accuracy * or 0 (perfect clock) if clock has no parent. * +* @set_phase: Shift the phase this clock signal in degrees specified +* by the second argument. Valid values for degrees are +* 0-359. Return 0 on success, otherwise -EERROR. +* * @init: Perform platform-specific initialization magic. * This is not not used by any of the basic clock types. * Please consider other ways of solving initialization problems
@@ -177,6 +181,7 @@ struct clk_ops { unsigned long parent_rate, u8 index);unsigned long (*recalc_accuracy)(struct clk_hw *hw,unsigned long parent_accuracy); +int (*set_phase)(struct clk_hw *hw,int degrees);void (*init)(struct clk_hw *hw);int (*debug_init)(struct clk_hw *hw,struct dentry *dentry); };
include/linux/clk.h +29 -0
@@ -106,6 +106,25 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb);*/ long clk_get_accuracy (struct clk *clk); +/** +* clk_set_phase - adjust the phase shift of a clock signal +* @clk: clock signal source +* @degrees: number of degrees the signal is shifted +* +* Shifts the phase of a clock signal by the specified degrees. Returns 0 on +* success, -EERROR otherwise. +*/ +int clk_set_phase (struct clk *clk,int degrees); + +/** +* clk_get_phase - return the phase shift of a clock signal +* @clk: clock signal source +* +* Returns the phase shift of a clock node in degrees, otherwise returns +* -EERROR. +*/ +int clk_get_phase (struct clk *clk); +#else static inline long clk_get_accuracy (struct clk *clk)
@@ -113,6 +132,16 @@ static inline long clk_get_accuracy(struct clk *clk) return -ENOTSUPP; } +static inline long clk_set_phase (struct clk *clk,int phase) +{ +return -ENOTSUPP ; +} + +static inline long clk_get_phase (struct clk *clk) +{ +return -ENOTSUPP ; +} +#endif /**
Signature · 1 line
2.0.1
PATCH 5/14 clk: Add a function to retrieve phase
In reply to Maxime RipardThe current phase API doesn't look into the actual hardware to get the phase value, but will rather get it from a variable only set by the set_phase function.
This will cause issue when the client driver will never call the set_phase function, where we can end up having a reported phase that will not match what the hardware has been programmed to by the bootloader or what phase is programmed out of reset.
Add a new get_phase function for the drivers to implement so that we can get this value.
--- drivers/clk/clk.c | 17 ++++++++++++++--- include/linux/clk-provider.h | 5 +++++ 2 files changed, 19 insertions(+), 3 deletions(-)
drivers/clk/clk.c +14 -3
@@ -1825,8 +1825,8 @@ out:* clk_get_phase - return the phase shift of a clock signal * @clk: clock signal source * -* Returns the phase shift of a clock node in degrees, otherwise returns -* -EERROR. +* Returns the phase shift of a clock node in degrees. Any negative +* values are errors. */ int clk_get_phase (struct clk *clk) {
@@ -1836,7 +1836,18 @@ int clk_get_phase(struct clk *clk) goto out;clk_prepare_lock (); - ret = clk->phase; + +if (clk->phase) { + ret = clk->phase; + goto out_unlock; + } + +if (!clk->ops->get_phase) + goto out_unlock; + + ret = clk->ops->get_phase (clk->hw); + +out_unlock:clk_prepare_unlock (); out:
include/linux/clk-provider.h +5 -0
@@ -129,6 +129,10 @@ struct dentry;* set then clock accuracy will be initialized to parent accuracy * or 0 (perfect clock) if clock has no parent. * +* @get_phase: Queries the hardware to get the current phase of a clock. +* Returned values are 0-359 degrees on success, negative +* error codes on failure. +* * @set_phase: Shift the phase this clock signal in degrees specified * by the second argument. Valid values for degrees are * 0-359. Return 0 on success, otherwise -EERROR.
@@ -181,6 +185,7 @@ struct clk_ops { unsigned long parent_rate, u8 index);unsigned long (*recalc_accuracy)(struct clk_hw *hw,unsigned long parent_accuracy); +int (*get_phase)(struct clk_hw *hw);int (*set_phase)(struct clk_hw *hw,int degrees);void (*init)(struct clk_hw *hw);int (*debug_init)(struct clk_hw *hw,struct dentry *dentry);
Signature · 1 line
2.0.1
PATCH 6/14 clk: sunxi: factors: Invert the probing logic
In reply to Maxime RipardUntil now, the factors clock probing was done directly by sunxi_init_clocks, with the factors registration being called directly with the clocks data passed as an argument.
This approch has shown its limits when we added more clocks, since we couldn't really split code with such a logic in smaller files, and led to a huge file having all the clocks.
Introduce an intermediate probing function, so that factor clocks will be able to directly be called by CLK_OF_DECLARE, which will in turn ease the split into several files.
--- drivers/clk/sunxi/clk-factors.c | 101 +++++++++++++++++++++++++++++++++++++--- drivers/clk/sunxi/clk-factors.h | 16 ++++++- drivers/clk/sunxi/clk-sunxi.c | 95 ++----------------------------------- 3 files changed, 113 insertions(+), 99 deletions(-)
drivers/clk/sunxi/clk-factors.c +95 -6
@@ -9,18 +9,18 @@*/ #include <linux/clk-provider.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/io.h> #include <linux/module.h> +#include <linux/of_address.h> #include <linux/slab.h> -#include <linux/io.h> -#include <linux/err.h> #include <linux/string.h> -#include <linux/delay.h> -#include "clk-factors.h" /* -* DOC: basic adjustable factor-based clock that cannot gate +* DOC: basic adjustable factor-based clock * * Traits of this clock: * prepare - clk_prepare only ensures that parents are prepared
@@ -32,6 +32,8 @@#define to_clk_factors (_hw) container_of(_hw, struct clk_factors, hw) +#define FACTORS_MAX_PARENTS 5 +#define SETMASK (len, pos) (((1U << (len)) - 1) << (pos))#define CLRMASK (len, pos) (~(SETMASK(len, pos)))#define FACTOR_GET (bit, len, reg) (((reg) & SETMASK(len, bit)) >> (bit))
@@ -174,10 +176,97 @@ static int clk_factors_set_rate(struct clk_hw *hw, unsigned long rate,return 0 ; } -const struct clk_ops clk_factors_ops = { +static const struct clk_ops clk_factors_ops = { .determine_rate = clk_factors_determine_rate, .prepare = clk_factors_prepare, .recalc_rate = clk_factors_recalc_rate, .round_rate = clk_factors_round_rate, .set_rate = clk_factors_set_rate, }; + +struct clk *__init sunxi_factors_register (struct device_node *node, +const struct factors_data *data, +spinlock_t *lock) +{ +struct clk *clk; +struct clk_factors *factors; +struct clk_gate *gate =NULL ; +struct clk_mux *mux =NULL ; +struct clk_hw *gate_hw =NULL ; +struct clk_hw *mux_hw =NULL ; +const char *clk_name = node->name; +const char *parents[FACTORS_MAX_PARENTS ]; +void *reg; +int i =0 ; + + reg =of_iomap (node,0 ); + +/* if we have a mux, we will have >1 parents */ +while (i <FACTORS_MAX_PARENTS && + (parents[i] =of_clk_get_parent_name (node, i)) !=NULL ) + i++; + +/* +* some factor clocks, such as pll5 and pll6, may have multiple +* outputs, and have their name designated in factors_data +*/ +if (data->name) + clk_name = data->name; +else +of_property_read_string (node,"clock-output-names" , &clk_name); + + factors =kzalloc (sizeof (struct clk_factors ),GFP_KERNEL ); +if (!factors) +return NULL ; + +/* set up factors properties */ + factors->reg = reg; + factors->config = data->table; + factors->get_factors = data->getter; + factors->lock = lock; + +/* Add a gate if this factor clock can be gated */ +if (data->enable) { + gate =kzalloc (sizeof (struct clk_gate ),GFP_KERNEL ); +if (!gate) { +kfree (factors); +return NULL ; + } + +/* set up gate properties */ + gate->reg = reg; + gate->bit_idx = data->enable; + gate->lock = factors->lock; + gate_hw = &gate->hw; + } + +/* Add a mux if this factor clock can be muxed */ +if (data->mux) { + mux =kzalloc (sizeof (struct clk_mux ),GFP_KERNEL ); +if (!mux) { +kfree (factors); +kfree (gate); +return NULL ; + } + +/* set up gate properties */ + mux->reg = reg; + mux->shift = data->mux; + mux->mask =SUNXI_FACTORS_MUX_MASK ; + mux->lock = factors->lock; + mux_hw = &mux->hw; + } + + clk =clk_register_composite (NULL , clk_name, + parents, i, + mux_hw, &clk_mux_ops, + &factors->hw, &clk_factors_ops, + gate_hw, &clk_gate_ops,0 ); + +if (!IS_ERR (clk)) { +of_clk_add_provider (node, of_clk_src_simple_get, clk); +clk_register_clkdev (clk, clk_name,NULL ); + } + +return clk; +}
drivers/clk/sunxi/clk-factors.h +15 -1
@@ -3,9 +3,12 @@#include <linux/clk-provider.h> #include <linux/clkdev.h> +#include <linux/spinlock.h> #define SUNXI_FACTORS_NOT_APPLICABLE (0) +#define SUNXI_FACTORS_MUX_MASK 0x3 +struct clk_factors_config {u8 nshift;u8 nwidth;
@@ -18,6 +21,14 @@ struct clk_factors_config {u8 n_start; }; +struct factors_data { +int enable; +int mux; +struct clk_factors_config *table; +void (*getter) (u32 *rate,u32 parent_rate,u8 *n,u8 *k,u8 *m,u8 *p); +const char *name; +}; +struct clk_factors {struct clk_hw hw;void __iomem *reg;
@@ -28,5 +39,8 @@ struct clk_factors { unsigned long min_rate; }; -extern const struct clk_ops clk_factors_ops; +struct clk *__init sunxi_factors_register (struct device_node *node, +const struct factors_data *data, +spinlock_t *lock); +#endif
drivers/clk/sunxi/clk-sunxi.c +3 -92
114 lines not on this page · raw message
Signature · 1 line
2.0.1
PATCH 7/14 clk: sunxi: Introduce mbus compatible
In reply to Maxime RipardEven though the mbus clock is a regular module clock, given its nature, it needs to be enabled all the time.
Introduce a new compatible, to differentiate it from the other module clocks.
--- Documentation/devicetree/bindings/clock/sunxi.txt | 1 + drivers/clk/sunxi/clk-sunxi.c | 1 + 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/clock/sunxi.txt +1 -0
@@ -46,6 +46,7 @@ Required properties: "allwinner,sun6i-a31-apb2-div-clk" - for the APB2 gates on A31 "allwinner,sun6i-a31-apb2-gates-clk" - for the APB2 gates on A31 "allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23 + "allwinner,sun4i-a10-mbus-clk" - for the MBUS clock on A10 "allwinner,sun4i-a10-mod0-clk" - for the module 0 family of clocks "allwinner,sun7i-a20-out-clk" - for the external output clocks "allwinner,sun7i-a20-gmac-clk" - for the GMAC clock module on A20/A31
drivers/clk/sunxi/clk-sunxi.c +1 -0
@@ -1110,6 +1110,7 @@ static const struct of_device_id clk_factors_match[] __initconst = { {.compatible = "allwinner,sun7i-a20-pll4-clk", .data = &sun7i_a20_pll4_data,}, {.compatible = "allwinner,sun6i-a31-pll6-clk", .data = &sun6i_a31_pll6_data,}, {.compatible = "allwinner,sun4i-a10-apb1-clk", .data = &sun4i_apb1_data,}, + {.compatible = "allwinner,sun4i-a10-mbus-clk", .data = &sun4i_mod0_data,}, {.compatible = "allwinner,sun4i-a10-mod0-clk", .data = &sun4i_mod0_data,}, {.compatible = "allwinner,sun7i-a20-out-clk", .data = &sun7i_a20_out_data,}, {}
Signature · 1 line
2.0.1
PATCH 7/14 clk: sunxi: Introduce mbus compatible
Hi,
Quoted 16 lines · Maxime Ripard
Even though the mbus clock is a regular module clock, given its nature, it needs to be enabled all the time.
Introduce a new compatible, to differentiate it from the other module clocks.
Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/clock/sunxi.txt | 1 + drivers/clk/sunxi/clk-sunxi.c | 1 + 2 files changed, 2 insertions(+)Documentation/devicetree/bindings/clock/sunxi.txt +0
-0
Documentation/devicetree/bindings/clock/sunxi.txt Required properties: · line 49
Quoted 4 lines
Documentation/devicetree/bindings/clock/sunxi.txt +1
-0@@ -46,6 +46,7 @@ Required properties: "allwinner,sun6i-a31-apb2-div-clk" - for the APB2 gates on A31 "allwinner,sun6i-a31-apb2-gates-clk" - for the APB2 gates on A31 "allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23 + "allwinner,sun4i-a10-mbus-clk" - for the MBUS clock on A10
This should probably be sun5i-a13-mbus-clk?
AFAIK the A10 doesn't have MBUS.
Quoted 23 lines
Documentation/devicetree/bindings/clock/sunxi.txt +0
-0"allwinner,sun4i-a10-mod0-clk" - for the module 0 family of clocks "allwinner,sun7i-a20-out-clk" - for the external output clocks "allwinner,sun7i-a20-gmac-clk" - for the GMAC clock module on A20/A31drivers/clk/sunxi/clk-sunxi.c +1
-1@@ -1110,6 +1110,7 @@ static const struct of_device_id clk_factors_match[] __initconst = { {.compatible = "allwinner,sun7i-a20-pll4-clk", .data = &sun7i_a20_pll4_data,}, {.compatible = "allwinner,sun6i-a31-pll6-clk", .data = &sun6i_a31_pll6_data,}, {.compatible = "allwinner,sun4i-a10-apb1-clk", .data = &sun4i_apb1_data,}, + {.compatible = "allwinner,sun4i-a10-mbus-clk", .data = &sun4i_mod0_data,}, {.compatible = "allwinner,sun4i-a10-mod0-clk", .data = &sun4i_mod0_data,}, {.compatible = "allwinner,sun7i-a20-out-clk", .data = &sun7i_a20_out_data,}, {} --2.0.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 7/14 clk: sunxi: Introduce mbus compatible
Quoted 15 lines · Chen-Yu Tsai
Hi,
Quoted 11 lines · Maxime Ripard
Even though the mbus clock is a regular module clock, given its nature, it needs to be enabled all the time.
Introduce a new compatible, to differentiate it from the other module clocks.
Signed-off-by Maxime Ripard <[email protected]>--- Documentation/devicetree/bindings/clock/sunxi.txt | 1 + drivers/clk/sunxi/clk-sunxi.c | 1 + 2 files changed, 2 insertions(+)
Quoted 12 lines
Documentation/devicetree/bindings/clock/sunxi.txt Required properties: · line 49
Quoted 9 lines
Documentation/devicetree/bindings/clock/sunxi.txt +1
-0@@ -46,6 +46,7 @@ Required properties: "allwinner,sun6i-a31-apb2-div-clk" - for the APB2 gates on A31 "allwinner,sun6i-a31-apb2-gates-clk" - for the APB2 gates on A31 "allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23 + "allwinner,sun4i-a10-mbus-clk" - for the MBUS clock on A10This should probably be sun5i-a13-mbus-clk?
AFAIK the A10 doesn't have MBUS.
Ah, right, thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/f24c7562/attachment.sig>
PATCH 8/14 ARM: sunxi: dt: Switch to the new mbus compatible
In reply to Maxime RipardNow that we have a compatible of its own for the mbus clock, switch to it.
--- arch/arm/boot/dts/sun5i-a10s.dtsi | 2 +- arch/arm/boot/dts/sun5i-a13.dtsi | 2 +- arch/arm/boot/dts/sun7i-a20.dtsi | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/dts/sun5i-a10s.dtsi +1 -1
@@ -287,7 +287,7 @@ mbus_clk: clk at 01c2015c { #clock-cells = <0>; - compatible = "allwinner,sun4i-a10-mod0-clk"; + compatible = "allwinner,sun4i-a10-mbus-clk"; reg = <0x01c2015c 0x4>; clocks = <&osc24M>, <&pll6 1>, <&pll5 1>; clock-output-names = "mbus";
arch/arm/boot/dts/sun5i-a13.dtsi +1 -1
@@ -286,7 +286,7 @@ mbus_clk: clk at 01c2015c { #clock-cells = <0>; - compatible = "allwinner,sun4i-a10-mod0-clk"; + compatible = "allwinner,sun4i-a10-mbus-clk"; reg = <0x01c2015c 0x4>; clocks = <&osc24M>, <&pll6 1>, <&pll5 1>; clock-output-names = "mbus";
arch/arm/boot/dts/sun7i-a20.dtsi +1 -1
@@ -346,7 +346,7 @@ mbus_clk: clk at 01c2015c { #clock-cells = <0>; - compatible = "allwinner,sun4i-a10-mod0-clk"; + compatible = "allwinner,sun4i-a10-mbus-clk"; reg = <0x01c2015c 0x4>; clocks = <&osc24M>, <&pll6 2>, <&pll5 1>; clock-output-names = "mbus";
Signature · 1 line
2.0.1
PATCH 9/14 clk: sunxi: Move mod0 clock to a file of its own
In reply to Maxime RipardSince we know have the ability to declare factors clock outside of clk-sunxi, create a new mod0 driver to deal with the mod0 clocks.
--- drivers/clk/sunxi/Makefile | 1 + drivers/clk/sunxi/clk-mod0.c | 82 +++++++++++++++++++++++++++++++++++++++++++ drivers/clk/sunxi/clk-sunxi.c | 1 - 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/sunxi/clk-mod0.c
drivers/clk/sunxi/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-y += clk-sunxi.o clk-factors.o obj-y += clk-a10-hosc.o obj-y += clk-a20-gmac.o +obj-y += clk-mod0.o obj-$(CONFIG_MFD_SUN6I_PRCM) += \ clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o \
drivers/clk/sunxi/clk-mod0.c new file +82 -0
82 lines not on this page · raw message
drivers/clk/sunxi/clk-sunxi.c +0 -1
@@ -1111,7 +1111,6 @@ static const struct of_device_id clk_factors_match[] __initconst = { {.compatible = "allwinner,sun6i-a31-pll6-clk", .data = &sun6i_a31_pll6_data,}, {.compatible = "allwinner,sun4i-a10-apb1-clk", .data = &sun4i_apb1_data,}, {.compatible = "allwinner,sun4i-a10-mbus-clk", .data = &sun4i_mod0_data,}, - {.compatible = "allwinner,sun4i-a10-mod0-clk", .data = &sun4i_mod0_data,}, {.compatible = "allwinner,sun7i-a20-out-clk", .data = &sun7i_a20_out_data,}, {} };
Signature · 1 line
2.0.1
PATCH 10/14 clk: sunxi: Move mbus to mod0 file
In reply to Maxime RipardMove the MBUS clock to the module clocks file. It's pretty trivial, but still requires to enable the clocks to make sure it won't get disabled.
--- drivers/clk/sunxi/clk-mod0.c | 12 +++++++++ drivers/clk/sunxi/clk-sunxi.c | 57 ------------------------------------------- 2 files changed, 12 insertions(+), 57 deletions(-)
drivers/clk/sunxi/clk-mod0.c +12 -0
@@ -80,3 +80,15 @@ static void __init sun4i_a10_mod0_setup(struct device_node *node)sunxi_factors_register (node, &sun4i_a10_mod0_data, &sun4i_a10_mod0_lock); }CLK_OF_DECLARE (sun4i_a10_mod0,"allwinner,sun4i-a10-mod0-clk" , sun4i_a10_mod0_setup); + +static DEFINE_SPINLOCK (sun4i_a10_mbus_lock); + +static void __init sun4i_a10_mbus_setup (struct device_node *node) +{ +struct clk *mbus =sunxi_factors_register (node, &sun4i_a10_mod0_data, &sun4i_a10_mbus_lock); + +/* The MBUS clocks needs to be always enabled */ +__clk_get (mbus); +clk_prepare_enable (mbus); +} +CLK_OF_DECLARE (sun4i_a10_mbus,"allwinner,sun4i-a10-mbus-clk" , sun4i_a10_mbus_setup);
drivers/clk/sunxi/clk-sunxi.c +0 -57
87 lines not on this page · raw message
Signature · 1 line
2.0.1
PATCH 11/14 ARM: sunxi: dt: Add sample and output mmc clocks
In reply to Maxime RipardAdd the sample and output clocks for the MMC phase support.
--- arch/arm/boot/dts/sun4i-a10.dtsi | 104 +++++++++++++++++++++++++++++++++++--- arch/arm/boot/dts/sun5i-a10s.dtsi | 79 ++++++++++++++++++++++++++--- arch/arm/boot/dts/sun5i-a13.dtsi | 80 +++++++++++++++++++++++++---- arch/arm/boot/dts/sun6i-a31.dtsi | 104 +++++++++++++++++++++++++++++++++++--- arch/arm/boot/dts/sun7i-a20.dtsi | 104 +++++++++++++++++++++++++++++++++++--- 5 files changed, 430 insertions(+), 41 deletions(-)
arch/arm/boot/dts/sun4i-a10.dtsi +96 -8
@@ -227,6 +227,22 @@ clock-output-names = "mmc0"; }; + mmc0_output_clk: clk_mmc_output at 01c20088 { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-mmc-output-clk"; + reg = <0x01c20088 0x4>; + clocks = <&mmc0_clk>; + clock-output-names = "mmc0_output"; + }; + + mmc0_sample_clk: clk_mmc_sample at 01c20088 { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-mmc-sample-clk"; + reg = <0x01c20088 0x4>; + clocks = <&mmc0_clk>; + clock-output-names = "mmc0_sample"; + }; + mmc1_clk: clk at 01c2008c { #clock-cells = <0>; compatible = "allwinner,sun4i-a10-mod0-clk";
@@ -235,6 +251,22 @@ clock-output-names = "mmc1"; }; + mmc1_output_clk: clk_mmc_output at 01c2008c { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-mmc-output-clk"; + reg = <0x01c2008c 0x4>; + clocks = <&mmc1_clk>; + clock-output-names = "mmc1_output"; + }; + + mmc1_sample_clk: clk_mmc_sample at 01c2008c { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-mmc-sample-clk"; + reg = <0x01c2008c 0x4>; + clocks = <&mmc1_clk>; + clock-output-names = "mmc1_sample"; + }; + mmc2_clk: clk at 01c20090 { #clock-cells = <0>; compatible = "allwinner,sun4i-a10-mod0-clk";
@@ -243,6 +275,22 @@ clock-output-names = "mmc2"; }; + mmc2_output_clk: clk_mmc_output at 01c20090 { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-mmc-output-clk"; + reg = <0x01c20090 0x4>; + clocks = <&mmc2_clk>; + clock-output-names = "mmc2_output"; + }; + + mmc2_sample_clk: clk_mmc_sample at 01c20090 { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-mmc-sample-clk"; + reg = <0x01c20090 0x4>; + clocks = <&mmc2_clk>; + clock-output-names = "mmc2_sample"; + }; + mmc3_clk: clk at 01c20094 { #clock-cells = <0>; compatible = "allwinner,sun4i-a10-mod0-clk";
@@ -251,6 +299,22 @@ clock-output-names = "mmc3"; }; + mmc3_output_clk: clk_mmc_output at 01c20094 { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-mmc-output-clk"; + reg = <0x01c20094 0x4>; + clocks = <&mmc3_clk>; + clock-output-names = "mmc3_output"; + }; + + mmc3_sample_clk: clk_mmc_sample at 01c20094 { + #clock-cells = <0>; + compatible = "allwinner,sun4i-a10-mmc-sample-clk"; + reg = <0x01c20094 0x4>; + clocks = <&mmc3_clk>; + clock-output-names = "mmc3_sample"; + }; + ts_clk: clk at 01c20098 { #clock-cells = <0>; compatible = "allwinner,sun4i-a10-mod0-clk";
@@ -380,8 +444,14 @@ mmc0: mmc at 01c0f000 { compatible = "allwinner,sun4i-a10-mmc"; reg = <0x01c0f000 0x1000>; - clocks = <&ahb_gates 8>, <&mmc0_clk>; - clock-names = "ahb", "mmc"; + clocks = <&ahb_gates 8>, + <&mmc0_clk>, + <&mmc0_sample_clk>, + <&mmc0_output_clk>; + clock-names = "ahb", + "mmc", + "sample", + "output"; interrupts = <32>; status = "disabled"; };
@@ -389,8 +459,14 @@ mmc1: mmc at 01c10000 { compatible = "allwinner,sun4i-a10-mmc"; reg = <0x01c10000 0x1000>; - clocks = <&ahb_gates 9>, <&mmc1_clk>; - clock-names = "ahb", "mmc"; + clocks = <&ahb_gates 9>, + <&mmc1_clk>, + <&mmc1_sample_clk>, + <&mmc1_output_clk>; + clock-names = "ahb", + "mmc", + "sample", + "output"; interrupts = <33>; status = "disabled"; };
@@ -398,8 +474,14 @@ mmc2: mmc at 01c11000 { compatible = "allwinner,sun4i-a10-mmc"; reg = <0x01c11000 0x1000>; - clocks = <&ahb_gates 10>, <&mmc2_clk>; - clock-names = "ahb", "mmc"; + clocks = <&ahb_gates 10>, + <&mmc2_clk>, + <&mmc2_sample_clk>, + <&mmc2_output_clk>; + clock-names = "ahb", + "mmc", + "sample", + "output"; interrupts = <34>; status = "disabled"; };
@@ -407,8 +489,14 @@ mmc3: mmc at 01c12000 { compatible = "allwinner,sun4i-a10-mmc"; reg = <0x01c12000 0x1000>; - clocks = <&ahb_gates 11>, <&mmc3_clk>; - clock-names = "ahb", "mmc"; + clocks = <&ahb_gates 11>, + <&mmc3_clk>, + <&mmc3_sample_clk>, + <&mmc3_output_clk>; + clock-names = "ahb", + "mmc", + "sample", + "output"; interrupts = <35>; status = "disabled"; };
arch/arm/boot/dts/sun5i-a10s.dtsi +72 -7
118 lines not on this page · raw message
arch/arm/boot/dts/sun5i-a13.dtsi +70 -10
116 lines not on this page · raw message
arch/arm/boot/dts/sun6i-a31.dtsi +96 -8
152 lines not on this page · raw message
arch/arm/boot/dts/sun7i-a20.dtsi +96 -8
152 lines not on this page · raw message
Signature · 1 line
2.0.1
PATCH 12/14 clk: sunxi: mod0: Introduce MMC proper phase handling
In reply to Maxime RipardThe MMC clock we thought we had until now are actually not one but three different clocks.
The main one is unchanged, and will have three outputs:
- The clock fed into the MMC
- a sample and output clocks, to deal with when should we output/sample data to/from the MMC bus
The phase control we had are actually controlling the two latter clocks, but the main MMC one is unchanged.
We can adjust the phase with a 3 bits value, from 0 to 7, 0 meaning a 180 phase shift, and the other values being the number of periods from the MMC parent clock to outphase the clock of.
--- Documentation/devicetree/bindings/clock/sunxi.txt | 2 + drivers/clk/sunxi/clk-mod0.c | 189 ++++++++++++++++++++++ 2 files changed, 191 insertions(+)
Documentation/devicetree/bindings/clock/sunxi.txt +2 -0
@@ -47,6 +47,8 @@ Required properties: "allwinner,sun6i-a31-apb2-gates-clk" - for the APB2 gates on A31 "allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23 "allwinner,sun4i-a10-mbus-clk" - for the MBUS clock on A10 + "allwinner,sun4i-a10-mmc-output-clk" - for the MMC output clock on A10 + "allwinner,sun4i-a10-mmc-sample-clk" - for the MMC sample clock on A10 "allwinner,sun4i-a10-mod0-clk" - for the module 0 family of clocks "allwinner,sun7i-a20-out-clk" - for the external output clocks "allwinner,sun7i-a20-gmac-clk" - for the GMAC clock module on A20/A31
drivers/clk/sunxi/clk-mod0.c +189 -0
198 lines not on this page · raw message
Signature · 1 line
2.0.1
PATCH 13/14 mmc: sunxi: Convert MMC driver to the standard clock phase API
In reply to Maxime RipardNow that we have proper support to use the generic phase API in our clock driver, switch the MMC driver to use it.
--- .../devicetree/bindings/mmc/sunxi-mmc.txt | 8 +-- drivers/mmc/host/sunxi-mmc.c | 72 +++++++++++++++------- 2 files changed, 53 insertions(+), 27 deletions(-)
Documentation/devicetree/bindings/mmc/sunxi-mmc.txt +4 -4
@@ -10,8 +10,8 @@ Absolute maximum transfer rate is 200MB/s Required properties: - compatible : "allwinner,sun4i-a10-mmc" or "allwinner,sun5i-a13-mmc" - reg : mmc controller base registers - - clocks : a list with 2 phandle + clock specifier pairs - - clock-names : must contain "ahb" and "mmc" + - clocks : a list with 4 phandle + clock specifier pairs + - clock-names : must contain "ahb", "mmc", "output" and "sample" - interrupts : mmc controller interrupt Optional properties:
@@ -25,8 +25,8 @@ Examples: mmc0: mmc at 01c0f000 { compatible = "allwinner,sun5i-a13-mmc"; reg = <0x01c0f000 0x1000>; - clocks = <&ahb_gates 8>, <&mmc0_clk>; - clock-names = "ahb", "mod"; + clocks = <&ahb_gates 8>, <&mmc0_clk>, <&mmc0_output_clk>, <&mmc0_sample_clk>; + clock-names = "ahb", "mod", "output", "sample"; interrupts = <0 32 4>; status = "disabled"; };
drivers/mmc/host/sunxi-mmc.c +49 -23
126 lines not on this page · raw message
Signature · 1 line
2.0.1
PATCH 13/14 mmc: sunxi: Convert MMC driver to the standard clock phase API
Quoted 4 lines · Maxime Ripard
Now that we have proper support to use the generic phase API in our clock driver, switch the MMC driver to use it.
Signed-off-by Maxime Ripard <[email protected]>
I see there are a dependency of the clk patches with the mmc patch. I suppose it's best to take this set through Mike's clk tree then.
Kind regards
Uffe
Quoted 175 lines
--- .../devicetree/bindings/mmc/sunxi-mmc.txt | 8 +-- drivers/mmc/host/sunxi-mmc.c | 72 +++++++++++++++------- 2 files changed, 53 insertions(+), 27 deletions(-)Documentation/devicetree/bindings/mmc/sunxi-mmc.txt +4
-4@@ -10,8 +10,8 @@ Absolute maximum transfer rate is 200MB/s Required properties: - compatible : "allwinner,sun4i-a10-mmc" or "allwinner,sun5i-a13-mmc" - reg : mmc controller base registers - - clocks : a list with 2 phandle + clock specifier pairs - - clock-names : must contain "ahb" and "mmc" + - clocks : a list with 4 phandle + clock specifier pairs + - clock-names : must contain "ahb", "mmc", "output" and "sample" - interrupts : mmc controller interrupt Optional properties:@@ -25,8 +25,8 @@ Examples: mmc0: mmc at 01c0f000 { compatible = "allwinner,sun5i-a13-mmc"; reg = <0x01c0f000 0x1000>; - clocks = <&ahb_gates 8>, <&mmc0_clk>; - clock-names = "ahb", "mod"; + clocks = <&ahb_gates 8>, <&mmc0_clk>, <&mmc0_output_clk>, <&mmc0_sample_clk>; + clock-names = "ahb", "mod", "output", "sample"; interrupts = <0 32 4>; status = "disabled"; };drivers/mmc/host/sunxi-mmc.c +49
-24@@ -22,7 +22,6 @@#include <linux/clk.h> #include <linux/clk-private.h> -#include <linux/clk/sunxi.h> #include <linux/gpio.h> #include <linux/platform_device.h> @@ -230,6 +229,8 @@ struct sunxi_mmc_host {/* clock management */ struct clk *clk_ahb;struct clk *clk_mmc; +struct clk *clk_sample; +struct clk *clk_output;/* irq */ spinlock_t lock;@@ -617,7 +618,7 @@ static int sunxi_mmc_oclk_onoff(struct sunxi_mmc_host *host, u32 oclk_en)static int sunxi_mmc_clk_set_rate (struct sunxi_mmc_host *host,struct mmc_ios *ios) { -u32 rate, oclk_dly, rval, sclk_dly, src_clk; +u32 rate, oclk_dly, rval, sclk_dly;int ret; rate =clk_round_rate (host->clk_mmc, ios->clock);@@ -643,34 +644,31 @@ static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host,/* determine delays */ if (rate <=400000 ) { - oclk_dly =0 ; - sclk_dly =7 ; + oclk_dly =180 ; + sclk_dly =42 ; }else if (rate <=25000000 ) { - oclk_dly =0 ; - sclk_dly =5 ; + oclk_dly =180 ; + sclk_dly =75 ; }else if (rate <=50000000 ) {if (ios->timing ==MMC_TIMING_UHS_DDR50 ) { - oclk_dly =2 ; - sclk_dly =4 ; + oclk_dly =60 ; + sclk_dly =120 ; }else { - oclk_dly =3 ; - sclk_dly =5 ; + oclk_dly =90 ; + sclk_dly =150 ; } + }else if (rate <=100000000 ) { + oclk_dly =6 ; + sclk_dly =24 ; + }else if (rate <=200000000 ) { + oclk_dly =3 ; + sclk_dly =12 ; }else { -/* rate > 50000000 */ - oclk_dly =2 ; - sclk_dly =4 ; +return -EINVAL ; } - src_clk =clk_get_rate (clk_get_parent (host->clk_mmc)); -if (src_clk >=300000000 && src_clk <=400000000 ) { -if (oclk_dly) - oclk_dly--; -if (sclk_dly) - sclk_dly--; - } - -clk_sunxi_mmc_phase_control (host->clk_mmc, sclk_dly, oclk_dly); +clk_set_phase (host->clk_sample, sclk_dly); +clk_set_phase (host->clk_output, oclk_dly);return sunxi_mmc_oclk_onoff (host,1 ); }@@ -909,6 +907,18 @@ static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host,return PTR_ERR (host->clk_mmc); } + host->clk_output =devm_clk_get (&pdev->dev,"output" ); +if (IS_ERR (host->clk_output)) { +dev_err (&pdev->dev,"Could not get output clock\n" ); +return PTR_ERR (host->clk_output); + } + + host->clk_sample =devm_clk_get (&pdev->dev,"sample" ); +if (IS_ERR (host->clk_sample)) { +dev_err (&pdev->dev,"Could not get sample clock\n" ); +return PTR_ERR (host->clk_sample); + } + host->reset =devm_reset_control_get (&pdev->dev,"ahb" ); ret =clk_prepare_enable (host->clk_ahb);@@ -923,11 +933,23 @@ static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host, goto error_disable_clk_ahb; } + ret =clk_prepare_enable (host->clk_output); +if (ret) { +dev_err (&pdev->dev,"Enable output clk err %d\n" , ret); + goto error_disable_clk_mmc; + } + + ret =clk_prepare_enable (host->clk_sample); +if (ret) { +dev_err (&pdev->dev,"Enable sample clk err %d\n" , ret); + goto error_disable_clk_output; + } +if (!IS_ERR (host->reset)) { ret =reset_control_deassert (host->reset);if (ret) {dev_err (&pdev->dev,"reset err %d\n" , ret); - goto error_disable_clk_mmc; + goto error_disable_clk_sample; } }@@ -946,6 +968,10 @@ static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host, error_assert_reset:if (!IS_ERR (host->reset))reset_control_assert (host->reset); +error_disable_clk_sample: +clk_disable_unprepare (host->clk_sample); +error_disable_clk_output: +clk_disable_unprepare (host->clk_output); error_disable_clk_mmc:clk_disable_unprepare (host->clk_mmc); error_disable_clk_ahb: --2.0.1
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 14/14 clk: sunxi: Remove custom phase function
In reply to Maxime RipardNow that we don't have any user left for our custom phase function, we can safely remove this hack from the code.
--- drivers/clk/sunxi/clk-sunxi.c | 37 ------------------------------------- include/linux/clk/sunxi.h | 22 ---------------------- 2 files changed, 59 deletions(-) delete mode 100644 include/linux/clk/sunxi.h
drivers/clk/sunxi/clk-sunxi.c +0 -37
@@ -361,43 +361,6 @@ static void sun7i_a20_get_out_factors(u32 *freq, u32 parent_rate, }/** -* clk_sunxi_mmc_phase_control() - configures MMC clock phase control -*/ - -void clk_sunxi_mmc_phase_control (struct clk *clk,u8 sample,u8 output) -{ -#define to_clk_composite (_hw) container_of(_hw, struct clk_composite, hw) -#define to_clk_factors (_hw) container_of(_hw, struct clk_factors, hw) - -struct clk_hw *hw =__clk_get_hw (clk); -struct clk_composite *composite =to_clk_composite (hw); -struct clk_hw *rate_hw = composite->rate_hw; -struct clk_factors *factors =to_clk_factors (rate_hw); -unsigned long flags =0 ; -u32 reg; - -if (factors->lock) -spin_lock_irqsave (factors->lock, flags); - - reg =readl (factors->reg); - -/* set sample clock phase control */ - reg &= ~(0x7 <<20 ); - reg |= ((sample &0x7 ) <<20 ); - -/* set output clock phase control */ - reg &= ~(0x7 <<8 ); - reg |= ((output &0x7 ) <<8 ); - -writel (reg, factors->reg); - -if (factors->lock) -spin_unlock_irqrestore (factors->lock, flags); -} -EXPORT_SYMBOL (clk_sunxi_mmc_phase_control); - - -/** * sunxi_factors_clk_setup() - Setup function for factor clocks */
include/linux/clk/sunxi.h deleted +0 -22
@@ -1,22 +0,0 @@ -/* -* Copyright 2013 - Hans de Goede <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -*/ - -#ifndef __LINUX_CLK_SUNXI_H_ -#define __LINUX_CLK_SUNXI_H_ - -#include <linux/clk.h> - -void clk_sunxi_mmc_phase_control (struct clk *clk,u8 sample,u8 output); - -#endif
Signature · 1 line
2.0.1
cover clk: sunxi: Improve MMC clocks support
In reply to Maxime RipardHi,
Quoted 9 lines · Maxime Ripard
Hi everyone,
Here is an attempt at improving the MMC clock support in the Allwinner SoCs.
Until now, the MMC clocks were having a custom phase function that was directly setting an obscure value in the right register, because we were not really having any idea of what these values were.
Quoted 8 lines
Now that we have more informations, we can introduce a common function call to get and set the phase of a particular clock, and use this in both our provider and our client.
Another issue we had so far on the A13 was that, out of reset, the PLL6 driving the MMC was running too high to be working. We can solve that by adding two new properties in the DT to setup the rate constraints we might have on a clock.
Looks good to me, thanks for working on this.
Question have you dumped the raw mmc0 clk reg before and after this patch set to verify that the end result is the same ?
Regards,
Hans
cover clk: sunxi: Improve MMC clocks support
Hi Hans,
Quoted 21 lines · Hans de Goede
Hi,
Quoted 9 lines · Maxime Ripard
Hi everyone,
Here is an attempt at improving the MMC clock support in the Allwinner SoCs.
Until now, the MMC clocks were having a custom phase function that was directly setting an obscure value in the right register, because we were not really having any idea of what these values were.
Quoted 8 lines
Now that we have more informations, we can introduce a common function call to get and set the phase of a particular clock, and use this in both our provider and our client.
Another issue we had so far on the A13 was that, out of reset, the PLL6 driving the MMC was running too high to be working. We can solve that by adding two new properties in the DT to setup the rate constraints we might have on a clock.
Quoted 4 lines
Looks good to me, thanks for working on this.
Question have you dumped the raw mmc0 clk reg before and after this patch set to verify that the end result is the same ?
I did at 100MHz, but I was missing other test cases, so more testing at the various other frequencies we might run at would be very much welcome (and some cross-testing).
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140724/57a6cf15/attachment.sig>