Skip to content

Commit

Permalink
Merge branches 'clk-qcom-set-rate-gate', 'clk-core-set-rate-gate', 'c…
Browse files Browse the repository at this point in the history
…lk-core-duty-cycle', 'clk-si-prepare' and 'clk-imx-gpio-gates' into clk-next

* clk-qcom-set-rate-gate:
  clk: qcom: drop CLK_SET_RATE_GATE from sdc clocks

* clk-core-set-rate-gate:
  clk: fix CLK_SET_RATE_GATE with clock rate protection

* clk-core-duty-cycle:
  clk: add duty cycle support

* clk-si-prepare:
  :  - SI544/SI514 clk on/off support
  clk-si514, clk-si544: Implement prepare/unprepare/is_prepared operations

* clk-imx-gpio-gates:
  :  - i.MX6UL GPIO clock gates in CCM CCGR
  clk: imx6ul: remove clks_init_on array
  clk: imx6ul: add GPIO clock gates
  dt-bindings: clock: imx6ul: Do not change the clock definition order
  • Loading branch information
bebarino committed Aug 15, 2018
5 parents 04cdd5a + 9461f7b + 9fba738 + e8f127c + 4a2eaa8 commit 5ef7748
Show file tree
Hide file tree
Showing 8 changed files with 412 additions and 48 deletions.
38 changes: 37 additions & 1 deletion drivers/clk/clk-si514.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,33 @@ static int si514_enable_output(struct clk_si514 *data, bool enable)
SI514_CONTROL_OE, enable ? SI514_CONTROL_OE : 0);
}

static int si514_prepare(struct clk_hw *hw)
{
struct clk_si514 *data = to_clk_si514(hw);

return si514_enable_output(data, true);
}

static void si514_unprepare(struct clk_hw *hw)
{
struct clk_si514 *data = to_clk_si514(hw);

si514_enable_output(data, false);
}

static int si514_is_prepared(struct clk_hw *hw)
{
struct clk_si514 *data = to_clk_si514(hw);
unsigned int val;
int err;

err = regmap_read(data->regmap, SI514_REG_CONTROL, &val);
if (err < 0)
return err;

return !!(val & SI514_CONTROL_OE);
}

/* Retrieve clock multiplier and dividers from hardware */
static int si514_get_muldiv(struct clk_si514 *data,
struct clk_si514_muldiv *settings)
Expand Down Expand Up @@ -235,12 +262,17 @@ static int si514_set_rate(struct clk_hw *hw, unsigned long rate,
{
struct clk_si514 *data = to_clk_si514(hw);
struct clk_si514_muldiv settings;
unsigned int old_oe_state;
int err;

err = si514_calc_muldiv(&settings, rate);
if (err)
return err;

err = regmap_read(data->regmap, SI514_REG_CONTROL, &old_oe_state);
if (err)
return err;

si514_enable_output(data, false);

err = si514_set_muldiv(data, &settings);
Expand All @@ -255,12 +287,16 @@ static int si514_set_rate(struct clk_hw *hw, unsigned long rate,
/* Applying a new frequency can take up to 10ms */
usleep_range(10000, 12000);

si514_enable_output(data, true);
if (old_oe_state & SI514_CONTROL_OE)
si514_enable_output(data, true);

return err;
}

static const struct clk_ops si514_clk_ops = {
.prepare = si514_prepare,
.unprepare = si514_unprepare,
.is_prepared = si514_is_prepared,
.recalc_rate = si514_recalc_rate,
.round_rate = si514_round_rate,
.set_rate = si514_set_rate,
Expand Down
38 changes: 37 additions & 1 deletion drivers/clk/clk-si544.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,33 @@ static int si544_enable_output(struct clk_si544 *data, bool enable)
SI544_OE_STATE_ODC_OE, enable ? SI544_OE_STATE_ODC_OE : 0);
}

static int si544_prepare(struct clk_hw *hw)
{
struct clk_si544 *data = to_clk_si544(hw);

return si544_enable_output(data, true);
}

static void si544_unprepare(struct clk_hw *hw)
{
struct clk_si544 *data = to_clk_si544(hw);

si544_enable_output(data, false);
}

static int si544_is_prepared(struct clk_hw *hw)
{
struct clk_si544 *data = to_clk_si544(hw);
unsigned int val;
int err;

err = regmap_read(data->regmap, SI544_REG_OE_STATE, &val);
if (err < 0)
return err;

return !!(val & SI544_OE_STATE_ODC_OE);
}

/* Retrieve clock multiplier and dividers from hardware */
static int si544_get_muldiv(struct clk_si544 *data,
struct clk_si544_muldiv *settings)
Expand Down Expand Up @@ -273,6 +300,7 @@ static int si544_set_rate(struct clk_hw *hw, unsigned long rate,
{
struct clk_si544 *data = to_clk_si544(hw);
struct clk_si544_muldiv settings;
unsigned int old_oe_state;
int err;

if (!is_valid_frequency(data, rate))
Expand All @@ -282,6 +310,10 @@ static int si544_set_rate(struct clk_hw *hw, unsigned long rate,
if (err)
return err;

err = regmap_read(data->regmap, SI544_REG_OE_STATE, &old_oe_state);
if (err)
return err;

si544_enable_output(data, false);

/* Allow FCAL for this frequency update */
Expand All @@ -303,12 +335,16 @@ static int si544_set_rate(struct clk_hw *hw, unsigned long rate,
/* Applying a new frequency can take up to 10ms */
usleep_range(10000, 12000);

si544_enable_output(data, true);
if (old_oe_state & SI544_OE_STATE_ODC_OE)
si544_enable_output(data, true);

return err;
}

static const struct clk_ops si544_clk_ops = {
.prepare = si544_prepare,
.unprepare = si544_unprepare,
.is_prepared = si544_is_prepared,
.recalc_rate = si544_recalc_rate,
.round_rate = si544_round_rate,
.set_rate = si544_set_rate,
Expand Down
Loading

0 comments on commit 5ef7748

Please sign in to comment.